diff --git a/index.js b/index.js index 2f379d56..a6d98566 100644 --- a/index.js +++ b/index.js @@ -1 +1 @@ -(()=>{"use strict";var e,t,i,s,a={3099:(e,t,i)=>{i.d(t,{K:()=>k});var s=i(2790),a=i(8078),r=i(2028),n=i(2383),h=i(1995),o=(i(1527),i(9080)),l=i(7221),c=i(3909),d=i(3693),u=i(4191),f=i(9345),p=i(6121),m=i(2991),g=i(1840),y=i(312),C=i(9178),T=i(8067),w=i(8934),S=i(8809),Z=i(1519),A=i(5810),v=i(3584),I=i(7958),O=i(2441),b=i(8056),L=i(551),E=i(1089),x=i(2157),_=i(8762);class k extends h.Z{static clientversion=225;static nodeId=10;static portOffset=0;static members=!0;static lowMemory=!1;static serverAddress="";static httpAddress="";static showDebug=!1;static githubRepository="https://raw.githubusercontent.com/2004scape/Server/main";static exponent=58778699976184461502525193738213253649000149147835990136706041084440742975821n;static modulus=7162900525229798032761816791230527296329313291232324290237849263501208207972894053929065636522363163621000728841182238772712427862772219676577293600221789n;static updateCounter=0;static update2Counter=0;static sidebarInputCounter=0;static opHeld1Counter=0;static opLoc4Counter=0;static opNpc5Counter=0;static drawCounter=0;static opHeld4Counter=0;static opLoc5Counter=0;static opNpc3Counter=0;static opHeld9Counter=0;static opPlayer2Counter=0;static updatePlayersCounter=0;static ifButton5Counter=0;static updateLocCounter=0;static setHighMemory=()=>{l.Z.lowMemory=!1,a.Z.lowMemory=!1,k.lowMemory=!1,c.Z.lowMemory=!1};static setLowMemory=()=>{l.Z.lowMemory=!0,a.Z.lowMemory=!0,k.lowMemory=!0,c.Z.lowMemory=!0};MAX_PLAYER_COUNT=2048;LOCAL_PLAYER_INDEX=2047;alreadyStarted=!1;errorStarted=!1;errorLoading=!1;errorHost=!1;db=null;loopCycle=0;ingame=!1;archiveChecksums=[];stream=null;in=n.Z.alloc(1);out=n.Z.alloc(1);loginout=n.Z.alloc(1);serverSeed=0n;idleNetCycles=0;idleTimeout=0;systemUpdateTimer=0;randomIn=null;packetType=0;packetSize=0;lastPacketType0=0;lastPacketType1=0;lastPacketType2=0;titleArchive=null;redrawTitleBackground=!0;titleScreenState=0;titleLoginField=0;imageTitle2=null;imageTitle3=null;imageTitle4=null;imageTitle0=null;imageTitle1=null;imageTitle5=null;imageTitle6=null;imageTitle7=null;imageTitle8=null;imageTitlebox=null;imageTitlebutton=null;loginMessage0="";loginMessage1="";username="";password="";fontPlain11=null;fontPlain12=null;fontBold12=null;fontQuill8=null;imageRunes=[];flameActive=!1;imageFlamesLeft=null;imageFlamesRight=null;flameBuffer1=null;flameBuffer0=null;flameBuffer3=null;flameBuffer2=null;flameGradient=null;flameGradient0=null;flameGradient1=null;flameGradient2=null;flameLineOffset=new Int32Array(256);flameCycle0=0;flameGradientCycle0=0;flameGradientCycle1=0;flamesInterval=null;areaSidebar=null;areaMapback=null;areaViewport=null;areaChatback=null;areaBackbase1=null;areaBackbase2=null;areaBackhmid1=null;areaBackleft1=null;areaBackleft2=null;areaBackright1=null;areaBackright2=null;areaBacktop1=null;areaBacktop2=null;areaBackvmid1=null;areaBackvmid2=null;areaBackvmid3=null;areaBackhmid2=null;areaChatbackOffsets=null;areaSidebarOffsets=null;areaViewportOffsets=null;compassMaskLineOffsets=new Int32Array(33);compassMaskLineLengths=new Int32Array(33);minimapMaskLineOffsets=new Int32Array(151);minimapMaskLineLengths=new Int32Array(151);imageInvback=null;imageChatback=null;imageMapback=null;imageBackbase1=null;imageBackbase2=null;imageBackhmid1=null;imageSideicons=new f.to(13,null);imageMinimap=null;imageCompass=null;imageMapscene=new f.to(50,null);imageMapfunction=new f.to(50,null);imageHitmarks=new f.to(20,null);imageHeadicons=new f.to(20,null);imageMapflag=null;imageCrosses=new f.to(8,null);imageMapdot0=null;imageMapdot1=null;imageMapdot2=null;imageMapdot3=null;imageScrollbar0=null;imageScrollbar1=null;imageRedstone1=null;imageRedstone2=null;imageRedstone3=null;imageRedstone1h=null;imageRedstone2h=null;imageRedstone1v=null;imageRedstone2v=null;imageRedstone3v=null;imageRedstone1hv=null;imageRedstone2hv=null;genderButtonImage0=null;genderButtonImage1=null;activeMapFunctions=new f.to(1e3,null);redrawSidebar=!1;redrawChatback=!1;redrawSideicons=!1;redrawPrivacySettings=!1;viewportInterfaceId=-1;dragCycles=0;crossMode=0;crossCycle=0;crossX=0;crossY=0;overrideChat=0;menuVisible=!1;menuArea=0;menuX=0;menuY=0;menuWidth=0;menuHeight=0;menuSize=0;menuOption=[];sidebarInterfaceId=-1;chatInterfaceId=-1;chatInterface=new s.Z;chatScrollHeight=78;chatScrollOffset=0;ignoreCount=0;ignoreName37=[];hintType=0;hintNpc=0;hintOffsetX=0;hintOffsetZ=0;hintPlayer=0;hintTileX=0;hintTileZ=0;hintHeight=0;skillExperience=[];skillLevel=[];skillBaseLevel=[];levelExperience=[];modalMessage=null;flashingTab=-1;selectedTab=3;tabInterfaceId=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1];publicChatSetting=0;privateChatSetting=0;tradeChatSetting=0;scrollGrabbed=!1;scrollInputPadding=0;showSocialInput=!1;socialMessage="";socialInput="";socialAction=0;chatbackInput="";chatbackInputOpen=!1;stickyChatInterfaceId=-1;messageText=new f.to(100,null);messageSender=new f.to(100,null);messageType=new Int32Array(100);messageIds=new Int32Array(100);privateMessageCount=0;splitPrivateChat=0;chatEffects=0;chatTyped="";viewportHoveredInterfaceIndex=0;sidebarHoveredInterfaceIndex=0;chatHoveredInterfaceIndex=0;objDragInterfaceId=0;objDragSlot=0;objDragArea=0;objGrabX=0;objGrabY=0;objDragCycles=0;objGrabThreshold=!1;objSelected=0;objSelectedSlot=0;objSelectedInterface=0;objInterface=0;objSelectedName=null;selectedArea=0;selectedItem=0;selectedInterface=0;selectedCycle=0;pressedContinueOption=!1;varps=[];varCache=[];spellSelected=0;activeSpellId=0;activeSpellFlags=0;spellCaption=null;mouseButtonsOption=0;menuAction=new Int32Array(500);menuParamA=new Int32Array(500);menuParamB=new Int32Array(500);menuParamC=new Int32Array(500);hoveredSlotParentId=0;hoveredSlot=0;lastHoveredInterfaceId=0;reportAbuseInput="";reportAbuseMuteOption=!1;reportAbuseInterfaceID=-1;lastAddress=0;daysSinceLastLogin=0;daysSinceRecoveriesChanged=0;unreadMessages=0;activeMapFunctionCount=0;activeMapFunctionX=new Int32Array(1e3);activeMapFunctionZ=new Int32Array(1e3);scene=null;sceneState=0;sceneDelta=0;sceneCycle=0;flagSceneTileX=0;flagSceneTileZ=0;cutscene=!1;cameraOffsetCycle=0;cameraAnticheatOffsetX=0;cameraAnticheatOffsetZ=0;cameraAnticheatAngle=0;cameraOffsetXModifier=2;cameraOffsetZModifier=2;cameraOffsetYawModifier=1;cameraModifierCycle=new Int32Array(5);cameraModifierEnabled=new f.to(5,!1);cameraModifierJitter=new Int32Array(5);cameraModifierWobbleScale=new Int32Array(5);cameraModifierWobbleSpeed=new Int32Array(5);cameraX=0;cameraY=0;cameraZ=0;cameraPitch=0;cameraYaw=0;cameraPitchClamp=0;minimapOffsetCycle=0;minimapAnticheatAngle=0;minimapZoom=0;minimapZoomModifier=1;minimapAngleModifier=2;minimapLevel=-1;baseX=0;baseZ=0;sceneCenterZoneX=0;sceneCenterZoneZ=0;sceneBaseTileX=0;sceneBaseTileZ=0;sceneMapLandData=null;sceneMapLocData=null;sceneMapIndex=null;mapLastBaseX=0;mapLastBaseZ=0;textureBuffer=new Int8Array(16384);levelCollisionMap=new f.to(d.Z.LEVELS,null);currentLevel=0;cameraMovedWrite=0;orbitCameraPitch=128;orbitCameraYaw=0;orbitCameraYawVelocity=0;orbitCameraPitchVelocity=0;orbitCameraX=0;orbitCameraZ=0;levelHeightmap=null;levelTileFlags=null;tileLastOccupiedCycle=new f.Nv(d.Z.SIZE,d.Z.SIZE);projectX=0;projectY=0;cutsceneDstLocalTileX=0;cutsceneDstLocalTileZ=0;cutsceneDstHeight=0;cutsceneRotateSpeed=0;cutsceneRotateAcceleration=0;cutsceneSrcLocalTileX=0;cutsceneSrcLocalTileZ=0;cutsceneSrcHeight=0;cutsceneMoveSpeed=0;cutsceneMoveAcceleration=0;players=new f.to(this.MAX_PLAYER_COUNT,null);playerCount=0;playerIds=new Int32Array(this.MAX_PLAYER_COUNT);entityUpdateCount=0;entityRemovalCount=0;entityUpdateIds=new Int32Array(this.MAX_PLAYER_COUNT);entityRemovalIds=new Int32Array(1e3);playerAppearanceBuffer=new f.to(this.MAX_PLAYER_COUNT,null);npcs=new f.to(8192,null);npcCount=0;npcIds=new Int32Array(8192);projectiles=new o.Z;spotanims=new o.Z;locList=new o.Z;temporaryLocs=new o.Z;levelObjStacks=new f.N$(d.Z.LEVELS,d.Z.SIZE,d.Z.SIZE,null);spawnedLocations=new o.Z;bfsStepX=new Int32Array(4e3);bfsStepZ=new Int32Array(4e3);bfsDirection=new Int32Array(d.Z.SIZE*d.Z.SIZE);bfsCost=new Int32Array(d.Z.SIZE*d.Z.SIZE);tryMoveNearest=0;localPlayer=null;energy=0;inMultizone=0;localPid=-1;weightCarried=0;heartbeatTimer=0;wildernessLevel=0;worldLocationState=0;rights=!1;designGenderMale=!0;updateDesignModel=!1;designIdentikits=new Int32Array(7);designColors=new Int32Array(5);friendCount=0;chatCount=0;static MAX_CHATS=50;chatX=new Int32Array(k.MAX_CHATS);chatY=new Int32Array(k.MAX_CHATS);chatHeight=new Int32Array(k.MAX_CHATS);chatWidth=new Int32Array(k.MAX_CHATS);chatColors=new Int32Array(k.MAX_CHATS);chatStyles=new Int32Array(k.MAX_CHATS);chatTimers=new Int32Array(k.MAX_CHATS);chats=new f.to(k.MAX_CHATS,null);friendName=new f.to(100,null);friendName37=new BigInt64Array(100);friendWorld=new Int32Array(100);socialName37=null;waveCount=0;waveEnabled=!0;waveIds=new Int32Array(50);waveLoops=new Int32Array(50);waveDelay=new Int32Array(50);waveVolume=192;lastWaveId=-1;lastWaveLoops=-1;lastWaveLength=0;lastWaveStartTime=0;nextMusicDelay=0;midiActive=!0;currentMidi=null;midiCrc=0;midiSize=0;midiVolume=192;unload=()=>{try{this.stream&&this.stream.close()}catch(e){}this.stream=null,(0,v.tb)(),this.out=null,this.loginout=null,this.in=null,this.sceneMapIndex=null,this.sceneMapLandData=null,this.sceneMapLocData=null,this.levelHeightmap=null,this.levelTileFlags=null,this.scene=null,this.levelCollisionMap=null,this.bfsDirection=null,this.bfsCost=null,this.bfsStepX=null,this.bfsStepZ=null,this.textureBuffer=null,this.areaSidebar=null,this.areaMapback=null,this.areaViewport=null,this.areaChatback=null,this.areaBackbase1=null,this.areaBackbase2=null,this.areaBackhmid1=null,this.areaBackleft1=null,this.areaBackleft2=null,this.areaBackright1=null,this.areaBackright2=null,this.areaBacktop1=null,this.areaBacktop2=null,this.areaBackvmid1=null,this.areaBackvmid2=null,this.areaBackvmid3=null,this.areaBackhmid2=null,this.imageInvback=null,this.imageMapback=null,this.imageChatback=null,this.imageBackbase1=null,this.imageBackbase2=null,this.imageBackhmid1=null,this.imageSideicons=null,this.imageRedstone1=null,this.imageRedstone2=null,this.imageRedstone3=null,this.imageRedstone1h=null,this.imageRedstone2h=null,this.imageRedstone1v=null,this.imageRedstone2v=null,this.imageRedstone3v=null,this.imageRedstone1hv=null,this.imageRedstone2hv=null,this.imageCompass=null,this.imageHitmarks=null,this.imageHeadicons=null,this.imageCrosses=null,this.imageMapdot0=null,this.imageMapdot1=null,this.imageMapdot2=null,this.imageMapdot3=null,this.imageMapscene=null,this.imageMapfunction=null,this.tileLastOccupiedCycle=null,this.players=null,this.playerIds=null,this.entityUpdateIds=null,this.playerAppearanceBuffer=null,this.entityRemovalIds=null,this.npcs=null,this.npcIds=null,this.levelObjStacks=null,this.spawnedLocations=null,this.temporaryLocs=null,this.projectiles=null,this.spotanims=null,this.locList=null,this.menuParamB=null,this.menuParamC=null,this.menuAction=null,this.menuParamA=null,this.menuOption=null,this.varps=null,this.activeMapFunctionX=null,this.activeMapFunctionZ=null,this.activeMapFunctions=null,this.imageMinimap=null,this.friendName=null,this.friendName37=null,this.friendWorld=null,this.imageTitle0=null,this.imageTitle1=null,this.imageTitle2=null,this.imageTitle3=null,this.imageTitle4=null,this.imageTitle5=null,this.imageTitle6=null,this.imageTitle7=null,this.imageTitle8=null,this.unloadTitle(),I.Z.unload(),O.Z.unload(),g.Z.unload(),b.Z.instances=null,S.Z.instances=null,s.Z.instances=null,T.Z.instances=null,L.Z.instances=null,L.Z.modelCache=null,E.Z.instances=null,this.drawArea=null,u.Z.modelCache=null,a.Z.unload(),l.Z.unload(),C.Z.unload(),x.Z.instances=[],_.Z.instances=[]};unloadTitle=()=>{this.flameActive=!1,this.flamesInterval&&(clearInterval(this.flamesInterval),this.flamesInterval=null),this.imageTitlebox=null,this.imageTitlebutton=null,this.imageRunes=[],this.flameGradient=null,this.flameGradient0=null,this.flameGradient1=null,this.flameGradient2=null,this.flameBuffer0=null,this.flameBuffer1=null,this.flameBuffer3=null,this.flameBuffer2=null,this.imageFlamesLeft=null,this.imageFlamesRight=null};loadArchive=async(e,t,i,s)=>{let a=5,h=await(this.db?.cacheload(e));if(h&&n.Z.crc32(h)!==i&&(h=void 0),h)return new r.Z(h);for(;!h;){await this.showProgress(s,`Requesting ${t}`);try{h=await(0,Z.GR)(`${k.httpAddress}/${e}${i}`)}catch(e){h=void 0;for(let e=a;e>0;e--)await this.showProgress(s,`Error loading - Will retry in ${e} secs.`),await(0,Z._v)(1e3);a*=2,a>60&&(a=60)}}return await(this.db?.cachesave(e,h)),new r.Z(h)};setMidi=async(e,t,i)=>{let s=await(this.db?.cacheload(e+".mid"));if(s&&12345678!==t&&n.Z.crc32(s)!==t&&(s=void 0),!s)try{s=await(0,Z.GR)(`${k.httpAddress}/${e}_${t}.mid`),i!==s.length&&(s=s.slice(0,i))}catch(e){}if(!s)return;await(this.db?.cachesave(e+".mid",s));const a=new n.Z(Uint8Array.from(s)).g4,r=A.Z.read(a,s,i,4);(0,v.Q6)(r,this.midiVolume)};drawError=()=>{if(p.E1.fillStyle="black",p.E1.fillRect(0,0,this.width,this.height),this.setFramerate(1),this.errorLoading){this.flameActive=!1,p.E1.font="bold 16px helvetica, sans-serif",p.E1.textAlign="left",p.E1.fillStyle="yellow";let e=35;p.E1.fillText("Sorry, an error has occured whilst loading RuneScape",30,e),e+=50,p.E1.fillStyle="white",p.E1.fillText("To fix this try the following (in order):",30,e),e+=50,p.E1.font="bold 12px helvetica, sans-serif",p.E1.fillText("1: Try closing ALL open web-browser windows, and reloading",30,e),e+=30,p.E1.fillText("2: Try clearing your web-browsers cache from tools->internet options",30,e),e+=30,p.E1.fillText("3: Try using a different game-world",30,e),e+=30,p.E1.fillText("4: Try rebooting your computer",30,e),e+=30,p.E1.fillText("5: Try selecting a different version of Java from the play-game menu",30,e)}if(this.errorHost&&(this.flameActive=!1,p.E1.font="bold 20px helvetica, sans-serif",p.E1.textAlign="left",p.E1.fillStyle="white",p.E1.fillText("Error - unable to load game!",50,50),p.E1.fillText("To play RuneScape make sure you play from",50,100),p.E1.fillText("https://2004scape.org",50,150)),this.errorStarted){this.flameActive=!1,p.E1.font="bold 13px helvetica, sans-serif",p.E1.textAlign="left",p.E1.fillStyle="yellow";let e=35;p.E1.fillText("Error a copy of RuneScape already appears to be loaded",30,e),e+=50,p.E1.fillStyle="white",p.E1.fillText("To fix this try the following (in order):",30,e),e+=50,p.E1.font="bold 12px helvetica, sans-serif",p.E1.fillText("1: Try closing ALL open web-browser windows, and reloading",30,e),e+=30,p.E1.fillText("2: Try rebooting your computer, and reloading",30,e)}};executeInterfaceScript=e=>{if(!e.scriptComparator)return!1;for(let t=0;t=s)return!1}else if(3===e.scriptComparator[t]){if(i<=s)return!1}else if(4===e.scriptComparator[t]){if(i===s)return!1}else if(i!==s)return!1}return!0};drawScrollbar=(e,t,i,s,a)=>{this.imageScrollbar0?.draw(e,t),this.imageScrollbar1?.draw(e,t+a-16),m.Z.fillRect(e,t+16,16,a-32,y.Z.SCROLLBAR_TRACK);let r=(a-32)*a/s|0;r<8&&(r=8);const n=(a-r-32)*i/(s-a)|0;m.Z.fillRect(e,t+n+16,16,r,y.Z.SCROLLBAR_GRIP_FOREGROUND),m.Z.drawVerticalLine(e,t+n+16,y.Z.SCROLLBAR_GRIP_HIGHLIGHT,r),m.Z.drawVerticalLine(e+1,t+n+16,y.Z.SCROLLBAR_GRIP_HIGHLIGHT,r),m.Z.drawHorizontalLine(e,t+n+16,y.Z.SCROLLBAR_GRIP_HIGHLIGHT,16),m.Z.drawHorizontalLine(e,t+n+17,y.Z.SCROLLBAR_GRIP_HIGHLIGHT,16),m.Z.drawVerticalLine(e+15,t+n+16,y.Z.SCROLLBAR_GRIP_LOWLIGHT,r),m.Z.drawVerticalLine(e+14,t+n+17,y.Z.SCROLLBAR_GRIP_LOWLIGHT,r-1),m.Z.drawHorizontalLine(e,t+n+r+15,y.Z.SCROLLBAR_GRIP_LOWLIGHT,16),m.Z.drawHorizontalLine(e+1,t+n+r+14,y.Z.SCROLLBAR_GRIP_LOWLIGHT,15)};updateInterfaceAnimation=(e,t)=>{let i=!1;const a=s.Z.instances[e];if(!a.childId)return!1;for(let e=0;es.delay[r.seqFrame];)r.seqCycle-=s.delay[r.seqFrame]+1,r.seqFrame++,r.seqFrame>=s.frameCount&&(r.seqFrame-=s.replayoff,(r.seqFrame<0||r.seqFrame>=s.frameCount)&&(r.seqFrame=0)),i=!0}}}return i};drawInterface=(e,t,i,r,n=!1)=>{if(0!==e.type||!e.childId||e.hide&&this.viewportHoveredInterfaceIndex!==e.id&&this.sidebarHoveredInterfaceIndex!==e.id&&this.chatHoveredInterfaceIndex!==e.id)return;const h=m.Z.left,o=m.Z.top,l=m.Z.right,c=m.Z.bottom;m.Z.setBounds(t,i,t+e.width,i+e.height);const d=e.childId.length;for(let h=0;h0&&this.updateInterfaceContent(c),c.type===s.Z.TYPE_LAYER)c.scrollPosition>c.scroll-c.height&&(c.scrollPosition=c.scroll-c.height),c.scrollPosition<0&&(c.scrollPosition=0),this.drawInterface(c,o,l,c.scrollPosition,n),c.scroll>c.height&&this.drawScrollbar(o+c.width,l,c.scrollPosition,c.scroll,c.height);else if(c.type===s.Z.TYPE_INV){let e=0;for(let t=0;t0){let t=0,i=0;const r=c.invSlotObjId[e]-1;if(s>=-32&&s<=512&&a>=-32&&a<=334||0!==this.objDragArea&&this.objDragSlot===e){const n=g.Z.getIcon(r,c.invSlotObjCount[e]);if(0!==this.objDragArea&&this.objDragSlot===e&&this.objDragInterfaceId===c.id?(t=this.mouseX-this.objGrabX,i=this.mouseY-this.objGrabY,t<5&&t>-5&&(t=0),i<5&&i>-5&&(i=0),this.objDragCycles<5&&(t=0,i=0),n.drawAlpha(128,s+t,a+i)):0!==this.selectedArea&&this.selectedItem===e&&this.selectedInterface===c.id?n.drawAlpha(128,s,a):n.draw(s,a),33===n.cropW||1!==c.invSlotObjCount[e]){const r=c.invSlotObjCount[e];this.fontPlain11?.drawString(s+t+1,a+10+i,this.formatObjCount(r),y.Z.BLACK),this.fontPlain11?.drawString(s+t,a+9+i,this.formatObjCount(r),y.Z.YELLOW)}}}else if(c.invSlotSprite&&e<20){const t=c.invSlotSprite[e];t?.draw(s,a)}e++}}else if(c.type===s.Z.TYPE_RECT)c.fill?m.Z.fillRect(o,l,c.width,c.height,c.colour):m.Z.drawRect(o,l,c.width,c.height,c.colour);else if(c.type===s.Z.TYPE_TEXT){const e=c.font;let t=c.colour,i=c.text;if(this.chatHoveredInterfaceIndex!==c.id&&this.sidebarHoveredInterfaceIndex!==c.id&&this.viewportHoveredInterfaceIndex!==c.id||0===c.overColour||(t=c.overColour),this.executeInterfaceScript(c)&&(t=c.activeColour,c.activeText&&c.activeText.length>0&&(i=c.activeText)),c.buttonType===s.Z.BUTTON_CONTINUE&&this.pressedContinueOption&&(i="Please wait...",t=c.colour),!e||!i)continue;for(let s=l+e.height;i.length>0;s+=e.height){if(-1!==i.indexOf("%")){for(;;){const e=i.indexOf("%1");if(-1===e)break;i=i.substring(0,e)+this.getIntString(this.executeClientscript1(c,0))+i.substring(e+2)}for(;;){const e=i.indexOf("%2");if(-1===e)break;i=i.substring(0,e)+this.getIntString(this.executeClientscript1(c,1))+i.substring(e+2)}for(;;){const e=i.indexOf("%3");if(-1===e)break;i=i.substring(0,e)+this.getIntString(this.executeClientscript1(c,2))+i.substring(e+2)}for(;;){const e=i.indexOf("%4");if(-1===e)break;i=i.substring(0,e)+this.getIntString(this.executeClientscript1(c,3))+i.substring(e+2)}for(;;){const e=i.indexOf("%5");if(-1===e)break;i=i.substring(0,e)+this.getIntString(this.executeClientscript1(c,4))+i.substring(e+2)}}const a=i.indexOf("\\n");let r;-1!==a?(r=i.substring(0,a),i=i.substring(a+2)):(r=i,i=""),c.center?e.drawStringTaggableCenter(o+(c.width/2|0),s,r,t,c.shadowed):e.drawStringTaggable(o,s,r,t,c.shadowed)}}else if(c.type===s.Z.TYPE_GRAPHIC){let e;e=this.executeInterfaceScript(c)?c.activeGraphic:c.graphic,e?.draw(o,l)}else if(c.type===s.Z.TYPE_MODEL){const e=a.Z.centerX,t=a.Z.centerY;a.Z.centerX=o+(c.width/2|0),a.Z.centerY=l+(c.height/2|0);const i=a.Z.sin[c.xan]*c.zoom>>16,s=a.Z.cos[c.xan]*c.zoom>>16,r=this.executeInterfaceScript(c);let n;n=r?c.activeAnim:c.anim;let h=null;if(-1===n)h=c.getModel(-1,-1,r);else{const e=T.Z.instances[n];e.frames&&e.iframes&&(h=c.getModel(e.frames[c.seqFrame],e.iframes[c.seqFrame],r))}h&&h.drawSimple(0,c.yan,0,c.xan,0,i,s),a.Z.centerX=e,a.Z.centerY=t}else if(c.type===s.Z.TYPE_INV_TEXT){const e=c.font;if(!e||!c.invSlotObjId||!c.invSlotObjCount)continue;let t=0;for(let i=0;i0){const a=g.Z.get(c.invSlotObjId[t]-1);let r=a.name;if((a.stackable||1!==c.invSlotObjCount[t])&&(r=r+" x"+this.formatObjCountTagged(c.invSlotObjCount[t])),!r)continue;const n=o+s*(c.marginX+115),h=l+i*(c.marginY+12);c.center?e.drawStringTaggableCenter(n+(c.width/2|0),h,r,c.colour,c.shadowed):e.drawStringTaggable(n,h,r,c.colour,c.shadowed)}t++}}}m.Z.setBounds(h,o,l,c)};updateInterfaceContent=e=>{let t=e.clientCode;if(t>=s.Z.CC_FRIENDS_START&&t<=s.Z.CC_FRIENDS_END)t--,t>=this.friendCount?(e.text="",e.buttonType=0):(e.text=this.friendName[t],e.buttonType=1);else if(t>=s.Z.CC_FRIENDS_UPDATE_START&&t<=s.Z.CC_FRIENDS_UPDATE_END)t-=s.Z.CC_FRIENDS_UPDATE_START,t>=this.friendCount?(e.text="",e.buttonType=0):(0===this.friendWorld[t]?e.text="@red@Offline":this.friendWorld[t]===k.nodeId?e.text="@gre@World-"+(this.friendWorld[t]-9):e.text="@yel@World-"+(this.friendWorld[t]-9),e.buttonType=1);else if(t===s.Z.CC_FRIENDS_SIZE)e.scroll=15*this.friendCount+20,e.scroll<=e.height&&(e.scroll=e.height+1);else if(t>=s.Z.CC_IGNORES_START&&t<=s.Z.CC_IGNORES_END)t-=s.Z.CC_IGNORES_START,t>=this.ignoreCount?(e.text="",e.buttonType=0):(e.text=w.Z.formatName(w.Z.fromBase37(this.ignoreName37[t])),e.buttonType=1);else if(t===s.Z.CC_IGNORES_SIZE)e.scroll=15*this.ignoreCount+20,e.scroll<=e.height&&(e.scroll=e.height+1);else if(t===s.Z.CC_DESIGN_PREVIEW){if(e.xan=150,e.yan=2047&(256*Math.sin(this.loopCycle/40)|0),this.updateDesignModel){this.updateDesignModel=!1;const t=new f.to(7,null);let i=0;for(let e=0;e<7;e++){const s=this.designIdentikits[e];s>=0&&(t[i++]=S.Z.instances[s].getModel())}const s=C.Z.modelFromModels(t,i);for(let e=0;e<5;e++)0!==this.designColors[e]&&(s.recolor(u.Z.DESIGN_BODY_COLOR[e][0],u.Z.DESIGN_BODY_COLOR[e][this.designColors[e]]),1===e&&s.recolor(u.Z.DESIGN_HAIR_COLOR[0],u.Z.DESIGN_HAIR_COLOR[this.designColors[e]]));if(this.localPlayer){const t=T.Z.instances[this.localPlayer.seqStandId].frames;t&&(s.createLabelReferences(),s.applyTransform(t[0]),s.calculateNormals(64,850,-30,-50,-30,!0),e.model=s)}}}else if(t===s.Z.CC_SWITCH_TO_MALE)this.genderButtonImage0||(this.genderButtonImage0=e.graphic,this.genderButtonImage1=e.activeGraphic),this.designGenderMale?e.graphic=this.genderButtonImage1:e.graphic=this.genderButtonImage0;else if(t===s.Z.CC_SWITCH_TO_FEMALE)this.genderButtonImage0||(this.genderButtonImage0=e.graphic,this.genderButtonImage1=e.activeGraphic),this.designGenderMale?e.graphic=this.genderButtonImage0:e.graphic=this.genderButtonImage1;else if(t===s.Z.CC_REPORT_INPUT)e.text=this.reportAbuseInput,this.loopCycle%20<10?e.text=e.text+"|":e.text=e.text+" ";else if(t===s.Z.CC_MOD_MUTE)this.rights?this.reportAbuseMuteOption?(e.colour=y.Z.RED,e.text="Moderator option: Mute player for 48 hours: "):(e.colour=y.Z.WHITE,e.text="Moderator option: Mute player for 48 hours: "):e.text="";else if(t===s.Z.CC_LAST_LOGIN_INFO||t===s.Z.CC_LAST_LOGIN_INFO2)if(0===this.lastAddress)e.text="";else{let t;t=0===this.daysSinceLastLogin?"earlier today":1===this.daysSinceLastLogin?"yesterday":this.daysSinceLastLogin+" days ago",e.text="You last logged in "+t+" from: "+w.Z.formatIPv4(this.lastAddress)}else if(t===s.Z.CC_UNREAD_MESSAGES)0===this.unreadMessages&&(e.text="0 unread messages",e.colour=y.Z.YELLOW),1===this.unreadMessages&&(e.text="1 unread message",e.colour=y.Z.GREEN),this.unreadMessages>1&&(e.text=this.unreadMessages+" unread messages",e.colour=y.Z.GREEN);else if(t===s.Z.CC_RECOVERY1)if(201===this.daysSinceRecoveriesChanged)e.text="";else if(200===this.daysSinceRecoveriesChanged)e.text="You have not yet set any password recovery questions.";else{let t;t=0===this.daysSinceRecoveriesChanged?"Earlier today":1===this.daysSinceRecoveriesChanged?"Yesterday":this.daysSinceRecoveriesChanged+" days ago",e.text=t+" you changed your recovery questions"}else t===s.Z.CC_RECOVERY2?201===this.daysSinceRecoveriesChanged?e.text="":200===this.daysSinceRecoveriesChanged?e.text="We strongly recommend you do so now to secure your account.":e.text="If you do not remember making this change then cancel it immediately":t===s.Z.CC_RECOVERY3&&(201===this.daysSinceRecoveriesChanged?e.text="":(this.daysSinceRecoveriesChanged,e.text="Do this from the 'account management' area on our front webpage"))};executeClientscript1=(e,t)=>{if(!e.scripts||t>=e.scripts.length)return-2;try{const i=e.scripts[t];if(!i)return-1;let a=0,r=0;for(;;){const e=i[r++];if(0===e)return a;if(1===e)a+=this.skillLevel[i[r++]];else if(2===e)a+=this.skillBaseLevel[i[r++]];else if(3===e)a+=this.skillExperience[i[r++]];else if(4===e){const e=s.Z.instances[i[r++]],t=i[r++]+1;if(e.invSlotObjId&&e.invSlotObjCount)for(let i=0;ie<999999999?String(e):"*";formatObjCountTagged=e=>{let t=String(e);for(let e=t.length-3;e>0;e-=3)t=t.substring(0,e)+","+t.substring(e);return t.length>8?t="@gre@"+t.substring(0,t.length-8)+" million @whi@("+t+")":t.length>4&&(t="@cya@"+t.substring(0,t.length-4)+"K @whi@("+t+")")," "+t};formatObjCount=e=>e<1e5?String(e):e<1e7?(e/1e3|0)+"K":(e/1e6|0)+"M"}},1803:(e,t,i)=>{i.d(t,{O:()=>n});var s=i(1995),a=i(3099),r=i(1519);async function n(){const e=window.location.hostname,t=window.location.protocol.startsWith("https");0===s.Z.getParameter("world").length&&s.Z.setParameter("world","1"),0===s.Z.getParameter("detail").length&&s.Z.setParameter("detail","high"),0===s.Z.getParameter("method").length&&s.Z.setParameter("method","0"),"localhost"===e&&"0"===s.Z.getParameter("world")?(a.K.serverAddress="http://localhost",a.K.httpAddress="http://localhost",a.K.portOffset=0):await async function(e){const t=await h(e,parseInt(s.Z.getParameter("world"),10)),i=new URL(t.address);a.K.nodeId=10+t.id-1,a.K.serverAddress=`${i.protocol}//${i.hostname}`,a.K.httpAddress=`${i.protocol}//${i.hostname}:${i.port}`,e||(a.K.serverAddress=a.K.serverAddress.replace("https:","http:")),a.K.portOffset=t.portOffset,a.K.members=!0===t?.members}(t),"low"===s.Z.getParameter("detail")?a.K.setLowMemory():a.K.setHighMemory()}async function h(e,t,i=0){if(i>=10)throw new Error("could not find world to connect!");const s=e?"https:":"http:";let a;try{a=JSON.parse(await(0,r.Di)(`${s}//2004scape.org/api/v1/worldlist`))}catch(s){return await(0,r._v)(1e3),h(e,t,++i)}return a.find((e=>e.id===t))||h(e,t,10)}},1979:(e,t,i)=>{i.a(e,(async(e,t)=>{try{var s=i(8067),a=i(7958),r=i(1840),n=i(2441),h=i(8809),o=i(551),l=i(1089),c=i(2790),d=i(651),u=i(2991),f=i(8078),p=i(664),m=i(6542),g=i(4628),y=i(9178),C=i(312),T=i(2383),w=i(1812),S=i(741),Z=i(7576),A=i(8432),v=i(9782),I=i(9995),O=i(9897),b=i(6054),L=i(6970),E=(i(1527),i(5810)),x=i(9080),_=i(8934),k=i(6884),R=i(7221),P=i(3909),M=i(3714),N=i(1908),B=i(5534),D=i(6150),Y=i(7396),X=i(3693),F=i(8603),H=i(4191),W=i(1353),z=i(7973),U=i(682),G=i(1810),V=i(5659),q=i(3584),j=i(1519),K=i(9345),J=i(3099),Q=i(2157),$=i(8762),ee=i(8056),te=i(1803);class e extends J.K{load=async()=>{if(this.alreadyStarted)this.errorStarted=!0;else{this.alreadyStarted=!0;try{await this.showProgress(10,"Connecting to fileserver"),await E.Z.load(await(await fetch("bz2.wasm")).arrayBuffer()),this.db=new A.Z(await A.Z.openDatabase());const e=new T.Z(new Uint8Array(await(0,j.GR)(`${J.K.httpAddress}/crc`)));for(let t=0;t<9;t++)this.archiveChecksums[t]=e.g4;J.K.lowMemory||await this.setMidi("scape_main",12345678,4e4);const t=await this.loadArchive("title","title screen",this.archiveChecksums[1],10);this.titleArchive=t,this.fontPlain11=g.Z.fromArchive(t,"p11"),this.fontPlain12=g.Z.fromArchive(t,"p12"),this.fontBold12=g.Z.fromArchive(t,"b12"),this.fontQuill8=g.Z.fromArchive(t,"q8"),await this.loadTitleBackground(),this.loadTitleImages();const i=await this.loadArchive("config","config",this.archiveChecksums[2],15),u=await this.loadArchive("interface","interface",this.archiveChecksums[3],20),C=await this.loadArchive("media","2d graphics",this.archiveChecksums[4],30),w=await this.loadArchive("models","3d graphics",this.archiveChecksums[5],40),S=await this.loadArchive("textures","textures",this.archiveChecksums[6],60),Z=await this.loadArchive("wordenc","chat system",this.archiveChecksums[7],65),v=await this.loadArchive("sounds","sound effects",this.archiveChecksums[8],70);this.levelTileFlags=new K.zi(X.Z.LEVELS,X.Z.SIZE,X.Z.SIZE),this.levelHeightmap=new K.AK(X.Z.LEVELS,X.Z.SIZE+1,X.Z.SIZE+1),this.levelHeightmap&&(this.scene=new R.Z(this.levelHeightmap,X.Z.SIZE,X.Z.LEVELS,X.Z.SIZE));for(let e=0;e34||e>34))999===t&&(t=s);else if(999!==t){i=s;break}this.minimapMaskLineOffsets[e-9]=t-21,this.minimapMaskLineLengths[e-9]=i-t}f.Z.init3D(479,96),this.areaChatbackOffsets=f.Z.lineOffset,f.Z.init3D(190,261),this.areaSidebarOffsets=f.Z.lineOffset,f.Z.init3D(512,334),this.areaViewportOffsets=f.Z.lineOffset;const z=new Int32Array(9);for(let e=0;e<9;e++){const t=32*e+128+15,i=3*t+600,s=f.Z.sin[t];z[e]=i*s>>16}R.Z.init(512,334,500,800,z),O.Z.unpack(Z),this.initializeLevelExperience()}catch(e){console.error(e),this.errorLoading=!0}}};update=async()=>{this.errorStarted||this.errorLoading||this.errorHost||(this.loopCycle++,this.ingame?await this.updateGame():await this.updateTitleScreen())};draw=async()=>{this.errorStarted||this.errorLoading||this.errorHost?this.drawError():(this.ingame?this.drawGame():await this.drawTitleScreen(),this.dragCycles=0)};refresh=()=>{this.redrawTitleBackground=!0};showProgress=async(e,t)=>{console.log(`${e}%: ${t}`),await this.loadTitle(),this.titleArchive?(this.imageTitle4?.bind(),this.fontBold12?.drawStringCenter(180,54,"RuneScape is loading - please wait...",C.Z.WHITE),u.Z.drawRect(28,62,304,34,C.Z.PROGRESS_RED),u.Z.drawRect(29,63,302,32,C.Z.BLACK),u.Z.fillRect(30,64,3*e,30,C.Z.PROGRESS_RED),u.Z.fillRect(30+3*e,64,300-3*e,30,C.Z.BLACK),this.fontBold12?.drawStringCenter(180,85,t,C.Z.WHITE),this.imageTitle4?.draw(214,186),this.redrawTitleBackground&&(this.redrawTitleBackground=!1,this.flameActive||(this.imageTitle0?.draw(0,0),this.imageTitle1?.draw(661,0)),this.imageTitle2?.draw(128,0),this.imageTitle3?.draw(214,386),this.imageTitle5?.draw(0,265),this.imageTitle6?.draw(574,265),this.imageTitle7?.draw(128,186),this.imageTitle8?.draw(574,186)),await(0,j._v)(5)):await super.showProgress(e,t)};runFlames=()=>{this.flameActive&&(this.updateFlames(),this.updateFlames(),this.drawFlames())};loadTitle=async()=>{this.imageTitle2||(this.drawArea=null,this.areaChatback=null,this.areaMapback=null,this.areaSidebar=null,this.areaViewport=null,this.areaBackbase1=null,this.areaBackbase2=null,this.areaBackhmid1=null,this.imageTitle0=new d.Z(128,265),u.Z.clear(),this.imageTitle1=new d.Z(128,265),u.Z.clear(),this.imageTitle2=new d.Z(533,186),u.Z.clear(),this.imageTitle3=new d.Z(360,146),u.Z.clear(),this.imageTitle4=new d.Z(360,200),u.Z.clear(),this.imageTitle5=new d.Z(214,267),u.Z.clear(),this.imageTitle6=new d.Z(215,267),u.Z.clear(),this.imageTitle7=new d.Z(86,79),u.Z.clear(),this.imageTitle8=new d.Z(87,79),u.Z.clear(),this.titleArchive&&(await this.loadTitleBackground(),this.loadTitleImages()),this.redrawTitleBackground=!0)};loadTitleBackground=async()=>{if(!this.titleArchive)return;const e=await m.Z.fromJpeg(this.titleArchive,"title");this.imageTitle0?.bind(),e.blitOpaque(0,0),this.imageTitle1?.bind(),e.blitOpaque(-661,0),this.imageTitle2?.bind(),e.blitOpaque(-128,0),this.imageTitle3?.bind(),e.blitOpaque(-214,-386),this.imageTitle4?.bind(),e.blitOpaque(-214,-186),this.imageTitle5?.bind(),e.blitOpaque(0,-265),this.imageTitle6?.bind(),e.blitOpaque(-128,-186),this.imageTitle7?.bind(),e.blitOpaque(-128,-186),this.imageTitle8?.bind(),e.blitOpaque(-574,-186),e.flipHorizontally(),this.imageTitle0?.bind(),e.blitOpaque(394,0),this.imageTitle1?.bind(),e.blitOpaque(-267,0),this.imageTitle2?.bind(),e.blitOpaque(266,0),this.imageTitle3?.bind(),e.blitOpaque(180,-386),this.imageTitle4?.bind(),e.blitOpaque(180,-186),this.imageTitle5?.bind(),e.blitOpaque(394,-265),this.imageTitle6?.bind(),e.blitOpaque(-180,-265),this.imageTitle7?.bind(),e.blitOpaque(212,-186),this.imageTitle8?.bind(),e.blitOpaque(-180,-186);const t=m.Z.fromArchive(this.titleArchive,"logo");this.imageTitle2?.bind(),t.draw((this.width/2|0)-(t.width/2|0)-128,18)};updateFlameBuffer=e=>{if(this.flameBuffer0&&this.flameBuffer1){this.flameBuffer0.fill(0);for(let e=0;e<5e3;e++){const e=128*Math.random()*256|0;this.flameBuffer0[e]=256*Math.random()|0}for(let e=0;e<20;e++){for(let e=1;e<255;e++)for(let t=1;t<127;t++){const i=t+(e<<7);this.flameBuffer1[i]=(this.flameBuffer0[i-1]+this.flameBuffer0[i+1]+this.flameBuffer0[i-128]+this.flameBuffer0[i+128])/4|0}const e=this.flameBuffer0;this.flameBuffer0=this.flameBuffer1,this.flameBuffer1=e}if(e){let t=0;for(let i=0;i{if(this.titleArchive){this.imageTitlebox=p.Z.fromArchive(this.titleArchive,"titlebox"),this.imageTitlebutton=p.Z.fromArchive(this.titleArchive,"titlebutton");for(let e=0;e<12;e++)this.imageRunes[e]=p.Z.fromArchive(this.titleArchive,"runes",e);this.imageFlamesLeft=new m.Z(128,265),this.imageFlamesRight=new m.Z(128,265),this.imageTitle0&&(0,j.fH)(this.imageTitle0.pixels,0,this.imageFlamesLeft.pixels,0,33920),this.imageTitle1&&(0,j.fH)(this.imageTitle1.pixels,0,this.imageFlamesRight.pixels,0,33920),this.flameGradient0=new Int32Array(256);for(let e=0;e<64;e++)this.flameGradient0[e]=262144*e;for(let e=0;e<64;e++)this.flameGradient0[e+64]=1024*e+C.Z.RED;for(let e=0;e<64;e++)this.flameGradient0[e+128]=4*e+C.Z.YELLOW;for(let e=0;e<64;e++)this.flameGradient0[e+192]=C.Z.WHITE;this.flameGradient1=new Int32Array(256);for(let e=0;e<64;e++)this.flameGradient1[e]=1024*e;for(let e=0;e<64;e++)this.flameGradient1[e+64]=4*e+C.Z.GREEN;for(let e=0;e<64;e++)this.flameGradient1[e+128]=262144*e+C.Z.CYAN;for(let e=0;e<64;e++)this.flameGradient1[e+192]=C.Z.WHITE;this.flameGradient2=new Int32Array(256);for(let e=0;e<64;e++)this.flameGradient2[e]=4*e;for(let e=0;e<64;e++)this.flameGradient2[e+64]=262144*e+C.Z.BLUE;for(let e=0;e<64;e++)this.flameGradient2[e+128]=1024*e+C.Z.MAGENTA;for(let e=0;e<64;e++)this.flameGradient2[e+192]=C.Z.WHITE;this.flameGradient=new Int32Array(256),this.flameBuffer0=new Int32Array(32768),this.flameBuffer1=new Int32Array(32768),this.updateFlameBuffer(null),this.flameBuffer3=new Int32Array(32768),this.flameBuffer2=new Int32Array(32768),this.showProgress(10,"Connecting to fileserver").then((()=>{this.flameActive||(this.flameActive=!0,this.flamesInterval=setInterval(this.runFlames,35))}))}};updateTitleScreen=async()=>{if(0===this.titleScreenState){let e=(this.width/2|0)-80,t=20+(this.height/2|0);t+=20,1===this.mouseClickButton&&this.mouseClickX>=e-75&&this.mouseClickX<=e+75&&this.mouseClickY>=t-20&&this.mouseClickY<=t+20&&(this.titleScreenState=3,this.titleLoginField=0),e=80+(this.width/2|0),1===this.mouseClickButton&&this.mouseClickX>=e-75&&this.mouseClickX<=e+75&&this.mouseClickY>=t-20&&this.mouseClickY<=t+20&&(this.loginMessage0="",this.loginMessage1="Enter your username & password.",this.titleScreenState=2,this.titleLoginField=0)}else if(2===this.titleScreenState){let e=(this.height/2|0)-40;e+=30,e+=25,1===this.mouseClickButton&&this.mouseClickY>=e-15&&this.mouseClickY=e-15&&this.mouseClickY=t-75&&this.mouseClickX<=t+75&&this.mouseClickY>=i-20&&this.mouseClickY<=i+20&&await this.login(this.username,this.password,!1),t=80+(this.width/2|0),1===this.mouseClickButton&&this.mouseClickX>=t-75&&this.mouseClickX<=t+75&&this.mouseClickY>=i-20&&this.mouseClickY<=i+20&&(this.titleScreenState=0,this.username="",this.password="");;){const e=this.pollKey();if(-1===e)return;let t=!1;for(let i=0;i0&&(this.username=this.username.substring(0,this.username.length-1)),9!==e&&10!==e&&13!==e||(this.titleLoginField=1),t&&(this.username=this.username+String.fromCharCode(e)),this.username.length>12&&(this.username=this.username.substring(0,12))):1===this.titleLoginField&&(8===e&&this.password.length>0&&(this.password=this.password.substring(0,this.password.length-1)),9!==e&&10!==e&&13!==e||(this.titleLoginField=0),t&&(this.password=this.password+String.fromCharCode(e)),this.password.length>20&&(this.password=this.password.substring(0,20)))}}else if(3===this.titleScreenState){const e=this.width/2|0;let t=50+(this.height/2|0);t+=20,1===this.mouseClickButton&&this.mouseClickX>=e-75&&this.mouseClickX<=e+75&&this.mouseClickY>=t-20&&this.mouseClickY<=t+20&&(this.titleScreenState=0)}};drawTitleScreen=async()=>{if(await this.loadTitle(),this.imageTitle4?.bind(),this.imageTitlebox?.draw(0,0),0===this.titleScreenState){let e=180,t=80;this.fontBold12?.drawStringTaggableCenter(e,t,"Welcome to RuneScape",C.Z.YELLOW,!0),e=100,t=120,this.imageTitlebutton?.draw(e-73,t-20),this.fontBold12?.drawStringTaggableCenter(e,t+5,"New user",C.Z.WHITE,!0),e=260,this.imageTitlebutton?.draw(e-73,t-20),this.fontBold12?.drawStringTaggableCenter(e,t+5,"Existing User",C.Z.WHITE,!0)}else if(2===this.titleScreenState){let e=100,t=60;this.loginMessage0.length>0?(this.fontBold12?.drawStringTaggableCenter(180,t-15,this.loginMessage0,C.Z.YELLOW,!0),this.fontBold12?.drawStringTaggableCenter(180,t,this.loginMessage1,C.Z.YELLOW,!0),t+=30):(this.fontBold12?.drawStringTaggableCenter(180,t-7,this.loginMessage1,C.Z.YELLOW,!0),t+=30),this.fontBold12?.drawStringTaggable(90,t,`Username: ${this.username}${0===this.titleLoginField&&this.loopCycle%40<20?"@yel@|":""}`,C.Z.WHITE,!0),t+=15,this.fontBold12?.drawStringTaggable(92,t,`Password: ${_.Z.toAsterisks(this.password)}${1===this.titleLoginField&&this.loopCycle%40<20?"@yel@|":""}`,C.Z.WHITE,!0),t=150,this.imageTitlebutton?.draw(e-73,t-20),this.fontBold12?.drawStringTaggableCenter(e,t+5,"Login",C.Z.WHITE,!0),e=260,this.imageTitlebutton?.draw(e-73,t-20),this.fontBold12?.drawStringTaggableCenter(e,t+5,"Cancel",C.Z.WHITE,!0)}else if(3===this.titleScreenState){this.fontBold12?.drawStringTaggableCenter(180,40,"Create a free account",C.Z.YELLOW,!0);const e=180;let t=65;this.fontBold12?.drawStringTaggableCenter(180,t,"To create a new account you need to",C.Z.WHITE,!0),t+=15,this.fontBold12?.drawStringTaggableCenter(180,t,"go back to the main RuneScape webpage",C.Z.WHITE,!0),t+=15,this.fontBold12?.drawStringTaggableCenter(180,t,"and choose the red 'create account'",C.Z.WHITE,!0),t+=15,this.fontBold12?.drawStringTaggableCenter(180,t,"button at the top right of that page.",C.Z.WHITE,!0),t=150,this.imageTitlebutton?.draw(e-73,t-20),this.fontBold12?.drawStringTaggableCenter(e,t+5,"Cancel",C.Z.WHITE,!0)}this.imageTitle4?.draw(214,186),this.redrawTitleBackground&&(this.redrawTitleBackground=!1,this.imageTitle2?.draw(128,0),this.imageTitle3?.draw(214,386),this.imageTitle5?.draw(0,265),this.imageTitle6?.draw(574,265),this.imageTitle7?.draw(128,186),this.imageTitle8?.draw(574,186))};login=async(e,t,i)=>{try{i||(this.loginMessage0="",this.loginMessage1="Connecting to server...",await this.drawTitleScreen()),this.stream=new w.Z(await w.Z.openSocket({host:J.K.serverAddress,port:43594+J.K.portOffset})),await(this.stream?.readBytes(this.in.data,0,8)),this.in.pos=0,this.serverSeed=this.in.g8;const s=new Int32Array([Math.floor(99999999*Math.random()),Math.floor(99999999*Math.random()),Number(this.serverSeed>>32n),Number(this.serverSeed&BigInt(4294967295))]);this.out.pos=0,this.out.p1(10),this.out.p4(s[0]),this.out.p4(s[1]),this.out.p4(s[2]),this.out.p4(s[3]),this.out.p4(0),this.out.pjstr(e),this.out.pjstr(t),this.out.rsaenc(J.K.modulus,J.K.exponent),this.loginout.pos=0,i?this.loginout.p1(18):this.loginout.p1(16),this.loginout.p1(this.out.pos+36+1+1),this.loginout.p1(J.K.clientversion),this.loginout.p1(J.K.lowMemory?1:0);for(let e=0;e<9;e++)this.loginout.p4(this.archiveChecksums[e]);this.loginout.pdata(this.out.data,this.out.pos,0),this.out.random=new Z.Z(s);for(let e=0;e<4;e++)s[e]+=50;this.randomIn=new Z.Z(s),this.stream?.write(this.loginout.data,this.loginout.pos,0);const a=await this.stream.read();if(1===a)return await(0,j._v)(2e3),void await this.login(e,t,i);if(2===a||18===a){this.rights=18===a,k.Z.setDisabled(),this.ingame=!0,this.out.pos=0,this.in.pos=0,this.packetType=-1,this.lastPacketType0=-1,this.lastPacketType1=-1,this.lastPacketType2=-1,this.packetSize=0,this.idleNetCycles=0,this.systemUpdateTimer=0,this.idleTimeout=0,this.hintType=0,this.menuSize=0,this.menuVisible=!1,this.idleCycles=0;for(let e=0;e<100;e++)this.messageText[e]=null;this.objSelected=0,this.spellSelected=0,this.sceneState=0,this.waveCount=0,this.cameraAnticheatOffsetX=(100*Math.random()|0)-50,this.cameraAnticheatOffsetZ=(110*Math.random()|0)-55,this.cameraAnticheatAngle=(80*Math.random()|0)-40,this.minimapAnticheatAngle=(120*Math.random()|0)-60,this.minimapZoom=(30*Math.random()|0)-20,this.orbitCameraYaw=(20*Math.random()|0)-10&2047,this.minimapLevel=-1,this.flagSceneTileX=0,this.flagSceneTileZ=0,this.playerCount=0,this.npcCount=0;for(let e=0;e{if(null!==this.players){this.systemUpdateTimer>1&&this.systemUpdateTimer--,this.idleTimeout>0&&this.idleTimeout--;for(let e=0;e<5&&await this.read();e++);if(this.ingame){for(let e=0;ethis.lastWaveStartTime+(this.lastWaveLength/22|0)&&(this.lastWaveLength=t.pos,this.lastWaveStartTime=Date.now(),this.lastWaveId=this.waveIds[e],this.lastWaveLoops=this.waveLoops[e],await(0,q.w3)(t.data.slice(0,t.pos),this.waveVolume))}catch(e){console.error(e)}this.waveCount--;for(let t=e;t0&&(this.nextMusicDelay-=20,this.nextMusicDelay<0&&(this.nextMusicDelay=0),0===this.nextMusicDelay&&this.midiActive&&!J.K.lowMemory&&this.currentMidi&&await this.setMidi(this.currentMidi,this.midiCrc,this.midiSize));const e=k.Z.flush();if(e&&(this.out.p1isaac(I.Z.EVENT_TRACKING),this.out.p2(e.pos),this.out.pdata(e.data,e.pos,0),e.release()),this.idleNetCycles++,this.idleNetCycles>750&&await this.tryReconnect(),this.updatePlayers(),this.updateNpcs(),this.updateEntityChats(),this.updateTemporaryLocs(),(1===this.actionKey[1]||1===this.actionKey[2]||1===this.actionKey[3]||1===this.actionKey[4])&&this.cameraMovedWrite++>5&&(this.cameraMovedWrite=0,this.out.p1isaac(I.Z.EVENT_CAMERA_POSITION),this.out.p2(this.orbitCameraPitch),this.out.p2(this.orbitCameraYaw),this.out.p1(this.minimapAnticheatAngle),this.out.p1(this.minimapZoom)),this.sceneDelta++,0!==this.crossMode&&(this.crossCycle+=20,this.crossCycle>=400&&(this.crossMode=0)),0!==this.selectedArea&&(this.selectedCycle++,this.selectedCycle>=15&&(2===this.selectedArea&&(this.redrawSidebar=!0),3===this.selectedArea&&(this.redrawChatback=!0),this.selectedArea=0)),0!==this.objDragArea&&(this.objDragCycles++,(this.mouseX>this.objGrabX+5||this.mouseXthis.objGrabY+5||this.mouseY=5){if(this.hoveredSlotParentId=-1,this.handleInput(),this.hoveredSlotParentId===this.objDragInterfaceId&&this.hoveredSlot!==this.objDragSlot){const e=c.Z.instances[this.objDragInterfaceId];if(e.invSlotObjId){const t=e.invSlotObjId[this.hoveredSlot];e.invSlotObjId[this.hoveredSlot]=e.invSlotObjId[this.objDragSlot],e.invSlotObjId[this.objDragSlot]=t}if(e.invSlotObjCount){const t=e.invSlotObjCount[this.hoveredSlot];e.invSlotObjCount[this.hoveredSlot]=e.invSlotObjCount[this.objDragSlot],e.invSlotObjCount[this.objDragSlot]=t}this.out.p1isaac(I.Z.INV_BUTTOND),this.out.p2(this.objDragInterfaceId),this.out.p2(this.objDragSlot),this.out.p2(this.hoveredSlot)}}else(1===this.mouseButtonsOption||this.isAddFriendOption(this.menuSize-1))&&this.menuSize>2?this.showContextMenu():this.menuSize>0&&await this.useMenuOption(this.menuSize-1);this.selectedCycle=10,this.mouseClickButton=0}if(J.K.updateCounter++,J.K.updateCounter>127&&(J.K.updateCounter=0,this.out.p1isaac(I.Z.ANTICHEAT_CYCLELOGIC3),this.out.p3(4991788)),-1!==R.Z.clickTileX&&this.localPlayer){const e=R.Z.clickTileX,t=R.Z.clickTileZ,i=this.tryMove(this.localPlayer.pathTileX[0],this.localPlayer.pathTileZ[0],e,t,0,0,0,0,0,0,!0);R.Z.clickTileX=-1,i&&(this.crossX=this.mouseClickX,this.crossY=this.mouseClickY,this.crossMode=1,this.crossCycle=0)}1===this.mouseClickButton&&this.modalMessage&&(this.modalMessage=null,this.redrawChatback=!0,this.mouseClickButton=0),await this.handleMouseInput(),this.handleMinimapInput(),this.handleTabInput(),this.handleChatSettingsInput(),1!==this.mouseButton&&1!==this.mouseClickButton||this.dragCycles++,2===this.sceneState&&this.updateOrbitCamera(),2===this.sceneState&&this.cutscene&&this.applyCutscene();for(let e=0;e<5;e++)this.cameraModifierCycle[e]++;if(await this.handleInputKey(),this.idleCycles++,this.idleCycles>4500&&(this.idleTimeout=250,this.idleCycles-=500,this.out.p1isaac(I.Z.IDLE_TIMER)),this.cameraOffsetCycle++,this.cameraOffsetCycle>500){this.cameraOffsetCycle=0;const e=8*Math.random()|0;1==(1&e)&&(this.cameraAnticheatOffsetX+=this.cameraOffsetXModifier),2==(2&e)&&(this.cameraAnticheatOffsetZ+=this.cameraOffsetZModifier),4==(4&e)&&(this.cameraAnticheatAngle+=this.cameraOffsetYawModifier)}if(this.cameraAnticheatOffsetX<-50&&(this.cameraOffsetXModifier=2),this.cameraAnticheatOffsetX>50&&(this.cameraOffsetXModifier=-2),this.cameraAnticheatOffsetZ<-55&&(this.cameraOffsetZModifier=2),this.cameraAnticheatOffsetZ>55&&(this.cameraOffsetZModifier=-2),this.cameraAnticheatAngle<-40&&(this.cameraOffsetYawModifier=1),this.cameraAnticheatAngle>40&&(this.cameraOffsetYawModifier=-1),this.minimapOffsetCycle++,this.minimapOffsetCycle>500){this.minimapOffsetCycle=0;const e=8*Math.random()|0;1==(1&e)&&(this.minimapAnticheatAngle+=this.minimapAngleModifier),2==(2&e)&&(this.minimapZoom+=this.minimapZoomModifier)}this.minimapAnticheatAngle<-60&&(this.minimapAngleModifier=2),this.minimapAnticheatAngle>60&&(this.minimapAngleModifier=-2),this.minimapZoom<-20&&(this.minimapZoomModifier=1),this.minimapZoom>10&&(this.minimapZoomModifier=-1),J.K.update2Counter++,J.K.update2Counter>110&&(J.K.update2Counter=0,this.out.p1isaac(I.Z.ANTICHEAT_CYCLELOGIC4),this.out.p4(0)),this.heartbeatTimer++,this.heartbeatTimer>50&&this.out.p1isaac(I.Z.NO_TIMEOUT);try{this.stream&&this.out.pos>0&&(this.stream.write(this.out.data,this.out.pos,0),this.out.pos=0,this.heartbeatTimer=0)}catch(e){console.log(e),await this.tryReconnect()}}}};drawGame=()=>{if(null===this.players)return;this.redrawTitleBackground&&(this.redrawTitleBackground=!1,this.areaBackleft1?.draw(0,11),this.areaBackleft2?.draw(0,375),this.areaBackright1?.draw(729,5),this.areaBackright2?.draw(752,231),this.areaBacktop1?.draw(0,0),this.areaBacktop2?.draw(561,0),this.areaBackvmid1?.draw(520,11),this.areaBackvmid2?.draw(520,231),this.areaBackvmid3?.draw(501,375),this.areaBackhmid2?.draw(0,345),this.redrawSidebar=!0,this.redrawChatback=!0,this.redrawSideicons=!0,this.redrawPrivacySettings=!0,2!==this.sceneState&&(this.areaViewport?.draw(8,11),this.areaMapback?.draw(561,5))),2===this.sceneState&&this.drawScene(),this.menuVisible&&1===this.menuArea&&(this.redrawSidebar=!0);let e=!1;if(-1!==this.sidebarInterfaceId&&(e=this.updateInterfaceAnimation(this.sidebarInterfaceId,this.sceneDelta),e&&(this.redrawSidebar=!0)),2===this.selectedArea&&(this.redrawSidebar=!0),2===this.objDragArea&&(this.redrawSidebar=!0),this.redrawSidebar&&(this.drawSidebar(),this.redrawSidebar=!1),-1===this.chatInterfaceId){this.chatInterface.scrollPosition=this.chatScrollHeight-this.chatScrollOffset-77,this.mouseX>453&&this.mouseX<565&&this.mouseY>350&&this.handleScrollInput(this.mouseX-22,this.mouseY-375,this.chatScrollHeight,77,!1,463,0,this.chatInterface);let e=this.chatScrollHeight-this.chatInterface.scrollPosition-77;e<0&&(e=0),e>this.chatScrollHeight-77&&(e=this.chatScrollHeight-77),this.chatScrollOffset!==e&&(this.chatScrollOffset=e,this.redrawChatback=!0)}-1!==this.chatInterfaceId&&(e=this.updateInterfaceAnimation(this.chatInterfaceId,this.sceneDelta),e&&(this.redrawChatback=!0)),3===this.selectedArea&&(this.redrawChatback=!0),3===this.objDragArea&&(this.redrawChatback=!0),this.modalMessage&&(this.redrawChatback=!0),this.menuVisible&&2===this.menuArea&&(this.redrawChatback=!0),this.redrawChatback&&(this.drawChatback(),this.redrawChatback=!1),2===this.sceneState&&(this.drawMinimap(),this.areaMapback?.draw(561,5)),-1!==this.flashingTab&&(this.redrawSideicons=!0),this.redrawSideicons&&(-1!==this.flashingTab&&this.flashingTab===this.selectedTab&&(this.flashingTab=-1,this.out.p1isaac(I.Z.TUTORIAL_CLICKSIDE),this.out.p1(this.selectedTab)),this.redrawSideicons=!1,this.areaBackhmid1?.bind(),this.imageBackhmid1?.draw(0,0),-1===this.sidebarInterfaceId&&(-1!==this.tabInterfaceId[this.selectedTab]&&(0===this.selectedTab?this.imageRedstone1?.draw(29,30):1===this.selectedTab?this.imageRedstone2?.draw(59,29):2===this.selectedTab?this.imageRedstone2?.draw(87,29):3===this.selectedTab?this.imageRedstone3?.draw(115,29):4===this.selectedTab?this.imageRedstone2h?.draw(156,29):5===this.selectedTab?this.imageRedstone2h?.draw(184,29):6===this.selectedTab&&this.imageRedstone1h?.draw(212,30)),-1!==this.tabInterfaceId[0]&&(0!==this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[0]?.draw(35,34),-1!==this.tabInterfaceId[1]&&(1!==this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[1]?.draw(59,32),-1!==this.tabInterfaceId[2]&&(2!==this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[2]?.draw(86,32),-1!==this.tabInterfaceId[3]&&(3!==this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[3]?.draw(121,33),-1!==this.tabInterfaceId[4]&&(4!==this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[4]?.draw(157,34),-1!==this.tabInterfaceId[5]&&(5!==this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[5]?.draw(185,32),-1!==this.tabInterfaceId[6]&&(6!==this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[6]?.draw(212,34)),this.areaBackhmid1?.draw(520,165),this.areaBackbase2?.bind(),this.imageBackbase2?.draw(0,0),-1===this.sidebarInterfaceId&&(-1!==this.tabInterfaceId[this.selectedTab]&&(7===this.selectedTab?this.imageRedstone1v?.draw(49,0):8===this.selectedTab?this.imageRedstone2v?.draw(81,0):9===this.selectedTab?this.imageRedstone2v?.draw(108,0):10===this.selectedTab?this.imageRedstone3v?.draw(136,1):11===this.selectedTab?this.imageRedstone2hv?.draw(178,0):12===this.selectedTab?this.imageRedstone2hv?.draw(205,0):13===this.selectedTab&&this.imageRedstone1hv?.draw(233,0)),-1!==this.tabInterfaceId[8]&&(8!==this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[7]?.draw(80,2),-1!==this.tabInterfaceId[9]&&(9!==this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[8]?.draw(107,3),-1!==this.tabInterfaceId[10]&&(10!==this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[9]?.draw(142,4),-1!==this.tabInterfaceId[11]&&(11!==this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[10]?.draw(179,2),-1!==this.tabInterfaceId[12]&&(12!==this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[11]?.draw(206,2),-1!==this.tabInterfaceId[13]&&(13!==this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[12]?.draw(230,2)),this.areaBackbase2?.draw(501,492),this.areaViewport?.bind()),this.redrawPrivacySettings&&(this.redrawPrivacySettings=!1,this.areaBackbase1?.bind(),this.imageBackbase1?.draw(0,0),this.fontPlain12?.drawStringTaggableCenter(57,33,"Public chat",C.Z.WHITE,!0),0===this.publicChatSetting&&this.fontPlain12?.drawStringTaggableCenter(57,46,"On",C.Z.GREEN,!0),1===this.publicChatSetting&&this.fontPlain12?.drawStringTaggableCenter(57,46,"Friends",C.Z.YELLOW,!0),2===this.publicChatSetting&&this.fontPlain12?.drawStringTaggableCenter(57,46,"Off",C.Z.RED,!0),3===this.publicChatSetting&&this.fontPlain12?.drawStringTaggableCenter(57,46,"Hide",C.Z.CYAN,!0),this.fontPlain12?.drawStringTaggableCenter(186,33,"Private chat",C.Z.WHITE,!0),0===this.privateChatSetting&&this.fontPlain12?.drawStringTaggableCenter(186,46,"On",C.Z.GREEN,!0),1===this.privateChatSetting&&this.fontPlain12?.drawStringTaggableCenter(186,46,"Friends",C.Z.YELLOW,!0),2===this.privateChatSetting&&this.fontPlain12?.drawStringTaggableCenter(186,46,"Off",C.Z.RED,!0),this.fontPlain12?.drawStringTaggableCenter(326,33,"Trade/duel",C.Z.WHITE,!0),0===this.tradeChatSetting&&this.fontPlain12?.drawStringTaggableCenter(326,46,"On",C.Z.GREEN,!0),1===this.tradeChatSetting&&this.fontPlain12?.drawStringTaggableCenter(326,46,"Friends",C.Z.YELLOW,!0),2===this.tradeChatSetting&&this.fontPlain12?.drawStringTaggableCenter(326,46,"Off",C.Z.RED,!0),this.fontPlain12?.drawStringTaggableCenter(462,38,"Report abuse",C.Z.WHITE,!0),this.areaBackbase1?.draw(0,471),this.areaViewport?.bind()),this.sceneDelta=0};drawScene=()=>{if(this.sceneCycle++,this.pushPlayers(),this.pushNpcs(),this.pushProjectiles(),this.pushSpotanims(),this.pushLocs(),!this.cutscene){let e=this.orbitCameraPitch;(this.cameraPitchClamp/256|0)>e&&(e=this.cameraPitchClamp/256|0),this.cameraModifierEnabled[4]&&this.cameraModifierWobbleScale[4]+128>e&&(e=this.cameraModifierWobbleScale[4]+128);const t=this.orbitCameraYaw+this.cameraAnticheatAngle&2047;if(this.localPlayer&&this.orbitCamera(this.orbitCameraX,this.getHeightmapY(this.currentLevel,this.localPlayer.x,this.localPlayer.z)-50,this.orbitCameraZ,t,e,3*e+600),J.K.drawCounter++,J.K.drawCounter>1802){J.K.drawCounter=0,this.out.p1isaac(I.Z.ANTICHEAT_CYCLELOGIC2),this.out.p1(0);const e=this.out.pos;this.out.p2(29711),this.out.p1(70),this.out.p1(256*Math.random()|0),this.out.p1(242),this.out.p1(186),this.out.p1(39),this.out.p1(61),0==(2*Math.random()|0)&&this.out.p1(13),0==(2*Math.random()|0)&&this.out.p2(57856),this.out.p2(65536*Math.random()|0),this.out.psize1(this.out.pos-e)}}let e;e=this.cutscene?this.getTopLevelCutscene():this.getTopLevel();const t=this.cameraX,i=this.cameraY,s=this.cameraZ,a=this.cameraPitch,r=this.cameraYaw;let n;for(let e=0;e<5;e++)this.cameraModifierEnabled[e]&&(n=Math.random()*(2*this.cameraModifierJitter[e]+1)-this.cameraModifierJitter[e]+Math.sin(this.cameraModifierCycle[e]*(this.cameraModifierWobbleSpeed[e]/100))*this.cameraModifierWobbleScale[e]|0,0===e&&(this.cameraX+=n),1===e&&(this.cameraY+=n),2===e&&(this.cameraZ+=n),3===e&&(this.cameraYaw=this.cameraYaw+n&2047),4===e&&(this.cameraPitch+=n,this.cameraPitch<128&&(this.cameraPitch=128),this.cameraPitch>383&&(this.cameraPitch=383)));n=f.Z.cycle,y.Z.checkHover=!0,y.Z.pickedCount=0,y.Z.mouseX=this.mouseX-8,y.Z.mouseY=this.mouseY-11,u.Z.clear(),this.scene?.draw(this.cameraX,this.cameraY,this.cameraZ,e,this.cameraYaw,this.cameraPitch,this.loopCycle),this.scene?.clearTemporaryLocs(),this.draw2DEntityElements(),this.drawTileHint(),J.K.showDebug&&this.drawDebug(),this.updateTextures(n),this.draw3DEntityElements(),this.areaViewport?.draw(8,11),this.cameraX=t,this.cameraY=i,this.cameraZ=s,this.cameraPitch=a,this.cameraYaw=r};clearCaches=()=>{a.Z.modelCacheStatic?.clear(),a.Z.modelCacheDynamic?.clear(),n.Z.modelCache?.clear(),r.Z.modelCache?.clear(),r.Z.iconCache?.clear(),H.Z.modelCache?.clear(),o.Z.modelCache?.clear()};projectFromEntity=(e,t)=>{this.projectFromGround(e.x,t,e.z)};projectFromGround=(e,t,i)=>{if(e<128||i<128||e>13056||i>13056)return this.projectX=-1,void(this.projectY=-1);const s=this.getHeightmapY(this.currentLevel,e,i)-t;this.project(e,s,i)};project=(e,t,i)=>{let s=e-this.cameraX,a=t-this.cameraY,r=i-this.cameraZ;const n=f.Z.sin[this.cameraPitch],h=f.Z.cos[this.cameraPitch],o=f.Z.sin[this.cameraYaw],l=f.Z.cos[this.cameraYaw];let c=r*o+s*l>>16;r=r*l-s*o>>16,s=c,c=a*h-r*n>>16,r=a*n+r*h>>16,a=c,r>=50?(this.projectX=f.Z.centerX+((s<<9)/r|0),this.projectY=f.Z.centerY+((a<<9)/r|0)):(this.projectX=-1,this.projectY=-1)};draw2DEntityElements=()=>{this.chatCount=0;for(let e=-1;e-1))for(let e=0;e<8;e++)0!=(s.headicons&1<=0&&10===this.hintType&&this.hintPlayer===this.playerIds[e]&&(this.projectFromEntity(t,t.height+15),this.projectX>-1&&this.imageHeadicons[7]&&this.imageHeadicons[7].draw(this.projectX-12,this.projectY-i))}else 1===this.hintType&&this.hintNpc===this.npcIds[e-this.playerCount]&&this.loopCycle%20<10&&(this.projectFromEntity(t,t.height+15),this.projectX>-1&&this.imageHeadicons[2]&&this.imageHeadicons[2].draw(this.projectX-12,this.projectY-28));if(t.chat&&(e>=this.playerCount||0===this.publicChatSetting||3===this.publicChatSetting||1===this.publicChatSetting&&this.isFriend(t.name))&&(this.projectFromEntity(t,t.height),this.projectX>-1&&this.chatCountthis.loopCycle+100&&(this.projectFromEntity(t,t.height+15),this.projectX>-1)){let e=30*t.health/t.totalHealth|0;e>30&&(e=30),u.Z.fillRect(this.projectX-15,this.projectY-3,e,5,C.Z.GREEN),u.Z.fillRect(this.projectX-15+e,this.projectY-3,30-e,5,C.Z.RED)}t.combatCycle>this.loopCycle+330&&(this.projectFromEntity(t,t.height/2|0),this.projectX>-1&&this.imageHitmarks[t.damageType]&&(this.imageHitmarks[t.damageType].draw(this.projectX-12,this.projectY-12),this.fontPlain11?.drawStringCenter(this.projectX,this.projectY+4,t.damage.toString(),C.Z.BLACK),this.fontPlain11?.drawStringCenter(this.projectX-1,this.projectY+3,t.damage.toString(),C.Z.WHITE)))}}for(let e=0;ethis.chatY[n]-this.chatHeight[n]&&i-athis.chatX[n]-this.chatWidth[n]&&this.chatY[n]-this.chatHeight[n]{2===this.hintType&&this.imageHeadicons[2]&&(this.projectFromGround((this.hintTileX-this.sceneBaseTileX<<7)+this.hintOffsetX,2*this.hintHeight,(this.hintTileZ-this.sceneBaseTileZ<<7)+this.hintOffsetZ),this.projectX>-1&&this.loopCycle%20<10&&this.imageHeadicons[2].draw(this.projectX-12,this.projectY-28))};drawDebug=()=>{const e=507;let t=20;this.fontPlain11?.drawStringRight(e,t,`FPS: ${this.fps}`,C.Z.YELLOW,!0),t+=13,this.fontPlain11?.drawStringRight(e,t,`Speed: ${this.ms.toFixed(4)} ms`,C.Z.YELLOW,!0),t+=13,this.fontPlain11?.drawStringRight(e,t,`Average: ${this.msAvg.toFixed(4)} ms`,C.Z.YELLOW,!0),t+=13,this.fontPlain11?.drawStringRight(e,t,`Slowest: ${this.slowestMS.toFixed(4)} ms`,C.Z.YELLOW,!0),t+=13,this.fontPlain11?.drawStringRight(e,t,`Occluders: ${R.Z.activeOccluderCount}`,C.Z.YELLOW,!0)};draw3DEntityElements=()=>{if(this.drawPrivateMessages(),1===this.crossMode&&this.imageCrosses[this.crossCycle/100|0]?.draw(this.crossX-8-8,this.crossY-8-11),2===this.crossMode&&this.imageCrosses[4+(this.crossCycle/100|0)]?.draw(this.crossX-8-8,this.crossY-8-11),-1!==this.viewportInterfaceId&&(this.updateInterfaceAnimation(this.viewportInterfaceId,this.sceneDelta),this.drawInterface(c.Z.instances[this.viewportInterfaceId],0,0,0)),this.drawWildyLevel(),this.menuVisible?0===this.menuArea&&this.drawMenu():(this.handleInput(),this.drawTooltip()),1===this.inMultizone&&(this.wildernessLevel>0||1===this.worldLocationState?this.imageHeadicons[1]?.draw(472,258):this.imageHeadicons[1]?.draw(472,296)),this.wildernessLevel>0&&(this.imageHeadicons[0]?.draw(472,296),this.fontPlain12?.drawStringCenter(484,329,"Level: "+this.wildernessLevel,C.Z.YELLOW)),1===this.worldLocationState&&(this.imageHeadicons[6]?.draw(472,296),this.fontPlain12?.drawStringCenter(484,329,"Arena",C.Z.YELLOW)),0!==this.systemUpdateTimer){let e=this.systemUpdateTimer/50|0;const t=e/60|0;e%=60,e<10?this.fontPlain12?.drawString(4,329,"System update in: "+t+":0"+e,C.Z.YELLOW):this.fontPlain12?.drawString(4,329,"System update in: "+t+":"+e,C.Z.YELLOW)}};drawPrivateMessages=()=>{if(0===this.splitPrivateChat)return;const e=this.fontPlain12;let t=0;0!==this.systemUpdateTimer&&(t=1);for(let i=0;i<100;i++){if(!this.messageText[i])continue;const s=this.messageType[i];let a;if((3===s||7===s)&&(7===s||0===this.privateChatSetting||1===this.privateChatSetting&&this.isFriend(this.messageSender[i]))&&(a=329-13*t,e?.drawString(4,a,"From "+this.messageSender[i]+": "+this.messageText[i],C.Z.BLACK),e?.drawString(4,a-1,"From "+this.messageSender[i]+": "+this.messageText[i],C.Z.CYAN),t++,t>=5))return;if(5===s&&this.privateChatSetting<2&&(a=329-13*t,e?.drawString(4,a,this.messageText[i],C.Z.BLACK),e?.drawString(4,a-1,this.messageText[i],C.Z.CYAN),t++,t>=5))return;if(6===s&&this.privateChatSetting<2&&(a=329-13*t,e?.drawString(4,a,"To "+this.messageSender[i]+": "+this.messageText[i],C.Z.BLACK),e?.drawString(4,a-1,"To "+this.messageSender[i]+": "+this.messageText[i],C.Z.CYAN),t++,t>=5))return}};drawWildyLevel=()=>{if(!this.localPlayer)return;const e=(this.localPlayer.x>>7)+this.sceneBaseTileX,t=(this.localPlayer.z>>7)+this.sceneBaseTileZ;if(this.wildernessLevel=e>=2944&&e<3392&&t>=3520&&t<6400?1+((t-3520)/8|0):e>=2944&&e<3392&&t>=9920&&t<12800?1+((t-9920)/8|0):0,this.worldLocationState=0,e>=3328&&e<3392&&t>=3200&&t<3264){const i=63&e,s=63&t;(i>=4&&i<=29&&s>=44&&s<=58||i>=36&&i<=61&&s>=44&&s<=58||i>=4&&i<=29&&s>=25&&s<=39||i>=36&&i<=61&&s>=25&&s<=39||i>=4&&i<=29&&s>=6&&s<=20||i>=36&&i<=61&&s>=6&&s<=20)&&(this.worldLocationState=1)}0===this.worldLocationState&&e>=3328&&e<=3393&&t>=3203&&t<=3325&&(this.worldLocationState=2),this.overrideChat=0,(e>=3053&&e<=3156&&t>=3056&&t<=3136||e>=3072&&e<=3118&&t>=9492&&t<=9535)&&(this.overrideChat=1),1===this.overrideChat&&e>=3139&&e<=3199&&t>=3008&&t<=3062&&(this.overrideChat=0)};drawSidebar=()=>{this.areaSidebar?.bind(),this.areaSidebarOffsets&&(f.Z.lineOffset=this.areaSidebarOffsets),this.imageInvback?.draw(0,0),-1!==this.sidebarInterfaceId?this.drawInterface(c.Z.instances[this.sidebarInterfaceId],0,0,0):-1!==this.tabInterfaceId[this.selectedTab]&&this.drawInterface(c.Z.instances[this.tabInterfaceId[this.selectedTab]],0,0,0),this.menuVisible&&1===this.menuArea&&this.drawMenu(),this.areaSidebar?.draw(562,231),this.areaViewport?.bind(),this.areaViewportOffsets&&(f.Z.lineOffset=this.areaViewportOffsets)};drawChatback=()=>{if(this.areaChatback?.bind(),this.areaChatbackOffsets&&(f.Z.lineOffset=this.areaChatbackOffsets),this.imageChatback?.draw(0,0),this.showSocialInput)this.fontBold12?.drawStringCenter(239,40,this.socialMessage,C.Z.BLACK),this.fontBold12?.drawStringCenter(239,60,this.socialInput+"*",C.Z.DARKBLUE);else if(this.chatbackInputOpen)this.fontBold12?.drawStringCenter(239,40,"Enter amount:",C.Z.BLACK),this.fontBold12?.drawStringCenter(239,60,this.chatbackInput+"*",C.Z.DARKBLUE);else if(this.modalMessage)this.fontBold12?.drawStringCenter(239,40,this.modalMessage,C.Z.BLACK),this.fontBold12?.drawStringCenter(239,60,"Click to continue",C.Z.DARKBLUE);else if(-1!==this.chatInterfaceId)this.drawInterface(c.Z.instances[this.chatInterfaceId],0,0,0);else if(-1===this.stickyChatInterfaceId){const e=this.fontPlain12;let t=0;u.Z.setBounds(0,0,463,77);for(let i=0;i<100;i++){const s=this.messageText[i];if(!s)continue;const a=this.messageType[i],r=this.chatScrollOffset+70-14*t;0===a&&(r>0&&r<110&&e?.drawString(4,r,s,C.Z.BLACK),t++),1===a&&(r>0&&r<110&&(e?.drawString(4,r,this.messageSender[i]+":",C.Z.WHITE),e?.drawString(e.stringWidth(this.messageSender[i])+12,r,s,C.Z.BLUE)),t++),2===a&&(0===this.publicChatSetting||1===this.publicChatSetting&&this.isFriend(this.messageSender[i]))&&(r>0&&r<110&&(e?.drawString(4,r,this.messageSender[i]+":",C.Z.BLACK),e?.drawString(e.stringWidth(this.messageSender[i])+12,r,s,C.Z.BLUE)),t++),3!==a&&7!==a||0!==this.splitPrivateChat||!(7===a||0===this.privateChatSetting||1===this.privateChatSetting&&this.isFriend(this.messageSender[i]))||(r>0&&r<110&&(e?.drawString(4,r,"From "+this.messageSender[i]+":",C.Z.BLACK),e?.drawString(e.stringWidth("From "+this.messageSender[i])+12,r,s,C.Z.DARKRED)),t++),4===a&&(0===this.tradeChatSetting||1===this.tradeChatSetting&&this.isFriend(this.messageSender[i]))&&(r>0&&r<110&&e?.drawString(4,r,this.messageSender[i]+" "+this.messageText[i],C.Z.TRADE_MESSAGE),t++),5===a&&0===this.splitPrivateChat&&this.privateChatSetting<2&&(r>0&&r<110&&e?.drawString(4,r,s,C.Z.DARKRED),t++),6===a&&0===this.splitPrivateChat&&this.privateChatSetting<2&&(r>0&&r<110&&(e?.drawString(4,r,"To "+this.messageSender[i]+":",C.Z.BLACK),e?.drawString(e.stringWidth("To "+this.messageSender[i])+12,r,s,C.Z.DARKRED)),t++),8===a&&(0===this.tradeChatSetting||1===this.tradeChatSetting&&this.isFriend(this.messageSender[i]))&&(r>0&&r<110&&e?.drawString(4,r,this.messageSender[i]+" "+this.messageText[i],C.Z.DUEL_MESSAGE),t++)}u.Z.resetBounds(),this.chatScrollHeight=14*t+7,this.chatScrollHeight<78&&(this.chatScrollHeight=78),this.drawScrollbar(463,0,this.chatScrollHeight-this.chatScrollOffset-77,this.chatScrollHeight,77),e?.drawString(4,90,_.Z.formatName(this.username)+":",C.Z.BLACK),e?.drawString(e.stringWidth(this.username+": ")+6,90,this.chatTyped+"*",C.Z.BLUE),u.Z.drawHorizontalLine(0,77,C.Z.BLACK,479)}else this.drawInterface(c.Z.instances[this.stickyChatInterfaceId],0,0,0);this.menuVisible&&2===this.menuArea&&this.drawMenu(),this.areaChatback?.draw(22,375),this.areaViewport?.bind(),this.areaViewportOffsets&&(f.Z.lineOffset=this.areaViewportOffsets)};drawMinimap=()=>{if(this.areaMapback?.bind(),!this.localPlayer)return;const e=this.orbitCameraYaw+this.minimapAnticheatAngle&2047;let t=48+(this.localPlayer.x/32|0),i=464-(this.localPlayer.z/32|0);this.imageMinimap?.drawRotatedMasked(21,9,146,151,this.minimapMaskLineOffsets,this.minimapMaskLineLengths,t,i,e,this.minimapZoom+256),this.imageCompass?.drawRotatedMasked(0,0,33,33,this.compassMaskLineOffsets,this.compassMaskLineLengths,25,25,this.orbitCameraYaw,256);for(let e=0;e{if(!t)return;const s=this.orbitCameraYaw+this.minimapAnticheatAngle&2047,a=i*i+e*e;if(a>6400)return;let r=f.Z.sin[s],n=f.Z.cos[s];r=256*r/(this.minimapZoom+256)|0,n=256*n/(this.minimapZoom+256)|0;const h=e*r+i*n>>16,o=e*n-i*r>>16;a>2500&&this.imageMapback?t.drawMasked(h+94-(t.cropW/2|0),83-o-(t.cropH/2|0),this.imageMapback):t.draw(h+94-(t.cropW/2|0),83-o-(t.cropH/2|0))};createMinimap=e=>{if(!this.imageMinimap)return;const t=this.imageMinimap.pixels,i=t.length;for(let e=0;e>14&32767;const s=a.Z.get(i).mapfunction;if(s<0)continue;let r=e,n=t;if(22!==s&&29!==s&&34!==s&&36!==s&&46!==s&&47!==s&&48!==s){const i=X.Z.SIZE,s=X.Z.SIZE,a=this.levelCollisionMap[this.currentLevel];if(a){const h=a.flags;for(let a=0;a<10;a++){const a=4*Math.random()|0;0===a&&r>0&&r>e-3&&(h[X.Z.index(r-1,n)]&F.Z.BLOCK_WEST)===F.Z.OPEN&&r--,1===a&&r0&&n>t-3&&(h[X.Z.index(r,n-1)]&F.Z.BLOCK_SOUTH)===F.Z.OPEN&&n--,3===a&&n{if(!this.scene||!this.imageMinimap)return;let n=this.scene.getWallBitset(i,e,t);if(0!==n){const h=this.scene.getInfo(i,e,t,n),o=h>>6&3,l=31&h;let c=s;n>0&&(c=r);const d=this.imageMinimap.pixels,u=4*e+512*(103-t)*4+24624,f=n>>14&32767,p=a.Z.get(f);if(-1===p.mapscene)l!==N.Z.WALL_STRAIGHT&&l!==N.Z.WALL_L||(o===B.Z.WEST?(d[u]=c,d[u+512]=c,d[u+1024]=c,d[u+1536]=c):o===B.Z.NORTH?(d[u]=c,d[u+1]=c,d[u+2]=c,d[u+3]=c):o===B.Z.EAST?(d[u+3]=c,d[u+3+512]=c,d[u+3+1024]=c,d[u+3+1536]=c):o===B.Z.SOUTH&&(d[u+1536]=c,d[u+1536+1]=c,d[u+1536+2]=c,d[u+1536+3]=c)),l===N.Z.WALL_SQUARE_CORNER&&(o===B.Z.WEST?d[u]=c:o===B.Z.NORTH?d[u+3]=c:o===B.Z.EAST?d[u+3+1536]=c:o===B.Z.SOUTH&&(d[u+1536]=c)),l===N.Z.WALL_L&&(o===B.Z.SOUTH?(d[u]=c,d[u+512]=c,d[u+1024]=c,d[u+1536]=c):o===B.Z.WEST?(d[u]=c,d[u+1]=c,d[u+2]=c,d[u+3]=c):o===B.Z.NORTH?(d[u+3]=c,d[u+3+512]=c,d[u+3+1024]=c,d[u+3+1536]=c):o===B.Z.EAST&&(d[u+1536]=c,d[u+1536+1]=c,d[u+1536+2]=c,d[u+1536+3]=c));else{const i=this.imageMapscene[p.mapscene];if(i){const s=(4*p.width-i.width)/2|0,a=(4*p.length-i.height)/2|0;i.draw(4*e+48+s,4*(X.Z.SIZE-t-p.length)+a+48)}}}if(n=this.scene.getLocBitset(i,e,t),0!==n){const s=this.scene.getInfo(i,e,t,n),r=s>>6&3,h=31&s,o=n>>14&32767,l=a.Z.get(o);if(-1!==l.mapscene){const i=this.imageMapscene[l.mapscene];if(i){const s=(4*l.width-i.width)/2|0,a=(4*l.length-i.height)/2|0;i.draw(4*e+48+s,4*(X.Z.SIZE-t-l.length)+a+48)}}else if(h===N.Z.WALL_DIAGONAL){let i=15658734;n>0&&(i=15597568);const s=this.imageMinimap.pixels,a=4*e+512*(X.Z.SIZE-1-t)*4+24624;r===B.Z.WEST||r===B.Z.EAST?(s[a+1536]=i,s[a+1024+1]=i,s[a+512+2]=i,s[a+3]=i):(s[a]=i,s[a+512+1]=i,s[a+1024+2]=i,s[a+1536+3]=i)}}if(n=this.scene.getGroundDecorationBitset(i,e,t),0!==n){const i=a.Z.get(n>>14&32767);if(-1!==i.mapscene){const s=this.imageMapscene[i.mapscene];if(s){const a=(4*i.width-s.width)/2|0,r=(4*i.length-s.height)/2|0;s.draw(4*e+48+a,4*(X.Z.SIZE-t-i.length)+r+48)}}}};drawTooltip=()=>{if(this.menuSize<2&&0===this.objSelected&&0===this.spellSelected)return;let e;e=1===this.objSelected&&this.menuSize<2?"Use "+this.objSelectedName+" with...":1===this.spellSelected&&this.menuSize<2?this.spellCaption+"...":this.menuOption[this.menuSize-1],this.menuSize>2&&(e=e+"@whi@ / "+(this.menuSize-2)+" more options"),this.fontBold12?.drawStringTooltip(4,15,e,C.Z.WHITE,!0,this.loopCycle/1e3|0)};drawMenu=()=>{const e=this.menuX,t=this.menuY,i=this.menuWidth,s=this.menuHeight,a=C.Z.OPTIONS_MENU;u.Z.fillRect(e,t,i,s,a),u.Z.fillRect(e+1,t+1,i-2,16,C.Z.BLACK),u.Z.drawRect(e+1,t+18,i-2,s-19,C.Z.BLACK),this.fontBold12?.drawString(e+3,t+14,"Choose Option",a);let r=this.mouseX,n=this.mouseY;0===this.menuArea&&(r-=8,n-=11),1===this.menuArea&&(r-=562,n-=231),2===this.menuArea&&(r-=22,n-=375);for(let s=0;se&&ra-13&&n{if(0!==this.objDragArea)return;let e=this.mouseClickButton;if(1===this.spellSelected&&this.mouseClickX>=520&&this.mouseClickY>=165&&this.mouseClickX<=788&&this.mouseClickY<=230&&(e=0),this.menuVisible){if(1!==e){let e=this.mouseX,t=this.mouseY;0===this.menuArea?(e-=8,t-=11):1===this.menuArea?(e-=562,t-=231):2===this.menuArea&&(e-=22,t-=375),(ethis.menuX+this.menuWidth+10||tthis.menuY+this.menuHeight+10)&&(this.menuVisible=!1,1===this.menuArea&&(this.redrawSidebar=!0),2===this.menuArea&&(this.redrawChatback=!0))}if(1===e){const e=this.menuX,t=this.menuY,i=this.menuWidth;let s=this.mouseClickX,a=this.mouseClickY;0===this.menuArea?(s-=8,a-=11):1===this.menuArea?(s-=562,a-=231):2===this.menuArea&&(s-=22,a-=375);let r=-1;for(let n=0;ne&&sh-13&&a0){const e=this.menuAction[this.menuSize-1];if(602===e||596===e||22===e||892===e||415===e||405===e||38===e||422===e||478===e||347===e||188===e){const e=this.menuParamB[this.menuSize-1],t=this.menuParamC[this.menuSize-1];if(c.Z.instances[t].draggable)return this.objGrabThreshold=!1,this.objDragCycles=0,this.objDragInterfaceId=t,this.objDragSlot=e,this.objDragArea=2,this.objGrabX=this.mouseClickX,this.objGrabY=this.mouseClickY,c.Z.instances[t].layer===this.viewportInterfaceId&&(this.objDragArea=1),void(c.Z.instances[t].layer===this.chatInterfaceId&&(this.objDragArea=3))}}if(1===e&&(1===this.mouseButtonsOption||this.isAddFriendOption(this.menuSize-1))&&this.menuSize>2&&(e=2),1===e&&this.menuSize>0&&await this.useMenuOption(this.menuSize-1),2!==e||this.menuSize<=0)return;this.showContextMenu()}};handleMinimapInput=()=>{if(1===this.mouseClickButton&&this.localPlayer){let e=this.mouseClickX-21-561,t=this.mouseClickY-9-5;if(e>=0&&t>=0&&e<146&&t<151){e-=73,t-=75;const i=this.orbitCameraYaw+this.minimapAnticheatAngle&2047;let s=f.Z.sin[i],a=f.Z.cos[i];s=s*(this.minimapZoom+256)>>8,a=a*(this.minimapZoom+256)>>8;const r=t*s+e*a>>11,n=t*a-e*s>>11,h=this.localPlayer.x+r>>7,o=this.localPlayer.z-n>>7;this.tryMove(this.localPlayer.pathTileX[0],this.localPlayer.pathTileZ[0],h,o,1,0,0,0,0,0,!0)&&(this.out.p1(e),this.out.p1(t),this.out.p2(this.orbitCameraYaw),this.out.p1(57),this.out.p1(this.minimapAnticheatAngle),this.out.p1(this.minimapZoom),this.out.p1(89),this.out.p2(this.localPlayer.x),this.out.p2(this.localPlayer.z),this.out.p1(this.tryMoveNearest),this.out.p1(63))}}};isAddFriendOption=e=>{if(e<0)return!1;let t=this.menuAction[e];return t>=2e3&&(t-=2e3),406===t};useMenuOption=async e=>{if(e<0)return;this.chatbackInputOpen&&(this.chatbackInputOpen=!1,this.redrawChatback=!0);let t=this.menuAction[e];const i=this.menuParamA[e],s=this.menuParamB[e],n=this.menuParamC[e];if(t>=2e3&&(t-=2e3),903===t||363===t){let i=this.menuOption[e];const s=i.indexOf("@whi@");if(-1!==s){i=i.substring(s+5).trim();const e=_.Z.formatName(_.Z.fromBase37(_.Z.toBase37(i)));let a=!1;for(let i=0;i=90&&this.out.p1isaac(I.Z.ANTICHEAT_OPLOGIC5),this.out.p1isaac(I.Z.OPHELD4)):347===t?this.out.p1isaac(I.Z.OPHELD5):422===t?this.out.p1isaac(I.Z.OPHELD3):405===t?(J.K.opHeld4Counter+=i,J.K.opHeld4Counter>=97&&(this.out.p1isaac(I.Z.ANTICHEAT_OPLOGIC3),this.out.p3(14953816)),this.out.p1isaac(I.Z.OPHELD1)):38===t&&this.out.p1isaac(I.Z.OPHELD2),this.out.p2(i),this.out.p2(s),this.out.p2(n),this.selectedCycle=0,this.selectedInterface=n,this.selectedItem=s,this.selectedArea=2,c.Z.instances[n].layer===this.viewportInterfaceId&&(this.selectedArea=1),c.Z.instances[n].layer===this.chatInterfaceId&&(this.selectedArea=3);else if(728===t||542===t||6===t||963===t||245===t){const e=this.npcs[i];e&&this.localPlayer&&(this.tryMove(this.localPlayer.pathTileX[0],this.localPlayer.pathTileZ[0],e.pathTileX[0],e.pathTileZ[0],2,1,1,0,0,0,!1),this.crossX=this.mouseClickX,this.crossY=this.mouseClickY,this.crossMode=2,this.crossCycle=0,542===t?this.out.p1isaac(I.Z.OPNPC2):6===t?(0==(3&i)&&J.K.opNpc3Counter++,J.K.opNpc3Counter>=124&&(this.out.p1isaac(I.Z.ANTICHEAT_OPLOGIC2),this.out.p4(0)),this.out.p1isaac(I.Z.OPNPC3)):963===t?this.out.p1isaac(I.Z.OPNPC4):728===t?this.out.p1isaac(I.Z.OPNPC1):245===t&&(0==(3&i)&&J.K.opNpc5Counter++,J.K.opNpc5Counter>=85&&(this.out.p1isaac(I.Z.ANTICHEAT_OPLOGIC4),this.out.p2(39596)),this.out.p1isaac(I.Z.OPNPC5)),this.out.p2(i))}else if(217===t)this.localPlayer&&(this.tryMove(this.localPlayer.pathTileX[0],this.localPlayer.pathTileZ[0],s,n,2,0,0,0,0,0,!1)||this.tryMove(this.localPlayer.pathTileX[0],this.localPlayer.pathTileZ[0],s,n,2,1,1,0,0,0,!1),this.crossX=this.mouseClickX,this.crossY=this.mouseClickY,this.crossMode=2,this.crossCycle=0,this.out.p1isaac(I.Z.OPOBJU),this.out.p2(s+this.sceneBaseTileX),this.out.p2(n+this.sceneBaseTileZ),this.out.p2(i),this.out.p2(this.objInterface),this.out.p2(this.objSelectedSlot),this.out.p2(this.objSelectedInterface));else if(1175===t){const e=i>>14&32767,t=a.Z.get(e);let s;s=t.desc?t.desc:"It's a "+t.name+".",this.addMessage(0,s,"")}else if(285===t)this.interactWithLoc(I.Z.OPLOC1,s,n,i);else if(881===t)this.out.p1isaac(I.Z.OPHELDU),this.out.p2(i),this.out.p2(s),this.out.p2(n),this.out.p2(this.objInterface),this.out.p2(this.objSelectedSlot),this.out.p2(this.objSelectedInterface),this.selectedCycle=0,this.selectedInterface=n,this.selectedItem=s,this.selectedArea=2,c.Z.instances[n].layer===this.viewportInterfaceId&&(this.selectedArea=1),c.Z.instances[n].layer===this.chatInterfaceId&&(this.selectedArea=3);else if(391===t)this.out.p1isaac(I.Z.OPHELDT),this.out.p2(i),this.out.p2(s),this.out.p2(n),this.out.p2(this.activeSpellId),this.selectedCycle=0,this.selectedInterface=n,this.selectedItem=s,this.selectedArea=2,c.Z.instances[n].layer===this.viewportInterfaceId&&(this.selectedArea=1),c.Z.instances[n].layer===this.chatInterfaceId&&(this.selectedArea=3);else if(660===t)this.menuVisible?this.scene?.click(s-8,n-11):this.scene?.click(this.mouseClickX-8,this.mouseClickY-11);else{if(188===t)return this.objSelected=1,this.objSelectedSlot=s,this.objSelectedInterface=n,this.objInterface=i,this.objSelectedName=r.Z.get(i).name,void(this.spellSelected=0);if(44===t)this.pressedContinueOption||(this.out.p1isaac(I.Z.RESUME_PAUSEBUTTON),this.out.p2(n),this.pressedContinueOption=!0);else if(1773===t){const e=r.Z.get(i);let t;t=n>=1e5?n+" x "+e.name:e.desc?e.desc:"It's a "+e.name+".",this.addMessage(0,t,"")}else if(900===t){const e=this.npcs[i];e&&this.localPlayer&&(this.tryMove(this.localPlayer.pathTileX[0],this.localPlayer.pathTileZ[0],e.pathTileX[0],e.pathTileZ[0],2,1,1,0,0,0,!1),this.crossX=this.mouseClickX,this.crossY=this.mouseClickY,this.crossMode=2,this.crossCycle=0,this.out.p1isaac(I.Z.OPNPCU),this.out.p2(i),this.out.p2(this.objInterface),this.out.p2(this.objSelectedSlot),this.out.p2(this.objSelectedInterface))}else if(1373===t||1544===t||151===t||1101===t){const e=this.players[i];e&&this.localPlayer&&(this.tryMove(this.localPlayer.pathTileX[0],this.localPlayer.pathTileZ[0],e.pathTileX[0],e.pathTileZ[0],2,1,1,0,0,0,!1),this.crossX=this.mouseClickX,this.crossY=this.mouseClickY,this.crossMode=2,this.crossCycle=0,1101===t?this.out.p1isaac(I.Z.OPPLAYER1):151===t?(J.K.opPlayer2Counter++,J.K.opPlayer2Counter>=90&&(this.out.p1isaac(I.Z.ANTICHEAT_OPLOGIC8),this.out.p2(31114)),this.out.p1isaac(I.Z.OPPLAYER2)):1373===t?this.out.p1isaac(I.Z.OPPLAYER4):1544===t&&this.out.p1isaac(I.Z.OPPLAYER3),this.out.p2(i))}else if(265===t){const e=this.npcs[i];e&&this.localPlayer&&(this.tryMove(this.localPlayer.pathTileX[0],this.localPlayer.pathTileZ[0],e.pathTileX[0],e.pathTileZ[0],2,1,1,0,0,0,!1),this.crossX=this.mouseClickX,this.crossY=this.mouseClickY,this.crossMode=2,this.crossCycle=0,this.out.p1isaac(I.Z.OPNPCT),this.out.p2(i),this.out.p2(this.activeSpellId))}else if(679===t){const t=this.menuOption[e],i=t.indexOf("@whi@");if(-1!==i){const e=_.Z.toBase37(t.substring(i+5).trim());let s=-1;for(let t=0;t0&&(this.redrawChatback=!0,this.chatbackInputOpen=!1,this.showSocialInput=!0,this.socialInput="",this.socialAction=3,this.socialName37=this.friendName37[s],this.socialMessage="Enter message to send to "+this.friendName[s])}}else if(55===t)this.interactWithLoc(I.Z.OPLOCT,s,n,i)&&this.out.p2(this.activeSpellId);else if(224===t||993===t||99===t||746===t||877===t)this.localPlayer&&(this.tryMove(this.localPlayer.pathTileX[0],this.localPlayer.pathTileZ[0],s,n,2,0,0,0,0,0,!1)||this.tryMove(this.localPlayer.pathTileX[0],this.localPlayer.pathTileZ[0],s,n,2,1,1,0,0,0,!1),this.crossX=this.mouseClickX,this.crossY=this.mouseClickY,this.crossMode=2,this.crossCycle=0,224===t?this.out.p1isaac(I.Z.OPOBJ1):746===t?this.out.p1isaac(I.Z.OPOBJ4):877===t?this.out.p1isaac(I.Z.OPOBJ5):99===t?this.out.p1isaac(I.Z.OPOBJ3):993===t&&this.out.p1isaac(I.Z.OPOBJ2),this.out.p2(s+this.sceneBaseTileX),this.out.p2(n+this.sceneBaseTileZ),this.out.p2(i));else if(1607===t){const e=this.npcs[i];if(e&&e.type){let t;t=e.type.desc?e.type.desc:"It's a "+e.type.name+".",this.addMessage(0,t,"")}}else if(504===t)this.interactWithLoc(I.Z.OPLOC2,s,n,i);else{if(930===t){const e=c.Z.instances[n];this.spellSelected=1,this.activeSpellId=n,this.activeSpellFlags=e.actionTarget,this.objSelected=0;let t=e.actionVerb;t&&-1!==t.indexOf(" ")&&(t=t.substring(0,t.indexOf(" ")));let i=e.actionVerb;return i&&-1!==i.indexOf(" ")&&(i=i.substring(i.indexOf(" ")+1)),this.spellCaption=t+" "+e.action+" "+i,void(16===this.activeSpellFlags&&(this.redrawSidebar=!0,this.selectedTab=3,this.redrawSideicons=!0))}if(951===t){const e=c.Z.instances[n];let t=!0;e.clientCode>0&&(t=this.handleInterfaceAction(e)),t&&(this.out.p1isaac(I.Z.IF_BUTTON),this.out.p2(n))}else if(602===t||596===t||22===t||892===t||415===t)22===t?this.out.p1isaac(I.Z.INV_BUTTON3):415===t?(0==(3&n)&&J.K.ifButton5Counter++,J.K.ifButton5Counter>=55&&(this.out.p1isaac(I.Z.ANTICHEAT_OPLOGIC7),this.out.p4(0)),this.out.p1isaac(I.Z.INV_BUTTON5)):602===t?this.out.p1isaac(I.Z.INV_BUTTON1):892===t?(0==(3&s)&&J.K.opHeld9Counter++,J.K.opHeld9Counter>=130&&(this.out.p1isaac(I.Z.ANTICHEAT_OPLOGIC9),this.out.p1(177)),this.out.p1isaac(I.Z.INV_BUTTON4)):596===t&&this.out.p1isaac(I.Z.INV_BUTTON2),this.out.p2(i),this.out.p2(s),this.out.p2(n),this.selectedCycle=0,this.selectedInterface=n,this.selectedItem=s,this.selectedArea=2,c.Z.instances[n].layer===this.viewportInterfaceId&&(this.selectedArea=1),c.Z.instances[n].layer===this.chatInterfaceId&&(this.selectedArea=3);else if(581===t)0==(3&i)&&J.K.opLoc4Counter++,J.K.opLoc4Counter>=99&&(this.out.p1isaac(I.Z.ANTICHEAT_OPLOGIC1),this.out.p4(0)),this.interactWithLoc(I.Z.OPLOC4,s,n,i);else if(965===t)this.localPlayer&&(this.tryMove(this.localPlayer.pathTileX[0],this.localPlayer.pathTileZ[0],s,n,2,0,0,0,0,0,!1)||this.tryMove(this.localPlayer.pathTileX[0],this.localPlayer.pathTileZ[0],s,n,2,1,1,0,0,0,!1),this.crossX=this.mouseClickX,this.crossY=this.mouseClickY,this.crossMode=2,this.crossCycle=0,this.out.p1isaac(I.Z.OPOBJT),this.out.p2(s+this.sceneBaseTileX),this.out.p2(n+this.sceneBaseTileZ),this.out.p2(i),this.out.p2(this.activeSpellId));else if(1501===t)J.K.opLoc5Counter+=this.sceneBaseTileZ,J.K.opLoc5Counter>=92&&(this.out.p1isaac(I.Z.ANTICHEAT_OPLOGIC6),this.out.p4(0)),this.interactWithLoc(I.Z.OPLOC5,s,n,i);else if(364===t)this.interactWithLoc(I.Z.OPLOC3,s,n,i);else if(1102===t){const e=r.Z.get(i);let t;t=e.desc?e.desc:"It's a "+e.name+".",this.addMessage(0,t,"")}else if(960===t){this.out.p1isaac(I.Z.IF_BUTTON),this.out.p2(n);const e=c.Z.instances[n];if(e.scripts&&e.scripts[0]&&5===e.scripts[0][0]){const t=e.scripts[0][1];e.scriptOperand&&this.varps[t]!==e.scriptOperand[0]&&(this.varps[t]=e.scriptOperand[0],await this.updateVarp(t),this.redrawSidebar=!0)}}else if(34===t){const t=this.menuOption[e],i=t.indexOf("@whi@");if(-1!==i){this.closeInterfaces(),this.reportAbuseInput=t.substring(i+5).trim(),this.reportAbuseMuteOption=!1;for(let e=0;e{const t=e.clientCode;if(t===c.Z.CC_ADD_FRIEND&&(this.redrawChatback=!0,this.chatbackInputOpen=!1,this.showSocialInput=!0,this.socialInput="",this.socialAction=1,this.socialMessage="Enter name of friend to add to list"),t===c.Z.CC_DEL_FRIEND&&(this.redrawChatback=!0,this.chatbackInputOpen=!1,this.showSocialInput=!0,this.socialInput="",this.socialAction=2,this.socialMessage="Enter name of friend to delete from list"),t===c.Z.CC_LOGOUT)return this.idleTimeout=250,!0;if(t===c.Z.CC_ADD_IGNORE&&(this.redrawChatback=!0,this.chatbackInputOpen=!1,this.showSocialInput=!0,this.socialInput="",this.socialAction=4,this.socialMessage="Enter name of player to add to list"),t===c.Z.CC_DEL_IGNORE&&(this.redrawChatback=!0,this.chatbackInputOpen=!1,this.showSocialInput=!0,this.socialInput="",this.socialAction=5,this.socialMessage="Enter name of player to delete from list"),t>=c.Z.CC_CHANGE_HEAD_L&&t<=c.Z.CC_CHANGE_FEET_R){const e=(t-300)/2|0,i=1&t;let s=this.designIdentikits[e];if(-1!==s)for(;;)if(0===i&&(s--,s<0&&(s=h.Z.count-1)),1===i&&(s++,s>=h.Z.count&&(s=0)),!h.Z.instances[s].disable&&h.Z.instances[s].type===e+(this.designGenderMale?0:7)){this.designIdentikits[e]=s,this.updateDesignModel=!0;break}}if(t>=c.Z.CC_RECOLOUR_HAIR_L&&t<=c.Z.CC_RECOLOUR_SKIN_R){const e=(t-314)/2|0,i=1&t;let s=this.designColors[e];0===i&&(s--,s<0&&(s=H.Z.DESIGN_BODY_COLOR[e].length-1)),1===i&&(s++,s>=H.Z.DESIGN_BODY_COLOR[e].length&&(s=0)),this.designColors[e]=s,this.updateDesignModel=!0}if(t!==c.Z.CC_SWITCH_TO_MALE||this.designGenderMale||(this.designGenderMale=!0,this.validateCharacterDesign()),t===c.Z.CC_SWITCH_TO_FEMALE&&this.designGenderMale&&(this.designGenderMale=!1,this.validateCharacterDesign()),t===c.Z.CC_ACCEPT_DESIGN){this.out.p1isaac(I.Z.IF_PLAYERDESIGN),this.out.p1(this.designGenderMale?0:1);for(let e=0;e<7;e++)this.out.p1(this.designIdentikits[e]);for(let e=0;e<5;e++)this.out.p1(this.designColors[e]);return!0}return t===c.Z.CC_MOD_MUTE&&(this.reportAbuseMuteOption=!this.reportAbuseMuteOption),t>=c.Z.CC_REPORT_RULE1&&t<=c.Z.CC_REPORT_RULE12&&(this.closeInterfaces(),this.reportAbuseInput.length>0&&(this.out.p1isaac(I.Z.BUG_REPORT),this.out.p8(_.Z.toBase37(this.reportAbuseInput)),this.out.p1(t-601),this.out.p1(this.reportAbuseMuteOption?1:0))),!1};validateCharacterDesign=()=>{this.updateDesignModel=!0;for(let e=0;e<7;e++){this.designIdentikits[e]=-1;for(let t=0;t{if(!this.localPlayer||!this.scene)return!1;const r=s>>14&32767,n=this.scene.getInfo(this.currentLevel,t,i,s);if(-1===n)return!1;const h=31&n,o=n>>6&3;if(h===N.Z.CENTREPIECE_STRAIGHT||h===N.Z.CENTREPIECE_DIAGONAL||h===N.Z.GROUND_DECOR){const e=a.Z.get(r);let s,n;o===B.Z.WEST||o===B.Z.EAST?(s=e.width,n=e.length):(s=e.length,n=e.width);let h=e.forceapproach;0!==o&&(h=(h<>4-o)),this.tryMove(this.localPlayer.pathTileX[0],this.localPlayer.pathTileZ[0],t,i,2,s,n,0,0,h,!1)}else this.tryMove(this.localPlayer.pathTileX[0],this.localPlayer.pathTileZ[0],t,i,2,0,0,o,h+1,0,!1);return this.crossX=this.mouseClickX,this.crossY=this.mouseClickY,this.crossMode=2,this.crossCycle=0,this.out.p1isaac(e),this.out.p2(t+this.sceneBaseTileX),this.out.p2(i+this.sceneBaseTileZ),this.out.p2(r),!0};handleTabInput=()=>{1===this.mouseClickButton&&(this.mouseClickX>=549&&this.mouseClickX<=583&&this.mouseClickY>=195&&this.mouseClickY<231&&-1!==this.tabInterfaceId[0]?(this.redrawSidebar=!0,this.selectedTab=0,this.redrawSideicons=!0):this.mouseClickX>=579&&this.mouseClickX<=609&&this.mouseClickY>=194&&this.mouseClickY<231&&-1!==this.tabInterfaceId[1]?(this.redrawSidebar=!0,this.selectedTab=1,this.redrawSideicons=!0):this.mouseClickX>=607&&this.mouseClickX<=637&&this.mouseClickY>=194&&this.mouseClickY<231&&-1!==this.tabInterfaceId[2]?(this.redrawSidebar=!0,this.selectedTab=2,this.redrawSideicons=!0):this.mouseClickX>=635&&this.mouseClickX<=679&&this.mouseClickY>=194&&this.mouseClickY<229&&-1!==this.tabInterfaceId[3]?(this.redrawSidebar=!0,this.selectedTab=3,this.redrawSideicons=!0):this.mouseClickX>=676&&this.mouseClickX<=706&&this.mouseClickY>=194&&this.mouseClickY<231&&-1!==this.tabInterfaceId[4]?(this.redrawSidebar=!0,this.selectedTab=4,this.redrawSideicons=!0):this.mouseClickX>=704&&this.mouseClickX<=734&&this.mouseClickY>=194&&this.mouseClickY<231&&-1!==this.tabInterfaceId[5]?(this.redrawSidebar=!0,this.selectedTab=5,this.redrawSideicons=!0):this.mouseClickX>=732&&this.mouseClickX<=766&&this.mouseClickY>=195&&this.mouseClickY<231&&-1!==this.tabInterfaceId[6]?(this.redrawSidebar=!0,this.selectedTab=6,this.redrawSideicons=!0):this.mouseClickX>=550&&this.mouseClickX<=584&&this.mouseClickY>=492&&this.mouseClickY<528&&-1!==this.tabInterfaceId[7]?(this.redrawSidebar=!0,this.selectedTab=7,this.redrawSideicons=!0):this.mouseClickX>=582&&this.mouseClickX<=612&&this.mouseClickY>=492&&this.mouseClickY<529&&-1!==this.tabInterfaceId[8]?(this.redrawSidebar=!0,this.selectedTab=8,this.redrawSideicons=!0):this.mouseClickX>=609&&this.mouseClickX<=639&&this.mouseClickY>=492&&this.mouseClickY<529&&-1!==this.tabInterfaceId[9]?(this.redrawSidebar=!0,this.selectedTab=9,this.redrawSideicons=!0):this.mouseClickX>=637&&this.mouseClickX<=681&&this.mouseClickY>=493&&this.mouseClickY<528&&-1!==this.tabInterfaceId[10]?(this.redrawSidebar=!0,this.selectedTab=10,this.redrawSideicons=!0):this.mouseClickX>=679&&this.mouseClickX<=709&&this.mouseClickY>=492&&this.mouseClickY<529&&-1!==this.tabInterfaceId[11]?(this.redrawSidebar=!0,this.selectedTab=11,this.redrawSideicons=!0):this.mouseClickX>=706&&this.mouseClickX<=736&&this.mouseClickY>=492&&this.mouseClickY<529&&-1!==this.tabInterfaceId[12]?(this.redrawSidebar=!0,this.selectedTab=12,this.redrawSideicons=!0):this.mouseClickX>=734&&this.mouseClickX<=768&&this.mouseClickY>=492&&this.mouseClickY<528&&-1!==this.tabInterfaceId[13]&&(this.redrawSidebar=!0,this.selectedTab=13,this.redrawSideicons=!0),J.K.sidebarInputCounter++,J.K.sidebarInputCounter>150&&(J.K.sidebarInputCounter=0,this.out.p1isaac(I.Z.ANTICHEAT_CYCLELOGIC1),this.out.p1(43)))};handleInputKey=async()=>{for(;;){let e;do{for(;;){if(e=this.pollKey(),-1===e)return;if(-1!==this.viewportInterfaceId&&this.viewportInterfaceId===this.reportAbuseInterfaceID){8===e&&this.reportAbuseInput.length>0&&(this.reportAbuseInput=this.reportAbuseInput.substring(0,this.reportAbuseInput.length-1));break}if(this.showSocialInput){if(e>=32&&e<=122&&this.socialInput.length<80&&(this.socialInput=this.socialInput+String.fromCharCode(e),this.redrawChatback=!0),8===e&&this.socialInput.length>0&&(this.socialInput=this.socialInput.substring(0,this.socialInput.length-1),this.redrawChatback=!0),13===e||10===e){let e;if(this.showSocialInput=!1,this.redrawChatback=!0,1===this.socialAction&&(e=_.Z.toBase37(this.socialInput),this.addFriend(e)),2===this.socialAction&&this.friendCount>0&&(e=_.Z.toBase37(this.socialInput),this.removeFriend(e)),3===this.socialAction&&this.socialInput.length>0&&this.socialName37){this.out.p1isaac(I.Z.MESSAGE_PRIVATE),this.out.p1(0);const e=this.out.pos;this.out.p8(this.socialName37),b.Z.pack(this.out,this.socialInput),this.out.psize1(this.out.pos-e),this.socialInput=_.Z.toSentenceCase(this.socialInput),this.socialInput=O.Z.filter(this.socialInput),this.addMessage(6,this.socialInput,_.Z.formatName(_.Z.fromBase37(this.socialName37))),2===this.privateChatSetting&&(this.privateChatSetting=1,this.redrawPrivacySettings=!0,this.out.p1isaac(I.Z.CHAT_SETMODE),this.out.p1(this.publicChatSetting),this.out.p1(this.privateChatSetting),this.out.p1(this.tradeChatSetting))}4===this.socialAction&&this.ignoreCount<100&&(e=_.Z.toBase37(this.socialInput),this.addIgnore(e)),5===this.socialAction&&this.ignoreCount>0&&(e=_.Z.toBase37(this.socialInput),this.removeIgnore(e))}}else if(this.chatbackInputOpen){if(e>=48&&e<=57&&this.chatbackInput.length<10&&(this.chatbackInput=this.chatbackInput+String.fromCharCode(e),this.redrawChatback=!0),8===e&&this.chatbackInput.length>0&&(this.chatbackInput=this.chatbackInput.substring(0,this.chatbackInput.length-1),this.redrawChatback=!0),13===e||10===e){if(this.chatbackInput.length>0){let e=0;try{e=parseInt(this.chatbackInput,10)}catch(e){}this.out.p1isaac(I.Z.RESUME_P_COUNTDIALOG),this.out.p4(e)}this.chatbackInputOpen=!1,this.redrawChatback=!0}}else if(-1===this.chatInterfaceId&&(e>=32&&e<=122&&this.chatTyped.length<80&&(this.chatTyped=this.chatTyped+String.fromCharCode(e),this.redrawChatback=!0),8===e&&this.chatTyped.length>0&&(this.chatTyped=this.chatTyped.substring(0,this.chatTyped.length-1),this.redrawChatback=!0),(13===e||10===e)&&this.chatTyped.length>0)){if("::clientdrop"===this.chatTyped)await this.tryReconnect();else if("::noclip"===this.chatTyped)for(let e=0;e122)&&(e<65||e>90)&&(e<48||e>57)&&32!==e);this.reportAbuseInput.length<12&&(this.reportAbuseInput=this.reportAbuseInput+String.fromCharCode(e))}};handleChatSettingsInput=()=>{if(1===this.mouseClickButton)if(this.mouseClickX>=8&&this.mouseClickX<=108&&this.mouseClickY>=490&&this.mouseClickY<=522)this.publicChatSetting=(this.publicChatSetting+1)%4,this.redrawPrivacySettings=!0,this.redrawChatback=!0,this.out.p1isaac(I.Z.CHAT_SETMODE),this.out.p1(this.publicChatSetting),this.out.p1(this.privateChatSetting),this.out.p1(this.tradeChatSetting);else if(this.mouseClickX>=137&&this.mouseClickX<=237&&this.mouseClickY>=490&&this.mouseClickY<=522)this.privateChatSetting=(this.privateChatSetting+1)%3,this.redrawPrivacySettings=!0,this.redrawChatback=!0,this.out.p1isaac(I.Z.CHAT_SETMODE),this.out.p1(this.publicChatSetting),this.out.p1(this.privateChatSetting),this.out.p1(this.tradeChatSetting);else if(this.mouseClickX>=275&&this.mouseClickX<=375&&this.mouseClickY>=490&&this.mouseClickY<=522)this.tradeChatSetting=(this.tradeChatSetting+1)%3,this.redrawPrivacySettings=!0,this.redrawChatback=!0,this.out.p1isaac(I.Z.CHAT_SETMODE),this.out.p1(this.publicChatSetting),this.out.p1(this.privateChatSetting),this.out.p1(this.tradeChatSetting);else if(this.mouseClickX>=416&&this.mouseClickX<=516&&this.mouseClickY>=490&&this.mouseClickY<=522){this.closeInterfaces(),this.reportAbuseInput="",this.reportAbuseMuteOption=!1;for(let e=0;e{if(this.scrollGrabbed?this.scrollInputPadding=32:this.scrollInputPadding=0,this.scrollGrabbed=!1,e>=r&&e=n&&t=r&&e=n+s-16&&t=r-this.scrollInputPadding&&e=n+16&&t0){let e=(s-32)*s/i|0;e<8&&(e=8);const r=t-n-(e/2|0)-16,o=s-e-32;h.scrollPosition=(i-s)*r/o|0,a&&(this.redrawSidebar=!0),this.scrollGrabbed=!0}};prepareGameScreen=()=>{this.areaChatback||(this.unloadTitle(),this.drawArea=null,this.imageTitle2=null,this.imageTitle3=null,this.imageTitle4=null,this.imageTitle0=null,this.imageTitle1=null,this.imageTitle5=null,this.imageTitle6=null,this.imageTitle7=null,this.imageTitle8=null,this.areaChatback=new d.Z(479,96),this.areaMapback=new d.Z(168,160),u.Z.clear(),this.imageMapback?.draw(0,0),this.areaSidebar=new d.Z(190,261),this.areaViewport=new d.Z(512,334),u.Z.clear(),this.areaBackbase1=new d.Z(501,61),this.areaBackbase2=new d.Z(288,40),this.areaBackhmid1=new d.Z(269,66),this.redrawTitleBackground=!0)};isFriend=e=>{if(!e)return!1;for(let t=0;t{if(0n===e)return;if(this.friendCount>=100)return void this.addMessage(0,"Your friends list is full. Max of 100 hit","");const t=_.Z.formatName(_.Z.fromBase37(e));for(let i=0;i{if(0n!==e)for(let t=0;t{if(0n===e)return;if(this.ignoreCount>=100)return void this.addMessage(0,"Your ignore list is full. Max of 100 hit","");const t=_.Z.formatName(_.Z.fromBase37(e));for(let i=0;i{if(0n!==e)for(let t=0;t{const i=this.levelObjStacks[this.currentLevel][e][t];if(!i)return void this.scene?.removeObjStack(this.currentLevel,e,t);let s=-99999999,a=null;for(let e=i.peekFront();e;e=i.prev()){const t=r.Z.get(e.index);let i=t.cost;t.stackable&&(i*=e.count+1),i>s&&(s=i,a=e)}if(!a)return;i.pushFront(a);let n=-1,h=-1,o=0,l=0;for(let e=i.peekFront();e;e=i.prev())e.index!==a.index&&-1===n&&(n=e.index,o=e.count),e.index!==a.index&&e.index!==n&&-1===h&&(h=e.index,l=e.count);let c=null;-1!==n&&(c=r.Z.get(n).getInterfaceModel(o));let d=null;-1!==h&&(d=r.Z.get(h).getInterfaceModel(l));const u=e+(t<<7)+1610612736|0,f=r.Z.get(a.index);this.scene?.addObjStack(e,t,this.getHeightmapY(this.currentLevel,128*e+64,128*t+64),this.currentLevel,u,f.getInterfaceModel(a.count),d,c)};addLoc=(e,t,i,s,r,n,h)=>{if(t<1||i<1||t>102||i>102)return;if(J.K.lowMemory&&e!==this.currentLevel)return;if(!this.scene)return;let o=0;if(h===M.Z.WALL&&(o=this.scene.getWallBitset(e,t,i)),h===M.Z.WALL_DECOR&&(o=this.scene.getWallDecorationBitset(e,i,t)),h===M.Z.GROUND&&(o=this.scene.getLocBitset(e,t,i)),h===M.Z.GROUND_DECOR&&(o=this.scene.getGroundDecorationBitset(e,t,i)),0!==o){const s=this.scene.getInfo(e,t,i,o),r=o>>14&32767,n=31&s,l=s>>6;if(h===M.Z.WALL){this.scene?.removeWall(e,t,i,1);const s=a.Z.get(r);s.blockwalk&&this.levelCollisionMap[e]?.removeWall(t,i,n,l,s.blockrange)}if(h===M.Z.WALL_DECOR&&this.scene?.removeWallDecoration(e,t,i),h===M.Z.GROUND){this.scene.removeLoc(e,t,i);const s=a.Z.get(r);if(t+s.width>X.Z.SIZE-1||i+s.width>X.Z.SIZE-1||t+s.length>X.Z.SIZE-1||i+s.length>X.Z.SIZE-1)return;s.blockwalk&&this.levelCollisionMap[e]?.removeLoc(t,i,s.width,s.length,l,s.blockrange)}if(h===M.Z.GROUND_DECOR){this.scene?.removeGroundDecoration(e,t,i);const s=a.Z.get(r);s.blockwalk&&s.active&&this.levelCollisionMap[e]?.removeFloor(t,i)}}if(s>=0){let a=e;this.levelTileFlags&&e<3&&2==(2&this.levelTileFlags[1][t][i])&&(a=e+1),P.Z.addLoc(e,t,i,this.scene,this.levelHeightmap,this.locList,this.levelCollisionMap[e],s,n,r,a)}};closeInterfaces=()=>{this.out.p1isaac(I.Z.CLOSE_MODAL),-1!==this.sidebarInterfaceId&&(this.sidebarInterfaceId=-1,this.redrawSidebar=!0,this.pressedContinueOption=!1,this.redrawSideicons=!0),-1!==this.chatInterfaceId&&(this.chatInterfaceId=-1,this.redrawChatback=!0,this.pressedContinueOption=!1),this.viewportInterfaceId=-1};tryReconnect=async()=>{if(this.idleTimeout>0)await this.logout();else{this.areaViewport?.bind(),this.fontPlain12?.drawStringCenter(257,144,"Connection lost",C.Z.BLACK),this.fontPlain12?.drawStringCenter(256,143,"Connection lost",C.Z.WHITE),this.fontPlain12?.drawStringCenter(257,159,"Please wait - attempting to reestablish",C.Z.BLACK),this.fontPlain12?.drawStringCenter(256,158,"Please wait - attempting to reestablish",C.Z.WHITE),this.areaViewport?.draw(8,11),this.flagSceneTileX=0;const e=this.stream;this.ingame=!1,await this.login(this.username,this.password,!0),this.ingame||await this.logout(),e?.close()}};logout=async()=>{this.stream&&this.stream.close(),this.stream=null,this.ingame=!1,this.titleScreenState=0,this.username="",this.password="",k.Z.setDisabled(),this.clearCaches(),this.scene?.reset();for(let e=0;e{if(!this.stream)return!1;try{let e=this.stream.available;if(0===e)return!1;if(-1===this.packetType&&(await this.stream.readBytes(this.in.data,0,1),this.packetType=255&this.in.data[0],this.randomIn&&(this.packetType=this.packetType-this.randomIn.nextInt&255),this.packetSize=S.Z.SERVERPROT_SIZES[this.packetType],e--),-1===this.packetSize){if(e<=0)return!1;await this.stream.readBytes(this.in.data,0,1),this.packetSize=255&this.in.data[0],e--}if(-2===this.packetSize){if(e<=1)return!1;await this.stream.readBytes(this.in.data,0,2),this.in.pos=0,this.packetSize=this.in.g2,e-=2}if(e0&&this.addMessage(5,i+" has logged in.",""),0===t&&this.addMessage(5,i+" has logged out.","")),i=null;break}i&&this.friendCount<100&&(this.friendName37[this.friendCount]=e,this.friendName[this.friendCount]=i,this.friendWorld[this.friendCount]=t,this.friendCount++,this.redrawSidebar=!0);let s=!1;for(;!s;){s=!0;for(let e=0;e=0&&s>=0&&i=X.Z.SIZE||e.z>=X.Z.SIZE)&&e.unlink();return 0!==this.flagSceneTileX&&(this.flagSceneTileX-=a,this.flagSceneTileZ-=r),this.cutscene=!1,this.packetType=-1,!0}if(this.packetType===v.Z.IF_SETPLAYERHEAD)return c.Z.instances[this.in.g2].model=this.localPlayer?.getHeadModel()||null,this.packetType=-1,!0;if(this.packetType===v.Z.HINT_ARROW)return this.hintType=this.in.g1,1===this.hintType&&(this.hintNpc=this.in.g2),this.hintType>=2&&this.hintType<=6&&(2===this.hintType&&(this.hintOffsetX=64,this.hintOffsetZ=64),3===this.hintType&&(this.hintOffsetX=0,this.hintOffsetZ=64),4===this.hintType&&(this.hintOffsetX=128,this.hintOffsetZ=64),5===this.hintType&&(this.hintOffsetX=64,this.hintOffsetZ=0),6===this.hintType&&(this.hintOffsetX=64,this.hintOffsetZ=128),this.hintType=2,this.hintTileX=this.in.g2,this.hintTileZ=this.in.g2,this.hintHeight=this.in.g1),10===this.hintType&&(this.hintPlayer=this.in.g2),this.packetType=-1,!0;if(this.packetType===v.Z.MIDI_SONG){const e=this.in.gjstr,t=this.in.g4,i=this.in.g4;return e!==this.currentMidi&&this.midiActive&&!J.K.lowMemory&&await this.setMidi(e,t,i),this.currentMidi=e,this.midiCrc=t,this.midiSize=i,this.nextMusicDelay=0,this.packetType=-1,!0}if(this.packetType===v.Z.LOGOUT)return await this.logout(),this.packetType=-1,!1;if(this.packetType===v.Z.DATA_LOC_DONE){const e=this.in.g1,t=this.in.g1;let i=-1;if(this.sceneMapIndex)for(let s=0;s=100&&(this.cameraX=128*this.cutsceneSrcLocalTileX+64,this.cameraZ=128*this.cutsceneSrcLocalTileZ+64,this.cameraY=this.getHeightmapY(this.currentLevel,this.cutsceneSrcLocalTileX,this.cutsceneSrcLocalTileZ)-this.cutsceneSrcHeight),this.packetType=-1,!0;if(this.packetType===v.Z.UPDATE_ZONE_FULL_FOLLOWS){this.baseX=this.in.g1,this.baseZ=this.in.g1;for(let e=this.baseX;e=this.baseX&&e.x=this.baseZ&&e.z1?this.addMessage(7,a,_.Z.formatName(_.Z.fromBase37(e))):this.addMessage(3,a,_.Z.formatName(_.Z.fromBase37(e)))}catch(e){}return this.packetType=-1,!0}if(this.packetType===v.Z.RESET_CLIENT_VARCACHE){for(let e=0;e=100){const e=128*this.cutsceneDstLocalTileX+64,t=128*this.cutsceneDstLocalTileZ+64,i=this.getHeightmapY(this.currentLevel,this.cutsceneDstLocalTileX,this.cutsceneDstLocalTileZ)-this.cutsceneDstHeight,s=e-this.cameraX,a=i-this.cameraY,r=t-this.cameraZ,n=0|Math.sqrt(s*s+r*r);this.cameraPitch=2047&(325.949*Math.atan2(a,n)|0),this.cameraYaw=2047&(-325.949*Math.atan2(s,r)|0),this.cameraPitch<128&&(this.cameraPitch=128),this.cameraPitch>383&&(this.cameraPitch=383)}return this.packetType=-1,!0}if(this.packetType===v.Z.IF_SHOWSIDE)return this.selectedTab=this.in.g1,this.redrawSidebar=!0,this.redrawSideicons=!0,this.packetType=-1,!0;if(this.packetType===v.Z.MESSAGE_GAME){const e=this.in.gjstr;let t;if(e.endsWith(":tradereq:")){const i=e.substring(0,e.indexOf(":"));t=_.Z.toBase37(i);let s=!1;for(let e=0;e>10&31,s=t>>5&31,a=31&t;return c.Z.instances[e].colour=(i<<19)+(s<<11)+(a<<3),this.packetType=-1,!0}if(this.packetType===v.Z.RESET_ANIMS){for(let e=0;e=this.levelExperience[i]&&(this.skillBaseLevel[e]=i+2);return this.packetType=-1,!0}if(this.packetType===v.Z.UPDATE_ZONE_PARTIAL_ENCLOSED){for(this.baseX=this.in.g1,this.baseZ=this.in.g1;this.in.pos=0&&e{try{this.minimapLevel=-1,this.temporaryLocs.clear(),this.locList.clear(),this.spotanims.clear(),this.projectiles.clear(),f.Z.clearTexels(),this.clearCaches(),this.scene?.reset();for(let e=0;e>8,i=255&this.sceneMapIndex[e];if(33===t&&i>=71&&i<=73){P.Z.lowMemory=!1;break}}if(J.K.lowMemory?this.scene?.setMinLevel(this.currentLevel):this.scene?.setMinLevel(0),this.sceneMapIndex&&this.sceneMapLandData){this.out.p1isaac(I.Z.NO_TIMEOUT);for(let i=0;i>8)-this.sceneBaseTileX,s=64*(255&this.sceneMapIndex[i])-this.sceneBaseTileZ,a=this.sceneMapLandData[i];if(a){const i=new T.Z(new Uint8Array(a)).g4,r=E.Z.read(i,a,a.length-4,4);e.readLandscape(8*(this.sceneCenterZoneX-6),8*(this.sceneCenterZoneZ-6),t,s,r)}else this.sceneCenterZoneZ<800&&e.clearLandscape(s,t,64,64)}}if(this.sceneMapIndex&&this.sceneMapLocData){this.out.p1isaac(I.Z.NO_TIMEOUT);for(let i=0;i>8)-this.sceneBaseTileX,n=64*(255&this.sceneMapIndex[i])-this.sceneBaseTileZ;e.readLocs(this.scene,this.locList,this.levelCollisionMap,a,r,n)}}}this.out.p1isaac(I.Z.NO_TIMEOUT),e.build(this.scene,this.levelCollisionMap),this.areaViewport?.bind(),this.out.p1isaac(I.Z.NO_TIMEOUT);for(let e=this.locList.peekFront();e;e=this.locList.prev())2===(this.levelTileFlags&&2&this.levelTileFlags[1][e.heightmapNE][e.heightmapNW])&&(e.heightmapSW--,e.heightmapSW<0&&e.unlink());for(let e=0;e{const t=c.Z.instances[e];if(t.childId)for(let e=0;e{let e=0;for(let t=0;t<99;t++){const i=t+1;e+=i+300*Math.pow(2,i/7)|0,this.levelExperience[t]=e/4|0}};addMessage=(e,t,i)=>{0===e&&-1!==this.stickyChatInterfaceId&&(this.modalMessage=t,this.mouseClickButton=0),-1===this.chatInterfaceId&&(this.redrawChatback=!0);for(let e=99;e>0;e--)this.messageType[e]=this.messageType[e-1],this.messageSender[e]=this.messageSender[e-1],this.messageText[e]=this.messageText[e-1];this.messageType[0]=e,this.messageSender[0]=i,this.messageText[0]=t};updateVarp=async e=>{const t=l.Z.instances[e].clientcode;if(0!==t){const i=this.varps[e];if(1===t&&(1===i&&f.Z.setBrightness(.9),2===i&&f.Z.setBrightness(.8),3===i&&f.Z.setBrightness(.7),4===i&&f.Z.setBrightness(.6),r.Z.iconCache?.clear(),this.redrawTitleBackground=!0),3===t){const e=this.midiActive;0===i&&(this.midiVolume=256,(0,q.nu)(256),this.midiActive=!0),1===i&&(this.midiVolume=192,(0,q.nu)(192),this.midiActive=!0),2===i&&(this.midiVolume=128,(0,q.nu)(128),this.midiActive=!0),3===i&&(this.midiVolume=64,(0,q.nu)(64),this.midiActive=!0),4===i&&(this.midiActive=!1),this.midiActive!==e&&(this.midiActive&&this.currentMidi?await this.setMidi(this.currentMidi,this.midiCrc,this.midiSize):(0,q.tb)(),this.nextMusicDelay=0)}4===t&&(0===i&&(this.waveVolume=256,(0,q.mQ)(256),this.waveEnabled=!0),1===i&&(this.waveVolume=192,(0,q.mQ)(192),this.waveEnabled=!0),2===i&&(this.waveVolume=128,(0,q.mQ)(128),this.waveEnabled=!0),3===i&&(this.waveVolume=64,(0,q.mQ)(64),this.waveEnabled=!0),4===i&&(this.waveEnabled=!1)),5===t&&(this.mouseButtonsOption=i),6===t&&(this.chatEffects=i),8===t&&(this.splitPrivateChat=i,this.redrawChatback=!0)}};handleChatMouseInput=(e,t)=>{let i=0;for(let e=0;e<100;e++){if(!this.messageText[e])continue;const s=this.messageType[e],a=this.chatScrollOffset+70+4-14*i;if(a<-20)break;0===s&&i++,1!==s&&2!==s||!(1===s||0===this.publicChatSetting||1===this.publicChatSetting&&this.isFriend(this.messageSender[e]))||(t>a-14&&t<=a&&this.localPlayer&&this.messageSender[e]!==this.localPlayer.name&&(this.rights&&(this.menuOption[this.menuSize]="Report abuse @whi@"+this.messageSender[e],this.menuAction[this.menuSize]=34,this.menuSize++),this.menuOption[this.menuSize]="Add ignore @whi@"+this.messageSender[e],this.menuAction[this.menuSize]=436,this.menuSize++,this.menuOption[this.menuSize]="Add friend @whi@"+this.messageSender[e],this.menuAction[this.menuSize]=406,this.menuSize++),i++),3!==s&&7!==s||0!==this.splitPrivateChat||!(7===s||0===this.privateChatSetting||1===this.privateChatSetting&&this.isFriend(this.messageSender[e]))||(t>a-14&&t<=a&&(this.rights&&(this.menuOption[this.menuSize]="Report abuse @whi@"+this.messageSender[e],this.menuAction[this.menuSize]=34,this.menuSize++),this.menuOption[this.menuSize]="Add ignore @whi@"+this.messageSender[e],this.menuAction[this.menuSize]=436,this.menuSize++,this.menuOption[this.menuSize]="Add friend @whi@"+this.messageSender[e],this.menuAction[this.menuSize]=406,this.menuSize++),i++),4===s&&(0===this.tradeChatSetting||1===this.tradeChatSetting&&this.isFriend(this.messageSender[e]))&&(t>a-14&&t<=a&&(this.menuOption[this.menuSize]="Accept trade @whi@"+this.messageSender[e],this.menuAction[this.menuSize]=903,this.menuSize++),i++),(5===s||6===s)&&0===this.splitPrivateChat&&this.privateChatSetting<2&&i++,8===s&&(0===this.tradeChatSetting||1===this.tradeChatSetting&&this.isFriend(this.messageSender[e]))&&(t>a-14&&t<=a&&(this.menuOption[this.menuSize]="Accept duel @whi@"+this.messageSender[e],this.menuAction[this.menuSize]=363,this.menuSize++),i++)}};handlePrivateChatInput=e=>{if(0==this.splitPrivateChat)return;let t=0;0!=this.systemUpdateTimer&&(t=1);for(let i=0;i<100;i++)if(null!=this.messageText[i]){const s=this.messageType[i];if((3==s||7==s)&&(7==s||0==this.privateChatSetting||1==this.privateChatSetting&&this.isFriend(this.messageSender[i]))){const s=329-13*t;if(this.mouseX>8&&this.mouseX<520&&e-11>s-10&&e-11<=s+3&&(this.rights&&(this.menuOption[this.menuSize]="Report abuse @whi@"+this.messageSender[i],this.menuAction[this.menuSize]=2034,this.menuSize++),this.menuOption[this.menuSize]="Add ignore @whi@"+this.messageSender[i],this.menuAction[this.menuSize]=2436,this.menuSize++,this.menuOption[this.menuSize]="Add friend @whi@"+this.messageSender[i],this.menuAction[this.menuSize]=2406,this.menuSize++),t++,t>=5)return}if((5==s||6==s)&&this.privateChatSetting<2&&(t++,t>=5))return}};handleInterfaceInput=(e,t,i,s,a,n)=>{if(0!==e.type||!e.childId||e.hide||ts+e.width||i>a+e.height||!e.childX||!e.childY)return;const h=e.childId.length;for(let o=0;o=0||0!==d.overColour)&&t>=h&&i>=l&&t=0?this.lastHoveredInterfaceId=d.overLayer:this.lastHoveredInterfaceId=d.id),0===d.type)this.handleInterfaceInput(d,t,i,h,l,d.scrollPosition),d.scroll>d.height&&this.handleScrollInput(t,i,d.scroll,d.height,!0,h+d.width,l,d);else if(2===d.type){let e=0;for(let s=0;s=n+32||i>=o+32){e++;continue}if(this.hoveredSlot=e,this.hoveredSlotParentId=d.id,!d.invSlotObjId||d.invSlotObjId[e]<=0){e++;continue}const c=r.Z.get(d.invSlotObjId[e]-1);if(1===this.objSelected&&d.interactable)d.id===this.objSelectedInterface&&e===this.objSelectedSlot||(this.menuOption[this.menuSize]="Use "+this.objSelectedName+" with @lre@"+c.name,this.menuAction[this.menuSize]=881,this.menuParamA[this.menuSize]=c.index,this.menuParamB[this.menuSize]=e,this.menuParamC[this.menuSize]=d.id,this.menuSize++);else if(1===this.spellSelected&&d.interactable)16==(16&this.activeSpellFlags)&&(this.menuOption[this.menuSize]=this.spellCaption+" @lre@"+c.name,this.menuAction[this.menuSize]=391,this.menuParamA[this.menuSize]=c.index,this.menuParamB[this.menuSize]=e,this.menuParamC[this.menuSize]=d.id,this.menuSize++);else{if(d.interactable)for(let t=4;t>=3;t--)c.iops&&c.iops[t]?(this.menuOption[this.menuSize]=c.iops[t]+" @lre@"+c.name,3===t?this.menuAction[this.menuSize]=478:4===t&&(this.menuAction[this.menuSize]=347),this.menuParamA[this.menuSize]=c.index,this.menuParamB[this.menuSize]=e,this.menuParamC[this.menuSize]=d.id,this.menuSize++):4===t&&(this.menuOption[this.menuSize]="Drop @lre@"+c.name,this.menuAction[this.menuSize]=347,this.menuParamA[this.menuSize]=c.index,this.menuParamB[this.menuSize]=e,this.menuParamC[this.menuSize]=d.id,this.menuSize++);if(d.usable&&(this.menuOption[this.menuSize]="Use @lre@"+c.name,this.menuAction[this.menuSize]=188,this.menuParamA[this.menuSize]=c.index,this.menuParamB[this.menuSize]=e,this.menuParamC[this.menuSize]=d.id,this.menuSize++),d.interactable&&c.iops)for(let t=2;t>=0;t--)c.iops[t]&&(this.menuOption[this.menuSize]=c.iops[t]+" @lre@"+c.name,0===t?this.menuAction[this.menuSize]=405:1===t?this.menuAction[this.menuSize]=38:2===t&&(this.menuAction[this.menuSize]=422),this.menuParamA[this.menuSize]=c.index,this.menuParamB[this.menuSize]=e,this.menuParamC[this.menuSize]=d.id,this.menuSize++);if(d.iops)for(let t=4;t>=0;t--)d.iops[t]&&(this.menuOption[this.menuSize]=d.iops[t]+" @lre@"+c.name,0===t?this.menuAction[this.menuSize]=602:1===t?this.menuAction[this.menuSize]=596:2===t?this.menuAction[this.menuSize]=22:3===t?this.menuAction[this.menuSize]=892:4===t&&(this.menuAction[this.menuSize]=415),this.menuParamA[this.menuSize]=c.index,this.menuParamB[this.menuSize]=e,this.menuParamC[this.menuSize]=d.id,this.menuSize++);this.menuOption[this.menuSize]="Examine @lre@"+c.name,this.menuAction[this.menuSize]=1773,this.menuParamA[this.menuSize]=c.index,d.invSlotObjCount&&(this.menuParamC[this.menuSize]=d.invSlotObjCount[e]),this.menuSize++}e++}}else if(t>=h&&i>=l&&t{let t=e.clientCode;return t>=c.Z.CC_FRIENDS_START&&t<=c.Z.CC_FRIENDS_UPDATE_END?(t>=c.Z.CC_FRIENDS_UPDATE_START?t-=c.Z.CC_FRIENDS_UPDATE_START:t--,this.menuOption[this.menuSize]="Remove @whi@"+this.friendName[t],this.menuAction[this.menuSize]=557,this.menuSize++,this.menuOption[this.menuSize]="Message @whi@"+this.friendName[t],this.menuAction[this.menuSize]=679,this.menuSize++,!0):t>=c.Z.CC_IGNORES_START&&t<=c.Z.CC_IGNORES_END&&(this.menuOption[this.menuSize]="Remove @whi@"+e.text,this.menuAction[this.menuSize]=556,this.menuSize++,!0)};handleViewportOptions=()=>{0===this.objSelected&&0===this.spellSelected&&(this.menuOption[this.menuSize]="Walk here",this.menuAction[this.menuSize]=660,this.menuParamB[this.menuSize]=this.mouseX,this.menuParamC[this.menuSize]=this.mouseY,this.menuSize++);let e=-1;for(let t=0;t>7&127,h=i>>29&3,o=i>>14&32767;if(i!==e){if(e=i,2===h&&this.scene&&this.scene.getInfo(this.currentLevel,s,n,i)>=0){const e=a.Z.get(o);if(1===this.objSelected)this.menuOption[this.menuSize]="Use "+this.objSelectedName+" with @cya@"+e.name,this.menuAction[this.menuSize]=450,this.menuParamA[this.menuSize]=i,this.menuParamB[this.menuSize]=s,this.menuParamC[this.menuSize]=n,this.menuSize++;else if(1!==this.spellSelected){if(e.ops)for(let t=4;t>=0;t--)e.ops[t]&&(this.menuOption[this.menuSize]=e.ops[t]+" @cya@"+e.name,0===t&&(this.menuAction[this.menuSize]=285),1===t&&(this.menuAction[this.menuSize]=504),2===t&&(this.menuAction[this.menuSize]=364),3===t&&(this.menuAction[this.menuSize]=581),4===t&&(this.menuAction[this.menuSize]=1501),this.menuParamA[this.menuSize]=i,this.menuParamB[this.menuSize]=s,this.menuParamC[this.menuSize]=n,this.menuSize++);this.menuOption[this.menuSize]="Examine @cya@"+e.name,this.menuAction[this.menuSize]=1175,this.menuParamA[this.menuSize]=i,this.menuParamB[this.menuSize]=s,this.menuParamC[this.menuSize]=n,this.menuSize++}else 4==(4&this.activeSpellFlags)&&(this.menuOption[this.menuSize]=this.spellCaption+" @cya@"+e.name,this.menuAction[this.menuSize]=55,this.menuParamA[this.menuSize]=i,this.menuParamB[this.menuSize]=s,this.menuParamC[this.menuSize]=n,this.menuSize++)}if(1===h){const e=this.npcs[o];if(e&&e.type&&1===e.type.size&&64==(127&e.x)&&64==(127&e.z))for(let t=0;t=0;i--)e.ops&&e.ops[i]?(this.menuOption[this.menuSize]=e.ops[i]+" @lre@"+e.name,0===i&&(this.menuAction[this.menuSize]=224),1===i&&(this.menuAction[this.menuSize]=993),2===i&&(this.menuAction[this.menuSize]=99),3===i&&(this.menuAction[this.menuSize]=746),4===i&&(this.menuAction[this.menuSize]=877),this.menuParamA[this.menuSize]=t.index,this.menuParamB[this.menuSize]=s,this.menuParamC[this.menuSize]=n,this.menuSize++):2===i&&(this.menuOption[this.menuSize]="Take @lre@"+e.name,this.menuAction[this.menuSize]=99,this.menuParamA[this.menuSize]=t.index,this.menuParamB[this.menuSize]=s,this.menuParamC[this.menuSize]=n,this.menuSize++);this.menuOption[this.menuSize]="Examine @lre@"+e.name,this.menuAction[this.menuSize]=1102,this.menuParamA[this.menuSize]=t.index,this.menuParamB[this.menuSize]=s,this.menuParamC[this.menuSize]=n,this.menuSize++}else 1==(1&this.activeSpellFlags)&&(this.menuOption[this.menuSize]=this.spellCaption+" @lre@"+e.name,this.menuAction[this.menuSize]=965,this.menuParamA[this.menuSize]=t.index,this.menuParamB[this.menuSize]=s,this.menuParamC[this.menuSize]=n,this.menuSize++)}}}}};addNpcOptions=(e,t,i,s)=>{if(this.menuSize>=400)return;let a=e.name;if(0!==e.vislevel&&this.localPlayer&&(a=a+this.getCombatLevelColorTag(this.localPlayer.combatLevel,e.vislevel)+" (level-"+e.vislevel+")"),1===this.objSelected)this.menuOption[this.menuSize]="Use "+this.objSelectedName+" with @yel@"+a,this.menuAction[this.menuSize]=900,this.menuParamA[this.menuSize]=t,this.menuParamB[this.menuSize]=i,this.menuParamC[this.menuSize]=s,this.menuSize++;else if(1!==this.spellSelected){let r;if(e.ops)for(r=4;r>=0;r--)e.ops[r]&&"attack"!==e.ops[r]?.toLowerCase()&&(this.menuOption[this.menuSize]=e.ops[r]+" @yel@"+a,0===r?this.menuAction[this.menuSize]=728:1===r?this.menuAction[this.menuSize]=542:2===r?this.menuAction[this.menuSize]=6:3===r?this.menuAction[this.menuSize]=963:4===r&&(this.menuAction[this.menuSize]=245),this.menuParamA[this.menuSize]=t,this.menuParamB[this.menuSize]=i,this.menuParamC[this.menuSize]=s,this.menuSize++);if(e.ops)for(r=4;r>=0;r--)if(e.ops[r]&&"attack"===e.ops[r]?.toLowerCase()){let n=0;this.localPlayer&&e.vislevel>this.localPlayer.combatLevel&&(n=2e3),this.menuOption[this.menuSize]=e.ops[r]+" @yel@"+a,0===r?this.menuAction[this.menuSize]=n+728:1===r?this.menuAction[this.menuSize]=n+542:2===r?this.menuAction[this.menuSize]=n+6:3===r?this.menuAction[this.menuSize]=n+963:4===r&&(this.menuAction[this.menuSize]=n+245),this.menuParamA[this.menuSize]=t,this.menuParamB[this.menuSize]=i,this.menuParamC[this.menuSize]=s,this.menuSize++}this.menuOption[this.menuSize]="Examine @yel@"+a,this.menuAction[this.menuSize]=1607,this.menuParamA[this.menuSize]=t,this.menuParamB[this.menuSize]=i,this.menuParamC[this.menuSize]=s,this.menuSize++}else 2==(2&this.activeSpellFlags)&&(this.menuOption[this.menuSize]=this.spellCaption+" @yel@"+a,this.menuAction[this.menuSize]=265,this.menuParamA[this.menuSize]=t,this.menuParamB[this.menuSize]=i,this.menuParamC[this.menuSize]=s,this.menuSize++)};addPlayerOptions=(e,t,i,s)=>{if(e===this.localPlayer||this.menuSize>=400)return;let a=null;this.localPlayer&&(a=e.name+this.getCombatLevelColorTag(this.localPlayer.combatLevel,e.combatLevel)+" (level-"+e.combatLevel+")"),1===this.objSelected?(this.menuOption[this.menuSize]="Use "+this.objSelectedName+" with @whi@"+a,this.menuAction[this.menuSize]=367,this.menuParamA[this.menuSize]=t,this.menuParamB[this.menuSize]=i,this.menuParamC[this.menuSize]=s,this.menuSize++):1!==this.spellSelected?(this.menuOption[this.menuSize]="Follow @whi@"+a,this.menuAction[this.menuSize]=1544,this.menuParamA[this.menuSize]=t,this.menuParamB[this.menuSize]=i,this.menuParamC[this.menuSize]=s,this.menuSize++,0===this.overrideChat&&(this.menuOption[this.menuSize]="Trade with @whi@"+a,this.menuAction[this.menuSize]=1373,this.menuParamA[this.menuSize]=t,this.menuParamB[this.menuSize]=i,this.menuParamC[this.menuSize]=s,this.menuSize++),this.wildernessLevel>0&&(this.menuOption[this.menuSize]="Attack @whi@"+a,this.localPlayer&&this.localPlayer.combatLevel>=e.combatLevel?this.menuAction[this.menuSize]=151:this.menuAction[this.menuSize]=2151,this.menuParamA[this.menuSize]=t,this.menuParamB[this.menuSize]=i,this.menuParamC[this.menuSize]=s,this.menuSize++),1===this.worldLocationState&&(this.menuOption[this.menuSize]="Fight @whi@"+a,this.menuAction[this.menuSize]=151,this.menuParamA[this.menuSize]=t,this.menuParamB[this.menuSize]=i,this.menuParamC[this.menuSize]=s,this.menuSize++),2===this.worldLocationState&&(this.menuOption[this.menuSize]="Duel-with @whi@"+a,this.menuAction[this.menuSize]=1101,this.menuParamA[this.menuSize]=t,this.menuParamB[this.menuSize]=i,this.menuParamC[this.menuSize]=s,this.menuSize++)):8==(8&this.activeSpellFlags)&&(this.menuOption[this.menuSize]=this.spellCaption+" @whi@"+a,this.menuAction[this.menuSize]=651,this.menuParamA[this.menuSize]=t,this.menuParamB[this.menuSize]=i,this.menuParamC[this.menuSize]=s,this.menuSize++);for(let e=0;e{const i=e-t;return i<-9?"@red@":i<-6?"@or3@":i<-3?"@or2@":i<0?"@or1@":i>9?"@gre@":i>6?"@gr3@":i>3?"@gr2@":i>0?"@gr1@":"@yel@"};handleInput=()=>{if(0===this.objDragArea){this.menuOption[0]="Cancel",this.menuAction[0]=1252,this.menuSize=1,this.handlePrivateChatInput(this.mouseY),this.lastHoveredInterfaceId=0,this.mouseX>8&&this.mouseY>11&&this.mouseX<520&&this.mouseY<345&&(-1===this.viewportInterfaceId?this.handleViewportOptions():this.handleInterfaceInput(c.Z.instances[this.viewportInterfaceId],this.mouseX,this.mouseY,8,11,0)),this.lastHoveredInterfaceId!==this.viewportHoveredInterfaceIndex&&(this.viewportHoveredInterfaceIndex=this.lastHoveredInterfaceId),this.lastHoveredInterfaceId=0,this.mouseX>562&&this.mouseY>231&&this.mouseX<752&&this.mouseY<492&&(-1!==this.sidebarInterfaceId?this.handleInterfaceInput(c.Z.instances[this.sidebarInterfaceId],this.mouseX,this.mouseY,562,231,0):-1!==this.tabInterfaceId[this.selectedTab]&&this.handleInterfaceInput(c.Z.instances[this.tabInterfaceId[this.selectedTab]],this.mouseX,this.mouseY,562,231,0)),this.lastHoveredInterfaceId!==this.sidebarHoveredInterfaceIndex&&(this.redrawSidebar=!0,this.sidebarHoveredInterfaceIndex=this.lastHoveredInterfaceId),this.lastHoveredInterfaceId=0,this.mouseX>22&&this.mouseY>375&&this.mouseX<431&&this.mouseY<471&&(-1===this.chatInterfaceId?this.handleChatMouseInput(this.mouseX-22,this.mouseY-375):this.handleInterfaceInput(c.Z.instances[this.chatInterfaceId],this.mouseX,this.mouseY,22,375,0)),-1!==this.chatInterfaceId&&this.lastHoveredInterfaceId!==this.chatHoveredInterfaceIndex&&(this.redrawChatback=!0,this.chatHoveredInterfaceIndex=this.lastHoveredInterfaceId);let e=!1;for(;!e;){e=!0;for(let t=0;t1e3){const i=this.menuOption[t];this.menuOption[t]=this.menuOption[t+1],this.menuOption[t+1]=i;const s=this.menuAction[t];this.menuAction[t]=this.menuAction[t+1],this.menuAction[t+1]=s;const a=this.menuParamB[t];this.menuParamB[t]=this.menuParamB[t+1],this.menuParamB[t+1]=a;const r=this.menuParamC[t];this.menuParamC[t]=this.menuParamC[t+1],this.menuParamC[t+1]=r;const n=this.menuParamA[t];this.menuParamA[t]=this.menuParamA[t+1],this.menuParamA[t+1]=n,e=!1}}}};showContextMenu=()=>{let e=0;if(this.fontBold12){let t;e=this.fontBold12.stringWidth("Choose Option");for(let i=0;ie&&(e=t)}e+=8;const t=15*this.menuSize+21;let i,s;this.mouseClickX>8&&this.mouseClickY>11&&this.mouseClickX<520&&this.mouseClickY<345&&(i=this.mouseClickX-(e/2|0)-8,i+e>512?i=512-e:i<0&&(i=0),s=this.mouseClickY-11,s+t>334?s=334-t:s<0&&(s=0),this.menuVisible=!0,this.menuArea=0,this.menuX=i,this.menuY=s,this.menuWidth=e,this.menuHeight=15*this.menuSize+22),this.mouseClickX>562&&this.mouseClickY>231&&this.mouseClickX<752&&this.mouseClickY<492&&(i=this.mouseClickX-(e/2|0)-562,i<0?i=0:i+e>190&&(i=190-e),s=this.mouseClickY-231,s<0?s=0:s+t>261&&(s=261-t),this.menuVisible=!0,this.menuArea=1,this.menuX=i,this.menuY=s,this.menuWidth=e,this.menuHeight=15*this.menuSize+22),this.mouseClickX>22&&this.mouseClickY>375&&this.mouseClickX<501&&this.mouseClickY<471&&(i=this.mouseClickX-(e/2|0)-22,i<0?i=0:i+e>479&&(i=479-e),s=this.mouseClickY-375,s<0?s=0:s+t>96&&(s=96-t),this.menuVisible=!0,this.menuArea=2,this.menuX=i,this.menuY=s,this.menuWidth=e,this.menuHeight=15*this.menuSize+22)};tryMove=(e,t,i,s,a,r,n,h,o,l,c)=>{const d=this.levelCollisionMap[this.currentLevel];if(!d)return!1;const u=X.Z.SIZE,f=X.Z.SIZE;for(let e=0;e0&&0===this.bfsDirection[t]&&(S[t]&F.Z.BLOCK_WEST)===F.Z.OPEN&&(this.bfsStepX[y]=p-1,this.bfsStepZ[y]=m,y=(y+1)%w,this.bfsDirection[t]=2,this.bfsCost[t]=e),t=X.Z.index(p+1,m),p0&&0===this.bfsDirection[t]&&(S[t]&F.Z.BLOCK_SOUTH)===F.Z.OPEN&&(this.bfsStepX[y]=p,this.bfsStepZ[y]=m-1,y=(y+1)%w,this.bfsDirection[t]=1,this.bfsCost[t]=e),t=X.Z.index(p,m+1),m0&&m>0&&0===this.bfsDirection[t]&&0==(S[t]&F.Z.BLOCK_SOUTH_WEST)&&(S[X.Z.index(p-1,m)]&F.Z.BLOCK_WEST)===F.Z.OPEN&&(S[X.Z.index(p,m-1)]&F.Z.BLOCK_SOUTH)===F.Z.OPEN&&(this.bfsStepX[y]=p-1,this.bfsStepZ[y]=m-1,y=(y+1)%w,this.bfsDirection[t]=3,this.bfsCost[t]=e),t=X.Z.index(p+1,m-1),p0&&0===this.bfsDirection[t]&&0==(S[t]&F.Z.BLOCK_SOUTH_EAST)&&(S[X.Z.index(p+1,m)]&F.Z.BLOCK_EAST)===F.Z.OPEN&&(S[X.Z.index(p,m-1)]&F.Z.BLOCK_SOUTH)===F.Z.OPEN&&(this.bfsStepX[y]=p+1,this.bfsStepZ[y]=m-1,y=(y+1)%w,this.bfsDirection[t]=9,this.bfsCost[t]=e),t=X.Z.index(p-1,m+1),p>0&&m=0&&i>=0&&a0){w=Math.min(C,25),C--;const e=this.bfsStepX[C],t=this.bfsStepZ[C];0===a?(this.out.p1isaac(I.Z.MOVE_GAMECLICK),this.out.p1(w+w+3)):1===a?(this.out.p1isaac(I.Z.MOVE_MINIMAPCLICK),this.out.p1(w+w+3+14)):2===a&&(this.out.p1isaac(I.Z.MOVE_OPCLICK),this.out.p1(w+w+3)),1===this.actionKey[5]?this.out.p1(1):this.out.p1(0),this.out.p2(e+this.sceneBaseTileX),this.out.p2(t+this.sceneBaseTileZ),this.flagSceneTileX=this.bfsStepX[0],this.flagSceneTileZ=this.bfsStepZ[0];for(let i=1;i{this.entityRemovalCount=0,this.entityUpdateCount=0,this.readLocalPlayer(e),this.readPlayers(e),this.readNewPlayers(e,t),this.readPlayerUpdates(e);for(let e=0;e{if(e.bits(),0!==e.gBit(1)){const t=e.gBit(2);if(0===t)this.entityUpdateIds[this.entityUpdateCount++]=this.LOCAL_PLAYER_INDEX;else if(1===t){const t=e.gBit(3);this.localPlayer?.step(!1,t),1===e.gBit(1)&&(this.entityUpdateIds[this.entityUpdateCount++]=this.LOCAL_PLAYER_INDEX)}else if(2===t){const t=e.gBit(3);this.localPlayer?.step(!0,t);const i=e.gBit(3);this.localPlayer?.step(!0,i),1===e.gBit(1)&&(this.entityUpdateIds[this.entityUpdateCount++]=this.LOCAL_PLAYER_INDEX)}else if(3===t){this.currentLevel=e.gBit(2);const t=e.gBit(7),i=e.gBit(7),s=e.gBit(1);this.localPlayer?.move(1===s,t,i),1===e.gBit(1)&&(this.entityUpdateIds[this.entityUpdateCount++]=this.LOCAL_PLAYER_INDEX)}}};readPlayers=e=>{const t=e.gBit(8);if(tthis.playerCount)throw new Error(`eek! ${this.username} Too many players`);this.playerCount=0;for(let i=0;i{let i;for(;e.bitPos+10<8*t&&(i=e.gBit(11),2047!==i);){if(!this.players[i]){this.players[i]=new H.Z;const e=this.playerAppearanceBuffer[i];e&&this.players[i]?.read(e)}this.playerIds[this.playerCount++]=i;const t=this.players[i];t&&(t.cycle=this.loopCycle);let s=e.gBit(5);s>15&&(s-=32);let a=e.gBit(5);a>15&&(a-=32);const r=e.gBit(1);this.localPlayer&&t?.move(1===r,this.localPlayer.pathTileX[0]+s,this.localPlayer.pathTileZ[0]+a),1===e.gBit(1)&&(this.entityUpdateIds[this.entityUpdateCount++]=i)}e.bytes()};readPlayerUpdates=e=>{for(let t=0;t{if(e.lastMask=i,e.lastMaskCycle=this.loopCycle,1==(1&i)){const i=a.g1,s=new Uint8Array(i),r=new T.Z(s);a.gdata(i,0,s),this.playerAppearanceBuffer[t]=r,e.read(r)}if(2==(2&i)){let t=a.g2;65535===t&&(t=-1),t===e.primarySeqId&&(e.primarySeqLoop=0);const i=a.g1;(-1===t||-1===e.primarySeqId||s.Z.instances[t].priority>s.Z.instances[e.primarySeqId].priority||0===s.Z.instances[e.primarySeqId].priority)&&(e.primarySeqId=t,e.primarySeqFrame=0,e.primarySeqCycle=0,e.primarySeqDelay=i,e.primarySeqLoop=0)}if(4==(4&i)&&(e.targetId=a.g2,65535===e.targetId&&(e.targetId=-1)),8==(8&i)&&(e.chat=a.gjstr,e.chatColor=0,e.chatStyle=0,e.chatTimer=150,e.name&&this.addMessage(2,e.chat,e.name)),16==(16&i)&&(e.damage=a.g1,e.damageType=a.g1,e.combatCycle=this.loopCycle+400,e.health=a.g1,e.totalHealth=a.g1),32==(32&i)&&(e.targetTileX=a.g2,e.targetTileZ=a.g2,e.lastFaceX=e.targetTileX,e.lastFaceZ=e.targetTileZ),64==(64&i)){const t=a.g2,i=a.g1,s=a.g1,r=a.pos;if(e.name){const r=_.Z.toBase37(e.name);let n=!1;if(i<=1)for(let e=0;e>8,e.chatStyle=255&t,e.chatTimer=150,i>1?this.addMessage(1,n,e.name):this.addMessage(2,n,e.name)}catch(e){}}a.pos=r+s}if(256==(256&i)){e.spotanimId=a.g2;const t=a.g4;e.spotanimOffset=t>>16,e.spotanimLastCycle=this.loopCycle+(65535&t),e.spotanimFrame=0,e.spotanimCycle=0,e.spotanimLastCycle>this.loopCycle&&(e.spotanimFrame=-1),65535===e.spotanimId&&(e.spotanimId=-1)}512==(512&i)&&(e.forceMoveStartSceneTileX=a.g1,e.forceMoveStartSceneTileZ=a.g1,e.forceMoveEndSceneTileX=a.g1,e.forceMoveEndSceneTileZ=a.g1,e.forceMoveEndCycle=a.g2+this.loopCycle,e.forceMoveStartCycle=a.g2+this.loopCycle,e.forceMoveFaceDirection=a.g1,e.pathLength=0,e.pathTileX[0]=e.forceMoveEndSceneTileX,e.pathTileZ[0]=e.forceMoveEndSceneTileZ)};readNpcInfo=(e,t)=>{this.entityRemovalCount=0,this.entityUpdateCount=0,this.readNpcs(e),this.readNewNpcs(e,t),this.readNpcUpdates(e);for(let e=0;e{e.bits();const t=e.gBit(8);if(tthis.npcCount)throw new Error(`eek! ${this.username} Too many npc!`);this.npcCount=0;for(let i=0;i{for(;e.bitPos+21<8*t;){const t=e.gBit(13);if(8191===t)break;this.npcs[t]||(this.npcs[t]=new W.Z);const i=this.npcs[t];this.npcIds[this.npcCount++]=t,i?(i.cycle=this.loopCycle,i.type=n.Z.get(e.gBit(11)),i.size=i.type.size,i.seqWalkId=i.type.walkanim,i.seqTurnAroundId=i.type.walkanim_b,i.seqTurnLeftId=i.type.walkanim_r,i.seqTurnRightId=i.type.walkanim_l,i.seqStandId=i.type.readyanim):e.gBit(11);let s=e.gBit(5);s>15&&(s-=32);let a=e.gBit(5);a>15&&(a-=32),this.localPlayer&&i?.move(!1,this.localPlayer.pathTileX[0]+s,this.localPlayer.pathTileZ[0]+a),1===e.gBit(1)&&(this.entityUpdateIds[this.entityUpdateCount++]=t)}e.bytes()};readNpcUpdates=e=>{for(let t=0;ts.Z.instances[a.primarySeqId].priority||0===s.Z.instances[a.primarySeqId].priority)&&(a.primarySeqId=t,a.primarySeqFrame=0,a.primarySeqCycle=0,a.primarySeqDelay=i,a.primarySeqLoop=0)}if(4==(4&r)&&(a.targetId=e.g2,65535===a.targetId&&(a.targetId=-1)),8==(8&r)&&(a.chat=e.gjstr,a.chatTimer=100),16==(16&r)&&(a.damage=e.g1,a.damageType=e.g1,a.combatCycle=this.loopCycle+400,a.health=e.g1,a.totalHealth=e.g1),32==(32&r)&&(a.type=n.Z.get(e.g2),a.seqWalkId=a.type.walkanim,a.seqTurnAroundId=a.type.walkanim_b,a.seqTurnLeftId=a.type.walkanim_r,a.seqTurnRightId=a.type.walkanim_l,a.seqStandId=a.type.readyanim),64==(64&r)){a.spotanimId=e.g2;const t=e.g4;a.spotanimOffset=t>>16,a.spotanimLastCycle=this.loopCycle+(65535&t),a.spotanimFrame=0,a.spotanimCycle=0,a.spotanimLastCycle>this.loopCycle&&(a.spotanimFrame=-1),65535===a.spotanimId&&(a.spotanimId=-1)}128==(128&r)&&(a.targetTileX=e.g2,a.targetTileZ=e.g2,a.lastFaceX=a.targetTileX,a.lastFaceZ=a.targetTileZ)}};updatePlayers=()=>{for(let e=-1;e1406){J.K.updatePlayersCounter=0,this.out.p1isaac(I.Z.ANTICHEAT_CYCLELOGIC6),this.out.p1(0);const e=this.out.pos;this.out.p1(162),this.out.p1(22),0==(2*Math.random()|0)&&this.out.p1(84),this.out.p2(31824),this.out.p2(13490),0==(2*Math.random()|0)&&this.out.p1(123),0==(2*Math.random()|0)&&this.out.p1(134),this.out.p1(100),this.out.p1(94),this.out.p2(35521),this.out.psize1(this.out.pos-e)}};updateEntity=e=>{(e.x<128||e.z<128||e.x>=13184||e.z>=13184)&&(e.primarySeqId=-1,e.spotanimId=-1,e.forceMoveEndCycle=0,e.forceMoveStartCycle=0,e.x=128*e.pathTileX[0]+64*e.size,e.z=128*e.pathTileZ[0]+64*e.size,e.pathLength=0),e===this.localPlayer&&(e.x<1536||e.z<1536||e.x>=11776||e.z>=11776)&&(e.primarySeqId=-1,e.spotanimId=-1,e.forceMoveEndCycle=0,e.forceMoveStartCycle=0,e.x=128*e.pathTileX[0]+64*e.size,e.z=128*e.pathTileZ[0]+64*e.size,e.pathLength=0),e.forceMoveEndCycle>this.loopCycle?this.updateForceMovement(e):e.forceMoveStartCycle>=this.loopCycle?this.startForceMovement(e):this.updateMovement(e),this.updateFacingDirection(e),this.updateSequences(e)};pushPlayers=()=>{if(this.localPlayer){this.localPlayer.x>>7===this.flagSceneTileX&&this.localPlayer.z>>7===this.flagSceneTileZ&&(this.flagSceneTileX=0);for(let e=-1;e50||this.playerCount>200)&&-1!==e&&t.secondarySeqId===t.seqStandId;const s=t.x>>7,a=t.z>>7;if(!(s<0||s>=X.Z.SIZE||a<0||a>=X.Z.SIZE))if(!t.locModel||this.loopCycle=t.locStopCycle){if(64==(127&t.x)&&64==(127&t.z)){if(this.tileLastOccupiedCycle[s][a]===this.sceneCycle)continue;this.tileLastOccupiedCycle[s][a]=this.sceneCycle}t.y=this.getHeightmapY(this.currentLevel,t.x,t.z),this.scene?.addTemporary(this.currentLevel,t.x,t.y,t.z,null,t,i,t.yaw,60,t.seqStretches)}else t.lowMemory=!1,t.y=this.getHeightmapY(this.currentLevel,t.x,t.z),this.scene?.addTemporary2(this.currentLevel,t.x,t.y,t.z,t.minTileX,t.minTileZ,t.maxTileX,t.maxTileZ,null,t,i,t.yaw)}}};updateNpcs=()=>{for(let e=0;e{for(let e=0;e>7,a=t.z>>7;if(!(s<0||s>=X.Z.SIZE||a<0||a>=X.Z.SIZE)){if(1===t.size&&64==(127&t.x)&&64==(127&t.z)){if(this.tileLastOccupiedCycle[s][a]===this.sceneCycle)continue;this.tileLastOccupiedCycle[s][a]=this.sceneCycle}this.scene?.addTemporary(this.currentLevel,t.x,this.getHeightmapY(this.currentLevel,t.x,t.z),t.z,null,t,i,t.yaw,64*(t.size-1)+60,t.seqStretches)}}};pushProjectiles=()=>{for(let e=this.projectiles.peekFront();e;e=this.projectiles.prev())if(e.level!==this.currentLevel||this.loopCycle>e.lastCycle)e.unlink();else if(this.loopCycle>=e.startCycle){if(e.target>0){const t=this.npcs[e.target-1];t&&e.updateVelocity(t.x,this.getHeightmapY(e.level,t.x,t.z)-e.offsetY,t.z,this.loopCycle)}if(e.target<0){const t=-e.target-1;let i;i=t===this.localPid?this.localPlayer:this.players[t],i&&e.updateVelocity(i.x,this.getHeightmapY(e.level,i.x,i.z)-e.offsetY,i.z,this.loopCycle)}e.update(this.sceneDelta),this.scene?.addTemporary(this.currentLevel,0|e.x,0|e.y,0|e.z,null,e,-1,e.yaw,60,!1)}};pushSpotanims=()=>{for(let e=this.spotanims.peekFront();e;e=this.spotanims.prev())e.level!==this.currentLevel||e.seqComplete?e.unlink():this.loopCycle>=e.startCycle&&(e.update(this.sceneDelta),e.seqComplete?e.unlink():this.scene?.addTemporary(e.level,e.x,e.y,e.z,null,e,-1,0,60,!1))};pushLocs=()=>{for(let e=this.locList.peekFront();e;e=this.locList.prev()){let t=!1;if(e.seqCycle+=this.sceneDelta,-1===e.seqFrame&&(e.seqFrame=0,t=!0),e.seq.delay)for(;e.seqCycle>e.seq.delay[e.seqFrame];)if(e.seqCycle-=e.seq.delay[e.seqFrame]+1,e.seqFrame++,t=!0,e.seqFrame>=e.seq.frameCount&&(e.seqFrame-=e.seq.replayoff,e.seqFrame<0||e.seqFrame>=e.seq.frameCount)){e.unlink(),t=!1;break}if(t&&this.scene){const t=e.heightmapSW,i=e.heightmapNE,s=e.heightmapNW;let r=0;if(0===e.heightmapSE?r=this.scene.getWallBitset(t,i,s):1===e.heightmapSE?r=this.scene.getWallDecorationBitset(t,s,i):2===e.heightmapSE?r=this.scene.getLocBitset(t,i,s):3===e.heightmapSE&&(r=this.scene.getGroundDecorationBitset(t,i,s)),this.levelHeightmap&&0!==r&&(r>>14&32767)===e.index){const n=this.levelHeightmap[t][i][s],h=this.levelHeightmap[t][i+1][s],o=this.levelHeightmap[t][i+1][s+1],l=this.levelHeightmap[t][i][s+1],c=a.Z.get(e.index);let d=-1;if(-1!==e.seqFrame&&e.seq.frames&&(d=e.seq.frames[e.seqFrame]),2===e.heightmapSE){const e=this.scene.getInfo(t,i,s,r);let a=31&e;const u=e>>6;a===N.Z.CENTREPIECE_DIAGONAL&&(a=N.Z.CENTREPIECE_STRAIGHT),this.scene?.setLocModel(t,i,s,c.getModel(a,u,n,h,o,l,d))}else if(1===e.heightmapSE)this.scene?.setWallDecorationModel(t,i,s,c.getModel(N.Z.WALLDECOR_STRAIGHT_NOOFFSET,0,n,h,o,l,d));else if(0===e.heightmapSE){const e=this.scene.getInfo(t,i,s,r),a=31&e,u=e>>6;if(a===N.Z.WALL_L){const e=u+1&3;this.scene?.setWallModels(i,s,t,c.getModel(N.Z.WALL_L,u+4,n,h,o,l,d),c.getModel(N.Z.WALL_L,e,n,h,o,l,d))}else this.scene?.setWallModel(t,i,s,c.getModel(a,u,n,h,o,l,d))}else if(3===e.heightmapSE){const e=this.scene.getInfo(t,i,s,r)>>6;this.scene?.setGroundDecorationModel(t,i,s,c.getModel(N.Z.GROUND_DECOR,e,n,h,o,l,d))}}else e.unlink()}}};updateEntityChats=()=>{for(let e=-1;e0&&(i.chatTimer--,0===i.chatTimer&&(i.chat=null))}for(let e=0;e0&&(i.chatTimer--,0===i.chatTimer&&(i.chat=null))}};updateTemporaryLocs=()=>{if(2===this.sceneState){for(let e=this.temporaryLocs.peekFront();e;e=this.temporaryLocs.prev())this.loopCycle>=e.lastCycle&&(this.addLoc(e.plane,e.x,e.z,e.locIndex,e.angle,e.shape,e.layer),e.unlink());J.K.updateLocCounter++,J.K.updateLocCounter>85&&(J.K.updateLocCounter=0,this.out.p1isaac(I.Z.ANTICHEAT_CYCLELOGIC5))}};updateForceMovement=e=>{const t=e.forceMoveEndCycle-this.loopCycle,i=128*e.forceMoveStartSceneTileX+64*e.size,s=128*e.forceMoveStartSceneTileZ+64*e.size;e.x+=(i-e.x)/t|0,e.z+=(s-e.z)/t|0,e.seqTrigger=0,0==e.forceMoveFaceDirection&&(e.dstYaw=1024),1==e.forceMoveFaceDirection&&(e.dstYaw=1536),2==e.forceMoveFaceDirection&&(e.dstYaw=0),3==e.forceMoveFaceDirection&&(e.dstYaw=512)};startForceMovement=e=>{if(e.forceMoveStartCycle==this.loopCycle||-1==e.primarySeqId||0!=e.primarySeqDelay||e.primarySeqCycle+1>s.Z.instances[e.primarySeqId].delay[e.primarySeqFrame]){const t=e.forceMoveStartCycle-e.forceMoveEndCycle,i=this.loopCycle-e.forceMoveEndCycle,s=128*e.forceMoveStartSceneTileX+64*e.size,a=128*e.forceMoveStartSceneTileZ+64*e.size,r=128*e.forceMoveEndSceneTileX+64*e.size,n=128*e.forceMoveEndSceneTileZ+64*e.size;e.x=(s*(t-i)+r*i)/t|0,e.z=(a*(t-i)+n*i)/t|0}e.seqTrigger=0,0==e.forceMoveFaceDirection&&(e.dstYaw=1024),1==e.forceMoveFaceDirection&&(e.dstYaw=1536),2==e.forceMoveFaceDirection&&(e.dstYaw=0),3==e.forceMoveFaceDirection&&(e.dstYaw=512),e.yaw=e.dstYaw};updateFacingDirection=e=>{if(-1!==e.targetId&&e.targetId<32768){const t=this.npcs[e.targetId];if(t){const i=e.x-t.x,s=e.z-t.z;0===i&&0===s||(e.dstYaw=2047&(325.949*Math.atan2(i,s)|0))}}if(e.targetId>=32768){let t=e.targetId-32768;t===this.localPid&&(t=this.LOCAL_PLAYER_INDEX);const i=this.players[t];if(i){const t=e.x-i.x,s=e.z-i.z;0===t&&0===s||(e.dstYaw=2047&(325.949*Math.atan2(t,s)|0))}}if((0!==e.targetTileX||0!==e.targetTileZ)&&(0===e.pathLength||e.seqTrigger>0)){const t=e.x-64*(e.targetTileX-this.sceneBaseTileX-this.sceneBaseTileX),i=e.z-64*(e.targetTileZ-this.sceneBaseTileZ-this.sceneBaseTileZ);0===t&&0===i||(e.dstYaw=2047&(325.949*Math.atan2(t,i)|0)),e.targetTileX=0,e.targetTileZ=0}const t=e.dstYaw-e.yaw&2047;if(0!==t&&(t<32||t>2016?e.yaw=e.dstYaw:t>1024?e.yaw-=32:e.yaw+=32,e.yaw&=2047,e.secondarySeqId===e.seqStandId&&e.yaw!==e.dstYaw)){if(-1!==e.seqTurnId)return void(e.secondarySeqId=e.seqTurnId);e.secondarySeqId=e.seqWalkId}};updateSequences=e=>{let t;if(e.seqStretches=!1,-1!==e.secondarySeqId&&(t=s.Z.instances[e.secondarySeqId],e.secondarySeqCycle++,t.delay&&e.secondarySeqFramet.delay[e.secondarySeqFrame]&&(e.secondarySeqCycle=0,e.secondarySeqFrame++),e.secondarySeqFrame>=t.frameCount&&(e.secondarySeqCycle=0,e.secondarySeqFrame=0)),-1!==e.primarySeqId&&0===e.primarySeqDelay){for(t=s.Z.instances[e.primarySeqId],e.primarySeqCycle++;t.delay&&e.primarySeqFramet.delay[e.primarySeqFrame];)e.primarySeqCycle-=t.delay[e.primarySeqFrame],e.primarySeqFrame++;e.primarySeqFrame>=t.frameCount&&(e.primarySeqFrame-=t.replayoff,e.primarySeqLoop++,e.primarySeqLoop>=t.replaycount&&(e.primarySeqId=-1),(e.primarySeqFrame<0||e.primarySeqFrame>=t.frameCount)&&(e.primarySeqId=-1)),e.seqStretches=t.stretches}if(e.primarySeqDelay>0&&e.primarySeqDelay--,-1!==e.spotanimId&&this.loopCycle>=e.spotanimLastCycle){for(e.spotanimFrame<0&&(e.spotanimFrame=0),t=o.Z.instances[e.spotanimId].seq,e.spotanimCycle++;t&&t.delay&&e.spotanimFramet.delay[e.spotanimFrame];)e.spotanimCycle-=t.delay[e.spotanimFrame],e.spotanimFrame++;t&&e.spotanimFrame>=t.frameCount&&(e.spotanimFrame<0||e.spotanimFrame>=t.frameCount)&&(e.spotanimId=-1)}};updateMovement=e=>{if(e.secondarySeqId=e.seqStandId,0===e.pathLength)return void(e.seqTrigger=0);if(-1!==e.primarySeqId&&0===e.primarySeqDelay&&!s.Z.instances[e.primarySeqId].labelGroups)return void e.seqTrigger++;const t=e.x,i=e.z,a=128*e.pathTileX[e.pathLength-1]+64*e.size,r=128*e.pathTileZ[e.pathLength-1]+64*e.size;if(a-t<=256&&a-t>=-256&&r-i<=256&&r-i>=-256){e.dstYaw=tr?1792:1536:t>a?ir?256:512:i1024&&(s-=2048);let n=e.seqTurnAroundId;s>=-256&&s<=256?n=e.seqWalkId:s>=256&&s<768?n=e.seqTurnRightId:s>=-768&&s<=-256&&(n=e.seqTurnLeftId),-1===n&&(n=e.seqWalkId),e.secondarySeqId=n;let h=4;e.yaw!==e.dstYaw&&-1===e.targetId&&(h=2),e.pathLength>2&&(h=6),e.pathLength>3&&(h=8),e.seqTrigger>0&&e.pathLength>1&&(h=8,e.seqTrigger--),e.pathRunning[e.pathLength-1]&&(h<<=1),h>=8&&e.secondarySeqId===e.seqWalkId&&-1!==e.seqRunId&&(e.secondarySeqId=e.seqRunId),ta&&(e.x=a)):t>a&&(e.x-=h,e.xr&&(e.z=r)):i>r&&(e.z-=h,e.z{let e=3;if(this.cameraPitch<310&&this.localPlayer){let t=this.cameraX>>7,i=this.cameraZ>>7;const s=this.localPlayer.x>>7,a=this.localPlayer.z>>7;let r,n,h,o;if(this.levelTileFlags&&0!=(4&this.levelTileFlags[this.currentLevel][t][i])&&(e=this.currentLevel),r=s>t?s-t:t-s,n=a>i?a-i:i-a,r>n)for(h=65536*n/r|0,o=32768;t!==s;)ts&&t--,this.levelTileFlags&&0!=(4&this.levelTileFlags[this.currentLevel][t][i])&&(e=this.currentLevel),o+=h,o>=65536&&(o-=65536,ia&&i--,this.levelTileFlags&&0!=(4&this.levelTileFlags[this.currentLevel][t][i])&&(e=this.currentLevel));else for(h=65536*r/n|0,o=32768;i!==a;)ia&&i--,this.levelTileFlags&&0!=(4&this.levelTileFlags[this.currentLevel][t][i])&&(e=this.currentLevel),o+=h,o>=65536&&(o-=65536,ts&&t--,this.levelTileFlags&&0!=(4&this.levelTileFlags[this.currentLevel][t][i])&&(e=this.currentLevel))}return this.localPlayer&&this.levelTileFlags&&0!=(4&this.levelTileFlags[this.currentLevel][this.localPlayer.x>>7][this.localPlayer.z>>7])&&(e=this.currentLevel),e};getTopLevelCutscene=()=>this.levelTileFlags?this.getHeightmapY(this.currentLevel,this.cameraX,this.cameraZ)-this.cameraY>=800||0==(4&this.levelTileFlags[this.currentLevel][this.cameraX>>7][this.cameraZ>>7])?3:this.currentLevel:0;getHeightmapY=(e,t,i)=>{if(!this.levelHeightmap)return 0;const s=Math.min(t>>7,X.Z.SIZE-1),a=Math.min(i>>7,X.Z.SIZE-1);let r=e;e<3&&this.levelTileFlags&&2==(2&this.levelTileFlags[1][s][a])&&(r=e+1);const n=127&t,h=127&i;return(this.levelHeightmap[r][s][a]*(128-n)+this.levelHeightmap[r][s+1][a]*n>>7)*(128-h)+(this.levelHeightmap[r][s][a+1]*(128-n)+this.levelHeightmap[r][s+1][a+1]*n>>7)*h>>7};orbitCamera=(e,t,i,s,a,r)=>{const n=2048-a&2047,h=2048-s&2047;let o,l,c,d=0,u=0,p=r;0!==n&&(o=f.Z.sin[n],l=f.Z.cos[n],c=u*l-r*o>>16,p=u*o+r*l>>16,u=c),0!==h&&(o=f.Z.sin[h],l=f.Z.cos[h],c=p*o+d*l>>16,p=p*l-d*o>>16,d=c),this.cameraX=e-d,this.cameraY=t-u,this.cameraZ=i-p,this.cameraPitch=a,this.cameraYaw=s};updateOrbitCamera=()=>{if(!this.localPlayer)return;const e=this.localPlayer.x+this.cameraAnticheatOffsetX,t=this.localPlayer.z+this.cameraAnticheatOffsetZ;(this.orbitCameraX-e<-500||this.orbitCameraX-e>500||this.orbitCameraZ-t<-500||this.orbitCameraZ-t>500)&&(this.orbitCameraX=e,this.orbitCameraZ=t),this.orbitCameraX!==e&&(this.orbitCameraX+=(e-this.orbitCameraX)/16|0),this.orbitCameraZ!==t&&(this.orbitCameraZ+=(t-this.orbitCameraZ)/16|0),1===this.actionKey[1]?this.orbitCameraYawVelocity+=(-this.orbitCameraYawVelocity-24)/2|0:1===this.actionKey[2]?this.orbitCameraYawVelocity+=(24-this.orbitCameraYawVelocity)/2|0:this.orbitCameraYawVelocity=this.orbitCameraYawVelocity/2|0,1===this.actionKey[3]?this.orbitCameraPitchVelocity+=(12-this.orbitCameraPitchVelocity)/2|0:1===this.actionKey[4]?this.orbitCameraPitchVelocity+=(-this.orbitCameraPitchVelocity-12)/2|0:this.orbitCameraPitchVelocity=this.orbitCameraPitchVelocity/2|0,this.orbitCameraYaw=2047&(this.orbitCameraYaw+this.orbitCameraYawVelocity/2|0),this.orbitCameraPitch+=this.orbitCameraPitchVelocity/2|0,this.orbitCameraPitch<128&&(this.orbitCameraPitch=128),this.orbitCameraPitch>383&&(this.orbitCameraPitch=383);const i=this.orbitCameraX>>7,s=this.orbitCameraZ>>7,a=this.getHeightmapY(this.currentLevel,this.orbitCameraX,this.orbitCameraZ);let r=0;if(this.levelHeightmap&&i>3&&s>3&&i<100&&s<100)for(let e=i-4;e<=i+4;e++)for(let t=s-4;t<=s+4;t++){let i=this.currentLevel;i<3&&this.levelTileFlags&&2==(2&this.levelTileFlags[1][e][t])&&i++;const s=a-this.levelHeightmap[i][e][t];s>r&&(r=s)}let n=192*r;n>98048&&(n=98048),n<32768&&(n=32768),n>this.cameraPitchClamp?this.cameraPitchClamp+=(n-this.cameraPitchClamp)/24|0:n{let e=128*this.cutsceneSrcLocalTileX+64,t=128*this.cutsceneSrcLocalTileZ+64,i=this.getHeightmapY(this.currentLevel,this.cutsceneSrcLocalTileX,this.cutsceneSrcLocalTileZ)-this.cutsceneSrcHeight;this.cameraXe&&(this.cameraX=e)),this.cameraX>e&&(this.cameraX-=this.cutsceneMoveSpeed+((this.cameraX-e)*this.cutsceneMoveAcceleration/1e3|0),this.cameraXi&&(this.cameraY=i)),this.cameraY>i&&(this.cameraY-=this.cutsceneMoveSpeed+((this.cameraY-i)*this.cutsceneMoveAcceleration/1e3|0),this.cameraYt&&(this.cameraZ=t)),this.cameraZ>t&&(this.cameraZ-=this.cutsceneMoveSpeed+((this.cameraZ-t)*this.cutsceneMoveAcceleration/1e3|0),this.cameraZ383&&(h=383),this.cameraPitchh&&(this.cameraPitch=h)),this.cameraPitch>h&&(this.cameraPitch-=this.cutsceneRotateSpeed+((this.cameraPitch-h)*this.cutsceneRotateAcceleration/1e3|0),this.cameraPitch1024&&(l-=2048),l<-1024&&(l+=2048),l>0&&(this.cameraYaw+=this.cutsceneRotateSpeed+(l*this.cutsceneRotateAcceleration/1e3|0),this.cameraYaw&=2047),l<0&&(this.cameraYaw-=this.cutsceneRotateSpeed+(-l*this.cutsceneRotateAcceleration/1e3|0),this.cameraYaw&=2047);let c=o-this.cameraYaw;c>1024&&(c-=2048),c<-1024&&(c+=2048),(c<0&&l>0||c>0&&l<0)&&(this.cameraYaw=o)};readZonePacket=(e,t)=>{const i=e.g1;let r=this.baseX+(i>>4&7),n=this.baseZ+(7&i);if(t===v.Z.LOC_ADD_CHANGE||t===v.Z.LOC_DEL){const i=e.g1,s=i>>2,a=3&i,h=N.m.layer(s);let o;if(o=t===v.Z.LOC_DEL?-1:e.g2,r>=0&&n>=0&&r>14&32767,s=31&e,a=e>>6}e=new D.Z(this.currentLevel,h,r,n,0,B.Z.WEST,N.Z.WALL_STRAIGHT,i,a,s),this.spawnedLocations.pushBack(e)}e&&(e.locIndex=o,e.shape=s,e.angle=a),this.addLoc(this.currentLevel,r,n,o,a,s,h)}}else if(t===v.Z.LOC_ANIM){const t=e.g1>>2,i=N.m.layer(t),a=e.g2;if(r>=0&&n>=0&&r>14&32767,this.currentLevel,i,r,n,s.Z.instances[a],!1);this.locList.pushBack(t)}}}else if(t===v.Z.OBJ_ADD){const t=e.g2,i=e.g2;if(r>=0&&n>=0&&r=0&&n>=0&&r=0&&n>=0&&r=0&&i>=0&&t=0&&n>=0&&r=0&&n>=0&&r>2,s=3&t,h=N.m.layer(i),o=e.g2,l=e.g2,c=e.g2,d=e.g2;let u,f=e.g1b,p=e.g1b,m=e.g1b,g=e.g1b;if(u=d===this.localPid?this.localPlayer:this.players[d],u&&this.levelHeightmap){const e=new Y.Z(this.currentLevel,h,r,n,-1,s,i,l+this.loopCycle);this.temporaryLocs.pushBack(e);const t=new Y.Z(this.currentLevel,h,r,n,o,s,i,c+this.loopCycle);this.temporaryLocs.pushBack(t);const d=this.levelHeightmap[this.currentLevel][r][n],y=this.levelHeightmap[this.currentLevel][r+1][n],C=this.levelHeightmap[this.currentLevel][r+1][n+1],T=this.levelHeightmap[this.currentLevel][r][n+1],w=a.Z.get(o);u.locStartCycle=l+this.loopCycle,u.locStopCycle=c+this.loopCycle,u.locModel=w.getModel(i,s,d,y,C,T,-1);let S,Z=w.width,A=w.length;s!==B.Z.NORTH&&s!==B.Z.SOUTH||(Z=w.length,A=w.width),u.locOffsetX=128*r+64*Z,u.locOffsetZ=128*n+64*A,u.locOffsetY=this.getHeightmapY(this.currentLevel,u.locOffsetX,u.locOffsetZ),f>m&&(S=f,f=m,m=S),p>g&&(S=p,p=g,g=S),u.minTileX=r+f,u.maxTileX=r+m,u.minTileZ=n+p,u.maxTileZ=n+g}}else if(t===v.Z.OBJ_COUNT){const t=e.g2,i=e.g2,s=e.g2;if(r>=0&&n>=0&&r{if(!J.K.lowMemory){if(f.Z.textureCycle[17]>=e){const e=f.Z.textures[17];if(!e)return;const t=e.width*e.height-1,i=e.width*this.sceneDelta*2,s=e.pixels,a=this.textureBuffer;for(let e=0;e<=t;e++)a[e]=s[e-i&t];e.pixels=a,this.textureBuffer=s,f.Z.pushTexture(17)}if(f.Z.textureCycle[24]>=e){const e=f.Z.textures[24];if(!e)return;const t=e.width*e.height-1,i=e.width*this.sceneDelta*2,s=e.pixels,a=this.textureBuffer;for(let e=0;e<=t;e++)a[e]=s[e-i&t];e.pixels=a,this.textureBuffer=s,f.Z.pushTexture(24)}}};updateFlames=()=>{if(this.flameBuffer3&&this.flameBuffer2&&this.flameBuffer0&&this.flameLineOffset){for(let e=10;e<117;e++)(100*Math.random()|0)<50&&(this.flameBuffer3[e+32512]=255);for(let e=0;e<100;e++){const e=2+(124*Math.random()|0)+(128+(128*Math.random()|0)<<7);this.flameBuffer3[e]=192}for(let e=1;e<255;e++)for(let t=1;t<127;t++){const i=t+(e<<7);this.flameBuffer2[i]=(this.flameBuffer3[i-1]+this.flameBuffer3[i+1]+this.flameBuffer3[i-128]+this.flameBuffer3[i+128])/4|0}this.flameCycle0+=128,this.flameCycle0>this.flameBuffer0.length&&(this.flameCycle0-=this.flameBuffer0.length,this.updateFlameBuffer(this.imageRunes[12*Math.random()|0]));for(let e=1;e<255;e++)for(let t=1;t<127;t++){const i=t+(e<<7);let s=this.flameBuffer2[i+128]-(this.flameBuffer0[i+this.flameCycle0&this.flameBuffer0.length-1]/5|0);s<0&&(s=0),this.flameBuffer3[i]=s}for(let e=0;e<255;e++)this.flameLineOffset[e]=this.flameLineOffset[e+1];if(this.flameLineOffset[255]=16*Math.sin(this.loopCycle/14)+14*Math.sin(this.loopCycle/15)+12*Math.sin(this.loopCycle/16)|0,this.flameGradientCycle0>0&&(this.flameGradientCycle0-=4),this.flameGradientCycle1>0&&(this.flameGradientCycle1-=4),0===this.flameGradientCycle0&&0===this.flameGradientCycle1){const e=2e3*Math.random()|0;0===e?this.flameGradientCycle0=1024:1===e&&(this.flameGradientCycle1=1024)}}};mix=(e,t,i)=>{const s=256-t;return((16711935&e)*s+(16711935&i)*t&4278255360)+((65280&e)*s+(65280&i)*t&16711680)>>8};drawFlames=()=>{if(!(this.flameGradient&&this.flameGradient0&&this.flameGradient1&&this.flameGradient2&&this.flameLineOffset&&this.flameBuffer3))return;const e=256;if(this.flameGradientCycle0>0)for(let e=0;e<256;e++)this.flameGradientCycle0>768?this.flameGradient[e]=this.mix(this.flameGradient0[e],1024-this.flameGradientCycle0,this.flameGradient1[e]):this.flameGradientCycle0>256?this.flameGradient[e]=this.flameGradient1[e]:this.flameGradient[e]=this.mix(this.flameGradient1[e],256-this.flameGradientCycle0,this.flameGradient0[e]);else if(this.flameGradientCycle1>0)for(let e=0;e<256;e++)this.flameGradientCycle1>768?this.flameGradient[e]=this.mix(this.flameGradient0[e],1024-this.flameGradientCycle1,this.flameGradient2[e]):this.flameGradientCycle1>256?this.flameGradient[e]=this.flameGradient2[e]:this.flameGradient[e]=this.mix(this.flameGradient2[e],256-this.flameGradientCycle1,this.flameGradient0[e]);else for(let e=0;e<256;e++)this.flameGradient[e]=this.flameGradient0[e];for(let e=0;e<33920;e++)this.imageTitle0&&this.imageFlamesLeft&&(this.imageTitle0.pixels[e]=this.imageFlamesLeft.pixels[e]);let t=0,i=1152;for(let s=1;s<255;s++){let a=22+(this.flameLineOffset[s]*(e-s)/e|0);a<0&&(a=0),t+=a;for(let e=a;e<128;e++){let e=this.flameBuffer3[t++];if(0===e)i++;else{const t=e,s=256-e;if(e=this.flameGradient[e],this.imageTitle0){const a=this.imageTitle0.pixels[i];this.imageTitle0.pixels[i++]=((16711935&e)*t+(16711935&a)*s&4278255360)+((65280&e)*t+(65280&a)*s&16711680)>>8}}}i+=a}this.imageTitle0?.draw(0,0);for(let e=0;e<33920;e++)this.imageTitle1&&this.imageFlamesRight&&(this.imageTitle1.pixels[e]=this.imageFlamesRight.pixels[e]);t=0,i=1176;for(let s=1;s<255;s++){const a=this.flameLineOffset[s]*(e-s)/e|0,r=103-a;i+=a;for(let e=0;e>8}}}t+=128-r,i+=128-r-a}this.imageTitle1?.draw(661,0)}}console.log(`RS2 user client - release #${J.K.clientversion}`),await(0,te.O)(),(new e).run().then((()=>{})),t()}catch(e){t(e)}}),1)},1995:(e,t,i)=>{i.d(t,{Z:()=>l});var s=i(651),a=i(8078),r=i(1519),n=i(9839),h=i(6884),o=i(6121);class l{static getParameter(e){return new URLSearchParams(window.location.search).get(e)??""}static setParameter(e,t){const i=new URL(window.location.toString());i.searchParams.set(e,t),window.history.pushState(null,"",i.toString())}slowestMS=0;averageMS=[];averageIndexMS=0;drawArea=null;state=0;deltime=20;mindel=1;otim=[];fps=0;fpos=0;frameTime=[];redrawScreen=!0;resizeToFit=!1;idleCycles=0;mouseButton=0;mouseX=0;mouseY=0;mouseClickButton=0;mouseClickX=0;mouseClickY=0;actionKey=[];keyQueue=[];keyQueueReadPos=0;keyQueueWritePos=0;constructor(e=!1){o.E1.fillStyle="black",o.E1.fillRect(0,0,o.JQ.width,o.JQ.height),this.resizeToFit=e,this.resizeToFit?this.resize(window.innerWidth,window.innerHeight):this.resize(o.JQ.width,o.JQ.height)}get width(){return o.JQ.width}get height(){return o.JQ.height}resize(e,t){o.JQ.width=e,o.JQ.height=t,this.drawArea=new s.Z(e,t),a.Z.init2D()}async run(){window.addEventListener("resize",(()=>{this.resizeToFit&&this.resize(window.innerWidth,window.innerHeight)}),!1),window.addEventListener("keydown",this.keyPressed),window.addEventListener("keyup",this.keyReleased),window.addEventListener("mousedown",this.mousePressed),window.addEventListener("mouseup",this.mouseReleased),window.addEventListener("mouseenter",this.mouseEntered),window.addEventListener("mouseleave",this.mouseExited),window.addEventListener("mousemove",this.mouseMoved),window.addEventListener("focusin",this.focusGained),window.addEventListener("focusout",this.focusLost),window.addEventListener("beforeunload",this.unload),o.JQ.oncontextmenu=e=>{e.preventDefault()},await this.showProgress(0,"Loading..."),await this.load();for(let e=0;e<10;e++)this.otim[e]=Date.now();let e,t=0,i=256,s=1,a=0;for(;this.state>=0;){if(this.state>0&&(this.state--,0===this.state))return void this.shutdown();const n=i,h=s;i=300,s=1,e=Date.now();const o=this.otim[t];if(0===o?(i=n,s=h):e>o&&(i=2560*this.deltime/(e-o)|0),i<25?i=25:i>256&&(i=256,s=this.deltime-(e-o)/10|0),this.otim[t]=e,t=(t+1)%10,s>1)for(let e=0;e<10;e++)0!==this.otim[e]&&(this.otim[e]+=s);for(s0&&(this.fps=1e3*i/(256*this.deltime)|0);const l=performance.now();this.redrawScreen&&this.refresh(),await this.draw(),this.frameTime[this.fpos]=(performance.now()-l)/1e3,this.fpos=(this.fpos+1)%this.frameTime.length}-1===this.state&&this.shutdown()}shutdown(){this.state=-2,this.unload()}setFramerate(e){this.deltime=1e3/e|0}start(){this.state>=0&&(this.state=0)}stop(){this.state>=0&&(this.state=4e3/this.deltime|0)}destroy(){this.state=-1}async load(){}async update(){}unload(){}async draw(){}refresh(){}async showProgress(e,t){const i=this.width,s=this.height;this.redrawScreen&&(o.E1.fillStyle="black",o.E1.fillRect(0,0,i,s),this.redrawScreen=!1);const a=s/2-18;o.E1.fillStyle="rgb(140, 17, 17)",o.E1.rect((i/2|0)-152,a,304,34),o.E1.fillRect((i/2|0)-150,a+2,3*e,30),o.E1.fillStyle="black",o.E1.fillRect((i/2|0)-150+3*e,a+2,300-3*e,30),o.E1.font="bold 13px helvetica, sans-serif",o.E1.textAlign="center",o.E1.fillStyle="white",o.E1.fillText(t,i/2|0,a+22),await(0,r._v)(5)}keyPressed=e=>{const t=e.key;n.v.includes(t)&&e.preventDefault(),this.idleCycles=0;const i=n.n[t];if(!i)return void console.error(`Unhandled key ${t}`);const s=i.key;let a=i.ch;a<30&&(a=0),37===s?a=1:39===s?a=2:38===s?a=3:40===s?a=4:17===s?a=5:8===s||127===s?a=8:9===s?a=9:10===s?a=10:s>=112&&s<=123?a=s+1008-112:36===s?a=1e3:35===s?a=1001:33===s?a=1002:34===s&&(a=1003),a>0&&a<128&&(this.actionKey[a]=1),a>4&&(this.keyQueue[this.keyQueueWritePos]=a,this.keyQueueWritePos=this.keyQueueWritePos+1&127),h.Z.enabled&&h.Z.keyPressed(a)};keyReleased=e=>{const t=e.key;n.v.includes(t)&&e.preventDefault(),this.idleCycles=0;const i=n.n[t];if(!i)return void console.error(`Unhandled key ${t}`);const s=i.key;let a=i.ch;a<30&&(a=0),37===s?a=1:39===s?a=2:38===s?a=3:40===s?a=4:17===s?a=5:8===s||127===s?a=8:9===s?a=9:10===s?a=10:s>=112&&s<=123?a=s+1008-112:36===s?a=1e3:35===s?a=1001:33===s?a=1002:34===s&&(a=1003),a>0&&a<128&&(this.actionKey[a]=0),h.Z.enabled&&h.Z.keyReleased(a)};pollKey(){let e=-1;return this.keyQueueWritePos!==this.keyQueueReadPos&&(e=this.keyQueue[this.keyQueueReadPos],this.keyQueueReadPos=this.keyQueueReadPos+1&127),e}mousePressed=e=>{let t=e.x,i=e.y;const{top:s,left:a}=this.getInsets;t-=a,i-=s;const r=o.JQ.getBoundingClientRect();t*=o.JQ.width/r.width,i*=o.JQ.height/r.height,t|=0,i|=0,this.idleCycles=0,this.mouseClickX=t,this.mouseClickY=i,2===e.buttons?(this.mouseClickButton=2,this.mouseButton=2):1===e.buttons&&(this.mouseClickButton=1,this.mouseButton=1),h.Z.enabled};mouseReleased=e=>{this.idleCycles=0,this.mouseButton=0,h.Z.enabled};mouseEntered=e=>{h.Z.enabled&&h.Z.mouseEntered()};mouseExited=e=>{h.Z.enabled&&h.Z.mouseExited()};mouseMoved=e=>{let t=e.x,i=e.y;const{top:s,left:a}=this.getInsets;t-=a,i-=s;const r=o.JQ.getBoundingClientRect();t*=o.JQ.width/r.width,i*=o.JQ.height/r.height,t|=0,i|=0,this.idleCycles=0,this.mouseX=t,this.mouseY=i,h.Z.enabled&&h.Z.mouseMoved(t,i)};focusGained=e=>{this.redrawScreen=!0,this.refresh(),h.Z.enabled&&h.Z.focusGained()};focusLost=e=>{h.Z.enabled&&h.Z.focusLost()};get ms(){const e=this.frameTime.length;let t=0;for(let i=0;ithis.slowestMS&&(this.slowestMS=i),this.averageMS[this.averageIndexMS]=i,this.averageIndexMS=(this.averageIndexMS+1)%250,i}get msAvg(){return this.averageMS.reduce(((e,t)=>e+t),0)/250}get getInsets(){const e=o.JQ.getBoundingClientRect(),t=window.getComputedStyle(o.JQ),i=parseFloat(t.paddingLeft||"0"),s=parseFloat(t.paddingTop||"0"),a=parseFloat(t.borderLeftWidth||"0"),r=parseFloat(t.borderTopWidth||"0"),n=e.left+a+i;return{top:e.top+r+s,left:n}}}},6884:(e,t,i)=>{i.d(t,{Z:()=>a});var s=i(2383);class a{static enabled=!1;static outBuffer=null;static oldBuffer=null;static lastTime=0;static trackedCount=0;static lastMoveTime=0;static lastX=0;static lastY=0;static setEnabled=()=>{this.outBuffer=s.Z.alloc(1),this.oldBuffer=null,this.lastTime=Date.now(),this.enabled=!0};static setDisabled=()=>{this.enabled=!1,this.outBuffer=null};static flush=()=>{let e=null;return this.oldBuffer&&this.enabled&&(e=this.oldBuffer),this.oldBuffer=null,e};static stop=()=>{let e=null;return this.outBuffer&&this.outBuffer.pos>0&&this.enabled&&(e=this.outBuffer),this.setDisabled(),e};static mousePressed=(e,t,i)=>{if(!(this.enabled&&e>=0&&e<789&&t>=0&&t<532))return;this.trackedCount++;const s=Date.now();let a=(s-this.lastTime)/10|0;a>250&&(a=250),this.lastTime=s,this.ensureCapacity(5),1===i?this.outBuffer?.p1(1):this.outBuffer?.p1(2),this.outBuffer?.p1(a),this.outBuffer?.p3(e+(t<<10))};static mouseReleased=e=>{if(!this.enabled)return;this.trackedCount++;const t=Date.now();let i=(t-this.lastTime)/10|0;i>250&&(i=250),this.lastTime=t,this.ensureCapacity(2),1===e?this.outBuffer?.p1(3):this.outBuffer?.p1(4),this.outBuffer?.p1(i)};static mouseMoved=(e,t)=>{if(!(this.enabled&&e>=0&&e<789&&t>=0&&t<532))return;const i=Date.now();if(i-this.lastMoveTime>=50){this.lastMoveTime=i,this.trackedCount++;let s=(i-this.lastTime)/10|0;s>250&&(s=250),this.lastTime=i,e-this.lastX<8&&e-this.lastX>=-8&&t-this.lastY<8&&t-this.lastY>=-8?(this.ensureCapacity(3),this.outBuffer?.p1(5),this.outBuffer?.p1(s),this.outBuffer?.p1(e+(t-this.lastY+8<<4)+8-this.lastX)):e-this.lastX<128&&e-this.lastX>=-128&&t-this.lastY<128&&t-this.lastY>=-128?(this.ensureCapacity(4),this.outBuffer?.p1(6),this.outBuffer?.p1(s),this.outBuffer?.p1(e+128-this.lastX),this.outBuffer?.p1(t+128-this.lastY)):(this.ensureCapacity(5),this.outBuffer?.p1(7),this.outBuffer?.p1(s),this.outBuffer?.p3(e+(t<<10))),this.lastX=e,this.lastY=t}};static keyPressed=e=>{if(!this.enabled)return;this.trackedCount++;const t=Date.now();let i=(t-this.lastTime)/10|0;i>250&&(i=250),this.lastTime=t,1e3===e?e=11:1001===e?e=12:1002===e?e=14:1003===e?e=15:e>=1008&&(e-=992),this.ensureCapacity(3),this.outBuffer?.p1(8),this.outBuffer?.p1(i),this.outBuffer?.p1(e)};static keyReleased=e=>{if(!this.enabled)return;this.trackedCount++;const t=Date.now();let i=(t-this.lastTime)/10|0;i>250&&(i=250),this.lastTime=t,1e3===e?e=11:1001===e?e=12:1002===e?e=14:1003===e?e=15:e>=1008&&(e-=992),this.ensureCapacity(3),this.outBuffer?.p1(9),this.outBuffer?.p1(i),this.outBuffer?.p1(e)};static focusGained=()=>{if(!this.enabled)return;this.trackedCount++;const e=Date.now();let t=(e-this.lastTime)/10|0;t>250&&(t=250),this.lastTime=e,this.ensureCapacity(2),this.outBuffer?.p1(10),this.outBuffer?.p1(t)};static focusLost=()=>{if(!this.enabled)return;this.trackedCount++;const e=Date.now();let t=(e-this.lastTime)/10|0;t>250&&(t=250),this.lastTime=e,this.ensureCapacity(2),this.outBuffer?.p1(11),this.outBuffer?.p1(t)};static mouseEntered=()=>{if(!this.enabled)return;this.trackedCount++;const e=Date.now();let t=(e-this.lastTime)/10|0;t>250&&(t=250),this.lastTime=e,this.ensureCapacity(2),this.outBuffer?.p1(12),this.outBuffer?.p1(t)};static mouseExited=()=>{if(!this.enabled)return;this.trackedCount++;const e=Date.now();let t=(e-this.lastTime)/10|0;t>250&&(t=250),this.lastTime=e,this.ensureCapacity(2),this.outBuffer?.p1(13),this.outBuffer?.p1(t)};static ensureCapacity=e=>{if(this.outBuffer&&this.outBuffer.pos+e>=500){const e=this.outBuffer;this.outBuffer=s.Z.alloc(1),this.oldBuffer=e}}}},9839:(e,t,i)=>{i.d(t,{n:()=>s,v:()=>a});const s={Backspace:{key:8,ch:8},Enter:{key:10,ch:10},Shift:{key:16,ch:65535},Escape:{key:27,ch:27},Tab:{key:9,ch:9},CapsLock:{key:20,ch:65535}," ":{key:32,ch:32},Control:{key:17,ch:65535},Alt:{key:18,ch:65535},Meta:{key:524,ch:65535},ArrowLeft:{key:37,ch:65535},ArrowRight:{key:39,ch:65535},ArrowUp:{key:38,ch:65535},ArrowDown:{key:40,ch:65535},Insert:{key:155,ch:65535},Home:{key:36,ch:65535},PageUp:{key:33,ch:65535},Delete:{key:127,ch:127},End:{key:35,ch:65535},PageDown:{key:34,ch:65535},"`":{key:192,ch:96},"~":{key:192,ch:126},"!":{key:49,ch:33},"@":{key:50,ch:64},"#":{key:51,ch:35},$:{key:52,ch:36},"%":{key:53,ch:37},"^":{key:54,ch:94},"&":{key:55,ch:38},"*":{key:56,ch:42},"(":{key:57,ch:40},")":{key:48,ch:41},"-":{key:45,ch:45},_:{key:45,ch:95},"=":{key:61,ch:61},"+":{key:61,ch:43},"[":{key:91,ch:91},"{":{key:91,ch:123},"]":{key:93,ch:93},"}":{key:93,ch:125},"\\":{key:92,ch:92},"|":{key:92,ch:124},";":{key:59,ch:59},":":{key:59,ch:58},"'":{key:222,ch:39},'"':{key:222,ch:34},",":{key:44,ch:44},"<":{key:44,ch:60},".":{key:46,ch:46},">":{key:46,ch:62},"/":{key:47,ch:47},"?":{key:47,ch:63},F1:{key:112,ch:65535},F2:{key:113,ch:65535},F3:{key:114,ch:65535},F4:{key:115,ch:65535},F5:{key:116,ch:65535},F6:{key:117,ch:65535},F7:{key:118,ch:65535},F8:{key:119,ch:65535},F9:{key:120,ch:65535},F10:{key:121,ch:65535},F11:{key:122,ch:65535},F12:{key:123,ch:65535},0:{key:48,ch:48},1:{key:49,ch:49},2:{key:50,ch:50},3:{key:51,ch:51},4:{key:52,ch:52},5:{key:53,ch:53},6:{key:54,ch:54},7:{key:55,ch:55},8:{key:56,ch:56},9:{key:57,ch:57},a:{key:65,ch:97},b:{key:66,ch:98},c:{key:67,ch:99},d:{key:68,ch:100},e:{key:69,ch:101},f:{key:70,ch:102},g:{key:71,ch:103},h:{key:72,ch:104},i:{key:73,ch:105},j:{key:74,ch:106},k:{key:75,ch:107},l:{key:76,ch:108},m:{key:77,ch:109},n:{key:78,ch:110},o:{key:79,ch:111},p:{key:80,ch:112},q:{key:81,ch:113},r:{key:82,ch:114},s:{key:83,ch:115},t:{key:84,ch:116},u:{key:85,ch:117},v:{key:86,ch:118},w:{key:87,ch:119},x:{key:88,ch:120},y:{key:89,ch:121},z:{key:90,ch:122},A:{key:65,ch:65},B:{key:66,ch:66},C:{key:67,ch:67},D:{key:68,ch:68},E:{key:69,ch:69},F:{key:70,ch:70},G:{key:71,ch:71},H:{key:72,ch:72},I:{key:73,ch:73},J:{key:74,ch:74},K:{key:75,ch:75},L:{key:76,ch:76},M:{key:77,ch:77},N:{key:78,ch:78},O:{key:79,ch:79},P:{key:80,ch:80},Q:{key:81,ch:81},R:{key:82,ch:82},S:{key:83,ch:83},T:{key:84,ch:84},U:{key:85,ch:85},V:{key:86,ch:86},W:{key:87,ch:87},X:{key:88,ch:88},Y:{key:89,ch:89},Z:{key:90,ch:90}},a=["Tab","F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","ArrowLeft","ArrowRight","ArrowUp","ArrowDown"]},2790:(e,t,i)=>{i.d(t,{Z:()=>c});var s=i(2383),a=i(9178),r=i(5542),n=i(6542),h=i(8934),o=i(9345),l=i(2991);class c{static instances=[];static imageCache=null;static modelCache=null;static TYPE_LAYER=0;static TYPE_UNUSED=1;static TYPE_INV=2;static TYPE_RECT=3;static TYPE_TEXT=4;static TYPE_GRAPHIC=5;static TYPE_MODEL=6;static TYPE_INV_TEXT=7;static BUTTON_OK=1;static BUTTON_TARGET=2;static BUTTON_CLOSE=3;static BUTTON_TOGGLE=4;static BUTTON_SELECT=5;static BUTTON_CONTINUE=6;static CC_FRIENDS_START=1;static CC_FRIENDS_END=100;static CC_FRIENDS_UPDATE_START=101;static CC_FRIENDS_UPDATE_END=200;static CC_ADD_FRIEND=201;static CC_DEL_FRIEND=202;static CC_FRIENDS_SIZE=203;static CC_LOGOUT=205;static CC_CHANGE_HEAD_L=300;static CC_CHANGE_HEAD_R=301;static CC_CHANGE_JAW_L=302;static CC_CHANGE_JAW_R=303;static CC_CHANGE_TORSO_L=304;static CC_CHANGE_TORSO_R=305;static CC_CHANGE_ARMS_L=306;static CC_CHANGE_ARMS_R=307;static CC_CHANGE_HANDS_L=308;static CC_CHANGE_HANDS_R=309;static CC_CHANGE_LEGS_L=310;static CC_CHANGE_LEGS_R=311;static CC_CHANGE_FEET_L=312;static CC_CHANGE_FEET_R=313;static CC_RECOLOUR_HAIR_L=314;static CC_RECOLOUR_HAIR_R=315;static CC_RECOLOUR_TORSO_L=316;static CC_RECOLOUR_TORSO_R=317;static CC_RECOLOUR_LEGS_L=318;static CC_RECOLOUR_LEGS_R=319;static CC_RECOLOUR_FEET_L=320;static CC_RECOLOUR_FEET_R=321;static CC_RECOLOUR_SKIN_L=322;static CC_RECOLOUR_SKIN_R=323;static CC_SWITCH_TO_MALE=324;static CC_SWITCH_TO_FEMALE=325;static CC_ACCEPT_DESIGN=326;static CC_DESIGN_PREVIEW=327;static CC_IGNORES_START=401;static CC_IGNORES_END=500;static CC_ADD_IGNORE=501;static CC_DEL_IGNORE=502;static CC_IGNORES_SIZE=503;static CC_REPORT_INPUT=600;static CC_REPORT_RULE1=601;static CC_REPORT_RULE2=602;static CC_REPORT_RULE3=603;static CC_REPORT_RULE4=604;static CC_REPORT_RULE5=605;static CC_REPORT_RULE6=606;static CC_REPORT_RULE7=607;static CC_REPORT_RULE8=608;static CC_REPORT_RULE9=609;static CC_REPORT_RULE10=610;static CC_REPORT_RULE11=611;static CC_REPORT_RULE12=612;static CC_MOD_MUTE=613;static CC_LAST_LOGIN_INFO=650;static CC_UNREAD_MESSAGES=651;static CC_RECOVERY1=652;static CC_RECOVERY2=653;static CC_RECOVERY3=654;static CC_LAST_LOGIN_INFO2=655;static unpack=(e,t,i)=>{this.imageCache=new r.Z(5e4),this.modelCache=new r.Z(5e4);const a=new s.Z(e.read("data"));let n=-1;for(a.pos+=2;a.pos0){s.scriptComparator=new Uint8Array(r),s.scriptOperand=new Uint16Array(r);for(let e=0;e0){s.scripts=new o.to(h,null);for(let e=0;e0){const a=i.lastIndexOf(",");s.invSlotSprite[e]=this.getImage(t,i.substring(0,a),parseInt(i.substring(a+1),10))}}s.iops=new o.to(5,null);for(let e=0;e<5;e++){const t=a.gjstr;s.iops[e]=t,0===t.length&&(s.iops[e]=null)}}if(s.type===c.TYPE_RECT&&(s.fill=1===a.g1),s.type===c.TYPE_TEXT||s.type===c.TYPE_UNUSED){s.center=1===a.g1;const e=a.g1;i&&(s.font=i[e]),s.shadowed=1===a.g1}if(s.type===c.TYPE_TEXT&&(s.text=a.gjstr,s.activeText=a.gjstr),s.type!==c.TYPE_UNUSED&&s.type!==c.TYPE_RECT&&s.type!==c.TYPE_TEXT||(s.colour=a.g4),s.type!==c.TYPE_RECT&&s.type!==c.TYPE_TEXT||(s.activeColour=a.g4,s.overColour=a.g4),s.type===c.TYPE_GRAPHIC){const e=a.gjstr;if(e.length>0){const i=e.lastIndexOf(",");s.graphic=this.getImage(t,e.substring(0,i),parseInt(e.substring(i+1),10))}const i=a.gjstr;if(i.length>0){const e=i.lastIndexOf(",");s.activeGraphic=this.getImage(t,i.substring(0,e),parseInt(i.substring(e+1),10))}}if(s.type===c.TYPE_MODEL){const e=a.g1;0!==e&&(s.model=this.getModel((e-1<<8)+a.g1));const t=a.g1;0!==t&&(s.activeModel=this.getModel((t-1<<8)+a.g1)),s.anim=a.g1,0===s.anim?s.anim=-1:s.anim=(s.anim-1<<8)+a.g1,s.activeAnim=a.g1,0===s.activeAnim?s.activeAnim=-1:s.activeAnim=(s.activeAnim-1<<8)+a.g1,s.zoom=a.g2,s.xan=a.g2,s.yan=a.g2}if(s.type===c.TYPE_INV_TEXT){s.invSlotObjId=new Int32Array(s.width*s.height),s.invSlotObjCount=new Int32Array(s.width*s.height),s.center=1===a.g1;const e=a.g1;i&&(s.font=i[e]),s.shadowed=1===a.g1,s.colour=a.g4,s.marginX=a.g2b,s.marginY=a.g2b,s.interactable=1===a.g1,s.iops=new o.to(5,null);for(let e=0;e<5;e++){const t=a.gjstr;s.iops[e]=t,0===t.length&&(s.iops[e]=null)}}s.buttonType!==c.BUTTON_TARGET&&s.type!==c.TYPE_INV||(s.actionVerb=a.gjstr,s.action=a.gjstr,s.actionTarget=a.g2),s.buttonType!==c.BUTTON_OK&&s.buttonType!==c.BUTTON_TOGGLE&&s.buttonType!==c.BUTTON_SELECT&&s.buttonType!==c.BUTTON_CONTINUE||(s.option=a.gjstr,0===s.option.length&&(s.buttonType===c.BUTTON_OK?s.option="Ok":s.buttonType===c.BUTTON_TOGGLE||s.buttonType===c.BUTTON_SELECT?s.option="Select":s.buttonType===c.BUTTON_CONTINUE&&(s.option="Continue")))}this.imageCache=null,this.modelCache=null};static getImage=(e,t,i)=>{const s=h.Z.hashCode(t)<<8n|BigInt(i);if(this.imageCache){const e=this.imageCache.get(s);if(e)return e}let a;try{a=n.Z.fromArchive(e,t,i),this.imageCache?.put(s,a)}catch(e){return null}return a};static getModel=e=>{if(this.modelCache){const t=this.modelCache.get(BigInt(e));if(t)return t}const t=a.Z.model(e);return this.modelCache?.put(BigInt(e),t),t};id=-1;layer=-1;type=-1;buttonType=-1;clientCode=0;width=0;height=0;overLayer=-1;scriptComparator=null;scriptOperand=null;scripts=null;scroll=0;hide=!1;draggable=!1;interactable=!1;usable=!1;marginX=0;marginY=0;invSlotOffsetX=null;invSlotOffsetY=null;invSlotSprite=null;iops=null;fill=!1;center=!1;font=null;shadowed=!1;text=null;activeText=null;colour=0;activeColour=0;overColour=0;graphic=null;activeGraphic=null;model=null;activeModel=null;anim=-1;activeAnim=-1;zoom=0;xan=0;yan=0;actionVerb=null;action=null;actionTarget=-1;option=null;childId=null;childX=null;childY=null;x=0;y=0;scrollPosition=0;invSlotObjId=null;invSlotObjCount=null;seqFrame=0;seqCycle=0;getModel=(e,t,i)=>{let s=this.model;if(i&&(s=this.activeModel),!s)return null;if(-1===e&&-1===t&&!s.faceColor)return s;const r=a.Z.modelShareColored(s,!0,!0,!1);return-1===e&&-1===t||r.createLabelReferences(),-1!==e&&r.applyTransform(e),-1!==t&&r.applyTransform(t),r.calculateNormals(64,768,-50,-10,-50,!0),r};getAbsoluteX(){if(this.layer===this.id)return this.x;let e=c.instances[this.layer];if(!e.childId||!e.childX||!e.childY)return this.x;let t=e.childId.indexOf(this.id);if(-1===t)return this.x;let i=e.childX[t];for(;e.layer!==e.id;){const s=c.instances[e.layer];s.childId&&s.childX&&s.childY&&(t=s.childId.indexOf(e.id),-1!==t&&(i+=s.childX[t])),e=s}return i}getAbsoluteY(){if(this.layer===this.id)return this.y;let e=c.instances[this.layer];if(!e.childId||!e.childX||!e.childY)return this.y;let t=e.childId.indexOf(this.id);if(-1===t)return this.y;let i=e.childY[t];for(;e.layer!==e.id;){const s=c.instances[e.layer];s.childId&&s.childX&&s.childY&&(t=s.childId.indexOf(e.id),-1!==t&&(i+=s.childY[t])),e=s}return i}outline(e){const t=this.getAbsoluteX(),i=this.getAbsoluteY();l.Z.drawRect(t,i,this.width,this.height,e)}move(e,t){if(this.layer===this.id)return;this.x=0,this.y=0;const i=c.instances[this.layer];if(i.childId&&i.childX&&i.childY){const s=i.childId.indexOf(this.id);-1!==s&&(i.childX[s]=e,i.childY[s]=t)}}delete(){if(this.layer===this.id)return;const e=c.instances[this.layer];if(e.childId&&e.childX&&e.childY){const t=e.childId.indexOf(this.id);-1!==t&&(e.childId.splice(t,1),e.childX.splice(t,1),e.childY.splice(t,1))}}}},8107:(e,t,i)=>{i.d(t,{r:()=>s});class s{id=-1;debugname=null;decodeType=(e,t)=>{for(this.id=e;;){const i=t.g1;if(0===i)break;this.decode(e,i,t)}}}},8056:(e,t,i)=>{i.d(t,{Z:()=>r});var s=i(2383),a=i(8107);class r extends a.r{static count=0;static instances=[];static unpack=e=>{const t=new s.Z(e.read("flo.dat"));this.count=t.g2;for(let e=0;e(i>179&&(t=t/2|0),i>192&&(t=t/2|0),i>217&&(t=t/2|0),i>243&&(t=t/2|0),((e/4|0)<<10)+((t/32|0)<<7)+(i/2|0));static mulHSL=(e,t)=>-1===e?12345678:((t=t*(127&e)/128|0)<2?t=2:t>126&&(t=126),(65408&e)+t);static adjustLightness=(e,t)=>-2===e?12345678:-1===e?(t<0?t=0:t>127&&(t=127),127-t):((t=t*(127&e)/128|0)<2?t=2:t>126&&(t=126),(65408&e)+t);rgb=0;texture=-1;opcode3=!1;occlude=!0;name=null;hue=0;saturation=0;lightness=0;luminance=0;chroma=0;hsl=0;decode=(e,t,i)=>{1===t?(this.rgb=i.g3,this.setColor(this.rgb)):2===t?this.texture=i.g1:3===t?this.opcode3=!0:5===t?this.occlude=!1:6===t?this.name=i.gjstr:console.log("Error unrecognised config code: ",t)};setColor=e=>{const t=(e>>16&255)/256,i=(e>>8&255)/256,s=(255&e)/256;let a=t;it&&(n=i),s>n&&(n=s);let h=0,o=0;const l=(a+n)/2;a!==n&&(l<.5&&(o=(n-a)/(n+a)),l>=.5&&(o=(n-a)/(2-n-a)),t===n?h=(i-s)/(n-a):i===n?h=(s-t)/(n-a)+2:s===n&&(h=(t-i)/(n-a)+4)),h/=6,this.hue=256*h|0,this.saturation=256*o|0,this.lightness=256*l|0,this.saturation<0?this.saturation=0:this.saturation>255&&(this.saturation=255),this.lightness<0?this.lightness=0:this.lightness>255&&(this.lightness=255),this.luminance=l>.5?(1-l)*o*512|0:l*o*512|0,this.luminance<1&&(this.luminance=1),this.chroma=h*this.luminance|0;let c=this.hue+(16*Math.random()|0)-8;c<0?c=0:c>255&&(c=255);let d=this.saturation+(48*Math.random()|0)-24;d<0?d=0:d>255&&(d=255);let u=this.lightness+(48*Math.random()|0)-24;u<0?u=0:u>255&&(u=255),this.hsl=r.hsl24to16(c,d,u)}}},8809:(e,t,i)=>{i.d(t,{Z:()=>h});var s=i(2383),a=i(8107),r=i(9178),n=i(9345);class h extends a.r{static count=0;static instances=[];static unpack=e=>{const t=new s.Z(e.read("idk.dat"));this.count=t.g2;for(let e=0;e{if(1===t)this.type=i.g1;else if(2===t){const e=i.g1;this.models=new Int32Array(e);for(let t=0;t=40&&t<50)this.recol_s[t-40]=i.g2;else if(t>=50&&t<60)this.recol_d[t-50]=i.g2;else{if(!(t>=60&&t<70))throw new Error(`Unrecognized idk config code: ${t}`);this.heads[t-60]=i.g2}};getModel=()=>{if(!this.models)return null;const e=new n.to(this.models.length,null);for(let t=0;t{let e=0;const t=new n.to(5,null);for(let i=0;i<5;i++)-1!==this.heads[i]&&(t[e++]=r.Z.model(this.heads[i]));const i=r.Z.modelFromModels(t,e);for(let e=0;e<6&&0!==this.recol_s[e];e++)i.recolor(this.recol_s[e],this.recol_d[e]);return i}}},7958:(e,t,i)=>{i.d(t,{Z:()=>c});var s=i(8107),a=i(2383),r=i(5542),n=i(9178),h=i(1908),o=i(5534),l=i(9345);class c extends s.r{static count=0;static cache=null;static dat=null;static offsets=null;static cachePos=0;static modelCacheStatic=new r.Z(500);static modelCacheDynamic=new r.Z(30);static unpack=e=>{this.dat=new a.Z(e.read("loc.dat"));const t=new a.Z(e.read("loc.idx"));this.count=t.g2,this.offsets=new Int32Array(this.count);let i=2;for(let e=0;e{if(!this.cache||!this.offsets||!this.dat)throw new Error("LocType not loaded!!!");for(let t=0;t<10;t++){const i=this.cache[t];if(i&&i.index===e)return i}this.cachePos=(this.cachePos+1)%10;const t=this.cache[this.cachePos];return this.dat.pos=this.offsets[e],t.index=e,t.reset(),t.decodeType(e,this.dat),t.shapes||(t.shapes=new Int32Array(1)),-1===t.active2&&t.shapes&&(t.active=t.shapes.length>0&&t.shapes[0]===h.Z.CENTREPIECE_STRAIGHT,t.ops&&(t.active=!0)),t};static unload=()=>{this.modelCacheStatic=null,this.modelCacheDynamic=null,this.offsets=null,this.cache=null,this.dat=null};index=-1;models=null;shapes=null;name=null;desc=null;recol_s=null;recol_d=null;width=1;length=1;blockwalk=!0;blockrange=!0;active=!1;active2=-1;hillskew=!1;sharelight=!1;occlude=!1;anim=-1;disposeAlpha=!1;walloff=16;ambient=0;contrast=0;ops=null;mapfunction=-1;mapscene=-1;mirror=!1;shadow=!0;resizex=128;resizey=128;resizez=128;forceapproach=0;xoff=0;yoff=0;zoff=0;forcedecor=!1;decode=(e,t,i)=>{if(1===t){const e=i.g1;this.models=new Int32Array(e),this.shapes=new Int32Array(e);for(let t=0;t=30&&t<39)this.ops||(this.ops=new l.to(5,null)),this.ops[t-30]=i.gjstr,"hidden"===this.ops[t-30]?.toLowerCase()&&(this.ops[t-30]=null);else if(40===t){const e=i.g1;this.recol_s=new Uint16Array(e),this.recol_d=new Uint16Array(e);for(let t=0;t{if(!this.shapes)return null;let l=-1;for(let t=0;t=this.models.length)return null;let f=this.models[l];if(-1===f)return null;const p=this.mirror!==t>3;p&&(f+=65536);let m=c.modelCacheStatic?.get(BigInt(f));m||(m=n.Z.model(65535&f),p&&m.rotateY180(),c.modelCacheStatic?.put(BigInt(f),m));const g=128!==this.resizex||128!==this.resizey||128!==this.resizez,y=0!==this.xoff||0!==this.yoff||0!==this.zoff;let C=n.Z.modelShareColored(m,!this.recol_s,!this.disposeAlpha,t===o.Z.WEST&&-1===h&&!g&&!y);for(-1!==h&&(C.createLabelReferences(),C.applyTransform(h),C.labelFaces=null,C.labelVertices=null);t-- >0;)C.rotateY90();if(this.recol_s&&this.recol_d)for(let e=0;e{this.models=null,this.shapes=null,this.name=null,this.desc=null,this.recol_s=null,this.recol_d=null,this.width=1,this.length=1,this.blockwalk=!0,this.blockrange=!0,this.active=!1,this.active2=-1,this.hillskew=!1,this.sharelight=!1,this.occlude=!1,this.anim=-1,this.walloff=16,this.ambient=0,this.contrast=0,this.ops=null,this.disposeAlpha=!1,this.mapfunction=-1,this.mapscene=-1,this.mirror=!1,this.shadow=!0,this.resizex=128,this.resizey=128,this.resizez=128,this.forceapproach=0,this.xoff=0,this.yoff=0,this.zoff=0,this.forcedecor=!1}}},2441:(e,t,i)=>{i.d(t,{Z:()=>o});var s=i(8107),a=i(2383),r=i(5542),n=i(9178),h=i(9345);class o extends s.r{static count=0;static cache=null;static dat=null;static offsets=null;static cachePos=0;static modelCache=new r.Z(30);static unpack=e=>{this.dat=new a.Z(e.read("npc.dat"));const t=new a.Z(e.read("npc.idx"));this.count=t.g2,this.offsets=new Int32Array(this.count);let i=2;for(let e=0;e{if(!this.cache||!this.offsets||!this.dat)throw new Error("LocType not loaded!!!");for(let t=0;t<20;t++){const i=this.cache[t];if(i&&i.index===e)return i}this.cachePos=(this.cachePos+1)%20;const t=this.cache[this.cachePos]=new o;return this.dat.pos=this.offsets[e],t.index=e,t.decodeType(e,this.dat),t};static unload=()=>{this.modelCache=null,this.offsets=null,this.cache=null,this.dat=null};index=-1;name=null;desc=null;size=1;models=null;heads=null;disposeAlpha=!1;readyanim=-1;walkanim=-1;walkanim_b=-1;walkanim_r=-1;walkanim_l=-1;hasalpha=!1;recol_s=null;recol_d=null;ops=null;code90=-1;code91=-1;code92=-1;visonmap=!0;vislevel=-1;resizeh=128;resizev=128;decode=(e,t,i)=>{if(1===t){const e=i.g1;this.models=new Uint16Array(e);for(let t=0;t=30&&t<40)this.ops||(this.ops=new h.to(5,null)),this.ops[t-30]=i.gjstr,"hidden"===this.ops[t-30]?.toLowerCase()&&(this.ops[t-30]=null);else if(40===t){const e=i.g1;this.recol_s=new Uint16Array(e),this.recol_d=new Uint16Array(e);for(let t=0;t{let s=null,a=null;if(o.modelCache&&(a=o.modelCache.get(BigInt(this.index)),!a&&this.models)){const e=new h.to(this.models.length,null);for(let t=0;t{if(!this.heads)return null;const e=new h.to(this.heads.length,null);for(let t=0;t{i.d(t,{Z:()=>u});var s=i(8107),a=i(2383),r=i(6542),n=i(5542),h=i(9178),o=i(8078),l=i(2991),c=i(312),d=i(9345);class u extends s.r{static count=0;static cache=null;static dat=null;static offsets=null;static cachePos=0;static membersWorld=!0;static modelCache=new n.Z(50);static iconCache=new n.Z(200);static unpack=(e,t)=>{this.membersWorld=t,this.dat=new a.Z(e.read("obj.dat"));const i=new a.Z(e.read("obj.idx"));this.count=i.g2,this.offsets=new Int32Array(this.count);let s=2;for(let e=0;e{if(!this.cache||!this.offsets||!this.dat)throw new Error("ObjType not loaded!!!");for(let t=0;t<10;t++){const i=this.cache[t];if(i&&i.index===e)return i}this.cachePos=(this.cachePos+1)%10;const t=this.cache[this.cachePos];return this.dat.pos=this.offsets[e],t.index=e,t.reset(),t.decodeType(e,this.dat),-1!==t.certtemplate&&t.toCertificate(),!this.membersWorld&&t.members&&(t.name="Members Object",t.desc="Login to a members' server to use this object.",t.ops=null,t.iops=null),t};static unload=()=>{this.modelCache=null,this.iconCache=null,this.offsets=null,this.cache=null,this.dat=null};static getIcon=(e,t)=>{if(u.iconCache){let i=u.iconCache.get(BigInt(e));if(i&&i.cropH!==t&&-1!==i.cropH&&(i.unlink(),i=null),i)return i}let i=u.get(e);if(i.countobj||(t=-1),i.countobj&&i.countco&&t>1){let e=-1;for(let s=0;s<10;s++)t>=i.countco[s]&&0!==i.countco[s]&&(e=i.countobj[s]);-1!==e&&(i=u.get(e))}const s=new r.Z(32,32),a=o.Z.centerX,n=o.Z.centerY,h=o.Z.lineOffset,d=l.Z.pixels,f=l.Z.width2d,p=l.Z.height2d,m=l.Z.left,g=l.Z.right,y=l.Z.top,C=l.Z.bottom;o.Z.jagged=!1,l.Z.bind(s.pixels,32,32),l.Z.fillRect(0,0,32,32,c.Z.BLACK),o.Z.init2D();const T=i.getInterfaceModel(1),w=o.Z.sin[i.xan2d]*i.zoom2d>>16,S=o.Z.cos[i.xan2d]*i.zoom2d>>16;T.drawSimple(0,i.yan2d,i.zan2d,i.xan2d,i.xof2d,w+(T.maxY/2|0)+i.yof2d,S+i.yof2d);for(let e=31;e>=0;e--)for(let t=31;t>=0;t--)0===s.pixels[e+32*t]&&(e>0&&s.pixels[e+32*t-1]>1||t>0&&s.pixels[e+32*(t-1)]>1||e<31&&s.pixels[e+32*t+1]>1||t<31&&s.pixels[e+32*(t+1)]>1)&&(s.pixels[e+32*t]=1);for(let e=31;e>=0;e--)for(let t=31;t>=0;t--)0===s.pixels[e+32*t]&&e>0&&t>0&&s.pixels[e+32*(t-1)-1]>0&&(s.pixels[e+32*t]=3153952);if(-1!==i.certtemplate){const e=this.getIcon(i.certlink,10),t=e.cropW,s=e.cropH;e.cropW=32,e.cropH=32,e.crop(5,5,22,22),e.cropW=t,e.cropH=s}return u.iconCache?.put(BigInt(e),s),l.Z.bind(d,f,p),l.Z.setBounds(m,y,g,C),o.Z.centerX=a,o.Z.centerY=n,o.Z.lineOffset=h,o.Z.jagged=!0,i.stackable?s.cropW=33:s.cropW=32,s.cropH=t,s};index=-1;model=0;name=null;desc=null;recol_s=null;recol_d=null;zoom2d=2e3;xan2d=0;yan2d=0;zan2d=0;xof2d=0;yof2d=0;code9=!1;code10=-1;stackable=!1;cost=1;members=!1;ops=null;iops=null;manwear=-1;manwear2=-1;manwearOffsetY=0;womanwear=-1;womanwear2=-1;womanwearOffsetY=0;manwear3=-1;womanwear3=-1;manhead=-1;manhead2=-1;womanhead=-1;womanhead2=-1;countobj=null;countco=null;certlink=-1;certtemplate=-1;decode=(e,t,i)=>{if(1===t)this.model=i.g2;else if(2===t)this.name=i.gjstr;else if(3===t)this.desc=i.gjstr;else if(4===t)this.zoom2d=i.g2;else if(5===t)this.xan2d=i.g2;else if(6===t)this.yan2d=i.g2;else if(7===t)this.xof2d=i.g2b,this.xof2d>32767&&(this.xof2d-=65536);else if(8===t)this.yof2d=i.g2b,this.yof2d>32767&&(this.yof2d-=65536);else if(9===t)this.code9=!0;else if(10===t)this.code10=i.g2;else if(11===t)this.stackable=!0;else if(12===t)this.cost=i.g4;else if(16===t)this.members=!0;else if(23===t)this.manwear=i.g2,this.manwearOffsetY=i.g1b;else if(24===t)this.manwear2=i.g2;else if(25===t)this.womanwear=i.g2,this.womanwearOffsetY=i.g1b;else if(26===t)this.womanwear2=i.g2;else if(t>=30&&t<35)this.ops||(this.ops=new d.to(5,null)),this.ops[t-30]=i.gjstr,"hidden"===this.ops[t-30]?.toLowerCase()&&(this.ops[t-30]=null);else if(t>=35&&t<40)this.iops||(this.iops=new d.to(5,null)),this.iops[t-35]=i.gjstr;else if(40===t){const e=i.g1;this.recol_s=new Uint16Array(e),this.recol_d=new Uint16Array(e);for(let t=0;t=100&&t<110&&(this.countobj&&this.countco||(this.countobj=new Uint16Array(10),this.countco=new Uint16Array(10)),this.countobj[t-100]=i.g2,this.countco[t-100]=i.g2)};getWornModel=e=>{let t=this.manwear;if(1===e&&(t=this.womanwear),-1===t)return null;let i=this.manwear2,s=this.manwear3;1===e&&(i=this.womanwear2,s=this.womanwear3);let a=h.Z.model(t);if(-1!==i){const e=h.Z.model(i);if(-1===s){const t=[a,e];a=h.Z.modelFromModels(t,2)}else{const t=[a,e,h.Z.model(s)];a=h.Z.modelFromModels(t,3)}}if(0===e&&0!==this.manwearOffsetY&&a.translate(this.manwearOffsetY,0,0),1===e&&0!==this.womanwearOffsetY&&a.translate(this.womanwearOffsetY,0,0),this.recol_s&&this.recol_d)for(let e=0;e{let t=this.manhead;if(1===e&&(t=this.womanhead),-1===t)return null;let i=this.manhead2;1===e&&(i=this.womanhead2);let s=h.Z.model(t);if(-1!==i){const e=[s,h.Z.model(i)];s=h.Z.modelFromModels(e,2)}if(this.recol_s&&this.recol_d)for(let e=0;e{if(this.countobj&&this.countco&&e>1){let t=-1;for(let i=0;i<10;i++)e>=this.countco[i]&&0!==this.countco[i]&&(t=this.countobj[i]);if(-1!==t)return u.get(t).getInterfaceModel(1)}if(u.modelCache){const e=u.modelCache.get(BigInt(this.index));if(e)return e}const t=h.Z.model(this.model);if(this.recol_s&&this.recol_d)for(let e=0;e{const e=u.get(this.certtemplate);this.model=e.model,this.zoom2d=e.zoom2d,this.xan2d=e.xan2d,this.yan2d=e.yan2d,this.zan2d=e.zan2d,this.xof2d=e.xof2d,this.yof2d=e.yof2d,this.recol_s=e.recol_s,this.recol_d=e.recol_d;const t=u.get(this.certlink);this.name=t.name,this.members=t.members,this.cost=t.cost;let i="a";const s=(t.name||"").toLowerCase().charAt(0);"a"!==s&&"e"!==s&&"i"!==s&&"o"!==s&&"u"!==s||(i="an"),this.desc=`Swap this note at any bank for ${i} ${t.name}.`,this.stackable=!0};reset=()=>{this.model=0,this.name=null,this.desc=null,this.recol_s=null,this.recol_d=null,this.zoom2d=2e3,this.xan2d=0,this.yan2d=0,this.zan2d=0,this.xof2d=0,this.yof2d=0,this.code9=!1,this.code10=-1,this.stackable=!1,this.cost=1,this.members=!1,this.ops=null,this.iops=null,this.manwear=-1,this.manwear2=-1,this.manwearOffsetY=0,this.womanwear=-1,this.womanwear2=-1,this.womanwearOffsetY=0,this.manwear3=-1,this.womanwear3=-1,this.manhead=-1,this.manhead2=-1,this.womanhead=-1,this.womanhead2=-1,this.countobj=null,this.countco=null,this.certlink=-1,this.certtemplate=-1}}},8067:(e,t,i)=>{i.d(t,{Z:()=>n});var s=i(8107),a=i(2383),r=i(8762);class n extends s.r{static count=0;static instances=[];static unpack=e=>{const t=new a.Z(e.read("seq.dat"));this.count=t.g2;for(let e=0;e{if(1===t){this.frameCount=i.g1,this.frames=new Int16Array(this.frameCount),this.iframes=new Int16Array(this.frameCount),this.delay=new Int16Array(this.frameCount);for(let e=0;e{i.d(t,{Z:()=>o});var s=i(8107),a=i(2383),r=i(8067),n=i(9178),h=i(5542);class o extends s.r{static count=0;static instances=[];static modelCache=new h.Z(30);static unpack=e=>{const t=new a.Z(e.read("spotanim.dat"));this.count=t.g2;for(let e=0;e{if(1===t)this.model=i.g2;else if(2===t)this.anim=i.g2,r.Z.instances&&(this.seq=r.Z.instances[this.anim]);else if(3===t)this.disposeAlpha=!0;else if(4===t)this.resizeh=i.g2;else if(5===t)this.resizev=i.g2;else if(6===t)this.orientation=i.g2;else if(7===t)this.ambient=i.g1;else if(8===t)this.contrast=i.g1;else if(t>=40&&t<50)this.recol_s[t-40]=i.g2;else{if(!(t>=50&&t<60))throw new Error(`Unrecognized spotanim config code: ${t}`);this.recol_d[t-50]=i.g2}};getModel=()=>{let e=o.modelCache?.get(BigInt(this.index));if(e)return e;e=n.Z.model(this.model);for(let t=0;t<6;t++)0!==this.recol_s[0]&&e.recolor(this.recol_s[t],this.recol_d[t]);return o.modelCache?.put(BigInt(this.index),e),e}}},1089:(e,t,i)=>{i.d(t,{Z:()=>r});var s=i(8107),a=i(2383);class r extends s.r{static count=0;static instances=[];static code3=[];static code3Count=0;static unpack=e=>{const t=new a.Z(e.read("varp.dat"));this.count=t.g2;for(let e=0;e{i.d(t,{Z:()=>s});class s{static OPEN=0;static WALL_NORTH_WEST=1;static WALL_NORTH=2;static WALL_NORTH_EAST=4;static WALL_EAST=8;static WALL_SOUTH_EAST=s.WALL_NORTH_WEST<<4;static WALL_SOUTH=s.WALL_NORTH<<4;static WALL_SOUTH_WEST=s.WALL_NORTH_EAST<<4;static WALL_WEST=s.WALL_EAST<<4;static LOC=256;static WALL_NORTH_WEST_PROJ_BLOCKER=512;static WALL_NORTH_PROJ_BLOCKER=1024;static WALL_NORTH_EAST_PROJ_BLOCKER=2048;static WALL_EAST_PROJ_BLOCKER=4096;static WALL_SOUTH_EAST_PROJ_BLOCKER=s.WALL_NORTH_WEST_PROJ_BLOCKER<<4;static WALL_SOUTH_PROJ_BLOCKER=s.WALL_NORTH_PROJ_BLOCKER<<4;static WALL_SOUTH_WEST_PROJ_BLOCKER=s.WALL_NORTH_EAST_PROJ_BLOCKER<<4;static WALL_WEST_PROJ_BLOCKER=s.WALL_EAST_PROJ_BLOCKER<<4;static LOC_PROJ_BLOCKER=s.LOC<<9;static FLOOR_DECORATION=524288;static FLOOR=2097152;static FLOOR_BLOCKED=s.FLOOR|s.FLOOR_DECORATION;static WALK_BLOCKED=s.LOC|s.FLOOR_BLOCKED;static BLOCK_SOUTH=s.WALL_NORTH|s.WALK_BLOCKED;static BLOCK_WEST=s.WALL_EAST|s.WALK_BLOCKED;static BLOCK_SOUTH_WEST=s.WALL_NORTH|s.WALL_NORTH_EAST|s.BLOCK_WEST;static BLOCK_NORTH=s.WALL_SOUTH|s.WALK_BLOCKED;static BLOCK_NORTH_WEST=s.WALL_EAST|s.WALL_SOUTH_EAST|s.BLOCK_NORTH;static BLOCK_EAST=s.WALL_WEST|s.WALK_BLOCKED;static BLOCK_SOUTH_EAST=s.WALL_NORTH_WEST|s.WALL_NORTH|s.BLOCK_EAST;static BLOCK_NORTH_EAST=s.WALL_SOUTH|s.WALL_SOUTH_WEST|s.BLOCK_EAST;static BOUNDS=16777215}},3693:(e,t,i)=>{i.d(t,{Z:()=>h});var s=i(8603),a=i(5534),r=i(1908),n=i(6439);class h{static LEVELS=4;static SIZE=104;static index=(e,t)=>e*h.SIZE+t;offsetX;offsetZ;sizeX;sizeZ;flags;constructor(){this.offsetX=0,this.offsetZ=0,this.sizeX=h.SIZE,this.sizeZ=h.SIZE,this.flags=new Int32Array(this.sizeX*this.sizeZ),this.reset()}reset=()=>{for(let e=0;e{this.flags[h.index(e-this.offsetX,t-this.offsetZ)]|=s.Z.FLOOR};removeFloor=(e,t)=>{this.flags[h.index(e-this.offsetX,t-this.offsetZ)]&=~s.Z.FLOOR};addLoc=(e,t,i,r,n,h)=>{let o=s.Z.LOC;h&&(o|=s.Z.LOC_PROJ_BLOCKER);const l=e-this.offsetX,c=t-this.offsetZ;if(n===a.Z.NORTH||n===a.Z.SOUTH){const e=i;i=r,r=e}for(let e=l;e=0&&e=0&&t{let o=s.Z.LOC;h&&(o|=s.Z.LOC_PROJ_BLOCKER);const l=e-this.offsetX,c=t-this.offsetZ;if(n===a.Z.NORTH||n===a.Z.SOUTH){const e=i;i=r,r=e}for(let e=l;e=0&&e=0&&t{const o=e-this.offsetX,l=t-this.offsetZ,c=h?s.Z.WALL_WEST_PROJ_BLOCKER:s.Z.WALL_WEST,d=h?s.Z.WALL_EAST_PROJ_BLOCKER:s.Z.WALL_EAST,u=h?s.Z.WALL_NORTH_PROJ_BLOCKER:s.Z.WALL_NORTH,f=h?s.Z.WALL_SOUTH_PROJ_BLOCKER:s.Z.WALL_SOUTH,p=h?s.Z.WALL_NORTH_WEST_PROJ_BLOCKER:s.Z.WALL_NORTH_WEST,m=h?s.Z.WALL_SOUTH_EAST_PROJ_BLOCKER:s.Z.WALL_SOUTH_EAST,g=h?s.Z.WALL_NORTH_EAST_PROJ_BLOCKER:s.Z.WALL_NORTH_EAST,y=h?s.Z.WALL_SOUTH_WEST_PROJ_BLOCKER:s.Z.WALL_SOUTH_WEST;i===r.Z.WALL_STRAIGHT?n===a.Z.WEST?(this.add(o,l,c),this.add(o-1,l,d)):n===a.Z.NORTH?(this.add(o,l,u),this.add(o,l+1,f)):n===a.Z.EAST?(this.add(o,l,d),this.add(o+1,l,c)):n===a.Z.SOUTH&&(this.add(o,l,f),this.add(o,l-1,u)):i===r.Z.WALL_DIAGONAL_CORNER||i===r.Z.WALL_SQUARE_CORNER?n===a.Z.WEST?(this.add(o,l,p),this.add(o-1,l+1,m)):n===a.Z.NORTH?(this.add(o,l,g),this.add(o+1,l+1,y)):n===a.Z.EAST?(this.add(o,l,m),this.add(o+1,l-1,p)):n===a.Z.SOUTH&&(this.add(o,l,y),this.add(o-1,l-1,g)):i===r.Z.WALL_L&&(n===a.Z.WEST?(this.add(o,l,u|c),this.add(o-1,l,d),this.add(o,l+1,f)):n===a.Z.NORTH?(this.add(o,l,u|d),this.add(o,l+1,f),this.add(o+1,l,c)):n===a.Z.EAST?(this.add(o,l,f|d),this.add(o+1,l,c),this.add(o,l-1,u)):n===a.Z.SOUTH&&(this.add(o,l,f|c),this.add(o,l-1,u),this.add(o-1,l,d))),h&&this.addWall(e,t,i,n,!1)};removeWall=(e,t,i,n,h)=>{const o=e-this.offsetX,l=t-this.offsetZ,c=h?s.Z.WALL_WEST_PROJ_BLOCKER:s.Z.WALL_WEST,d=h?s.Z.WALL_EAST_PROJ_BLOCKER:s.Z.WALL_EAST,u=h?s.Z.WALL_NORTH_PROJ_BLOCKER:s.Z.WALL_NORTH,f=h?s.Z.WALL_SOUTH_PROJ_BLOCKER:s.Z.WALL_SOUTH,p=h?s.Z.WALL_NORTH_WEST_PROJ_BLOCKER:s.Z.WALL_NORTH_WEST,m=h?s.Z.WALL_SOUTH_EAST_PROJ_BLOCKER:s.Z.WALL_SOUTH_EAST,g=h?s.Z.WALL_NORTH_EAST_PROJ_BLOCKER:s.Z.WALL_NORTH_EAST,y=h?s.Z.WALL_SOUTH_WEST_PROJ_BLOCKER:s.Z.WALL_SOUTH_WEST;i===r.Z.WALL_STRAIGHT?n===a.Z.WEST?(this.remove(o,l,c),this.remove(o-1,l,d)):n===a.Z.NORTH?(this.remove(o,l,u),this.remove(o,l+1,f)):n===a.Z.EAST?(this.remove(o,l,d),this.remove(o+1,l,c)):n===a.Z.SOUTH&&(this.remove(o,l,f),this.remove(o,l-1,u)):i===r.Z.WALL_DIAGONAL_CORNER||i===r.Z.WALL_SQUARE_CORNER?n===a.Z.WEST?(this.remove(o,l,p),this.remove(o-1,l+1,m)):n===a.Z.NORTH?(this.remove(o,l,g),this.remove(o+1,l+1,y)):n===a.Z.EAST?(this.remove(o,l,m),this.remove(o+1,l-1,p)):n===a.Z.SOUTH&&(this.remove(o,l,y),this.remove(o-1,l-1,g)):i===r.Z.WALL_L&&(n===a.Z.WEST?(this.remove(o,l,u|c),this.remove(o-1,l,d),this.remove(o,l+1,f)):n===a.Z.NORTH?(this.remove(o,l,u|d),this.remove(o,l+1,f),this.remove(o+1,l,c)):n===a.Z.EAST?(this.remove(o,l,f|d),this.remove(o+1,l,c),this.remove(o,l-1,u)):n===a.Z.SOUTH&&(this.remove(o,l,f|c),this.remove(o,l-1,u),this.remove(o-1,l,d))),h&&this.removeWall(e,t,i,n,!1)};reachedWall=(e,t,i,n,o,l)=>{if(e===i&&t===n)return!0;const c=e-this.offsetX,d=t-this.offsetZ,u=i-this.offsetX,f=n-this.offsetZ,p=h.index(c,d);if(o===r.Z.WALL_STRAIGHT){if(l===a.Z.WEST){if(c===u-1&&d===f)return!0;if(c===u&&d===f+1&&(this.flags[p]&s.Z.BLOCK_NORTH)===s.Z.OPEN)return!0;if(c===u&&d===f-1&&(this.flags[p]&s.Z.BLOCK_SOUTH)===s.Z.OPEN)return!0}else if(l===a.Z.NORTH){if(c===u&&d===f+1)return!0;if(c===u-1&&d===f&&(this.flags[p]&s.Z.BLOCK_WEST)===s.Z.OPEN)return!0;if(c===u+1&&d===f&&(this.flags[p]&s.Z.BLOCK_EAST)===s.Z.OPEN)return!0}else if(l===a.Z.EAST){if(c===u+1&&d===f)return!0;if(c===u&&d===f+1&&(this.flags[p]&s.Z.BLOCK_NORTH)===s.Z.OPEN)return!0;if(c===u&&d===f-1&&(this.flags[p]&s.Z.BLOCK_SOUTH)===s.Z.OPEN)return!0}else if(l===a.Z.SOUTH){if(c===u&&d===f-1)return!0;if(c===u-1&&d===f&&(this.flags[p]&s.Z.BLOCK_WEST)===s.Z.OPEN)return!0;if(c===u+1&&d===f&&(this.flags[p]&s.Z.BLOCK_EAST)===s.Z.OPEN)return!0}}else if(o===r.Z.WALL_L){if(l===a.Z.WEST){if(c===u-1&&d===f)return!0;if(c===u&&d===f+1)return!0;if(c===u+1&&d===f&&(this.flags[p]&s.Z.BLOCK_EAST)===s.Z.OPEN)return!0;if(c===u&&d===f-1&&(this.flags[p]&s.Z.BLOCK_SOUTH)===s.Z.OPEN)return!0}else if(l===a.Z.NORTH){if(c===u-1&&d===f&&(this.flags[p]&s.Z.BLOCK_WEST)===s.Z.OPEN)return!0;if(c===u&&d===f+1)return!0;if(c===u+1&&d===f)return!0;if(c===u&&d===f-1&&(this.flags[p]&s.Z.BLOCK_SOUTH)===s.Z.OPEN)return!0}else if(l===a.Z.EAST){if(c===u-1&&d===f&&(this.flags[p]&s.Z.BLOCK_WEST)===s.Z.OPEN)return!0;if(c===u&&d===f+1&&(this.flags[p]&s.Z.BLOCK_NORTH)===s.Z.OPEN)return!0;if(c===u+1&&d===f)return!0;if(c===u&&d===f-1)return!0}else if(l===a.Z.SOUTH){if(c===u-1&&d===f)return!0;if(c===u&&d===f+1&&(this.flags[p]&s.Z.BLOCK_NORTH)===s.Z.OPEN)return!0;if(c===u+1&&d===f&&(this.flags[p]&s.Z.BLOCK_EAST)===s.Z.OPEN)return!0;if(c===u&&d===f-1)return!0}}else if(o===r.Z.WALL_DIAGONAL){if(c===u&&d===f+1&&(this.flags[p]&s.Z.WALL_SOUTH)===s.Z.OPEN)return!0;if(c===u&&d===f-1&&(this.flags[p]&s.Z.WALL_NORTH)===s.Z.OPEN)return!0;if(c===u-1&&d===f&&(this.flags[p]&s.Z.WALL_EAST)===s.Z.OPEN)return!0;if(c===u+1&&d===f&&(this.flags[p]&s.Z.WALL_WEST)===s.Z.OPEN)return!0}return!1};reachedWallDecoration=(e,t,i,n,o,l)=>{if(e===i&&t===n)return!0;const c=e-this.offsetX,d=t-this.offsetZ,u=i-this.offsetX,f=n-this.offsetZ,p=h.index(c,d);if(o===r.Z.WALLDECOR_DIAGONAL_OFFSET||o===r.Z.WALLDECOR_DIAGONAL_NOOFFSET){if(o===r.Z.WALLDECOR_DIAGONAL_NOOFFSET&&(l=l+2&3),l===a.Z.WEST){if(c===u+1&&d===f&&(this.flags[p]&s.Z.WALL_WEST)===s.Z.OPEN)return!0;if(c===u&&d===f-1&&(this.flags[p]&s.Z.WALL_NORTH)===s.Z.OPEN)return!0}else if(l===a.Z.NORTH){if(c===u-1&&d===f&&(this.flags[p]&s.Z.WALL_EAST)===s.Z.OPEN)return!0;if(c===u&&d===f-1&&(this.flags[p]&s.Z.WALL_NORTH)===s.Z.OPEN)return!0}else if(l===a.Z.EAST){if(c===u-1&&d===f&&(this.flags[p]&s.Z.WALL_EAST)===s.Z.OPEN)return!0;if(c===u&&d===f+1&&(this.flags[p]&s.Z.WALL_SOUTH)===s.Z.OPEN)return!0}else if(l===a.Z.SOUTH){if(c===u+1&&d===f&&(this.flags[p]&s.Z.WALL_WEST)===s.Z.OPEN)return!0;if(c===u&&d===f+1&&(this.flags[p]&s.Z.WALL_SOUTH)===s.Z.OPEN)return!0}}else if(o===r.Z.WALLDECOR_DIAGONAL_BOTH){if(c===u&&d===f+1&&(this.flags[p]&s.Z.WALL_SOUTH)===s.Z.OPEN)return!0;if(c===u&&d===f-1&&(this.flags[p]&s.Z.WALL_NORTH)===s.Z.OPEN)return!0;if(c===u-1&&d===f&&(this.flags[p]&s.Z.WALL_EAST)===s.Z.OPEN)return!0;if(c===u+1&&d===f&&(this.flags[p]&s.Z.WALL_WEST)===s.Z.OPEN)return!0}return!1};reachedLoc=(e,t,i,a,r,o,l)=>{const c=i+r-1,d=a+o-1,u=h.index(e-this.offsetX,t-this.offsetZ);return e>=i&&e<=c&&t>=a&&t<=d||e===i-1&&t>=a&&t<=d&&(this.flags[u]&s.Z.WALL_EAST)===s.Z.OPEN&&(l&n.Z.WEST)===s.Z.OPEN||e===c+1&&t>=a&&t<=d&&(this.flags[u]&s.Z.WALL_WEST)===s.Z.OPEN&&(l&n.Z.EAST)===s.Z.OPEN||t===a-1&&e>=i&&e<=c&&(this.flags[u]&s.Z.WALL_NORTH)===s.Z.OPEN&&(l&n.Z.SOUTH)===s.Z.OPEN||t===d+1&&e>=i&&e<=c&&(this.flags[u]&s.Z.WALL_SOUTH)===s.Z.OPEN&&(l&n.Z.NORTH)===s.Z.OPEN};add=(e,t,i)=>{this.flags[h.index(e,t)]|=i};remove=(e,t,i)=>{this.flags[h.index(e,t)]&=s.Z.BOUNDS-i}}},6439:(e,t,i)=>{i.d(t,{Z:()=>s});class s{static NORTH=1;static EAST=2;static SOUTH=4;static WEST=8;static SOUTH_WEST=s.WEST|s.SOUTH;static NORTH_WEST=s.WEST|s.NORTH;static SOUTH_EAST=s.EAST|s.SOUTH;static NORTH_EAST=s.EAST|s.NORTH}},5534:(e,t,i)=>{var s;i.d(t,{Z:()=>a}),function(e){e[e.WEST=0]="WEST",e[e.NORTH=1]="NORTH",e[e.EAST=2]="EAST",e[e.SOUTH=3]="SOUTH"}(s||(s={}));const a=s},3714:(e,t,i)=>{var s;i.d(t,{Z:()=>a}),function(e){e[e.WALL=0]="WALL",e[e.WALL_DECOR=1]="WALL_DECOR",e[e.GROUND=2]="GROUND",e[e.GROUND_DECOR=3]="GROUND_DECOR"}(s||(s={}));const a=s},1908:(e,t,i)=>{i.d(t,{Z:()=>r,m:()=>n});var s,a=i(3714);!function(e){e[e.WALL_STRAIGHT=0]="WALL_STRAIGHT",e[e.WALL_DIAGONAL_CORNER=1]="WALL_DIAGONAL_CORNER",e[e.WALL_L=2]="WALL_L",e[e.WALL_SQUARE_CORNER=3]="WALL_SQUARE_CORNER",e[e.WALLDECOR_STRAIGHT_NOOFFSET=4]="WALLDECOR_STRAIGHT_NOOFFSET",e[e.WALLDECOR_STRAIGHT_OFFSET=5]="WALLDECOR_STRAIGHT_OFFSET",e[e.WALLDECOR_DIAGONAL_OFFSET=6]="WALLDECOR_DIAGONAL_OFFSET",e[e.WALLDECOR_DIAGONAL_NOOFFSET=7]="WALLDECOR_DIAGONAL_NOOFFSET",e[e.WALLDECOR_DIAGONAL_BOTH=8]="WALLDECOR_DIAGONAL_BOTH",e[e.WALL_DIAGONAL=9]="WALL_DIAGONAL",e[e.CENTREPIECE_STRAIGHT=10]="CENTREPIECE_STRAIGHT",e[e.CENTREPIECE_DIAGONAL=11]="CENTREPIECE_DIAGONAL",e[e.ROOF_STRAIGHT=12]="ROOF_STRAIGHT",e[e.ROOF_DIAGONAL_WITH_ROOFEDGE=13]="ROOF_DIAGONAL_WITH_ROOFEDGE",e[e.ROOF_DIAGONAL=14]="ROOF_DIAGONAL",e[e.ROOF_L_CONCAVE=15]="ROOF_L_CONCAVE",e[e.ROOF_L_CONVEX=16]="ROOF_L_CONVEX",e[e.ROOF_FLAT=17]="ROOF_FLAT",e[e.ROOFEDGE_STRAIGHT=18]="ROOFEDGE_STRAIGHT",e[e.ROOFEDGE_DIAGONAL_CORNER=19]="ROOFEDGE_DIAGONAL_CORNER",e[e.ROOFEDGE_L=20]="ROOFEDGE_L",e[e.ROOFEDGE_SQUARE_CORNER=21]="ROOFEDGE_SQUARE_CORNER",e[e.GROUND_DECOR=22]="GROUND_DECOR"}(s||(s={}));const r=s;class n{static layer(e){switch(e){case s.WALL_STRAIGHT:case s.WALL_DIAGONAL_CORNER:case s.WALL_L:case s.WALL_SQUARE_CORNER:return a.Z.WALL;case s.WALLDECOR_STRAIGHT_NOOFFSET:case s.WALLDECOR_STRAIGHT_OFFSET:case s.WALLDECOR_DIAGONAL_OFFSET:case s.WALLDECOR_DIAGONAL_NOOFFSET:case s.WALLDECOR_DIAGONAL_BOTH:return a.Z.WALL_DECOR;case s.WALL_DIAGONAL:case s.CENTREPIECE_STRAIGHT:case s.CENTREPIECE_DIAGONAL:case s.ROOF_STRAIGHT:case s.ROOF_DIAGONAL_WITH_ROOFEDGE:case s.ROOF_DIAGONAL:case s.ROOF_L_CONCAVE:case s.ROOF_L_CONVEX:case s.ROOF_FLAT:case s.ROOFEDGE_STRAIGHT:case s.ROOFEDGE_DIAGONAL_CORNER:case s.ROOFEDGE_L:case s.ROOFEDGE_SQUARE_CORNER:return a.Z.GROUND;case s.GROUND_DECOR:return a.Z.GROUND_DECOR;default:throw new Error("Invalid loc shape.")}}}},3909:(e,t,i)=>{i.d(t,{Z:()=>g});var s=i(3693),a=i(8056),r=i(2383),n=i(8078),h=i(7221),o=i(7958),l=i(682),c=i(8067),d=i(1908),u=i(5534),f=i(312),p=i(9190),m=i(9345);class g{static ROTATION_WALL_TYPE=Int32Array.of(1,2,4,8);static ROTATION_WALL_CORNER_TYPE=Int32Array.of(16,32,64,128);static WALL_DECORATION_ROTATION_FORWARD_X=Int32Array.of(1,0,-1,0);static WALL_DECORATION_ROTATION_FORWARD_Z=Int32Array.of(0,-1,0,1);static randomHueOffset=(17*Math.random()|0)-8;static randomLightnessOffset=(33*Math.random()|0)-16;static lowMemory=!0;static levelBuilt=0;static fullbright=!1;static perlin=(e,t)=>{let i=this.perlinScale(e+45365,t+91923,4)+(this.perlinScale(e+10294,t+37821,2)-128>>1)+(this.perlinScale(e,t,1)-128>>2)-128;return i=35+(.3*i|0),i<10?i=10:i>60&&(i=60),i};static perlinScale=(e,t,i)=>{const s=e/i|0,a=e&i-1,r=t/i|0,n=t&i-1,h=this.smoothNoise(s,r),o=this.smoothNoise(s+1,r),l=this.smoothNoise(s,r+1),c=this.smoothNoise(s+1,r+1),d=this.interpolate(h,o,a,i),u=this.interpolate(l,c,a,i);return this.interpolate(d,u,n,i)};static interpolate=(e,t,i,s)=>{const a=65536-n.Z.cos[1024*i/s|0]>>1;return(e*(65536-a)>>16)+(t*a>>16)};static smoothNoise=(e,t)=>((this.noise(e-1,t-1)+this.noise(e+1,t-1)+this.noise(e-1,t+1)+this.noise(e+1,t+1))/16|0)+((this.noise(e-1,t)+this.noise(e+1,t)+this.noise(e,t-1)+this.noise(e,t+1))/8|0)+(this.noise(e,t)/4|0);static noise=(e,t)=>{const i=e+57*t,s=i<<13^i,a=BigInt(s)*(BigInt(s)*BigInt(s)*15731n+789221n)+1376312589n&0x7fffffffn;return 255&Number(a>>19n)};static addLoc=(e,t,i,s,a,r,n,h,f,p,m)=>{const y=a[m][t][i],C=a[m][t+1][i],T=a[m][t+1][i+1],w=a[m][t][i+1],S=y+C+T+w>>2,Z=o.Z.get(h);let A=t+(i<<7)+(h<<14)+1073741824|0;Z.active||(A+=-2147483648),A|=0;const v=((p<<6)+f|0)<<24>>24;if(f===d.Z.GROUND_DECOR)s?.addGroundDecoration(Z.getModel(d.Z.GROUND_DECOR,p,y,C,T,w,-1),e,t,i,S,A,v),Z.blockwalk&&Z.active&&n.addFloor(t,i),-1!==Z.anim&&r.pushBack(new l.Z(h,e,3,t,i,c.Z.instances[Z.anim],!0));else if(f===d.Z.CENTREPIECE_STRAIGHT||f===d.Z.CENTREPIECE_DIAGONAL){const a=Z.getModel(d.Z.CENTREPIECE_STRAIGHT,p,y,C,T,w,-1);if(a){let r,n,h=0;f===d.Z.CENTREPIECE_DIAGONAL&&(h+=256),p===u.Z.NORTH||p===u.Z.SOUTH?(r=Z.length,n=Z.width):(r=Z.width,n=Z.length),s?.addLoc(e,t,i,S,a,null,A,v,r,n,h)}Z.blockwalk&&n.addLoc(t,i,Z.width,Z.length,p,Z.blockrange),-1!==Z.anim&&r.pushBack(new l.Z(h,e,2,t,i,c.Z.instances[Z.anim],!0))}else if(f>=d.Z.ROOF_STRAIGHT)s?.addLoc(e,t,i,S,Z.getModel(f,p,y,C,T,w,-1),null,A,v,1,1,0),Z.blockwalk&&n.addLoc(t,i,Z.width,Z.length,p,Z.blockrange),-1!==Z.anim&&r.pushBack(new l.Z(h,e,2,t,i,c.Z.instances[Z.anim],!0));else if(f===d.Z.WALL_STRAIGHT)s?.addWall(e,t,i,S,g.ROTATION_WALL_TYPE[p],0,Z.getModel(d.Z.WALL_STRAIGHT,p,y,C,T,w,-1),null,A,v),Z.blockwalk&&n.addWall(t,i,f,p,Z.blockrange),-1!==Z.anim&&r.pushBack(new l.Z(h,e,0,t,i,c.Z.instances[Z.anim],!0));else if(f===d.Z.WALL_DIAGONAL_CORNER)s?.addWall(e,t,i,S,g.ROTATION_WALL_CORNER_TYPE[p],0,Z.getModel(d.Z.WALL_DIAGONAL_CORNER,p,y,C,T,w,-1),null,A,v),Z.blockwalk&&n.addWall(t,i,f,p,Z.blockrange),-1!==Z.anim&&r.pushBack(new l.Z(h,e,0,t,i,c.Z.instances[Z.anim],!0));else if(f===d.Z.WALL_L){const a=p+1&3;s?.addWall(e,t,i,S,g.ROTATION_WALL_TYPE[p],g.ROTATION_WALL_TYPE[a],Z.getModel(d.Z.WALL_L,p+4,y,C,T,w,-1),Z.getModel(d.Z.WALL_L,a,y,C,T,w,-1),A,v),Z.blockwalk&&n.addWall(t,i,f,p,Z.blockrange),-1!==Z.anim&&r.pushBack(new l.Z(h,e,0,t,i,c.Z.instances[Z.anim],!0))}else if(f===d.Z.WALL_SQUARE_CORNER)s?.addWall(e,t,i,S,g.ROTATION_WALL_CORNER_TYPE[p],0,Z.getModel(d.Z.WALL_SQUARE_CORNER,p,y,C,T,w,-1),null,A,v),Z.blockwalk&&n.addWall(t,i,f,p,Z.blockrange),-1!==Z.anim&&r.pushBack(new l.Z(h,e,0,t,i,c.Z.instances[Z.anim],!0));else if(f===d.Z.WALL_DIAGONAL)s?.addLoc(e,t,i,S,Z.getModel(f,p,y,C,T,w,-1),null,A,v,1,1,0),Z.blockwalk&&n.addLoc(t,i,Z.width,Z.length,p,Z.blockrange),-1!==Z.anim&&r.pushBack(new l.Z(h,e,2,t,i,c.Z.instances[Z.anim],!0));else if(f===d.Z.WALLDECOR_STRAIGHT_NOOFFSET)s?.setWallDecoration(e,t,i,S,0,0,A,Z.getModel(d.Z.WALLDECOR_STRAIGHT_NOOFFSET,u.Z.WEST,y,C,T,w,-1),v,512*p,g.ROTATION_WALL_TYPE[p]),-1!==Z.anim&&r.pushBack(new l.Z(h,e,1,t,i,c.Z.instances[Z.anim],!0));else if(f===d.Z.WALLDECOR_STRAIGHT_OFFSET){let a=16;if(s){const r=s.getWallBitset(e,t,i);r>0&&(a=o.Z.get(r>>14&32767).walloff)}s?.setWallDecoration(e,t,i,S,g.WALL_DECORATION_ROTATION_FORWARD_X[p]*a,g.WALL_DECORATION_ROTATION_FORWARD_Z[p]*a,A,Z.getModel(d.Z.WALLDECOR_STRAIGHT_NOOFFSET,u.Z.WEST,y,C,T,w,-1),v,512*p,g.ROTATION_WALL_TYPE[p]),-1!==Z.anim&&r.pushBack(new l.Z(h,e,1,t,i,c.Z.instances[Z.anim],!0))}else f===d.Z.WALLDECOR_DIAGONAL_OFFSET?(s?.setWallDecoration(e,t,i,S,0,0,A,Z.getModel(d.Z.WALLDECOR_STRAIGHT_NOOFFSET,u.Z.WEST,y,C,T,w,-1),v,p,256),-1!==Z.anim&&r.pushBack(new l.Z(h,e,1,t,i,c.Z.instances[Z.anim],!0))):f===d.Z.WALLDECOR_DIAGONAL_NOOFFSET?(s?.setWallDecoration(e,t,i,S,0,0,A,Z.getModel(d.Z.WALLDECOR_STRAIGHT_NOOFFSET,u.Z.WEST,y,C,T,w,-1),v,p,512),-1!==Z.anim&&r.pushBack(new l.Z(h,e,1,t,i,c.Z.instances[Z.anim],!0))):f===d.Z.WALLDECOR_DIAGONAL_BOTH&&(s?.setWallDecoration(e,t,i,S,0,0,A,Z.getModel(d.Z.WALLDECOR_STRAIGHT_NOOFFSET,u.Z.WEST,y,C,T,w,-1),v,p,768),-1!==Z.anim&&r.pushBack(new l.Z(h,e,1,t,i,c.Z.instances[Z.anim],!0)))};maxTileX;maxTileZ;levelHeightmap;levelTileFlags;levelTileUnderlayIds;levelTileOverlayIds;levelTileOverlayShape;levelTileOverlayRotation;levelShademap;levelLightmap;blendChroma;blendSaturation;blendLightness;blendLuminance;blendMagnitude;levelOccludemap;constructor(e,t,i,a){this.maxTileX=e,this.maxTileZ=t,this.levelHeightmap=i,this.levelTileFlags=a,this.levelTileUnderlayIds=new m.zi(s.Z.LEVELS,e,t),this.levelTileOverlayIds=new m.zi(s.Z.LEVELS,e,t),this.levelTileOverlayShape=new m.zi(s.Z.LEVELS,e,t),this.levelTileOverlayRotation=new m.zi(s.Z.LEVELS,e,t),this.levelOccludemap=new m.AK(s.Z.LEVELS,e+1,t+1),this.levelShademap=new m.zi(s.Z.LEVELS,e+1,t+1),this.levelLightmap=new m.Nv(e+1,t+1),this.blendChroma=new Int32Array(t),this.blendSaturation=new Int32Array(t),this.blendLightness=new Int32Array(t),this.blendLuminance=new Int32Array(t),this.blendMagnitude=new Int32Array(t)}build=(e,t)=>{for(let e=0;e=0&&t[s]?.addFloor(i,a)}g.randomHueOffset+=(5*Math.random()|0)-2,g.randomHueOffset<-8?g.randomHueOffset=-8:g.randomHueOffset>8&&(g.randomHueOffset=8),g.randomLightnessOffset+=(5*Math.random()|0)-2,g.randomLightnessOffset<-16?g.randomLightnessOffset=-16:g.randomLightnessOffset>16&&(g.randomLightnessOffset=16);for(let t=0;t>8;for(let e=1;e>2)+(i[a+1][e]>>3)+(i[a][e-1]>>2)+(i[a][e+1]>>3)+(i[a][e]>>1);this.levelLightmap[a][e]=u-f}for(let e=0;e=0&&s0){const t=a.Z.instances[i-1];this.blendChroma[e]+=t.chroma,this.blendSaturation[e]+=t.saturation,this.blendLightness[e]+=t.lightness,this.blendLuminance[e]+=t.luminance,r=this.blendMagnitude[e]++}}const n=i-5;if(n>=0&&n0){const t=a.Z.instances[i-1];this.blendChroma[e]-=t.chroma,this.blendSaturation[e]-=t.saturation,this.blendLightness[e]-=t.lightness,this.blendLuminance[e]-=t.luminance,r=this.blendMagnitude[e]--}}}if(i>=1&&i=0&&d=0&&m=1&&c0||m>0){const y=this.levelHeightmap[t][i][c],C=this.levelHeightmap[t][i+1][c],T=this.levelHeightmap[t][i+1][c+1],w=this.levelHeightmap[t][i][c+1],S=this.levelLightmap[i][c],Z=this.levelLightmap[i+1][c],A=this.levelLightmap[i+1][c+1],v=this.levelLightmap[i][c+1];let I=-1,O=-1;if(d>0){const e=256*s/o|0,t=r/l|0;let i=h/l|0;I=a.Z.hsl24to16(e,t,i);const n=e+g.randomHueOffset&255;i+=g.randomLightnessOffset,i<0?i=0:i>255&&(i=255),O=a.Z.hsl24to16(n,t,i)}if(t>0){let e=0!==d||this.levelTileOverlayShape[t][i][c]===p.Z.PLAIN;m>0&&!a.Z.instances[m-1].occlude&&(e=!1),e&&y===C&&y===T&&y===w&&(this.levelOccludemap[t][i][c]|=2340)}let b=0;if(-1!==I&&(b=n.Z.palette[a.Z.mulHSL(O,96)]),0===m)e?.setTile(t,i,c,p.Z.PLAIN,u.Z.WEST,-1,y,C,T,w,a.Z.mulHSL(I,S),a.Z.mulHSL(I,Z),a.Z.mulHSL(I,A),a.Z.mulHSL(I,v),f.Z.BLACK,f.Z.BLACK,f.Z.BLACK,f.Z.BLACK,b,f.Z.BLACK);else{const s=this.levelTileOverlayShape[t][i][c]+1,r=this.levelTileOverlayRotation[t][i][c],h=a.Z.instances[m-1];let o,l,d=h.texture;d>=0?(l=n.Z.getAverageTextureRGB(d),o=-1):h.rgb===f.Z.MAGENTA?(l=0,o=-2,d=-1):(o=a.Z.hsl24to16(h.hue,h.saturation,h.lightness),l=n.Z.palette[a.Z.adjustLightness(h.hsl,96)]),e?.setTile(t,i,c,s,r,d,y,C,T,w,a.Z.mulHSL(I,S),a.Z.mulHSL(I,Z),a.Z.mulHSL(I,A),a.Z.mulHSL(I,v),a.Z.adjustLightness(o,S),a.Z.adjustLightness(o,Z),a.Z.adjustLightness(o,A),a.Z.adjustLightness(o,v),b,l)}}}}}}for(let i=1;i0&&(e<<=3,t<<=3,i<<=3);for(let s=0;s<=a;s++)for(let r=0;r<=this.maxTileZ;r++)for(let n=0;n<=this.maxTileX;n++){if(0!=(this.levelOccludemap[s][n][r]&e)){let t=r,i=r,o=s,l=s;for(;t>0&&0!=(this.levelOccludemap[s][n][t-1]&e);)t--;for(;i0;){for(let s=t;s<=i;s++)if(0==(this.levelOccludemap[o-1][n][s]&e))break e;o--}e:for(;l=8){const s=this.levelHeightmap[l][n][t]-240,r=this.levelHeightmap[o][n][t];h.Z.addOccluder(a,1,128*n,s,128*t,128*n,r,128*i+128);for(let s=o;s<=l;s++)for(let a=t;a<=i;a++)this.levelOccludemap[s][n][a]&=~e}}if(0!=(this.levelOccludemap[s][n][r]&t)){let e=n,i=n,o=s,l=s;for(;e>0&&0!=(this.levelOccludemap[s][e-1][r]&t);)e--;for(;i0;){for(let s=e;s<=i;s++)if(0==(this.levelOccludemap[o-1][s][r]&t))break e;o--}e:for(;l=8){const s=this.levelHeightmap[l][e][r]-240,n=this.levelHeightmap[o][e][r];h.Z.addOccluder(a,2,128*e,s,128*r,128*i+128,n,128*r);for(let s=o;s<=l;s++)for(let a=e;a<=i;a++)this.levelOccludemap[s][a][r]&=~t}}if(0!=(this.levelOccludemap[s][n][r]&i)){let e=n,t=n,o=r,l=r;for(;o>0&&0!=(this.levelOccludemap[s][n][o-1]&i);)o--;for(;l0;){for(let t=o;t<=l;t++)if(0==(this.levelOccludemap[s][e-1][t]&i))break e;e--}e:for(;t=4){const r=this.levelHeightmap[s][e][o];h.Z.addOccluder(a,4,128*e,r,128*o,128*t+128,r,128*l+128);for(let a=e;a<=t;a++)for(let e=o;e<=l;e++)this.levelOccludemap[s][a][e]&=~i}}}}}};clearLandscape=(e,t,i,r)=>{let n=0;for(let e=0;e>24;break}for(let a=e;a=0&&e=0&&a{const h=new r.Z(new Uint8Array(n));for(let r=0;r=0&&l=0&&c>24,this.levelTileOverlayRotation[r][l][c]=(d-2&3)<<24>>24):d<=81?this.levelTileFlags[r][l][c]=d-49<<24>>24:this.levelTileUnderlayIds[r][l][c]=d-81<<24>>24}else for(;d=h.g1,0!==d;){if(1===d){h.g1;break}d<=49&&h.g1}}};readLocs=(e,t,i,a,n,h)=>{const o=new r.Z(new Uint8Array(a));let l=-1;for(;;){const a=o.gsmarts;if(0===a)return;l+=a;let r=0;for(;;){const a=o.gsmarts;if(0===a)break;r+=a-1;const c=63&r,d=r>>6&63,u=r>>12,f=o.g1,p=f>>2,m=3&f,g=d+n,y=c+h;if(g>0&&y>0&&g=0&&(a=i[s]),this.addLoc(u,g,y,e,t,a,l,p,m)}}}};addLoc=(e,t,i,s,a,r,n,h,f)=>{if(g.lowMemory){if(0!=(16&this.levelTileFlags[e][t][i]))return;if(this.getDrawLevel(e,t,i)!==g.levelBuilt)return}const p=this.levelHeightmap[e][t][i],m=this.levelHeightmap[e][t+1][i],y=this.levelHeightmap[e][t+1][i+1],C=this.levelHeightmap[e][t][i+1],T=p+m+y+C>>2,w=o.Z.get(n);let S=t+(i<<7)+(n<<14)+1073741824|0;w.active||(S+=-2147483648),S|=0;const Z=((f<<6)+h|0)<<24>>24;if(h===d.Z.GROUND_DECOR)(!g.lowMemory||w.active||w.forcedecor)&&(s?.addGroundDecoration(w.getModel(d.Z.GROUND_DECOR,f,p,m,y,C,-1),e,t,i,T,S,Z),w.blockwalk&&w.active&&r&&r.addFloor(t,i),-1!==w.anim&&a.pushBack(new l.Z(n,e,3,t,i,c.Z.instances[w.anim],!0)));else if(h===d.Z.CENTREPIECE_STRAIGHT||h===d.Z.CENTREPIECE_DIAGONAL){const o=w.getModel(d.Z.CENTREPIECE_STRAIGHT,f,p,m,y,C,-1);if(o){let a,r,n=0;if(h===d.Z.CENTREPIECE_DIAGONAL&&(n+=256),f===u.Z.NORTH||f===u.Z.SOUTH?(a=w.length,r=w.width):(a=w.width,r=w.length),s?.addLoc(e,t,i,T,o,null,S,Z,a,r,n)&&w.shadow)for(let s=0;s<=a;s++)for(let a=0;a<=r;a++){let r=o.radius/4|0;r>30&&(r=30),r>this.levelShademap[e][t+s][i+a]&&(this.levelShademap[e][t+s][i+a]=r<<24>>24)}}w.blockwalk&&r&&r.addLoc(t,i,w.width,w.length,f,w.blockrange),-1!==w.anim&&a.pushBack(new l.Z(n,e,2,t,i,c.Z.instances[w.anim],!0))}else if(h>=d.Z.ROOF_STRAIGHT)s?.addLoc(e,t,i,T,w.getModel(h,f,p,m,y,C,-1),null,S,Z,1,1,0),h>=d.Z.ROOF_STRAIGHT&&h<=d.Z.ROOF_FLAT&&h!==d.Z.ROOF_DIAGONAL_WITH_ROOFEDGE&&e>0&&(this.levelOccludemap[e][t][i]|=2340),w.blockwalk&&r&&r.addLoc(t,i,w.width,w.length,f,w.blockrange),-1!==w.anim&&a.pushBack(new l.Z(n,e,2,t,i,c.Z.instances[w.anim],!0));else if(h===d.Z.WALL_STRAIGHT)s?.addWall(e,t,i,T,g.ROTATION_WALL_TYPE[f],0,w.getModel(d.Z.WALL_STRAIGHT,f,p,m,y,C,-1),null,S,Z),f===u.Z.WEST?(w.shadow&&(this.levelShademap[e][t][i]=50,this.levelShademap[e][t][i+1]=50),w.occlude&&(this.levelOccludemap[e][t][i]|=585)):f===u.Z.NORTH?(w.shadow&&(this.levelShademap[e][t][i+1]=50,this.levelShademap[e][t+1][i+1]=50),w.occlude&&(this.levelOccludemap[e][t][i+1]|=1170)):f===u.Z.EAST?(w.shadow&&(this.levelShademap[e][t+1][i]=50,this.levelShademap[e][t+1][i+1]=50),w.occlude&&(this.levelOccludemap[e][t+1][i]|=585)):f===u.Z.SOUTH&&(w.shadow&&(this.levelShademap[e][t][i]=50,this.levelShademap[e][t+1][i]=50),w.occlude&&(this.levelOccludemap[e][t][i]|=1170)),w.blockwalk&&r&&r.addWall(t,i,h,f,w.blockrange),-1!==w.anim&&a.pushBack(new l.Z(n,e,0,t,i,c.Z.instances[w.anim],!0)),16!==w.walloff&&s?.setWallDecorationOffset(e,t,i,w.walloff);else if(h===d.Z.WALL_DIAGONAL_CORNER)s?.addWall(e,t,i,T,g.ROTATION_WALL_CORNER_TYPE[f],0,w.getModel(d.Z.WALL_DIAGONAL_CORNER,f,p,m,y,C,-1),null,S,Z),w.shadow&&(f===u.Z.WEST?this.levelShademap[e][t][i+1]=50:f===u.Z.NORTH?this.levelShademap[e][t+1][i+1]=50:f===u.Z.EAST?this.levelShademap[e][t+1][i]=50:f===u.Z.SOUTH&&(this.levelShademap[e][t][i]=50)),w.blockwalk&&r&&r.addWall(t,i,h,f,w.blockrange),-1!==w.anim&&a.pushBack(new l.Z(n,e,0,t,i,c.Z.instances[w.anim],!0));else if(h===d.Z.WALL_L){const o=f+1&3;s?.addWall(e,t,i,T,g.ROTATION_WALL_TYPE[f],g.ROTATION_WALL_TYPE[o],w.getModel(d.Z.WALL_L,f+4,p,m,y,C,-1),w.getModel(d.Z.WALL_L,o,p,m,y,C,-1),S,Z),w.occlude&&(f===u.Z.WEST?(this.levelOccludemap[e][t][i]|=265,this.levelOccludemap[e][t][i+1]|=1170):f===u.Z.NORTH?(this.levelOccludemap[e][t][i+1]|=1170,this.levelOccludemap[e][t+1][i]|=585):f===u.Z.EAST?(this.levelOccludemap[e][t+1][i]|=585,this.levelOccludemap[e][t][i]|=1170):f===u.Z.SOUTH&&(this.levelOccludemap[e][t][i]|=1170,this.levelOccludemap[e][t][i]|=585)),w.blockwalk&&r&&r.addWall(t,i,h,f,w.blockrange),-1!==w.anim&&a.pushBack(new l.Z(n,e,0,t,i,c.Z.instances[w.anim],!0)),16!==w.walloff&&s?.setWallDecorationOffset(e,t,i,w.walloff)}else if(h===d.Z.WALL_SQUARE_CORNER)s?.addWall(e,t,i,T,g.ROTATION_WALL_CORNER_TYPE[f],0,w.getModel(d.Z.WALL_SQUARE_CORNER,f,p,m,y,C,-1),null,S,Z),w.shadow&&(f===u.Z.WEST?this.levelShademap[e][t][i+1]=50:f===u.Z.NORTH?this.levelShademap[e][t+1][i+1]=50:f===u.Z.EAST?this.levelShademap[e][t+1][i]=50:f===u.Z.SOUTH&&(this.levelShademap[e][t][i]=50)),w.blockwalk&&r&&r.addWall(t,i,h,f,w.blockrange),-1!==w.anim&&a.pushBack(new l.Z(n,e,0,t,i,c.Z.instances[w.anim],!0));else if(h===d.Z.WALL_DIAGONAL)s?.addLoc(e,t,i,T,w.getModel(h,f,p,m,y,C,-1),null,S,Z,1,1,0),w.blockwalk&&r&&r.addLoc(t,i,w.width,w.length,f,w.blockrange),-1!==w.anim&&a.pushBack(new l.Z(n,e,2,t,i,c.Z.instances[w.anim],!0));else if(h===d.Z.WALLDECOR_STRAIGHT_NOOFFSET)s?.setWallDecoration(e,t,i,T,0,0,S,w.getModel(d.Z.WALLDECOR_STRAIGHT_NOOFFSET,u.Z.WEST,p,m,y,C,-1),Z,512*f,g.ROTATION_WALL_TYPE[f]),-1!==w.anim&&a.pushBack(new l.Z(n,e,1,t,i,c.Z.instances[w.anim],!0));else if(h===d.Z.WALLDECOR_STRAIGHT_OFFSET){let r=16;if(s){const a=s.getWallBitset(e,t,i);a>0&&(r=o.Z.get(a>>14&32767).walloff)}s?.setWallDecoration(e,t,i,T,g.WALL_DECORATION_ROTATION_FORWARD_X[f]*r,g.WALL_DECORATION_ROTATION_FORWARD_Z[f]*r,S,w.getModel(d.Z.WALLDECOR_STRAIGHT_NOOFFSET,u.Z.WEST,p,m,y,C,-1),Z,512*f,g.ROTATION_WALL_TYPE[f]),-1!==w.anim&&a.pushBack(new l.Z(n,e,1,t,i,c.Z.instances[w.anim],!0))}else h===d.Z.WALLDECOR_DIAGONAL_OFFSET?(s?.setWallDecoration(e,t,i,T,0,0,S,w.getModel(d.Z.WALLDECOR_STRAIGHT_NOOFFSET,u.Z.WEST,p,m,y,C,-1),Z,f,256),-1!==w.anim&&a.pushBack(new l.Z(n,e,1,t,i,c.Z.instances[w.anim],!0))):h===d.Z.WALLDECOR_DIAGONAL_NOOFFSET?(s?.setWallDecoration(e,t,i,T,0,0,S,w.getModel(d.Z.WALLDECOR_STRAIGHT_NOOFFSET,u.Z.WEST,p,m,y,C,-1),Z,f,512),-1!==w.anim&&a.pushBack(new l.Z(n,e,1,t,i,c.Z.instances[w.anim],!0))):h===d.Z.WALLDECOR_DIAGONAL_BOTH&&(s?.setWallDecoration(e,t,i,T,0,0,S,w.getModel(d.Z.WALLDECOR_STRAIGHT_NOOFFSET,u.Z.WEST,p,m,y,C,-1),Z,f,768),-1!==w.anim&&a.pushBack(new l.Z(n,e,1,t,i,c.Z.instances[w.anim],!0)))};getDrawLevel=(e,t,i)=>0==(8&this.levelTileFlags[e][t][i])?e<=0||0==(2&this.levelTileFlags[1][t][i])?e:e-1:0}},7221:(e,t,i)=>{i.d(t,{Z:()=>T});var s=i(8078),a=i(6539),r=i(220),n=i(4138),h=i(3693),o=i(4155),l=i(3806),c=i(9118),d=i(9080),u=i(6711),f=i(9865),p=i(2991),m=i(8570),g=i(9190),y=i(5534),C=i(9345);class T{static visibilityMatrix=new C.nz(8,32,51,51,!1);static locBuffer=new C.to(100,null);static levelOccluderCount=new Int32Array(h.Z.LEVELS);static levelOccluders=new C.IY(h.Z.LEVELS,500,null);static activeOccluders=new C.to(500,null);static drawTileQueue=new d.Z;static cycle=0;static viewportLeft=0;static viewportTop=0;static viewportRight=0;static viewportBottom=0;static viewportCenterX=0;static viewportCenterY=0;static sinEyePitch=0;static cosEyePitch=0;static sinEyeYaw=0;static cosEyeYaw=0;static eyeX=0;static eyeY=0;static eyeZ=0;static eyeTileX=0;static eyeTileZ=0;static minDrawTileX=0;static maxDrawTileX=0;static minDrawTileZ=0;static maxDrawTileZ=0;static topLevel=0;static tilesRemaining=0;static takingInput=!1;static visibilityMap=null;static FRONT_WALL_TYPES=Int32Array.of(19,55,38,155,255,110,137,205,76);static DIRECTION_ALLOW_WALL_CORNER_TYPE=Int32Array.of(160,192,80,96,0,144,80,48,160);static BACK_WALL_TYPES=Int32Array.of(76,8,137,4,0,1,38,2,19);static WALL_CORNER_TYPE_16_BLOCK_LOC_SPANS=Int32Array.of(0,0,2,0,0,2,1,1,0);static WALL_CORNER_TYPE_32_BLOCK_LOC_SPANS=Int32Array.of(2,0,0,2,0,0,0,4,4);static WALL_CORNER_TYPE_64_BLOCK_LOC_SPANS=Int32Array.of(0,4,4,8,0,0,8,0,0);static WALL_CORNER_TYPE_128_BLOCK_LOC_SPANS=Int32Array.of(1,1,0,0,0,8,0,0,8);static WALL_DECORATION_INSET_X=Int32Array.of(53,-53,-53,53);static WALL_DECORATION_INSET_Z=Int32Array.of(-53,-53,53,53);static WALL_DECORATION_OUTSET_X=Int32Array.of(-45,45,45,-45);static WALL_DECORATION_OUTSET_Z=Int32Array.of(45,45,-45,-45);static MINIMAP_TILE_MASK=[new Int32Array(16),Int32Array.of(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),Int32Array.of(1,0,0,0,1,1,0,0,1,1,1,0,1,1,1,1),Int32Array.of(1,1,0,0,1,1,0,0,1,0,0,0,1,0,0,0),Int32Array.of(0,0,1,1,0,0,1,1,0,0,0,1,0,0,0,1),Int32Array.of(0,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1),Int32Array.of(1,1,1,0,1,1,1,0,1,1,1,1,1,1,1,1),Int32Array.of(1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0),Int32Array.of(0,0,0,0,0,0,0,0,1,0,0,0,1,1,0,0),Int32Array.of(1,1,1,1,1,1,1,1,0,1,1,1,0,0,1,1),Int32Array.of(1,1,1,1,1,1,0,0,1,0,0,0,1,0,0,0),Int32Array.of(0,0,0,0,0,0,1,1,0,1,1,1,0,1,1,1),Int32Array.of(0,0,0,0,0,0,0,0,0,1,1,0,1,1,1,1)];static MINIMAP_TILE_ROTATION_MAP=[Int32Array.of(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15),Int32Array.of(12,8,4,0,13,9,5,1,14,10,6,2,15,11,7,3),Int32Array.of(15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0),Int32Array.of(3,7,11,15,2,6,10,14,1,5,9,13,0,4,8,12)];static TEXTURE_HSL=Int32Array.of(41,39248,41,4643,41,41,41,41,41,41,41,41,41,41,41,43086,41,41,41,41,41,41,41,8602,41,28992,41,41,41,41,41,5056,41,41,41,41,41,41,41,41,41,41,41,41,41,41,3131,41,41,41);static activeOccluderCount=0;static mouseX=0;static mouseY=0;static clickTileX=-1;static clickTileZ=-1;static lowMemory=!0;static init=(e,t,i,a,r)=>{this.viewportLeft=0,this.viewportTop=0,this.viewportRight=e,this.viewportBottom=t,this.viewportCenterX=e/2|0,this.viewportCenterY=t/2|0;const n=new C.nz(9,32,53,53,!1);for(let e=128;e<=384;e+=32)for(let t=0;t<2048;t+=64){this.sinEyePitch=s.Z.sin[e],this.cosEyePitch=s.Z.cos[e],this.sinEyeYaw=s.Z.sin[t],this.cosEyeYaw=s.Z.cos[t];const h=(e-128)/32|0,o=t/64|0;for(let e=-26;e<=26;e++)for(let t=-26;t<=26;t++){const s=128*e,l=128*t;let c=!1;for(let e=-i;e<=a;e+=128)if(this.testPoint(s,l,r[h]+e)){c=!0;break}n[h][o][e+25+1][t+25+1]=c}}for(let e=0;e<8;e++)for(let t=0;t<32;t++)for(let i=-25;i<25;i++)for(let s=-25;s<25;s++){let a=!1;e:for(let r=-1;r<=1;r++)for(let h=-1;h<=1;h++){if(n[e][t][i+r+25+1][s+h+25+1]){a=!0;break e}if(n[e][(t+1)%31][i+r+25+1][s+h+25+1]){a=!0;break e}if(n[e+1][t][i+r+25+1][s+h+25+1]){a=!0;break e}if(n[e+1][(t+1)%31][i+r+25+1][s+h+25+1]){a=!0;break e}}this.visibilityMatrix[e][t][i+25][s+25]=a}};static unload=()=>{this.locBuffer=null,this.levelOccluderCount=null,this.levelOccluders=null,this.drawTileQueue=null,this.visibilityMatrix=null,this.activeOccluders=null,this.visibilityMap=null,console.log("World3D unloaded!")};static addOccluder=(e,t,i,s,a,r,h,o)=>{T.levelOccluders[e][T.levelOccluderCount[e]++]=new n.Z(i/128|0,r/128|0,a/128|0,o/128|0,t,i,r,a,o,s,h)};static testPoint=(e,t,i)=>{const s=t*this.sinEyeYaw+e*this.cosEyeYaw>>16,a=t*this.cosEyeYaw-e*this.sinEyeYaw>>16,r=i*this.sinEyePitch+a*this.cosEyePitch>>16,n=i*this.cosEyePitch-a*this.sinEyePitch>>16;if(r<50||r>3500)return!1;const h=this.viewportCenterX+((s<<9)/r|0),o=this.viewportCenterY+((n<<9)/r|0);return h>=this.viewportLeft&&h<=this.viewportRight&&o>=this.viewportTop&&o<=this.viewportBottom};maxLevel;maxTileX;maxTileZ;levelHeightmaps;levelTiles;temporaryLocs;levelTileOcclusionCycles;mergeIndexA;mergeIndexB;temporaryLocCount=0;minLevel=0;tmpMergeIndex=0;constructor(e,t,i,s){this.maxLevel=i,this.maxTileX=s,this.maxTileZ=t,this.levelTiles=new C.N$(i,s,t,null),this.levelTileOcclusionCycles=new C.AK(i,s+1,t+1),this.levelHeightmaps=e,this.temporaryLocs=new C.to(5e3,null),this.mergeIndexA=new Int32Array(1e4),this.mergeIndexB=new Int32Array(1e4),this.reset()}reset=()=>{for(let e=0;e{this.minLevel=e;for(let t=0;t{const i=this.levelTiles[0][e][t];for(let i=0;i<3;i++){this.levelTiles[i][e][t]=this.levelTiles[i+1][e][t];const s=this.levelTiles[i][e][t];s&&s.level--}this.levelTiles[0][e][t]||(this.levelTiles[0][e][t]=new r.Z(0,e,t));const s=this.levelTiles[0][e][t];s&&(s.bridge=i),this.levelTiles[3][e][t]=null};setDrawLevel=(e,t,i,s)=>{const a=this.levelTiles[e][t][i];a&&(a.drawLevel=s)};setTile=(e,t,i,s,a,n,h,o,l,c,d,u,p,y,C,T,w,S,Z,A)=>{if(s===g.Z.PLAIN){for(let s=e;s>=0;s--)this.levelTiles[s][t][i]||(this.levelTiles[s][t][i]=new r.Z(s,t,i));const s=this.levelTiles[e][t][i];s&&(s.underlay=new f.Z(d,u,p,y,-1,Z,!1))}else if(s===g.Z.DIAGONAL){for(let s=e;s>=0;s--)this.levelTiles[s][t][i]||(this.levelTiles[s][t][i]=new r.Z(s,t,i));const s=this.levelTiles[e][t][i];s&&(s.underlay=new f.Z(C,T,w,S,n,A,h===o&&h===l&&h===c))}else{for(let s=e;s>=0;s--)this.levelTiles[s][t][i]||(this.levelTiles[s][t][i]=new r.Z(s,t,i));const f=this.levelTiles[e][t][i];f&&(f.overlay=new m.Z(t,s,T,o,p,a,d,c,A,C,n,S,Z,l,w,y,h,i,u))}};addGroundDecoration=(e,t,i,s,a,n,h)=>{this.levelTiles[t][i][s]||(this.levelTiles[t][i][s]=new r.Z(t,i,s));const l=this.levelTiles[t][i][s];l&&(l.groundDecoration=new o.Z(a,128*i+64,128*s+64,e,n,h))};removeGroundDecoration=(e,t,i)=>{const s=this.levelTiles[e][t][i];s&&(s.groundDecoration=null)};addObjStack=(e,t,i,s,a,n,h,o)=>{let l=0;const c=this.levelTiles[s][e][t];if(c)for(let e=0;el&&(l=i)}else this.levelTiles[s][e][t]=new r.Z(s,e,t);const d=this.levelTiles[s][e][t];d&&(d.objStack=new u.Z(i,128*e+64,128*t+64,n,h,o,a,l))};removeObjStack=(e,t,i)=>{const s=this.levelTiles[e][t][i];s&&(s.objStack=null)};addWall=(e,t,i,s,a,n,h,o,c,d)=>{if(!h&&!o)return;for(let s=e;s>=0;s--)this.levelTiles[s][t][i]||(this.levelTiles[s][t][i]=new r.Z(s,t,i));const u=this.levelTiles[e][t][i];u&&(u.wall=new l.Z(s,128*t+64,128*i+64,a,n,h,o,c,d))};removeWall=(e,t,i,s)=>{const a=this.levelTiles[e][t][i];1===s&&a&&(a.wall=null)};setWallDecoration=(e,t,i,s,a,n,h,o,l,d,u)=>{if(!o)return;for(let s=e;s>=0;s--)this.levelTiles[s][t][i]||(this.levelTiles[s][t][i]=new r.Z(s,t,i));const f=this.levelTiles[e][t][i];f&&(f.wallDecoration=new c.Z(s,128*t+a+64,128*i+n+64,u,d,o,h,l))};removeWallDecoration=(e,t,i)=>{const s=this.levelTiles[e][t][i];s&&(s.wallDecoration=null)};setWallDecorationOffset=(e,t,i,s)=>{const a=this.levelTiles[e][t][i];if(!a)return;const r=a.wallDecoration;if(!r)return;const n=128*t+64,h=128*i+64;r.x=n+((r.x-n)*s/16|0),r.z=h+((r.z-h)*s/16|0)};setWallDecorationModel=(e,t,i,s)=>{if(!s)return;const a=this.levelTiles[e][t][i];if(!a)return;const r=a.wallDecoration;r&&(r.model=s)};setGroundDecorationModel=(e,t,i,s)=>{if(!s)return;const a=this.levelTiles[e][t][i];if(!a)return;const r=a.groundDecoration;r&&(r.model=s)};setWallModel=(e,t,i,s)=>{if(!s)return;const a=this.levelTiles[e][t][i];if(!a)return;const r=a.wall;r&&(r.modelA=s)};setWallModels=(e,t,i,s,a)=>{if(!s)return;const r=this.levelTiles[i][e][t];if(!r)return;const n=r.wall;n&&(n.modelA=s,n.modelB=a)};addLoc=(e,t,i,s,a,r,n,h,o,l,c)=>{if(!a&&!r)return!0;const d=128*t+64*o,u=128*i+64*l;return this.addLoc2(d,u,s,e,t,i,o,l,a,r,n,h,c,!1)};addTemporary=(e,t,i,s,a,r,n,h,o,l)=>{if(!a&&!r)return!0;let c=t-o,d=s-o,u=t+o,f=s+o;return l&&(h>640&&h<1408&&(f+=128),h>1152&&h<1920&&(u+=128),(h>1664||h<384)&&(d-=128),h>128&&h<896&&(c-=128)),c=c/128|0,d=d/128|0,u=u/128|0,f=f/128|0,this.addLoc2(t,s,i,e,c,d,u+1-c,f-d+1,a,r,n,0,h,!0)};addTemporary2=(e,t,i,s,a,r,n,h,o,l,c,d)=>!o&&!l||this.addLoc2(t,s,i,e,a,r,n+1-a,h-r+1,o,l,c,0,d,!0);removeLoc=(e,t,i)=>{const s=this.levelTiles[e][t][i];if(s)for(let e=0;e>29&3)&&a.minSceneTileX===t&&a.minSceneTileZ===i)return void this.removeLoc2(a)}};setLocModel=(e,t,i,s)=>{if(!s)return;const a=this.levelTiles[e][t][i];if(a)for(let e=0;e>29&3))return void(t.model=s)}};clearTemporaryLocs=()=>{for(let e=0;e{const s=this.levelTiles[e][t][i];return s&&s.wall?s.wall.bitset:0};getWallDecorationBitset=(e,t,i)=>{const s=this.levelTiles[e][i][t];return s&&s.wallDecoration?s.wallDecoration.bitset:0};getLocBitset=(e,t,i)=>{const s=this.levelTiles[e][t][i];if(!s)return 0;for(let e=0;e>29&3)&&a.minSceneTileX===t&&a.minSceneTileZ===i)return a.bitset}return 0};getGroundDecorationBitset=(e,t,i)=>{const s=this.levelTiles[e][t][i];return s&&s.groundDecoration?s.groundDecoration.bitset:0};getInfo=(e,t,i,s)=>{const a=this.levelTiles[e][t][i];if(a){if(a.wall&&a.wall.bitset===s)return 255&a.wall.info;if(a.wallDecoration&&a.wallDecoration.bitset===s)return 255&a.wallDecoration.info;if(a.groundDecoration&&a.groundDecoration.bitset===s)return 255&a.groundDecoration.info;for(let e=0;e{const r=t*(0|Math.sqrt(i*i+s*s+a*a))>>8;for(let t=0;t{if(t0){const a=this.levelTiles[e][t+1][i-1];a&&a.groundDecoration&&a.groundDecoration.model&&a.groundDecoration.model.vertexNormal&&this.mergeNormals(s,a.groundDecoration.model,128,0,-128,!0)}};mergeLocNormals=(e,t,i,s,a,r)=>{let n=!0,h=t;const o=t+s,l=i-1,c=i+a;for(let d=e;d<=e+1;d++)if(d!==this.maxLevel){for(let u=h;u<=o;u++)if(!(u<0||u>=this.maxTileX))for(let h=l;h<=c;h++){if(h<0||h>=this.maxTileZ||n&&u=i||u===t))continue;const l=this.levelTiles[d][u][h];if(!l)continue;const f=128*(u-t)+64*(1-s),p=128*(h-i)+64*(1-a),m=((this.levelHeightmaps[d][u][h]+this.levelHeightmaps[d][u+1][h]+this.levelHeightmaps[d][u][h+1]+this.levelHeightmaps[d][u+1][h+1])/4|0)-((this.levelHeightmaps[e][t][i]+this.levelHeightmaps[e][t+1][i]+this.levelHeightmaps[e][t][i+1]+this.levelHeightmaps[e][t+1][i+1])/4|0),g=l.wall;g&&g.modelA&&g.modelA.vertexNormal&&this.mergeNormals(r,g.modelA,f,m,p,n),g&&g.modelB&&g.modelB.vertexNormal&&this.mergeNormals(r,g.modelB,f,m,p,n);for(let e=0;e{this.tmpMergeIndex++;let n=0;const h=t.vertexX,o=t.vertexCount;if(e.vertexNormal&&e.vertexNormalOriginal)for(let r=0;rt.minY)continue;const u=e.vertexX[r]-i;if(ut.maxX)continue;const f=e.vertexZ[r]-a;if(ft.maxZ)continue;if(t.vertexNormal&&t.vertexNormalOriginal)for(let e=0;e{const n=this.levelTiles[e][t][i];if(!n)return;const h=n.underlay;if(h){const e=h.color;if(0!==e)for(let t=0;t<4;t++)s[a]=e,s[a+1]=e,s[a+2]=e,s[a+3]=e,a+=r;return}const o=n.overlay;if(!o)return;const l=o.shape,c=o.rotation,d=o.backgroundRgb,u=o.foregroundRgb,f=T.MINIMAP_TILE_MASK[l],p=T.MINIMAP_TILE_ROTATION_MAP[c];let m=0;if(0===d)for(let e=0;e<4;e++)0!==f[p[m++]]&&(s[a]=u),0!==f[p[m++]]&&(s[a+1]=u),0!==f[p[m++]]&&(s[a+2]=u),0!==f[p[m++]]&&(s[a+3]=u),a+=r;else for(let e=0;e<4;e++)s[a]=0===f[p[m++]]?d:u,s[a+1]=0===f[p[m++]]?d:u,s[a+2]=0===f[p[m++]]?d:u,s[a+3]=0===f[p[m++]]?d:u,a+=r};click=(e,t)=>{T.takingInput=!0,T.mouseX=e,T.mouseY=t,T.clickTileX=-1,T.clickTileZ=-1};draw=(e,t,i,a,r,n,h)=>{e<0?e=0:e>=128*this.maxTileX&&(e=128*this.maxTileX-1),i<0?i=0:i>=128*this.maxTileZ&&(i=128*this.maxTileZ-1),T.cycle++,T.sinEyePitch=s.Z.sin[n],T.cosEyePitch=s.Z.cos[n],T.sinEyeYaw=s.Z.sin[r],T.cosEyeYaw=s.Z.cos[r],T.visibilityMap=T.visibilityMatrix[(n-128)/32|0][r/64|0],T.eyeX=e,T.eyeY=t,T.eyeZ=i,T.eyeTileX=e/128|0,T.eyeTileZ=i/128|0,T.topLevel=a,T.minDrawTileX=T.eyeTileX-25,T.minDrawTileX<0&&(T.minDrawTileX=0),T.minDrawTileZ=T.eyeTileZ-25,T.minDrawTileZ<0&&(T.minDrawTileZ=0),T.maxDrawTileX=T.eyeTileX+25,T.maxDrawTileX>this.maxTileX&&(T.maxDrawTileX=this.maxTileX),T.maxDrawTileZ=T.eyeTileZ+25,T.maxDrawTileZ>this.maxTileZ&&(T.maxDrawTileZ=this.maxTileZ),this.updateActiveOccluders(),T.tilesRemaining=0;for(let e=this.minLevel;e=2e3)?(n.visible=!0,n.update=!0,n.containsLocs=n.locCount>0,T.tilesRemaining++):(n.visible=!1,n.update=!1,n.checkLocSpans=0))}}for(let e=this.minLevel;e=T.maxDrawTileX))for(let e=-25;e<=0;e++){const a=T.eyeTileZ+e,r=T.eyeTileZ-e;let n;if(i>=T.minDrawTileX&&(a>=T.minDrawTileZ&&(n=t[i][a],n&&n.visible&&this.drawTile(n,!0,h)),r=T.minDrawTileZ&&(n=t[s][a],n&&n.visible&&this.drawTile(n,!0,h)),r=T.maxDrawTileX))for(let e=-25;e<=0;e++){const a=T.eyeTileZ+e,r=T.eyeTileZ-e;let n;if(i>=T.minDrawTileX&&(a>=T.minDrawTileZ&&(n=t[i][a],n&&n.visible&&this.drawTile(n,!1,h)),r=T.minDrawTileZ&&(n=t[s][a],n&&n.visible&&this.drawTile(n,!1,h)),r{if(!c&&!d)return!1;for(let e=n;e=this.maxTileX||t>=this.maxTileZ)return!1;const i=this.levelTiles[s][e][t];if(i&&i.locCount>=5)return!1}const g=new a.Z(s,i,e,t,c,d,p,n,n+o-1,h,h+l-1,u,f);for(let e=n;en&&(i|=1),eh&&(i+=8),t=0;i--)this.levelTiles[i][e][t]||(this.levelTiles[i][e][t]=new r.Z(i,e,t));const a=this.levelTiles[s][e][t];a&&(a.locs[a.locCount]=g,a.locSpan[a.locCount]=i,a.locSpans|=i,a.locCount++)}return m&&(this.temporaryLocs[this.temporaryLocCount++]=g),!0};removeLoc2=e=>{for(let t=e.minSceneTileX;t<=e.maxSceneTileX;t++)for(let i=e.minSceneTileZ;i<=e.maxSceneTileZ;i++){const s=this.levelTiles[e.level][t][i];if(s){for(let t=0;t{const e=T.levelOccluderCount[T.topLevel],t=T.levelOccluders[T.topLevel];T.activeOccluderCount=0;for(let i=0;i=0&&s<=50){a=e.minTileZ+25-T.eyeTileZ,a<0&&(a=0),r=e.maxTileZ+25-T.eyeTileZ,r>50&&(r=50);let t=!1;for(;a<=r;)if(T.visibilityMap&&T.visibilityMap[s][a++]){t=!0;break}if(t){if(n=T.eyeX-e.minX,n>32)e.mode=1;else{if(n>=-32)continue;e.mode=2,n=-n}e.minDeltaZ=(e.minZ-T.eyeZ<<8)/n|0,e.maxDeltaZ=(e.maxZ-T.eyeZ<<8)/n|0,e.minDeltaY=(e.minY-T.eyeY<<8)/n|0,e.maxDeltaY=(e.maxY-T.eyeY<<8)/n|0,T.activeOccluders[T.activeOccluderCount++]=e}}}else if(2===e.type){if(s=e.minTileZ+25-T.eyeTileZ,s>=0&&s<=50){a=e.minTileX+25-T.eyeTileX,a<0&&(a=0),r=e.maxTileX+25-T.eyeTileX,r>50&&(r=50);let t=!1;for(;a<=r;)if(T.visibilityMap&&T.visibilityMap[a++][s]){t=!0;break}if(t){if(n=T.eyeZ-e.minZ,n>32)e.mode=3;else{if(n>=-32)continue;e.mode=4,n=-n}e.minDeltaX=(e.minX-T.eyeX<<8)/n|0,e.maxDeltaX=(e.maxX-T.eyeX<<8)/n|0,e.minDeltaY=(e.minY-T.eyeY<<8)/n|0,e.maxDeltaY=(e.maxY-T.eyeY<<8)/n|0,T.activeOccluders[T.activeOccluderCount++]=e}}}else if(4===e.type&&(s=e.minY-T.eyeY,s>128&&(a=e.minTileZ+25-T.eyeTileZ,a<0&&(a=0),r=e.maxTileZ+25-T.eyeTileZ,r>50&&(r=50),a<=r))){let t=e.minTileX+25-T.eyeTileX;t<0&&(t=0),n=e.maxTileX+25-T.eyeTileX,n>50&&(n=50);let i=!1;e:for(let e=t;e<=n;e++)for(let t=a;t<=r;t++)if(T.visibilityMap&&T.visibilityMap[e][t]){i=!0;break e}i&&(e.mode=5,e.minDeltaX=(e.minX-T.eyeX<<8)/s|0,e.maxDeltaX=(e.maxX-T.eyeX<<8)/s|0,e.minDeltaZ=(e.minZ-T.eyeZ<<8)/s|0,e.maxDeltaZ=(e.maxZ-T.eyeZ<<8)/s|0,T.activeOccluders[T.activeOccluderCount++]=e)}}};drawTile=(e,t,i)=>{for(T.drawTileQueue.pushBack(e);;){let e;do{if(e=T.drawTileQueue.pollFront(),!e)return}while(!e.update);const s=e.x,a=e.z,r=e.level,n=e.occludeLevel,h=this.levelTiles[r];if(e.visible){if(t){if(r>0){const e=this.levelTiles[r-1][s][a];if(e&&e.update)continue}if(s<=T.eyeTileX&&s>T.minDrawTileX){const t=h[s-1][a];if(t&&t.update&&(t.visible||0==(1&e.locSpans)))continue}if(s>=T.eyeTileX&&sT.minDrawTileZ){const t=h[s][a-1];if(t&&t.update&&(t.visible||0==(8&e.locSpans)))continue}if(a>=T.eyeTileZ&&aa&&(l+=6),c=T.FRONT_WALL_TYPES[l],e.backWallTypes=T.BACK_WALL_TYPES[l]),d&&(0==(d.typeA&T.DIRECTION_ALLOW_WALL_CORNER_TYPE[l])?e.checkLocSpans=0:16===d.typeA?(e.checkLocSpans=3,e.blockLocSpans=T.WALL_CORNER_TYPE_16_BLOCK_LOC_SPANS[l],e.inverseBlockLocSpans=3-e.blockLocSpans):32===d.typeA?(e.checkLocSpans=6,e.blockLocSpans=T.WALL_CORNER_TYPE_32_BLOCK_LOC_SPANS[l],e.inverseBlockLocSpans=6-e.blockLocSpans):64===d.typeA?(e.checkLocSpans=12,e.blockLocSpans=T.WALL_CORNER_TYPE_64_BLOCK_LOC_SPANS[l],e.inverseBlockLocSpans=12-e.blockLocSpans):(e.checkLocSpans=9,e.blockLocSpans=T.WALL_CORNER_TYPE_128_BLOCK_LOC_SPANS[l],e.inverseBlockLocSpans=9-e.blockLocSpans),0==(d.typeA&c)||this.wallVisible(n,s,a,d.typeA)||d.modelA?.draw(0,T.sinEyePitch,T.cosEyePitch,T.sinEyeYaw,T.cosEyeYaw,d.x-T.eyeX,d.y-T.eyeY,d.z-T.eyeZ,d.bitset),0==(d.typeB&c)||this.wallVisible(n,s,a,d.typeB)||d.modelB?.draw(0,T.sinEyePitch,T.cosEyePitch,T.sinEyeYaw,T.cosEyeYaw,d.x-T.eyeX,d.y-T.eyeY,d.z-T.eyeZ,d.bitset)),u&&!this.visible(n,s,a,u.model.maxY))if(0!=(u.type&c))u.model.draw(u.angle,T.sinEyePitch,T.cosEyePitch,T.sinEyeYaw,T.cosEyeYaw,u.x-T.eyeX,u.y-T.eyeY,u.z-T.eyeZ,u.bitset);else if(0!=(768&u.type)){const e=u.x-T.eyeX,t=u.y-T.eyeY,i=u.z-T.eyeZ,s=u.angle;let a,r;if(a=s===y.Z.NORTH||s===y.Z.EAST?-e:e,r=s===y.Z.EAST||s===y.Z.SOUTH?-i:i,0!=(256&u.type)&&ra){const a=e+T.WALL_DECORATION_OUTSET_X[s],r=i+T.WALL_DECORATION_OUTSET_Z[s];u.model.draw(512*s+1280&2047,T.sinEyePitch,T.cosEyePitch,T.sinEyeYaw,T.cosEyeYaw,a,t,r,u.bitset)}}if(o){const t=e.groundDecoration;t&&t.model?.draw(0,T.sinEyePitch,T.cosEyePitch,T.sinEyeYaw,T.cosEyeYaw,t.x-T.eyeX,t.y-T.eyeY,t.z-T.eyeZ,t.bitset);const i=e.objStack;i&&0===i.offset&&(i.bottomObj&&i.bottomObj.draw(0,T.sinEyePitch,T.cosEyePitch,T.sinEyeYaw,T.cosEyeYaw,i.x-T.eyeX,i.y-T.eyeY,i.z-T.eyeZ,i.bitset),i.middleObj&&i.middleObj.draw(0,T.sinEyePitch,T.cosEyePitch,T.sinEyeYaw,T.cosEyeYaw,i.x-T.eyeX,i.y-T.eyeY,i.z-T.eyeZ,i.bitset),i.topObj&&i.topObj.draw(0,T.sinEyePitch,T.cosEyePitch,T.sinEyeYaw,T.cosEyeYaw,i.x-T.eyeX,i.y-T.eyeY,i.z-T.eyeZ,i.bitset))}const f=e.locSpans;if(0!==f){if(sT.eyeTileX&&0!=(1&f)){const e=h[s-1][a];e&&e.update&&T.drawTileQueue.pushBack(e)}if(a>T.eyeTileZ&&0!=(8&f)){const e=h[s][a-1];e&&e.update&&T.drawTileQueue.pushBack(e)}}}if(0!==e.checkLocSpans){let t=!0;for(let i=0;it.minSceneTileX&&(r+=1),it.minSceneTileZ&&(r+=8),ss&&(s=a);const n=T.eyeTileZ-t.minSceneTileZ,o=t.maxSceneTileZ-T.eyeTileZ;t.distance=o>n?s+o:s+n}for(;;){let e=-50,t=-1;for(let i=0;ie&&(e=s.distance,t=i)}if(-1===t)break;const o=T.locBuffer[t];if(o){o.cycle=T.cycle;let e=o.model;e||(e=o.entity?.draw(i)??null),e&&!this.locVisible(n,o.minSceneTileX,o.maxSceneTileX,o.minSceneTileZ,o.maxSceneTileZ,e.maxY)&&e.draw(o.yaw,T.sinEyePitch,T.cosEyePitch,T.sinEyeYaw,T.cosEyeYaw,o.x-T.eyeX,o.y-T.eyeY,o.z-T.eyeZ,o.bitset);for(let e=o.minSceneTileX;e<=o.maxSceneTileX;e++)for(let t=o.minSceneTileZ;t<=o.maxSceneTileZ;t++){const i=h[e][t];i&&(0!==i.checkLocSpans?T.drawTileQueue.pushBack(i):e===s&&t===a||!i.update||T.drawTileQueue.pushBack(i))}}}if(e.containsLocs)continue}if(!e.update||0!==e.checkLocSpans)continue;if(s<=T.eyeTileX&&s>T.minDrawTileX){const e=h[s-1][a];if(e&&e.update)continue}if(s>=T.eyeTileX&&sT.minDrawTileZ){const e=h[s][a-1];if(e&&e.update)continue}if(a>=T.eyeTileZ&&a=r){const r=e+T.WALL_DECORATION_INSET_X[a],n=s+T.WALL_DECORATION_INSET_Z[a];t.model.draw(512*a+256,T.sinEyePitch,T.cosEyePitch,T.sinEyeYaw,T.cosEyeYaw,r,i,n,t.bitset)}if(0!=(512&t.type)&&n<=r){const r=e+T.WALL_DECORATION_OUTSET_X[a],n=s+T.WALL_DECORATION_OUTSET_Z[a];t.model.draw(512*a+1280&2047,T.sinEyePitch,T.cosEyePitch,T.sinEyeYaw,T.cosEyeYaw,r,i,n,t.bitset)}}const i=e.wall;i&&(0==(i.typeB&e.backWallTypes)||this.wallVisible(n,s,a,i.typeB)||i.modelB?.draw(0,T.sinEyePitch,T.cosEyePitch,T.sinEyeYaw,T.cosEyeYaw,i.x-T.eyeX,i.y-T.eyeY,i.z-T.eyeZ,i.bitset),0==(i.typeA&e.backWallTypes)||this.wallVisible(n,s,a,i.typeA)||i.modelA?.draw(0,T.sinEyePitch,T.cosEyePitch,T.sinEyeYaw,T.cosEyeYaw,i.x-T.eyeX,i.y-T.eyeY,i.z-T.eyeZ,i.bitset))}if(rT.eyeTileX){const e=h[s-1][a];e&&e.update&&T.drawTileQueue.pushBack(e)}if(a>T.eyeTileZ){const e=h[s][a-1];e&&e.update&&T.drawTileQueue.pushBack(e)}}};drawTileUnderlay=(e,t,i,a,r,n,h,o)=>{let l,c,d,u,f=l=(i<<7)-T.eyeX,m=c=(a<<7)-T.eyeZ,g=d=f+128,y=u=m+128,C=this.levelHeightmaps[t][i][a]-T.eyeY,w=this.levelHeightmaps[t][i+1][a]-T.eyeY,S=this.levelHeightmaps[t][i+1][a+1]-T.eyeY,Z=this.levelHeightmaps[t][i][a+1]-T.eyeY,A=m*h+f*o>>16;if(m=m*o-f*h>>16,f=A,A=C*n-m*r>>16,m=C*r+m*n>>16,C=A,m<50)return;if(A=c*h+g*o>>16,c=c*o-g*h>>16,g=A,A=w*n-c*r>>16,c=w*r+c*n>>16,w=A,c<50)return;if(A=y*h+d*o>>16,y=y*o-d*h>>16,d=A,A=S*n-y*r>>16,y=S*r+y*n>>16,S=A,y<50)return;if(A=u*h+l*o>>16,u=u*o-l*h>>16,l=A,A=Z*n-u*r>>16,u=Z*r+u*n>>16,Z=A,u<50)return;const v=s.Z.centerX+((f<<9)/m|0),I=s.Z.centerY+((C<<9)/m|0),O=s.Z.centerX+((g<<9)/c|0),b=s.Z.centerY+((w<<9)/c|0),L=s.Z.centerX+((d<<9)/y|0),E=s.Z.centerY+((S<<9)/y|0),x=s.Z.centerX+((l<<9)/u|0),_=s.Z.centerY+((Z<<9)/u|0);if(s.Z.alpha=0,(L-x)*(b-_)-(E-_)*(O-x)>0)if(s.Z.clipX=L<0||x<0||O<0||L>p.Z.boundX||x>p.Z.boundX||O>p.Z.boundX,T.takingInput&&this.pointInsideTriangle(T.mouseX,T.mouseY,E,_,b,L,x,O)&&(T.clickTileX=i,T.clickTileZ=a),-1===e.textureId)12345678!==e.northeastColor&&s.Z.fillGouraudTriangle(L,x,O,E,_,b,e.northeastColor,e.northwestColor,e.southeastColor);else if(T.lowMemory){const t=T.TEXTURE_HSL[e.textureId];s.Z.fillGouraudTriangle(L,x,O,E,_,b,this.mulLightness(t,e.northeastColor),this.mulLightness(t,e.northwestColor),this.mulLightness(t,e.southeastColor))}else e.flat?s.Z.fillTexturedTriangle(L,x,O,E,_,b,e.northeastColor,e.northwestColor,e.southeastColor,f,C,m,g,l,w,Z,c,u,e.textureId):s.Z.fillTexturedTriangle(L,x,O,E,_,b,e.northeastColor,e.northwestColor,e.southeastColor,d,S,y,l,g,Z,w,u,c,e.textureId);if(!((v-O)*(_-b)-(I-b)*(x-O)<=0))if(s.Z.clipX=v<0||O<0||x<0||v>p.Z.boundX||O>p.Z.boundX||x>p.Z.boundX,T.takingInput&&this.pointInsideTriangle(T.mouseX,T.mouseY,I,b,_,v,O,x)&&(T.clickTileX=i,T.clickTileZ=a),-1!==e.textureId){if(!T.lowMemory)return void s.Z.fillTexturedTriangle(v,O,x,I,b,_,e.southwestColor,e.southeastColor,e.northwestColor,f,C,m,g,l,w,Z,c,u,e.textureId);const t=T.TEXTURE_HSL[e.textureId];s.Z.fillGouraudTriangle(v,O,x,I,b,_,this.mulLightness(t,e.southwestColor),this.mulLightness(t,e.southeastColor),this.mulLightness(t,e.northwestColor))}else 12345678!==e.southwestColor&&s.Z.fillGouraudTriangle(v,O,x,I,b,_,e.southwestColor,e.southeastColor,e.northwestColor)};drawTileOverlay=(e,t,i,a,r,n,h)=>{let o=i.vertexX.length;for(let e=0;e>16;if(l=l*h-t*n>>16,t=c,c=o*r-l*a>>16,l=o*a+l*r>>16,o=c,l<50)return;i.triangleTextureIds&&(m.Z.tmpViewspaceX[e]=t,m.Z.tmpViewspaceY[e]=o,m.Z.tmpViewspaceZ[e]=l),m.Z.tmpScreenX[e]=s.Z.centerX+((t<<9)/l|0),m.Z.tmpScreenY[e]=s.Z.centerY+((o<<9)/l|0)}s.Z.alpha=0,o=i.triangleVertexA.length;for(let a=0;a0)if(s.Z.clipX=o<0||l<0||c<0||o>p.Z.boundX||l>p.Z.boundX||c>p.Z.boundX,T.takingInput&&this.pointInsideTriangle(T.mouseX,T.mouseY,d,u,f,o,l,c)&&(T.clickTileX=e,T.clickTileZ=t),i.triangleTextureIds&&-1!==i.triangleTextureIds[a])if(T.lowMemory){const e=T.TEXTURE_HSL[i.triangleTextureIds[a]];s.Z.fillGouraudTriangle(o,l,c,d,u,f,this.mulLightness(e,i.triangleColorA[a]),this.mulLightness(e,i.triangleColorB[a]),this.mulLightness(e,i.triangleColorC[a]))}else i.flat?s.Z.fillTexturedTriangle(o,l,c,d,u,f,i.triangleColorA[a],i.triangleColorB[a],i.triangleColorC[a],m.Z.tmpViewspaceX[0],m.Z.tmpViewspaceY[0],m.Z.tmpViewspaceZ[0],m.Z.tmpViewspaceX[1],m.Z.tmpViewspaceX[3],m.Z.tmpViewspaceY[1],m.Z.tmpViewspaceY[3],m.Z.tmpViewspaceZ[1],m.Z.tmpViewspaceZ[3],i.triangleTextureIds[a]):s.Z.fillTexturedTriangle(o,l,c,d,u,f,i.triangleColorA[a],i.triangleColorB[a],i.triangleColorC[a],m.Z.tmpViewspaceX[r],m.Z.tmpViewspaceY[r],m.Z.tmpViewspaceZ[r],m.Z.tmpViewspaceX[n],m.Z.tmpViewspaceX[h],m.Z.tmpViewspaceY[n],m.Z.tmpViewspaceY[h],m.Z.tmpViewspaceZ[n],m.Z.tmpViewspaceZ[h],i.triangleTextureIds[a]);else 12345678!==i.triangleColorA[a]&&s.Z.fillGouraudTriangle(o,l,c,d,u,f,i.triangleColorA[a],i.triangleColorB[a],i.triangleColorC[a])}};tileVisible=(e,t,i)=>{const s=this.levelTileOcclusionCycles[e][t][i];if(s===-T.cycle)return!1;if(s===T.cycle)return!0;{const s=t<<7,a=i<<7;return this.occluded(s+1,this.levelHeightmaps[e][t][i],a+1)&&this.occluded(s+128-1,this.levelHeightmaps[e][t+1][i],a+1)&&this.occluded(s+128-1,this.levelHeightmaps[e][t+1][i+1],a+128-1)&&this.occluded(s+1,this.levelHeightmaps[e][t][i+1],a+128-1)?(this.levelTileOcclusionCycles[e][t][i]=T.cycle,!0):(this.levelTileOcclusionCycles[e][t][i]=-T.cycle,!1)}};wallVisible=(e,t,i,s)=>{if(!this.tileVisible(e,t,i))return!1;const a=t<<7,r=i<<7,n=this.levelHeightmaps[e][t][i]-1,h=n-120,o=n-230,l=n-238;if(s<16){if(1===s){if(a>T.eyeX){if(!this.occluded(a,n,r))return!1;if(!this.occluded(a,n,r+128))return!1}if(e>0){if(!this.occluded(a,h,r))return!1;if(!this.occluded(a,h,r+128))return!1}return!!this.occluded(a,o,r)&&this.occluded(a,o,r+128)}if(2===s){if(r0){if(!this.occluded(a,h,r+128))return!1;if(!this.occluded(a+128,h,r+128))return!1}return!!this.occluded(a,o,r+128)&&this.occluded(a+128,o,r+128)}if(4===s){if(a0){if(!this.occluded(a+128,h,r))return!1;if(!this.occluded(a+128,h,r+128))return!1}return!!this.occluded(a+128,o,r)&&this.occluded(a+128,o,r+128)}if(8===s){if(r>T.eyeZ){if(!this.occluded(a,n,r))return!1;if(!this.occluded(a+128,n,r))return!1}if(e>0){if(!this.occluded(a,h,r))return!1;if(!this.occluded(a+128,h,r))return!1}return!!this.occluded(a,o,r)&&this.occluded(a+128,o,r)}}return!!this.occluded(a+64,l,r+64)&&(16===s?this.occluded(a,o,r+128):32===s?this.occluded(a+128,o,r+128):64===s?this.occluded(a+128,o,r):128===s?this.occluded(a,o,r):(console.warn("Warning unsupported wall type!"),!0))};visible=(e,t,i,s)=>{if(this.tileVisible(e,t,i)){const a=t<<7,r=i<<7;return this.occluded(a+1,this.levelHeightmaps[e][t][i]-s,r+1)&&this.occluded(a+128-1,this.levelHeightmaps[e][t+1][i]-s,r+1)&&this.occluded(a+128-1,this.levelHeightmaps[e][t+1][i+1]-s,r+128-1)&&this.occluded(a+1,this.levelHeightmaps[e][t][i+1]-s,r+128-1)}return!1};locVisible=(e,t,i,s,a,r)=>{let n,h;if(t!==i||s!==a){for(n=t;n<=i;n++)for(h=s;h<=a;h++)if(this.levelTileOcclusionCycles[e][n][h]===-T.cycle)return!1;h=1+(t<<7);const o=2+(s<<7),l=this.levelHeightmaps[e][t][s]-r;if(!this.occluded(h,l,o))return!1;const c=(i<<7)-1;if(!this.occluded(c,l,o))return!1;const d=(a<<7)-1;return!!this.occluded(h,l,d)&&this.occluded(c,l,d)}return!!this.tileVisible(e,t,s)&&(n=t<<7,h=s<<7,this.occluded(n+1,this.levelHeightmaps[e][t][s]-r,h+1)&&this.occluded(n+128-1,this.levelHeightmaps[e][t+1][s]-r,h+1)&&this.occluded(n+128-1,this.levelHeightmaps[e][t+1][s+1]-r,h+128-1)&&this.occluded(n+1,this.levelHeightmaps[e][t][s+1]-r,h+128-1))};occluded=(e,t,i)=>{for(let s=0;s0){const e=a.minZ+(a.minDeltaZ*s>>8),r=a.maxZ+(a.maxDeltaZ*s>>8),n=a.minY+(a.minDeltaY*s>>8),h=a.maxY+(a.maxDeltaY*s>>8);if(i>=e&&i<=r&&t>=n&&t<=h)return!0}}else if(2===a.mode){const s=e-a.minX;if(s>0){const e=a.minZ+(a.minDeltaZ*s>>8),r=a.maxZ+(a.maxDeltaZ*s>>8),n=a.minY+(a.minDeltaY*s>>8),h=a.maxY+(a.maxDeltaY*s>>8);if(i>=e&&i<=r&&t>=n&&t<=h)return!0}}else if(3===a.mode){const s=a.minZ-i;if(s>0){const i=a.minX+(a.minDeltaX*s>>8),r=a.maxX+(a.maxDeltaX*s>>8),n=a.minY+(a.minDeltaY*s>>8),h=a.maxY+(a.maxDeltaY*s>>8);if(e>=i&&e<=r&&t>=n&&t<=h)return!0}}else if(4===a.mode){const s=i-a.minZ;if(s>0){const i=a.minX+(a.minDeltaX*s>>8),r=a.maxX+(a.maxDeltaX*s>>8),n=a.minY+(a.minDeltaY*s>>8),h=a.maxY+(a.maxDeltaY*s>>8);if(e>=i&&e<=r&&t>=n&&t<=h)return!0}}else if(5===a.mode){const s=t-a.minY;if(s>0){const t=a.minX+(a.minDeltaX*s>>8),r=a.maxX+(a.maxDeltaX*s>>8),n=a.minZ+(a.minDeltaZ*s>>8),h=a.maxZ+(a.maxDeltaZ*s>>8);if(e>=t&&e<=r&&i>=n&&i<=h)return!0}}}return!1};pointInsideTriangle=(e,t,i,s,a,r,n,h)=>{if(ti&&t>s&&t>a)return!1;if(er&&e>n&&e>h)return!1;const o=(t-s)*(h-n)-(e-n)*(a-s);return((t-i)*(n-r)-(e-r)*(s-i))*o>0&&o*((t-a)*(r-h)-(e-h)*(i-a))>0};mulLightness=(e,t)=>((t=(127-t)*(127&e)/160|0)<2?t=2:t>126&&(t=126),(65408&e)+t)}},9129:(e,t,i)=>{i.d(t,{Z:()=>a});var s=i(3064);class a extends s.Z{}},682:(e,t,i)=>{i.d(t,{Z:()=>a});var s=i(3064);class a extends s.Z{heightmapSW;heightmapSE;heightmapNE;heightmapNW;index;seq;seqFrame;seqCycle;constructor(e,t,i,s,a,r,n){super(),this.heightmapSW=t,this.heightmapSE=i,this.heightmapNE=s,this.heightmapNW=a,this.index=e,this.seq=r,n&&-1!==r.replayoff&&this.seq.delay?(this.seqFrame=Math.random()*this.seq.frameCount|0,this.seqCycle=Math.random()*this.seq.delay[this.seqFrame]|0):(this.seqFrame=-1,this.seqCycle=0)}}},1353:(e,t,i)=>{i.d(t,{Z:()=>h});var s=i(8839),a=i(9178),r=i(551),n=i(8067);class h extends s.Z{type=null;draw=()=>{if(!this.type)return null;if(-1===this.spotanimId||-1===this.spotanimFrame)return this.getSequencedModel();const e=this.getSequencedModel();if(!e)return null;const t=r.Z.instances[this.spotanimId],i=a.Z.modelShareColored(t.getModel(),!0,!t.disposeAlpha,!1);i.translate(-this.spotanimOffset,0,0),i.createLabelReferences(),t.seq&&t.seq.frames&&i.applyTransform(t.seq.frames[this.spotanimFrame]),i.labelFaces=null,i.labelVertices=null,128===t.resizeh&&128===t.resizev||i.scale(t.resizeh,t.resizev,t.resizeh),i.calculateNormals(64+t.ambient,850+t.contrast,-30,-50,-30,!0);const s=[e,i],n=a.Z.modelFromModelsBounds(s,2);return 1===this.type.size&&(n.pickable=!0),n};isVisible=()=>null!==this.type;getSequencedModel=()=>{if(!this.type)return null;if(this.primarySeqId>=0&&0===this.primarySeqDelay){const e=n.Z.instances[this.primarySeqId].frames;if(e){const t=e[this.primarySeqFrame];let i=-1;if(this.secondarySeqId>=0&&this.secondarySeqId!==this.seqStandId){const e=n.Z.instances[this.secondarySeqId].frames;e&&(i=e[this.secondarySeqFrame])}return this.type.getSequencedModel(t,i,n.Z.instances[this.primarySeqId].labelGroups)}}let e=-1;if(this.secondarySeqId>=0){const t=n.Z.instances[this.secondarySeqId].frames;t&&(e=t[this.secondarySeqFrame])}const t=this.type.getSequencedModel(e,-1,null);return t?(this.height=t.maxY,t):null}}},7973:(e,t,i)=>{i.d(t,{Z:()=>a});var s=i(3064);class a extends s.Z{index;count;constructor(e,t){super(),this.index=e,this.count=t}}},8839:(e,t,i)=>{i.d(t,{Z:()=>n});var s=i(9129),a=i(8067),r=i(9345);class n extends s.Z{x=0;z=0;yaw=0;seqStretches=!1;size=1;seqStandId=-1;seqTurnId=-1;seqWalkId=-1;seqTurnAroundId=-1;seqTurnLeftId=-1;seqTurnRightId=-1;seqRunId=-1;chat=null;chatTimer=100;chatColor=0;chatStyle=0;damage=0;damageType=0;combatCycle=-1e3;health=0;totalHealth=0;targetId=-1;targetTileX=0;targetTileZ=0;secondarySeqId=-1;secondarySeqFrame=0;secondarySeqCycle=0;primarySeqId=-1;primarySeqFrame=0;primarySeqCycle=0;primarySeqDelay=0;primarySeqLoop=0;spotanimId=-1;spotanimFrame=0;spotanimCycle=0;spotanimLastCycle=0;spotanimOffset=0;forceMoveStartSceneTileX=0;forceMoveEndSceneTileX=0;forceMoveStartSceneTileZ=0;forceMoveEndSceneTileZ=0;forceMoveEndCycle=0;forceMoveStartCycle=0;forceMoveFaceDirection=0;cycle=0;height=0;dstYaw=0;pathLength=0;pathTileX=new Int32Array(10);pathTileZ=new Int32Array(10);pathRunning=new r.to(10,!1);seqTrigger=0;lastMask=-1;lastMaskCycle=-1;lastFaceX=-1;lastFaceZ=-1;move=(e,t,i)=>{if(-1!==this.primarySeqId&&a.Z.instances[this.primarySeqId].priority<=1&&(this.primarySeqId=-1),!e){const e=t-this.pathTileX[0],s=i-this.pathTileZ[0];if(e>=-8&&e<=8&&s>=-8&&s<=8){this.pathLength<9&&this.pathLength++;for(let e=this.pathLength;e>0;e--)this.pathTileX[e]=this.pathTileX[e-1],this.pathTileZ[e]=this.pathTileZ[e-1],this.pathRunning[e]=this.pathRunning[e-1];return this.pathTileX[0]=t,this.pathTileZ[0]=i,void(this.pathRunning[0]=!1)}}this.pathLength=0,this.seqTrigger=0,this.pathTileX[0]=t,this.pathTileZ[0]=i,this.x=128*this.pathTileX[0]+64*this.size,this.z=128*this.pathTileZ[0]+64*this.size};step=(e,t)=>{let i=this.pathTileX[0],s=this.pathTileZ[0];0===t?(i--,s++):1===t?s++:2===t?(i++,s++):3===t?i--:4===t?i++:5===t?(i--,s--):6===t?s--:7===t&&(i++,s--),-1!==this.primarySeqId&&a.Z.instances[this.primarySeqId].priority<=1&&(this.primarySeqId=-1),this.pathLength<9&&this.pathLength++;for(let e=this.pathLength;e>0;e--)this.pathTileX[e]=this.pathTileX[e-1],this.pathTileZ[e]=this.pathTileZ[e-1],this.pathRunning[e]=this.pathRunning[e-1];this.pathTileX[0]=i,this.pathTileZ[0]=s,this.pathRunning[0]=e}}},4191:(e,t,i)=>{i.d(t,{Z:()=>u});var s=i(8839),a=i(9178),r=i(5542),n=i(551),h=i(8067),o=i(8809),l=i(1840),c=i(8934),d=i(9345);class u extends s.Z{static DESIGN_HAIR_COLOR=[9104,10275,7595,3610,7975,8526,918,38802,24466,10145,58654,5027,1457,16565,34991,25486];static DESIGN_BODY_COLOR=[[6798,107,10283,16,4797,7744,5799,4634,33697,22433,2983,54193],[8741,12,64030,43162,7735,8404,1701,38430,24094,10153,56621,4783,1341,16578,35003,25239],[25238,8742,12,64030,43162,7735,8404,1701,38430,24094,10153,56621,4783,1341,16578,35003],[4626,11146,6439,12,4758,10270],[4550,4537,5681,5673,5790,6806,8076,4574]];static modelCache=new r.Z(200);name=null;visible=!1;gender=0;headicons=0;appearances=new Uint16Array(12);colors=new Uint16Array(5);combatLevel=0;appearanceHashcode=0n;y=0;locStartCycle=0;locStopCycle=0;locOffsetX=0;locOffsetY=0;locOffsetZ=0;locModel=null;minTileX=0;minTileZ=0;maxTileX=0;maxTileZ=0;lowMemory=!1;draw(e){if(!this.visible)return null;let t=this.getSequencedModel();if(this.height=t.maxY,t.pickable=!0,this.lowMemory)return t;if(-1!==this.spotanimId&&-1!==this.spotanimFrame){const e=n.Z.instances[this.spotanimId],i=a.Z.modelShareColored(e.getModel(),!0,!e.disposeAlpha,!1);i.translate(-this.spotanimOffset,0,0),i.createLabelReferences(),e.seq&&e.seq.frames&&i.applyTransform(e.seq.frames[this.spotanimFrame]),i.labelFaces=null,i.labelVertices=null,128===e.resizeh&&128===e.resizev||i.scale(e.resizeh,e.resizev,e.resizeh),i.calculateNormals(e.ambient+64,e.contrast+850,-30,-50,-30,!0);const s=[t,i];t=a.Z.modelFromModelsBounds(s,2)}if(this.locModel&&(e>=this.locStopCycle&&(this.locModel=null),e>=this.locStartCycle&&ethis.visible;read=e=>{e.pos=0,this.gender=e.g1,this.headicons=e.g1;for(let t=0;t<12;t++){const i=e.g1;this.appearances[t]=0===i?0:(i<<8)+e.g1}for(let t=0;t<5;t++){let i=e.g1;(i<0||i>=u.DESIGN_BODY_COLOR[t].length)&&(i=0),this.colors[t]=i}this.seqStandId=e.g2,65535===this.seqStandId&&(this.seqStandId=-1),this.seqTurnId=e.g2,65535===this.seqTurnId&&(this.seqTurnId=-1),this.seqWalkId=e.g2,65535===this.seqWalkId&&(this.seqWalkId=-1),this.seqTurnAroundId=e.g2,65535===this.seqTurnAroundId&&(this.seqTurnAroundId=-1),this.seqTurnLeftId=e.g2,65535===this.seqTurnLeftId&&(this.seqTurnLeftId=-1),this.seqTurnRightId=e.g2,65535===this.seqTurnRightId&&(this.seqTurnRightId=-1),this.seqRunId=e.g2,65535===this.seqRunId&&(this.seqRunId=-1),this.name=c.Z.formatName(c.Z.fromBase37(e.g8)),this.combatLevel=e.g1,this.visible=!0,this.appearanceHashcode=0n;for(let e=0;e<12;e++)this.appearanceHashcode<<=0x4n,this.appearances[e]>=256&&(this.appearanceHashcode+=BigInt(this.appearances[e])-256n);this.appearances[0]>=256&&(this.appearanceHashcode+=BigInt(this.appearances[0])-256n>>4n),this.appearances[1]>=256&&(this.appearanceHashcode+=BigInt(this.appearances[1])-256n>>8n);for(let e=0;e<5;e++)this.appearanceHashcode<<=0x3n,this.appearanceHashcode+=BigInt(this.colors[e]);this.appearanceHashcode<<=0x1n,this.appearanceHashcode+=BigInt(this.gender)};getHeadModel=()=>{if(!this.visible)return null;const e=new d.to(12,null);let t=0;for(let i=0;i<12;i++){const s=this.appearances[i];if(s>=256&&s<512&&(e[t++]=o.Z.instances[s-256].getHeadModel()),s>=512){const i=l.Z.get(s-512).getHeadModel(this.gender);i&&(e[t++]=i)}}const i=a.Z.modelFromModels(e,t);for(let e=0;e<5;e++)0!==this.colors[e]&&(i.recolor(u.DESIGN_BODY_COLOR[e][0],u.DESIGN_BODY_COLOR[e][this.colors[e]]),1===e&&i.recolor(u.DESIGN_HAIR_COLOR[0],u.DESIGN_HAIR_COLOR[this.colors[e]]));return i};getSequencedModel=()=>{let e=this.appearanceHashcode,t=-1,i=-1,s=-1,r=-1;if(this.primarySeqId>=0&&0===this.primarySeqDelay){const a=h.Z.instances[this.primarySeqId];if(a.frames&&(t=a.frames[this.primarySeqFrame]),this.secondarySeqId>=0&&this.secondarySeqId!==this.seqStandId){const e=h.Z.instances[this.secondarySeqId].frames;e&&(i=e[this.secondarySeqFrame])}a.mainhand>=0&&(s=a.mainhand,e+=BigInt(s-this.appearances[5])<<8n),a.offhand>=0&&(r=a.offhand,e+=BigInt(r-this.appearances[3])<<16n)}else if(this.secondarySeqId>=0){const e=h.Z.instances[this.secondarySeqId].frames;e&&(t=e[this.secondarySeqFrame])}let n=u.modelCache?.get(e);if(!n){const t=new d.to(12,null);let i=0;for(let e=0;e<12;e++){let a=this.appearances[e];if(r>=0&&3===e&&(a=r),s>=0&&5===e&&(a=s),a>=256&&a<512){const e=o.Z.instances[a-256].getModel();e&&(t[i++]=e)}if(a>=512){const e=l.Z.get(a-512).getWornModel(this.gender);e&&(t[i++]=e)}}n=a.Z.modelFromModels(t,i);for(let e=0;e<5;e++)0!==this.colors[e]&&(n.recolor(u.DESIGN_BODY_COLOR[e][0],u.DESIGN_BODY_COLOR[e][this.colors[e]]),1===e&&n.recolor(u.DESIGN_HAIR_COLOR[0],u.DESIGN_HAIR_COLOR[this.colors[e]]));n.createLabelReferences(),n.calculateNormals(64,850,-30,-50,-30,!0),u.modelCache?.put(e,n)}if(this.lowMemory)return n;const c=a.Z.modelShareAlpha(n,!0);return-1!==t&&-1!==i?c.applyTransforms(t,i,h.Z.instances[this.primarySeqId].labelGroups):-1!==t&&c.applyTransform(t),c.calculateBoundsCylinder(),c.labelFaces=null,c.labelVertices=null,c}}},1810:(e,t,i)=>{i.d(t,{Z:()=>n});var s=i(551),a=i(9129),r=i(9178);class n extends a.Z{spotanim;level;srcX;srcZ;srcY;offsetY;startCycle;lastCycle;peakPitch;arc;target;mobile=!1;x=0;z=0;y=0;velocityX=0;velocityZ=0;velocity=0;velocityY=0;accelerationY=0;yaw=0;pitch=0;seqFrame=0;seqCycle=0;constructor(e,t,i,a,r,n,h,o,l,c,d){super(),this.spotanim=s.Z.instances[e],this.level=t,this.srcX=i,this.srcZ=r,this.srcY=a,this.startCycle=n,this.lastCycle=h,this.peakPitch=o,this.arc=l,this.target=c,this.offsetY=d}updateVelocity=(e,t,i,s)=>{if(!this.mobile){const t=e-this.srcX,s=i-this.srcZ,a=Math.sqrt(t*t+s*s);this.x=this.srcX+t*this.arc/a,this.z=this.srcZ+s*this.arc/a,this.y=this.srcY}const a=this.lastCycle+1-s;this.velocityX=(e-this.x)/a,this.velocityZ=(i-this.z)/a,this.velocity=Math.sqrt(this.velocityX*this.velocityX+this.velocityZ*this.velocityZ),this.mobile||(this.velocityY=-this.velocity*Math.tan(.02454369*this.peakPitch)),this.accelerationY=2*(t-this.y-this.velocityY*a)/(a*a)};update=e=>{if(this.mobile=!0,this.x+=this.velocityX*e,this.z+=this.velocityZ*e,this.y+=this.velocityY*e+.5*this.accelerationY*e*e,this.velocityY+=this.accelerationY*e,this.yaw=2047&(325.949*Math.atan2(this.velocityX,this.velocityZ)+1024|0),this.pitch=2047&(325.949*Math.atan2(this.velocityY,this.velocity)|0),this.spotanim.seq&&this.spotanim.seq.delay)for(this.seqCycle+=e;this.seqCycle>this.spotanim.seq.delay[this.seqFrame];)this.seqCycle-=this.spotanim.seq.delay[this.seqFrame]+1,this.seqFrame++,this.seqFrame>=this.spotanim.seq.frameCount&&(this.seqFrame=0)};draw=()=>{const e=this.spotanim.getModel(),t=r.Z.modelShareColored(e,!0,!this.spotanim.disposeAlpha,!1);return this.spotanim.seq&&this.spotanim.seq.frames&&(t.createLabelReferences(),t.applyTransform(this.spotanim.seq.frames[this.seqFrame]),t.labelFaces=null,t.labelVertices=null),128===this.spotanim.resizeh&&128===this.spotanim.resizev||t.scale(this.spotanim.resizeh,this.spotanim.resizev,this.spotanim.resizeh),t.rotateX(this.pitch),t.calculateNormals(64+this.spotanim.ambient,850+this.spotanim.contrast,-30,-50,-30,!0),t}}},5659:(e,t,i)=>{i.d(t,{Z:()=>n});var s=i(9129),a=i(551),r=i(9178);class n extends s.Z{type;level;x;z;y;startCycle;seqComplete=!1;seqFrame=0;seqCycle=0;constructor(e,t,i,s,r,n,h){super(),this.type=a.Z.instances[e],this.level=t,this.x=i,this.z=s,this.y=r,this.startCycle=n+h}update=e=>{if(this.type.seq&&this.type.seq.delay)for(this.seqCycle+=e;this.seqCycle>this.type.seq.delay[this.seqFrame];)this.seqCycle-=this.type.seq.delay[this.seqFrame]+1,this.seqFrame++,this.seqFrame>=this.type.seq.frameCount&&(this.seqFrame=0,this.seqComplete=!0)};draw=()=>{const e=this.type.getModel(),t=r.Z.modelShareColored(e,!0,!this.type.disposeAlpha,!1);return!this.seqComplete&&this.type.seq&&this.type.seq.frames&&(t.createLabelReferences(),t.applyTransform(this.type.seq.frames[this.seqFrame]),t.labelFaces=null,t.labelVertices=null),128===this.type.resizeh&&128===this.type.resizev||t.scale(this.type.resizeh,this.type.resizev,this.type.resizeh),0!==this.type.orientation&&(90===this.type.orientation?t.rotateY90():180===this.type.orientation?(t.rotateY90(),t.rotateY90()):270===this.type.orientation&&(t.rotateY90(),t.rotateY90(),t.rotateY90())),t.calculateNormals(64+this.type.ambient,850+this.type.contrast,-30,-50,-30,!0),t}}},4155:(e,t,i)=>{i.d(t,{Z:()=>s});class s{y;x;z;model;bitset;info;constructor(e,t,i,s,a,r){this.y=e,this.x=t,this.z=i,this.model=s,this.bitset=a,this.info=r}}},6539:(e,t,i)=>{i.d(t,{Z:()=>s});class s{level;y;x;z;model;entity;yaw;minSceneTileX;maxSceneTileX;minSceneTileZ;maxSceneTileZ;bitset;info;distance=0;cycle=0;constructor(e,t,i,s,a,r,n,h,o,l,c,d,u){this.level=e,this.y=t,this.x=i,this.z=s,this.model=a,this.entity=r,this.yaw=n,this.minSceneTileX=h,this.maxSceneTileX=o,this.minSceneTileZ=l,this.maxSceneTileZ=c,this.bitset=d,this.info=u}}},7396:(e,t,i)=>{i.d(t,{Z:()=>a});var s=i(3064);class a extends s.Z{plane;layer;x;z;locIndex;angle;shape;lastCycle;constructor(e,t,i,s,a,r,n,h){super(),this.plane=e,this.layer=t,this.x=i,this.z=s,this.locIndex=a,this.angle=r,this.shape=n,this.lastCycle=h}}},6150:(e,t,i)=>{i.d(t,{Z:()=>a});var s=i(3064);class a extends s.Z{plane;layer;x;z;locIndex;angle;shape;lastLocIndex;lastAngle;lastShape;constructor(e,t,i,s,a,r,n,h,o,l){super(),this.plane=e,this.layer=t,this.x=i,this.z=s,this.locIndex=a,this.angle=r,this.shape=n,this.lastLocIndex=h,this.lastAngle=o,this.lastShape=l}}},6711:(e,t,i)=>{i.d(t,{Z:()=>s});class s{y;x;z;topObj;middleObj;bottomObj;bitset;offset;constructor(e,t,i,s,a,r,n,h){this.y=e,this.x=t,this.z=i,this.topObj=s,this.middleObj=a,this.bottomObj=r,this.bitset=n,this.offset=h}}},4138:(e,t,i)=>{i.d(t,{Z:()=>s});class s{minTileX;maxTileX;minTileZ;maxTileZ;type;minX;maxX;minZ;maxZ;minY;maxY;mode=0;minDeltaX=0;maxDeltaX=0;minDeltaZ=0;maxDeltaZ=0;minDeltaY=0;maxDeltaY=0;constructor(e,t,i,s,a,r,n,h,o,l,c){this.minTileX=e,this.maxTileX=t,this.minTileZ=i,this.maxTileZ=s,this.type=a,this.minX=r,this.maxX=n,this.minZ=h,this.maxZ=o,this.minY=l,this.maxY=c}}},220:(e,t,i)=>{i.d(t,{Z:()=>r});var s=i(3064),a=i(9345);class r extends s.Z{level;x;z;occludeLevel;locs;locSpan;underlay=null;overlay=null;wall=null;wallDecoration=null;groundDecoration=null;objStack=null;bridge=null;locCount=0;locSpans=0;drawLevel=0;visible=!1;update=!1;containsLocs=!1;checkLocSpans=0;blockLocSpans=0;inverseBlockLocSpans=0;backWallTypes=0;constructor(e,t,i){super(),this.occludeLevel=this.level=e,this.x=t,this.z=i,this.locs=new a.to(5,null),this.locSpan=new Int32Array(5)}}},8570:(e,t,i)=>{i.d(t,{Z:()=>s});class s{static tmpScreenX=new Int32Array(6);static tmpScreenY=new Int32Array(6);static tmpViewspaceX=new Int32Array(6);static tmpViewspaceY=new Int32Array(6);static tmpViewspaceZ=new Int32Array(6);static SHAPE_POINTS=[Int32Array.of(1,3,5,7),Int32Array.of(1,3,5,7),Int32Array.of(1,3,5,7),Int32Array.of(1,3,5,7,6),Int32Array.of(1,3,5,7,6),Int32Array.of(1,3,5,7,6),Int32Array.of(1,3,5,7,6),Int32Array.of(1,3,5,7,2,6),Int32Array.of(1,3,5,7,2,8),Int32Array.of(1,3,5,7,2,8),Int32Array.of(1,3,5,7,11,12),Int32Array.of(1,3,5,7,11,12),Int32Array.of(1,3,5,7,13,14)];static SHAPE_PATHS=[Int32Array.of(0,1,2,3,0,0,1,3),Int32Array.of(1,1,2,3,1,0,1,3),Int32Array.of(0,1,2,3,1,0,1,3),Int32Array.of(0,0,1,2,0,0,2,4,1,0,4,3),Int32Array.of(0,0,1,4,0,0,4,3,1,1,2,4),Int32Array.of(0,0,4,3,1,0,1,2,1,0,2,4),Int32Array.of(0,1,2,4,1,0,1,4,1,0,4,3),Int32Array.of(0,4,1,2,0,4,2,5,1,0,4,5,1,0,5,3),Int32Array.of(0,4,1,2,0,4,2,3,0,4,3,5,1,0,4,5),Int32Array.of(0,0,4,5,1,4,1,2,1,4,2,3,1,4,3,5),Int32Array.of(0,0,1,5,0,1,4,5,0,1,2,4,1,0,5,3,1,5,4,3,1,4,2,3),Int32Array.of(1,0,1,5,1,1,4,5,1,1,2,4,0,0,5,3,0,5,4,3,0,4,2,3),Int32Array.of(1,0,5,4,1,0,1,5,0,0,4,3,0,4,5,3,0,5,2,3,0,1,2,5)];static FULL_SQUARE=128;static HALF_SQUARE=this.FULL_SQUARE/2|0;static CORNER_SMALL=this.FULL_SQUARE/4|0;static CORNER_BIG=3*this.FULL_SQUARE/4|0;vertexX;vertexY;vertexZ;triangleColorA;triangleColorB;triangleColorC;triangleVertexA;triangleVertexB;triangleVertexC;triangleTextureIds;flat;shape;rotation;backgroundRgb;foregroundRgb;constructor(e,t,i,a,r,n,h,o,l,c,d,u,f,p,m,g,y,C,T){this.flat=!(y!==a||y!==p||y!==o),this.shape=t,this.rotation=n,this.backgroundRgb=f,this.foregroundRgb=l;const w=s.SHAPE_POINTS[t],S=w.length;this.vertexX=new Int32Array(S),this.vertexY=new Int32Array(S),this.vertexZ=new Int32Array(S);const Z=new Int32Array(S),A=new Int32Array(S),v=e*s.FULL_SQUARE,I=C*s.FULL_SQUARE;for(let e=0;e8&&S<=12&&(S=9+(S-n-9&3)),S>12&&S<=16&&(S=13+(S-n-13&3)),1===S?(t=v,l=I,d=y,f=h,C=c):2===S?(t=v+s.HALF_SQUARE,l=I,d=y+a>>1,f=h+T>>1,C=c+i>>1):3===S?(t=v+s.FULL_SQUARE,l=I,d=a,f=T,C=i):4===S?(t=v+s.FULL_SQUARE,l=I+s.HALF_SQUARE,d=a+p>>1,f=T+r>>1,C=i+m>>1):5===S?(t=v+s.FULL_SQUARE,l=I+s.FULL_SQUARE,d=p,f=r,C=m):6===S?(t=v+s.HALF_SQUARE,l=I+s.FULL_SQUARE,d=p+o>>1,f=r+g>>1,C=m+u>>1):7===S?(t=v,l=I+s.FULL_SQUARE,d=o,f=g,C=u):8===S?(t=v,l=I+s.HALF_SQUARE,d=o+y>>1,f=g+h>>1,C=u+c>>1):9===S?(t=v+s.HALF_SQUARE,l=I+s.CORNER_SMALL,d=y+a>>1,f=h+T>>1,C=c+i>>1):10===S?(t=v+s.CORNER_BIG,l=I+s.HALF_SQUARE,d=a+p>>1,f=T+r>>1,C=i+m>>1):11===S?(t=v+s.HALF_SQUARE,l=I+s.CORNER_BIG,d=p+o>>1,f=r+g>>1,C=m+u>>1):12===S?(t=v+s.CORNER_SMALL,l=I+s.HALF_SQUARE,d=o+y>>1,f=g+h>>1,C=u+c>>1):13===S?(t=v+s.CORNER_SMALL,l=I+s.CORNER_SMALL,d=y,f=h,C=c):14===S?(t=v+s.CORNER_BIG,l=I+s.CORNER_SMALL,d=a,f=T,C=i):15===S?(t=v+s.CORNER_BIG,l=I+s.CORNER_BIG,d=p,f=r,C=m):(t=v+s.CORNER_SMALL,l=I+s.CORNER_BIG,d=o,f=g,C=u),this.vertexX[e]=t,this.vertexY[e]=d,this.vertexZ[e]=l,Z[e]=f,A[e]=C}const O=s.SHAPE_PATHS[t],b=O.length/4|0;this.triangleVertexA=new Int32Array(b),this.triangleVertexB=new Int32Array(b),this.triangleVertexC=new Int32Array(b),this.triangleColorA=new Int32Array(b),this.triangleColorB=new Int32Array(b),this.triangleColorC=new Int32Array(b),this.triangleTextureIds=-1!==d?new Int32Array(b):null;let L=0;for(let e=0;e{var s;i.d(t,{Z:()=>a}),function(e){e[e.PLAIN=0]="PLAIN",e[e.DIAGONAL=1]="DIAGONAL",e[e.LEFT_SEMI_DIAGONAL_SMALL=2]="LEFT_SEMI_DIAGONAL_SMALL",e[e.RIGHT_SEMI_DIAGONAL_SMALL=3]="RIGHT_SEMI_DIAGONAL_SMALL",e[e.LEFT_SEMI_DIAGONAL_BIG=4]="LEFT_SEMI_DIAGONAL_BIG",e[e.RIGHT_SEMI_DIAGONAL_BIG=5]="RIGHT_SEMI_DIAGONAL_BIG",e[e.HALF_SQUARE=6]="HALF_SQUARE",e[e.CORNER_SMALL=7]="CORNER_SMALL",e[e.CORNER_BIG=8]="CORNER_BIG",e[e.FAN_SMALL=9]="FAN_SMALL",e[e.FAN_BIG=10]="FAN_BIG",e[e.TRAPEZIUM=11]="TRAPEZIUM"}(s||(s={}));const a=s},9865:(e,t,i)=>{i.d(t,{Z:()=>s});class s{southwestColor;southeastColor;northeastColor;northwestColor;textureId;color;flat;constructor(e,t,i,s,a,r,n){this.southwestColor=e,this.southeastColor=t,this.northeastColor=i,this.northwestColor=s,this.textureId=a,this.color=r,this.flat=n}}},3806:(e,t,i)=>{i.d(t,{Z:()=>s});class s{y;x;z;typeA;typeB;modelA;modelB;bitset;info;constructor(e,t,i,s,a,r,n,h,o){this.y=e,this.x=t,this.z=i,this.typeA=s,this.typeB=a,this.modelA=r,this.modelB=n,this.bitset=h,this.info=o}}},9118:(e,t,i)=>{i.d(t,{Z:()=>s});class s{y;x;z;type;angle;model;bitset;info;constructor(e,t,i,s,a,r,n,h){this.y=e,this.x=t,this.z=i,this.type=s,this.angle=a,this.model=r,this.bitset=n,this.info=h}}},3832:(e,t,i)=>{i.d(t,{Z:()=>a});var s=i(3064);class a{size;nodes;constructor(e){this.size=e,this.nodes=[];for(let t=0;t{const t=this.nodes[Number(e&BigInt(this.size-1))];if(!t.prev)return null;for(let i=t.prev;i!==t;i=i.prev)if(i&&i.id===e)return i;return null};put=(e,t)=>{t.next&&t.unlink();const i=this.nodes[Number(e&BigInt(this.size-1))];t.next=i.next,t.prev=i,t.next&&(t.next.prev=t),t.prev.next=t,t.id=e}}},6327:(e,t,i)=>{i.d(t,{Z:()=>a});var s=i(3064);class a extends s.Z{nextHashable;prevHashable;constructor(){super(),this.nextHashable=this,this.prevHashable=this}uncache=()=>{this.prevHashable&&this.nextHashable&&(this.prevHashable.nextHashable=this.nextHashable,this.nextHashable.prevHashable=this.prevHashable,this.nextHashable=null,this.prevHashable=null)}}},8934:(e,t,i)=>{i.d(t,{Z:()=>s});class s{static BASE37_LOOKUP=["_","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"];static toBase37=e=>{e=e.trim();let t=0n;for(let i=0;i=65&&s<=90?t+=BigInt(s+1-65):s>=97&&s<=122?t+=BigInt(s+1-97):s>=48&&s<=57&&(t+=BigInt(s+27-48))}return t};static fromBase37=e=>{if(e<0n||e>=6582952005840035281n)return"invalid_name";if(e%37n===0n)return"invalid_name";let t=0;const i=Array(12);for(;0n!==e;){const s=e;e/=37n,i[11-t++]=this.BASE37_LOOKUP[Number(s-37n*e)]}return i.slice(12-t).join("")};static toSentenceCase=e=>{const t=[...e.toLowerCase()];let i=!0;for(let e=0;e="a"&&s<="z"&&(t[e]=s.toUpperCase(),i=!1),"."!==s&&"!"!==s||(i=!0)}return t.join("")};static toAsterisks=e=>{let t="";for(let i=0;i(e>>24&255)+"."+(e>>16&255)+"."+(e>>8&255)+"."+(255&e);static formatName=e=>{if(0===e.length)return e;const t=[...e];for(let e=0;e="a"&&t[e+1]<="z"&&(t[e+1]=String.fromCharCode(t[e+1].charCodeAt(0)+"A".charCodeAt(0)-97)));return t[0]>="a"&&t[0]<="z"&&(t[0]=String.fromCharCode(t[0].charCodeAt(0)+"A".charCodeAt(0)-97)),t.join("")};static hashCode=e=>{const t=e.toUpperCase();let i=0n;for(let e=0;e>56n)&0xffffffffffffffn;return i}}},9080:(e,t,i)=>{i.d(t,{Z:()=>a});var s=i(3064);class a{head;peeked=null;constructor(){const e=new s.Z;e.prev=e,e.next=e,this.head=e}pushBack=e=>{e.next&&e.unlink(),e.next=this.head.next,e.prev=this.head,e.next&&(e.next.prev=e),e.prev.next=e};pushFront=e=>{e.next&&e.unlink(),e.next=this.head,e.prev=this.head.prev,e.next.prev=e,e.prev&&(e.prev.next=e)};pollFront=()=>{const e=this.head.prev;return e===this.head?null:(e?.unlink(),e)};peekFront=()=>{const e=this.head.prev;return e===this.head?(this.peeked=null,null):(this.peeked=e?.prev||null,e)};peekBack=()=>{const e=this.head.next;return e===this.head?(this.peeked=null,null):(this.peeked=e?.next||null,e)};prev=()=>{const e=this.peeked;return e===this.head?(this.peeked=null,null):(this.peeked=e?.prev||null,e)};next=()=>{const e=this.peeked;return e===this.head?(this.peeked=null,null):(this.peeked=e?.next||null,e)};clear=()=>{for(;;){const e=this.head.prev;if(e===this.head)return;e?.unlink()}}}},3064:(e,t,i)=>{i.d(t,{Z:()=>s});class s{id;prev;next;constructor(){this.id=0n,this.prev=this,this.next=this}unlink=()=>{this.next&&this.prev&&(this.next.prev=this.prev,this.prev.next=this.next,this.prev=null,this.next=null)}}},5542:(e,t,i)=>{i.d(t,{Z:()=>r});var s=i(8329),a=i(3832);class r{capacity;hashtable;history;available;constructor(e){this.capacity=e,this.available=e,this.hashtable=new a.Z(1024),this.history=new s.Z}get=e=>{const t=this.hashtable.get(e);return t&&this.history.push(t),t};put=(e,t)=>{if(0===this.available){const e=this.history.pop();e?.unlink(),e?.uncache()}else this.available--;this.hashtable.put(e,t),this.history.push(t)};clear=()=>{const e=this.history.pop();e?(e.unlink(),e.uncache()):this.available=this.capacity}}},8329:(e,t,i)=>{i.d(t,{Z:()=>a});var s=i(6327);class a{head;constructor(){this.head=new s.Z}push=e=>{e.prevHashable&&e.uncache(),e.prevHashable=this.head.prevHashable,e.nextHashable=this.head,e.prevHashable&&(e.prevHashable.nextHashable=e),e.nextHashable.prevHashable=e};pop=()=>{const e=this.head.nextHashable;return e===this.head?null:(e?.uncache(),e)}}},6121:(e,t,i)=>{i.d(t,{E1:()=>a,Ew:()=>n,JQ:()=>s,nS:()=>r,tw:()=>h});const s=document.getElementById("canvas"),a=s.getContext("2d",{willReadFrequently:!0}),r=document.createElement("canvas"),n=document.createElement("img"),h=r.getContext("2d",{willReadFrequently:!0})},312:(e,t,i)=>{i.d(t,{Z:()=>s});class s{static RED=16711680;static GREEN=65280;static BLUE=255;static YELLOW=16776960;static CYAN=65535;static MAGENTA=16711935;static WHITE=16777215;static BLACK=0;static LIGHTRED=16748608;static DARKRED=8388608;static DARKBLUE=128;static ORANGE1=16756736;static ORANGE2=16740352;static ORANGE3=16723968;static GREEN1=12648192;static GREEN2=8453888;static GREEN3=4259584;static PROGRESS_RED=9179409;static OPTIONS_MENU=6116423;static SCROLLBAR_TRACK=2301979;static SCROLLBAR_GRIP_FOREGROUND=5063219;static SCROLLBAR_GRIP_HIGHLIGHT=7759444;static SCROLLBAR_GRIP_LOWLIGHT=3353893;static TRADE_MESSAGE=8388736;static DUEL_MESSAGE=13350793;static CHAT_COLORS=Int32Array.of(s.YELLOW,s.RED,s.GREEN,s.CYAN,s.MAGENTA,s.WHITE)}},2991:(e,t,i)=>{i.d(t,{Z:()=>a});var s=i(6327);class a extends s.Z{static pixels=new Int32Array;static width2d=0;static height2d=0;static top=0;static bottom=0;static left=0;static right=0;static boundX=0;static centerX2d=0;static centerY2d=0;static bind=(e,t,i)=>{this.pixels=e,this.width2d=t,this.height2d=i,this.setBounds(0,0,t,i)};static resetBounds=()=>{this.left=0,this.top=0,this.right=this.width2d,this.bottom=this.height2d,this.boundX=this.right-1,this.centerX2d=this.right/2|0};static setBounds=(e,t,i,s)=>{e<0&&(e=0),t<0&&(t=0),i>this.width2d&&(i=this.width2d),s>this.height2d&&(s=this.height2d),this.top=t,this.bottom=s,this.left=e,this.right=i,this.boundX=this.right-1,this.centerX2d=this.right/2|0,this.centerY2d=this.bottom/2|0};static clear=()=>{const e=this.width2d*this.height2d;for(let t=0;t{this.drawHorizontalLine(e,t,a,i),this.drawHorizontalLine(e,t+s-1,a,i),this.drawVerticalLine(e,t,a,s),this.drawVerticalLine(e+i-1,t,a,s)};static drawHorizontalLine=(e,t,i,s)=>{if(t=this.bottom)return;ethis.right&&(s=this.right-e);const a=e+t*this.width2d;for(let e=0;e{if(e=this.right)return;tthis.bottom&&(s=this.bottom-t);const a=e+t*this.width2d;for(let e=0;e{const r=Math.abs(i-e),n=Math.abs(s-t),h=e=this.left&&e=this.top&&t-n&&(l-=n,e+=h),i{ethis.right&&(i=this.right-e),t+s>this.bottom&&(s=this.bottom-t);const r=this.width2d-i;let n=e+t*this.width2d;for(let e=-s;e<0;e++){for(let e=-i;e<0;e++)this.pixels[n++]=a;n+=r}};static setPixel=(e,t,i)=>{e=this.right||t=this.bottom||(this.pixels[e+t*this.width2d]=i)}}},8078:(e,t,i)=>{i.d(t,{Z:()=>n});var s=i(2991),a=i(664),r=i(9345);class n extends s.Z{static lowMemory=!1;static reciprocal15=new Int32Array(512);static reciprocal16=new Int32Array(2048);static sin=new Int32Array(2048);static cos=new Int32Array(2048);static palette=new Int32Array(65536);static textures=new r.to(50,null);static textureCount=0;static lineOffset=new Int32Array;static centerX=0;static centerY=0;static jagged=!0;static clipX=!1;static alpha=0;static texelPool=null;static activeTexels=new r.to(50,null);static poolSize=0;static cycle=0;static textureCycle=new Int32Array(50);static texturePalette=new r.to(50,null);static opaque=!1;static textureTranslucent=new r.to(50,!1);static averageTextureRGB=new Int32Array(50);static{for(let e=1;e<512;e++)this.reciprocal15[e]=32768/e|0;for(let e=1;e<2048;e++)this.reciprocal16[e]=65536/e|0;for(let e=0;e<2048;e++)this.sin[e]=65536*Math.sin(.0030679615757712823*e)|0,this.cos[e]=65536*Math.cos(.0030679615757712823*e)|0}static unload=()=>{this.reciprocal15=null,this.reciprocal15=null,this.sin=null,this.cos=null,this.lineOffset=null,this.textures=null,this.textureTranslucent=null,this.averageTextureRGB=null,this.texelPool=null,this.activeTexels=null,this.textureCycle=null,this.palette=null,this.texturePalette=null,console.log("Draw3D unloaded!")};static init2D=()=>{this.lineOffset=new Int32Array(this.height2d);for(let e=0;e{this.lineOffset=new Int32Array(t);for(let i=0;i{this.texelPool=null,this.activeTexels.fill(null)};static unpackTextures=e=>{this.textureCount=0;for(let t=0;t<50;t++)try{this.textures[t]=a.Z.fromArchive(e,t.toString()),this.lowMemory&&128===this.textures[t]?.cropW?this.textures[t]?.shrink():this.textures[t]?.crop(),this.textureCount++}catch(e){}};static getAverageTextureRGB=e=>{if(0!==this.averageTextureRGB[e])return this.averageTextureRGB[e];const t=this.texturePalette[e];if(!t)return 0;let i=0,s=0,a=0;const r=t.length;for(let e=0;e>16&255,s+=t[e]>>8&255,a+=255&t[e];let n=((i/r|0)<<16)+((s/r|0)<<8)+(a/r|0);return n=this.setGamma(n,1.4),0===n&&(n=1),this.averageTextureRGB[e]=n,n};static setBrightness=e=>{const t=e+.03*Math.random()-.015;let i=0;for(let e=0;e<512;e++){const s=(e/8|0)/64+.0078125,a=(7&e)/8+.0625;for(let e=0;e<128;e++){const r=e/128;let n=r,h=r,o=r;if(0!==a){let e;e=r<.5?r*(a+1):r+a-r*a;const t=2*r-e;let i=s+.3333333333333333;i>1&&i--;let l=s-.3333333333333333;l<0&&l++,n=6*i<1?t+6*(e-t)*i:2*i<1?e:3*i<2?t+(e-t)*(.6666666666666666-i)*6:t,h=6*s<1?t+6*(e-t)*s:2*s<1?e:3*s<2?t+(e-t)*(.6666666666666666-s)*6:t,o=6*l<1?t+6*(e-t)*l:2*l<1?e:3*l<2?t+(e-t)*(.6666666666666666-l)*6:t}const l=((256*n|0)<<16)+((256*h|0)<<8)+(256*o|0);this.palette[i++]=this.setGamma(l,t)}}for(let e=0;e<50;e++){const i=this.textures[e];if(!i)continue;const s=i.palette;this.texturePalette[e]=new Int32Array(s.length);for(let i=0;i{const i=(e>>16)/256,s=(e>>8&255)/256,a=(255&e)/256;return((256*Math.pow(i,t)|0)<<16)+((256*Math.pow(s,t)|0)<<8)+(256*Math.pow(a,t)|0)};static initPool=e=>{this.texelPool||(this.poolSize=e,this.lowMemory?this.texelPool=new r.Nv(e,16384):this.texelPool=new r.Nv(e,65536),this.activeTexels.fill(null))};static fillGouraudTriangle=(e,t,i,s,a,r,n,h,o)=>{let l=0,c=0;a!==s&&(l=(t-e<<16)/(a-s)|0,c=(h-n<<15)/(a-s)|0);let d=0,u=0;r!==a&&(d=(i-t<<16)/(r-a)|0,u=(o-h<<15)/(r-a)|0);let f=0,p=0;if(r!==s&&(f=(e-i<<16)/(s-r)|0,p=(n-o<<15)/(s-r)|0),s<=a&&s<=r){if(sthis.bottom&&(a=this.bottom),r>this.bottom&&(r=this.bottom),ad)for(r-=a,a-=s,s=this.lineOffset[s];;){if(--a<0)for(;;){if(--r<0)return;this.drawGouraudScanline(i>>16,t>>16,o>>7,h>>7,this.pixels,s,0),i+=f,t+=d,o+=p,h+=u,s+=this.width2d}this.drawGouraudScanline(i>>16,e>>16,o>>7,n>>7,this.pixels,s,0),i+=f,e+=l,o+=p,n+=c,s+=this.width2d}else for(r-=a,a-=s,s=this.lineOffset[s];;){if(--a<0)for(;;){if(--r<0)return;this.drawGouraudScanline(t>>16,i>>16,h>>7,o>>7,this.pixels,s,0),i+=f,t+=d,o+=p,h+=u,s+=this.width2d}this.drawGouraudScanline(e>>16,i>>16,n>>7,o>>7,this.pixels,s,0),i+=f,e+=l,o+=p,n+=c,s+=this.width2d}else if(t=e<<=16,h=n<<=15,s<0&&(t-=f*s,e-=l*s,h-=p*s,n-=c*s,s=0),i<<=16,o<<=15,r<0&&(i-=d*r,o-=u*r,r=0),s!==r&&fl)for(a-=r,r-=s,s=this.lineOffset[s];;){if(--r<0)for(;;){if(--a<0)return;this.drawGouraudScanline(i>>16,e>>16,o>>7,n>>7,this.pixels,s,0),i+=d,e+=l,o+=u,n+=c,s+=this.width2d}this.drawGouraudScanline(t>>16,e>>16,h>>7,n>>7,this.pixels,s,0),t+=f,e+=l,h+=p,n+=c,s+=this.width2d}else for(a-=r,r-=s,s=this.lineOffset[s];;){if(--r<0)for(;;){if(--a<0)return;this.drawGouraudScanline(e>>16,i>>16,n>>7,o>>7,this.pixels,s,0),i+=d,e+=l,o+=u,n+=c,s+=this.width2d}this.drawGouraudScanline(e>>16,t>>16,n>>7,h>>7,this.pixels,s,0),t+=f,e+=l,h+=p,n+=c,s+=this.width2d}}else if(a<=r){if(athis.bottom&&(r=this.bottom),s>this.bottom&&(s=this.bottom),rf)for(s-=r,r-=a,a=this.lineOffset[a];;){if(--r<0)for(;;){if(--s<0)return;this.drawGouraudScanline(e>>16,i>>16,n>>7,o>>7,this.pixels,a,0),e+=l,i+=f,n+=c,o+=p,a+=this.width2d}this.drawGouraudScanline(e>>16,t>>16,n>>7,h>>7,this.pixels,a,0),e+=l,t+=d,n+=c,h+=u,a+=this.width2d}else for(s-=r,r-=a,a=this.lineOffset[a];;){if(--r<0)for(;;){if(--s<0)return;this.drawGouraudScanline(i>>16,e>>16,o>>7,n>>7,this.pixels,a,0),e+=l,i+=f,n+=c,o+=p,a+=this.width2d}this.drawGouraudScanline(t>>16,e>>16,h>>7,n>>7,this.pixels,a,0),e+=l,t+=d,n+=c,h+=u,a+=this.width2d}else if(i=t<<=16,o=h<<=15,a<0&&(i-=l*a,t-=d*a,o-=c*a,h-=u*a,a=0),e<<=16,n<<=15,s<0&&(e-=f*s,n-=p*s,s=0),r-=s,s-=a,a=this.lineOffset[a],l>16,t>>16,n>>7,h>>7,this.pixels,a,0),e+=f,t+=d,n+=p,h+=u,a+=this.width2d}this.drawGouraudScanline(i>>16,t>>16,o>>7,h>>7,this.pixels,a,0),i+=l,t+=d,o+=c,h+=u,a+=this.width2d}else for(;;){if(--s<0)for(;;){if(--r<0)return;this.drawGouraudScanline(t>>16,e>>16,h>>7,n>>7,this.pixels,a,0),e+=f,t+=d,n+=p,h+=u,a+=this.width2d}this.drawGouraudScanline(t>>16,i>>16,h>>7,o>>7,this.pixels,a,0),i+=l,t+=d,o+=c,h+=u,a+=this.width2d}}else if(rthis.bottom&&(s=this.bottom),a>this.bottom&&(a=this.bottom),s>16,e>>16,h>>7,n>>7,this.pixels,r,0),t+=d,e+=l,h+=u,n+=c,r+=this.width2d}this.drawGouraudScanline(t>>16,i>>16,h>>7,o>>7,this.pixels,r,0),t+=d,i+=f,h+=u,o+=p,r+=this.width2d}else for(;;){if(--s<0)for(;;){if(--a<0)return;this.drawGouraudScanline(e>>16,t>>16,n>>7,h>>7,this.pixels,r,0),t+=d,e+=l,h+=u,n+=c,r+=this.width2d}this.drawGouraudScanline(i>>16,t>>16,o>>7,h>>7,this.pixels,r,0),t+=d,i+=f,h+=u,o+=p,r+=this.width2d}else if(e=i<<=16,n=o<<=15,r<0&&(e-=d*r,i-=f*r,n-=u*r,o-=p*r,r=0),t<<=16,h<<=15,a<0&&(t-=l*a,h-=c*a,a=0),s-=a,a-=r,r=this.lineOffset[r],d>16,i>>16,h>>7,o>>7,this.pixels,r,0),t+=l,i+=f,h+=c,o+=p,r+=this.width2d}this.drawGouraudScanline(e>>16,i>>16,n>>7,o>>7,this.pixels,r,0),e+=d,i+=f,n+=u,o+=p,r+=this.width2d}else for(;;){if(--a<0)for(;;){if(--s<0)return;this.drawGouraudScanline(i>>16,t>>16,o>>7,h>>7,this.pixels,r,0),t+=l,i+=f,h+=c,o+=p,r+=this.width2d}this.drawGouraudScanline(i>>16,e>>16,o>>7,n>>7,this.pixels,r,0),e+=d,i+=f,n+=u,o+=p,r+=this.width2d}};static drawGouraudScanline=(e,t,i,s,a,r,n)=>{let h;if(this.jagged){let o;if(this.clipX){if(o=t-e>3?(s-i)/(t-e)|0:0,t>this.boundX&&(t=this.boundX),e<0&&(i-=e*o,e=0),e>=t)return;r+=e,n=t-e>>2,o<<=2}else{if(!(e>2)>0?(s-i)*this.reciprocal15[n]>>15:0}if(0===this.alpha)for(;;){if(--n<0){if((n=t-e&3)>0){h=this.palette[i>>8];do{a[r++]=h,n--}while(n>0);return}break}h=this.palette[i>>8],i+=o,a[r++]=h,a[r++]=h,a[r++]=h,a[r++]=h}else{const s=this.alpha,l=256-this.alpha;for(;;){if(--n<0){if((n=t-e&3)>0){h=this.palette[i>>8],h=((16711935&h)*l>>8&16711935)+((65280&h)*l>>8&65280);do{a[r++]=h+((16711935&a[r])*s>>8&16711935)+((65280&a[r])*s>>8&65280),n--}while(n>0)}break}h=this.palette[i>>8],i+=o,h=((16711935&h)*l>>8&16711935)+((65280&h)*l>>8&65280),a[r++]=h+((16711935&a[r])*s>>8&16711935)+((65280&a[r])*s>>8&65280),a[r++]=h+((16711935&a[r])*s>>8&16711935)+((65280&a[r])*s>>8&65280),a[r++]=h+((16711935&a[r])*s>>8&16711935)+((65280&a[r])*s>>8&65280),a[r++]=h+((16711935&a[r])*s>>8&16711935)+((65280&a[r])*s>>8&65280)}}}else if(ethis.boundX&&(t=this.boundX),e<0&&(i-=e*o,e=0),e>=t))return;if(r+=e,n=t-e,0===this.alpha)do{a[r++]=this.palette[i>>8],i+=o,n--}while(n>0);else{const e=this.alpha,t=256-this.alpha;do{h=this.palette[i>>8],i+=o,h=((16711935&h)*t>>8&16711935)+((65280&h)*t>>8&65280),a[r++]=h+((16711935&a[r])*e>>8&16711935)+((65280&a[r])*e>>8&65280),n--}while(n>0)}}};static fillTriangle=(e,t,i,s,a,r,n)=>{let h=0;a!==s&&(h=(t-e<<16)/(a-s)|0);let o=0;r!==a&&(o=(i-t<<16)/(r-a)|0);let l=0;if(r!==s&&(l=(e-i<<16)/(s-r)|0),s<=a&&s<=r){if(sthis.bottom&&(a=this.bottom),r>this.bottom&&(r=this.bottom),ao)for(r-=a,a-=s,s=this.lineOffset[s];;){if(--a<0)for(;;){if(--r<0)return;this.drawScanline(i>>16,t>>16,this.pixels,s,n),i+=l,t+=o,s+=this.width2d}this.drawScanline(i>>16,e>>16,this.pixels,s,n),i+=l,e+=h,s+=this.width2d}else for(r-=a,a-=s,s=this.lineOffset[s];;){if(--a<0)for(;;){if(--r<0)return;this.drawScanline(t>>16,i>>16,this.pixels,s,n),i+=l,t+=o,s+=this.width2d}this.drawScanline(e>>16,i>>16,this.pixels,s,n),i+=l,e+=h,s+=this.width2d}else if(t=e<<=16,s<0&&(t-=l*s,e-=h*s,s=0),i<<=16,r<0&&(i-=o*r,r=0),s!==r&&lh)for(a-=r,r-=s,s=this.lineOffset[s];;){if(--r<0)for(;;){if(--a<0)return;this.drawScanline(i>>16,e>>16,this.pixels,s,n),i+=o,e+=h,s+=this.width2d}this.drawScanline(t>>16,e>>16,this.pixels,s,n),t+=l,e+=h,s+=this.width2d}else for(a-=r,r-=s,s=this.lineOffset[s];;){if(--r<0)for(;;){if(--a<0)return;this.drawScanline(e>>16,i>>16,this.pixels,s,n),i+=o,e+=h,s+=this.width2d}this.drawScanline(e>>16,t>>16,this.pixels,s,n),t+=l,e+=h,s+=this.width2d}}else if(a<=r){if(athis.bottom&&(r=this.bottom),s>this.bottom&&(s=this.bottom),rl)for(s-=r,r-=a,a=this.lineOffset[a];;){if(--r<0)for(;;){if(--s<0)return;this.drawScanline(e>>16,i>>16,this.pixels,a,n),e+=h,i+=l,a+=this.width2d}this.drawScanline(e>>16,t>>16,this.pixels,a,n),e+=h,t+=o,a+=this.width2d}else for(s-=r,r-=a,a=this.lineOffset[a];;){if(--r<0)for(;;){if(--s<0)return;this.drawScanline(i>>16,e>>16,this.pixels,a,n),e+=h,i+=l,a+=this.width2d}this.drawScanline(t>>16,e>>16,this.pixels,a,n),e+=h,t+=o,a+=this.width2d}else if(i=t<<=16,a<0&&(i-=h*a,t-=o*a,a=0),e<<=16,s<0&&(e-=l*s,s=0),h>16,t>>16,this.pixels,a,n),e+=l,t+=o,a+=this.width2d}this.drawScanline(i>>16,t>>16,this.pixels,a,n),i+=h,t+=o,a+=this.width2d}else for(r-=s,s-=a,a=this.lineOffset[a];;){if(--s<0)for(;;){if(--r<0)return;this.drawScanline(t>>16,e>>16,this.pixels,a,n),e+=l,t+=o,a+=this.width2d}this.drawScanline(t>>16,i>>16,this.pixels,a,n),i+=h,t+=o,a+=this.width2d}}else if(rthis.bottom&&(s=this.bottom),a>this.bottom&&(a=this.bottom),s>16,e>>16,this.pixels,r,n),t+=o,e+=h,r+=this.width2d}this.drawScanline(t>>16,i>>16,this.pixels,r,n),t+=o,i+=l,r+=this.width2d}else for(a-=s,s-=r,r=this.lineOffset[r];;){if(--s<0)for(;;){if(--a<0)return;this.drawScanline(e>>16,t>>16,this.pixels,r,n),t+=o,e+=h,r+=this.width2d}this.drawScanline(i>>16,t>>16,this.pixels,r,n),t+=o,i+=l,r+=this.width2d}else if(e=i<<=16,r<0&&(e-=o*r,i-=l*r,r=0),t<<=16,a<0&&(t-=h*a,a=0),o>16,i>>16,this.pixels,r,n),t+=h,i+=l,r+=this.width2d}this.drawScanline(e>>16,i>>16,this.pixels,r,n),e+=o,i+=l,r+=this.width2d}else for(s-=a,a-=r,r=this.lineOffset[r];;){if(--a<0)for(;;){if(--s<0)return;this.drawScanline(i>>16,t>>16,this.pixels,r,n),t+=h,i+=l,r+=this.width2d}this.drawScanline(i>>16,e>>16,this.pixels,r,n),e+=o,i+=l,r+=this.width2d}};static fillTexturedTriangle=(e,t,i,s,a,r,n,h,o,l,c,d,u,f,p,m,g,y,C)=>{const T=this.getTexels(C);this.opaque=!this.textureTranslucent[C];const w=l-u,S=c-p,Z=d-g,A=f-l,v=m-c,I=y-d;let O=A*c-v*l<<14;const b=v*d-I*c<<8,L=I*l-A*d<<5;let E=w*c-S*l<<14;const x=S*d-Z*c<<8,_=Z*l-w*d<<5;let k=S*A-w*v<<14;const R=Z*v-S*I<<8,P=w*I-Z*A<<5;let M=0,N=0;a!==s&&(M=(t-e<<16)/(a-s)|0,N=(h-n<<16)/(a-s)|0);let B=0,D=0;r!==a&&(B=(i-t<<16)/(r-a)|0,D=(o-h<<16)/(r-a)|0);let Y=0,X=0;if(r!==s&&(Y=(e-i<<16)/(s-r)|0,X=(n-o<<16)/(s-r)|0),s<=a&&s<=r){if(sthis.bottom&&(a=this.bottom),r>this.bottom&&(r=this.bottom),aB)for(r-=a,a-=s,s=this.lineOffset[s];;){if(--a<0)for(;;){if(--r<0)return;this.drawTexturedScanline(i>>16,t>>16,this.pixels,s,T,0,0,O,E,k,b,x,R,o>>8,h>>8),i+=Y,t+=B,o+=X,h+=D,s+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}this.drawTexturedScanline(i>>16,e>>16,this.pixels,s,T,0,0,O,E,k,b,x,R,o>>8,n>>8),i+=Y,e+=M,o+=X,n+=N,s+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}else for(r-=a,a-=s,s=this.lineOffset[s];;){if(--a<0)for(;;){if(--r<0)return;this.drawTexturedScanline(t>>16,i>>16,this.pixels,s,T,0,0,O,E,k,b,x,R,h>>8,o>>8),i+=Y,t+=B,o+=X,h+=D,s+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}this.drawTexturedScanline(e>>16,i>>16,this.pixels,s,T,0,0,O,E,k,b,x,R,n>>8,o>>8),i+=Y,e+=M,o+=X,n+=N,s+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}}else{t=e<<=16,h=n<<=16,s<0&&(t-=Y*s,e-=M*s,h-=X*s,n-=N*s,s=0),i<<=16,o<<=16,r<0&&(i-=B*r,o-=D*r,r=0);const l=s-this.centerY;if(O+=L*l,E+=_*l,k+=P*l,O|=0,E|=0,k|=0,(s===r||Y>=M)&&(s!==r||B<=M))for(a-=r,r-=s,s=this.lineOffset[s];;){if(--r<0)for(;;){if(--a<0)return;this.drawTexturedScanline(e>>16,i>>16,this.pixels,s,T,0,0,O,E,k,b,x,R,n>>8,o>>8),i+=B,e+=M,o+=D,n+=N,s+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}this.drawTexturedScanline(e>>16,t>>16,this.pixels,s,T,0,0,O,E,k,b,x,R,n>>8,h>>8),t+=Y,e+=M,h+=X,n+=N,s+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}else for(a-=r,r-=s,s=this.lineOffset[s];;){if(--r<0)for(;;){if(--a<0)return;this.drawTexturedScanline(i>>16,e>>16,this.pixels,s,T,0,0,O,E,k,b,x,R,o>>8,n>>8),i+=B,e+=M,o+=D,n+=N,s+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}this.drawTexturedScanline(t>>16,e>>16,this.pixels,s,T,0,0,O,E,k,b,x,R,h>>8,n>>8),t+=Y,e+=M,h+=X,n+=N,s+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}}}else if(a<=r){if(athis.bottom&&(r=this.bottom),s>this.bottom&&(s=this.bottom),rY)for(s-=r,r-=a,a=this.lineOffset[a];;){if(--r<0)for(;;){if(--s<0)return;this.drawTexturedScanline(e>>16,i>>16,this.pixels,a,T,0,0,O,E,k,b,x,R,n>>8,o>>8),e+=M,i+=Y,n+=N,o+=X,a+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}this.drawTexturedScanline(e>>16,t>>16,this.pixels,a,T,0,0,O,E,k,b,x,R,n>>8,h>>8),e+=M,t+=B,n+=N,h+=D,a+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}else for(s-=r,r-=a,a=this.lineOffset[a];;){if(--r<0)for(;;){if(--s<0)return;this.drawTexturedScanline(i>>16,e>>16,this.pixels,a,T,0,0,O,E,k,b,x,R,o>>8,n>>8),e+=M,i+=Y,n+=N,o+=X,a+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}this.drawTexturedScanline(t>>16,e>>16,this.pixels,a,T,0,0,O,E,k,b,x,R,h>>8,n>>8),e+=M,t+=B,n+=N,h+=D,a+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}}else{i=t<<=16,o=h<<=16,a<0&&(i-=M*a,t-=B*a,o-=N*a,h-=D*a,a=0),e<<=16,n<<=16,s<0&&(e-=Y*s,n-=X*s,s=0);const l=a-this.centerY;if(O+=L*l,E+=_*l,k+=P*l,O|=0,E|=0,k|=0,r-=s,s-=a,a=this.lineOffset[a],M>16,t>>16,this.pixels,a,T,0,0,O,E,k,b,x,R,n>>8,h>>8),e+=Y,t+=B,n+=X,h+=D,a+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}this.drawTexturedScanline(i>>16,t>>16,this.pixels,a,T,0,0,O,E,k,b,x,R,o>>8,h>>8),i+=M,t+=B,o+=N,h+=D,a+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}else for(;;){if(--s<0)for(;;){if(--r<0)return;this.drawTexturedScanline(t>>16,e>>16,this.pixels,a,T,0,0,O,E,k,b,x,R,h>>8,n>>8),e+=Y,t+=B,n+=X,h+=D,a+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}this.drawTexturedScanline(t>>16,i>>16,this.pixels,a,T,0,0,O,E,k,b,x,R,h>>8,o>>8),i+=M,t+=B,o+=N,h+=D,a+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}}}else if(rthis.bottom&&(s=this.bottom),a>this.bottom&&(a=this.bottom),s>16,e>>16,this.pixels,r,T,0,0,O,E,k,b,x,R,h>>8,n>>8),t+=B,e+=M,h+=D,n+=N,r+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}this.drawTexturedScanline(t>>16,i>>16,this.pixels,r,T,0,0,O,E,k,b,x,R,h>>8,o>>8),t+=B,i+=Y,h+=D,o+=X,r+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}else for(;;){if(--s<0)for(;;){if(--a<0)return;this.drawTexturedScanline(e>>16,t>>16,this.pixels,r,T,0,0,O,E,k,b,x,R,n>>8,h>>8),t+=B,e+=M,h+=D,n+=N,r+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}this.drawTexturedScanline(i>>16,t>>16,this.pixels,r,T,0,0,O,E,k,b,x,R,o>>8,h>>8),t+=B,i+=Y,h+=D,o+=X,r+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}}else{e=i<<=16,n=o<<=16,r<0&&(e-=B*r,i-=Y*r,n-=D*r,o-=X*r,r=0),t<<=16,h<<=16,a<0&&(t-=M*a,h-=N*a,a=0);const l=r-this.centerY;if(O+=L*l,E+=_*l,k+=P*l,O|=0,E|=0,k|=0,s-=a,a-=r,r=this.lineOffset[r],B>16,i>>16,this.pixels,r,T,0,0,O,E,k,b,x,R,h>>8,o>>8),t+=M,i+=Y,h+=N,o+=X,r+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}this.drawTexturedScanline(e>>16,i>>16,this.pixels,r,T,0,0,O,E,k,b,x,R,n>>8,o>>8),e+=B,i+=Y,n+=D,o+=X,r+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}else for(;;){if(--a<0)for(;;){if(--s<0)return;this.drawTexturedScanline(i>>16,t>>16,this.pixels,r,T,0,0,O,E,k,b,x,R,o>>8,h>>8),t+=M,i+=Y,h+=N,o+=X,r+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}this.drawTexturedScanline(i>>16,e>>16,this.pixels,r,T,0,0,O,E,k,b,x,R,o>>8,n>>8),e+=B,i+=Y,n+=D,o+=X,r+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}}};static drawTexturedScanline=(e,t,i,s,a,r,n,h,o,l,c,d,u,f,p)=>{if(e>=t)return;let m,g,y,C,T,w,S,Z,A;if(this.clipX){if(m=(p-f)/(t-e)|0,t>this.boundX&&(t=this.boundX),e<0&&(f-=e*m,e=0),e>=t)return;g=t-e>>3,m<<=12}else t-e>7?(g=t-e>>3,m=(p-f)*this.reciprocal15[g]>>6):(g=0,m=0);if(f<<=9,s+=e,this.lowMemory&&a)if(y=0,C=0,w=e-this.centerX,h+=(c>>3)*w,o+=(d>>3)*w,l+=(u>>3)*w,h|=0,o|=0,T=(l|=0)>>12,0!==T&&(n=o/T|0,(r=h/T|0)<0?r=0:r>4032&&(r=4032)),h+=c,o+=d,l+=u,h|=0,o|=0,T=(l|=0)>>12,0!==T&&(y=h/T|0,C=o/T|0,y<7?y=7:y>4032&&(y=4032)),S=y-r>>3,Z=C-n>>3,r+=f>>3&786432,A=f>>23,this.opaque){for(;g-- >0;)i[s++]=a[(4032&n)+(r>>6)]>>>A,r+=S,n+=Z,i[s++]=a[(4032&n)+(r>>6)]>>>A,r+=S,n+=Z,i[s++]=a[(4032&n)+(r>>6)]>>>A,r+=S,n+=Z,i[s++]=a[(4032&n)+(r>>6)]>>>A,r+=S,n+=Z,i[s++]=a[(4032&n)+(r>>6)]>>>A,r+=S,n+=Z,i[s++]=a[(4032&n)+(r>>6)]>>>A,r+=S,n+=Z,i[s++]=a[(4032&n)+(r>>6)]>>>A,r+=S,n+=Z,i[s++]=a[(4032&n)+(r>>6)]>>>A,r=y,n=C,h+=c,o+=d,T=(l+=u)>>12,0!==T&&(y=h/T|0,C=o/T|0,y<7?y=7:y>4032&&(y=4032)),S=y-r>>3,Z=C-n>>3,r+=(f+=m)>>3&786432,A=f>>23;for(g=t-e&7;g-- >0;)i[s++]=a[(4032&n)+(r>>6)]>>>A,r+=S,n+=Z}else{for(;g-- >0;){let e;0!=(e=a[(4032&n)+(r>>6)]>>>A)&&(i[s]=e),s+=1,0!=(e=a[(4032&(n+=Z))+((r+=S)>>6)]>>>A)&&(i[s]=e),s++,0!=(e=a[(4032&(n+=Z))+((r+=S)>>6)]>>>A)&&(i[s]=e),s++,0!=(e=a[(4032&(n+=Z))+((r+=S)>>6)]>>>A)&&(i[s]=e),s++,0!=(e=a[(4032&(n+=Z))+((r+=S)>>6)]>>>A)&&(i[s]=e),s++,0!=(e=a[(4032&(n+=Z))+((r+=S)>>6)]>>>A)&&(i[s]=e),s++,0!=(e=a[(4032&(n+=Z))+((r+=S)>>6)]>>>A)&&(i[s]=e),s++,0!=(e=a[(4032&(n+=Z))+((r+=S)>>6)]>>>A)&&(i[s]=e),s+=1,r=y,n=C,h+=c,o+=d,l+=u,h|=0,o|=0,T=(l|=0)>>12,0!==T&&(y=h/T|0,C=o/T|0,y<7?y=7:y>4032&&(y=4032)),S=y-r>>3,Z=C-n>>3,r+=(f+=m)>>3&786432,A=f>>23}for(g=t-e&7;g-- >0;){let e;0!=(e=a[(4032&n)+(r>>6)]>>>A)&&(i[s]=e),s++,r+=S,n+=Z}}else if(y=0,C=0,w=e-this.centerX,h+=(c>>3)*w,o+=(d>>3)*w,l+=(u>>3)*w,h|=0,o|=0,T=(l|=0)>>14,0!==T&&(n=o/T|0,(r=h/T|0)<0?r=0:r>16256&&(r=16256)),h+=c,o+=d,l+=u,h|=0,o|=0,T=(l|=0)>>14,0!==T&&(y=h/T|0,C=o/T|0,y<7?y=7:y>16256&&(y=16256)),S=y-r>>3,Z=C-n>>3,r+=6291456&f,A=f>>23,this.opaque&&a){for(;g-- >0;)i[s++]=a[(16256&n)+(r>>7)]>>>A,r+=S,n+=Z,i[s++]=a[(16256&n)+(r>>7)]>>>A,r+=S,n+=Z,i[s++]=a[(16256&n)+(r>>7)]>>>A,r+=S,n+=Z,i[s++]=a[(16256&n)+(r>>7)]>>>A,r+=S,n+=Z,i[s++]=a[(16256&n)+(r>>7)]>>>A,r+=S,n+=Z,i[s++]=a[(16256&n)+(r>>7)]>>>A,r+=S,n+=Z,i[s++]=a[(16256&n)+(r>>7)]>>>A,r+=S,n+=Z,i[s++]=a[(16256&n)+(r>>7)]>>>A,r=y,n=C,h+=c,o+=d,l+=u,h|=0,o|=0,T=(l|=0)>>14,0!==T&&(y=h/T|0,C=o/T|0,y<7?y=7:y>16256&&(y=16256)),S=y-r>>3,Z=C-n>>3,r+=6291456&(f+=m),A=f>>23;for(g=t-e&7;g-- >0;)i[s++]=a[(16256&n)+(r>>7)]>>>A,r+=S,n+=Z}else{for(;g-- >0&&a;){let e;0!=(e=a[(16256&n)+(r>>7)]>>>A)&&(i[s]=e),s+=1,0!=(e=a[(16256&(n+=Z))+((r+=S)>>7)]>>>A)&&(i[s]=e),s++,0!=(e=a[(16256&(n+=Z))+((r+=S)>>7)]>>>A)&&(i[s]=e),s++,0!=(e=a[(16256&(n+=Z))+((r+=S)>>7)]>>>A)&&(i[s]=e),s++,0!=(e=a[(16256&(n+=Z))+((r+=S)>>7)]>>>A)&&(i[s]=e),s++,0!=(e=a[(16256&(n+=Z))+((r+=S)>>7)]>>>A)&&(i[s]=e),s++,0!=(e=a[(16256&(n+=Z))+((r+=S)>>7)]>>>A)&&(i[s]=e),s++,0!=(e=a[(16256&(n+=Z))+((r+=S)>>7)]>>>A)&&(i[s]=e),s++,r=y,n=C,h+=c,o+=d,l+=u,h|=0,o|=0,T=(l|=0)>>14,0!==T&&(y=h/T|0,C=o/T|0,y<7?y=7:y>16256&&(y=16256)),S=y-r>>3,Z=C-n>>3,r+=6291456&(f+=m),A=f>>23}for(g=t-e&7;g-- >0&&a;){let e;0!=(e=a[(16256&n)+(r>>7)]>>>A)&&(i[s]=e),s++,r+=S,n+=Z}}};static drawScanline=(e,t,i,s,a)=>{if(this.clipX&&(t>this.boundX&&(t=this.boundX),e<0&&(e=0)),e>=t)return;s+=e;let r=t-e>>2;if(0===this.alpha)for(;;){if(r--,r<0)for(r=t-e&3;;){if(r--,r<0)return;i[s++]=a}i[s++]=a,i[s++]=a,i[s++]=a,i[s++]=a}const n=this.alpha,h=256-this.alpha;for(a=((16711935&a)*h>>8&16711935)+((65280&a)*h>>8&65280);;){if(r--,r<0)for(r=t-e&3;;){if(r--,r<0)return;i[s++]=a+((16711935&i[s])*n>>8&16711935)+((65280&i[s])*n>>8&65280)}i[s++]=a+((16711935&i[s])*n>>8&16711935)+((65280&i[s])*n>>8&65280),i[s++]=a+((16711935&i[s])*n>>8&16711935)+((65280&i[s])*n>>8&65280),i[s++]=a+((16711935&i[s])*n>>8&16711935)+((65280&i[s])*n>>8&65280),i[s++]=a+((16711935&i[s])*n>>8&16711935)+((65280&i[s])*n>>8&65280)}};static pushTexture=e=>{this.activeTexels[e]&&this.texelPool&&(this.texelPool[this.poolSize++]=this.activeTexels[e],this.activeTexels[e]=null)};static getTexels=e=>{if(this.textureCycle[e]=this.cycle++,this.activeTexels[e])return this.activeTexels[e];let t;if(this.poolSize>0&&this.texelPool)t=this.texelPool[--this.poolSize],this.texelPool[this.poolSize]=null;else{let e=0,i=-1;for(let t=0;t>>3)&16316671,t[a+8192]=r-(r>>>2)&16316671,t[a+12288]=r-(r>>>2)-(r>>>3)&16316671}}else{if(64===i.width)for(let e=0;e<128;e++)for(let a=0;a<128;a++)t[a+(e<<7|0)]=s[i.pixels[(a>>1)+(e>>1<<6|0)]];else for(let e=0;e<16384;e++)t[e]=s[i.pixels[e]];this.textureTranslucent[e]=!1;for(let i=0;i<16384;i++){t[i]&=16316671;const s=t[i];0===s&&(this.textureTranslucent[e]=!0),t[i+16384]=s-(s>>>3)&16316671,t[i+32768]=s-(s>>>2)&16316671,t[i+49152]=s-(s>>>2)-(s>>>3)&16316671}}return t}}},5147:(e,t,i)=>{i.d(t,{Y:()=>a});var s=i(6121);const a=async e=>{255!==e[0]&&(e[0]=255),URL.revokeObjectURL(s.Ew.src),s.Ew.src=URL.createObjectURL(new Blob([e],{type:"image/jpeg"})),await new Promise((e=>s.Ew.onload=()=>e())),s.tw.clearRect(0,0,s.nS.width,s.nS.height);const t=s.Ew.naturalWidth,i=s.Ew.naturalHeight;return s.nS.width=t,s.nS.height=i,s.tw.drawImage(s.Ew,0,0),s.tw.getImageData(0,0,t,i)}},9178:(e,t,i)=>{i.d(t,{Z:()=>d});var s=i(2383),a=i(2991),r=i(8078),n=i(8762),h=i(6327),o=i(9345);class l{vertexCount=0;faceCount=0;texturedFaceCount=0;vertexFlagsOffset=-1;vertexXOffset=-1;vertexYOffset=-1;vertexZOffset=-1;vertexLabelsOffset=-1;faceVerticesOffset=-1;faceOrientationsOffset=-1;faceColorsOffset=-1;faceInfosOffset=-1;facePrioritiesOffset=0;faceAlphasOffset=-1;faceLabelsOffset=-1;faceTextureAxisOffset=-1;data=null}class c{x=0;y=0;z=0;w=0}class d extends h.Z{static metadata=null;static head=null;static face1=null;static face2=null;static face3=null;static face4=null;static face5=null;static point1=null;static point2=null;static point3=null;static point4=null;static point5=null;static vertex1=null;static vertex2=null;static axis=null;static faceClippedX=new o.to(4096,!1);static faceNearClipped=new o.to(4096,!1);static vertexScreenX=new Int32Array(4096);static vertexScreenY=new Int32Array(4096);static vertexScreenZ=new Int32Array(4096);static vertexViewSpaceX=new Int32Array(4096);static vertexViewSpaceY=new Int32Array(4096);static vertexViewSpaceZ=new Int32Array(4096);static tmpDepthFaceCount=new Int32Array(1500);static tmpDepthFaces=new o.Nv(1500,512);static tmpPriorityFaceCount=new Int32Array(12);static tmpPriorityFaces=new o.Nv(12,2e3);static tmpPriority10FaceDepth=new Int32Array(2e3);static tmpPriority11FaceDepth=new Int32Array(2e3);static tmpPriorityDepthSum=new Int32Array(12);static clippedX=new Int32Array(10);static clippedY=new Int32Array(10);static clippedColor=new Int32Array(10);static baseX=0;static baseY=0;static baseZ=0;static checkHover=!1;static mouseX=0;static mouseY=0;static pickedCount=0;static pickedBitsets=new Int32Array(1e3);static checkHoverFace=!1;static unpack(e){try{d.head=new s.Z(e.read("ob_head.dat")),d.face1=new s.Z(e.read("ob_face1.dat")),d.face2=new s.Z(e.read("ob_face2.dat")),d.face3=new s.Z(e.read("ob_face3.dat")),d.face4=new s.Z(e.read("ob_face4.dat")),d.face5=new s.Z(e.read("ob_face5.dat")),d.point1=new s.Z(e.read("ob_point1.dat")),d.point2=new s.Z(e.read("ob_point2.dat")),d.point3=new s.Z(e.read("ob_point3.dat")),d.point4=new s.Z(e.read("ob_point4.dat")),d.point5=new s.Z(e.read("ob_point5.dat")),d.vertex1=new s.Z(e.read("ob_vertex1.dat")),d.vertex2=new s.Z(e.read("ob_vertex2.dat")),d.axis=new s.Z(e.read("ob_axis.dat")),d.head.pos=0,d.point1.pos=0,d.point2.pos=0,d.point3.pos=0,d.point4.pos=0,d.vertex1.pos=0,d.vertex2.pos=0;const t=d.head.g2;d.metadata=new o.to(t+100,null);let i=0,a=0,r=0,n=0,h=0,c=0,u=0;for(let e=0;e127&&(t=127),127-t):((t=t*(127&e)>>7)<2?t=2:t>126&&(t=126),(65408&e)+t)}static modelCopyFaces=(e,t,i)=>{const s=e.vertexCount,a=e.faceCount,r=e.texturedFaceCount;let n,h,l,u,f;if(t){n=new Int32Array(s);for(let t=0;t{const a=e.vertexCount,r=e.faceCount,n=e.texturedFaceCount;let h,o,l,c,u;if(s)h=e.vertexX,o=e.vertexY,l=e.vertexZ;else{h=new Int32Array(a),o=new Int32Array(a),l=new Int32Array(a);for(let t=0;t{const i=e.vertexCount,s=e.faceCount,a=e.texturedFaceCount,r=new Int32Array(i),n=new Int32Array(i),h=new Int32Array(i);for(let t=0;t{let i=!1,s=!1,a=!1,r=!1,n=0,h=0,o=0,l=-1;for(let c=0;c{let i=!1,s=!1,a=!1,r=!1,n=0,h=0,o=0,l=-1;for(let c=0;c{let h=-1;const o=e.vertexX[t],l=e.vertexY[t],c=e.vertexZ[t];for(let e=0;e{if(!d.metadata)throw new Error("cant loading model metadata!!!!!");const t=d.metadata[e];if(!t)throw console.log(`Error model:${e} not found!`),new Error("cant loading model metadata!!!!!");if(!(d.head&&d.face1&&d.face2&&d.face3&&d.face4&&d.face5&&d.point1&&d.point2&&d.point3&&d.point4&&d.point5&&d.vertex1&&d.vertex2&&d.axis))throw new Error("cant loading model!!!!!");const i=t.vertexCount,s=t.faceCount,a=t.texturedFaceCount,r=new Int32Array(i),n=new Int32Array(i),h=new Int32Array(i),o=new Int32Array(s),l=new Int32Array(s),c=new Int32Array(s),u=new Int32Array(a),f=new Int32Array(a),p=new Int32Array(a);let m=null;t.vertexLabelsOffset>=0&&(m=new Int32Array(i));let g=null;t.faceInfosOffset>=0&&(g=new Int32Array(s));let y=null,C=0;t.facePrioritiesOffset>=0?y=new Int32Array(s):C=-t.facePrioritiesOffset-1;let T=null;t.faceAlphasOffset>=0&&(T=new Int32Array(s));let w=null;t.faceLabelsOffset>=0&&(w=new Int32Array(s));const S=new Int32Array(s);d.point1.pos=t.vertexFlagsOffset,d.point2.pos=t.vertexXOffset,d.point3.pos=t.vertexYOffset,d.point4.pos=t.vertexZOffset,d.point5.pos=t.vertexLabelsOffset;let Z,A,v,I=0,O=0,b=0;for(let e=0;e{if(!d.metadata||!d.metadata[t])throw new Error("No model metadata");const i=d.metadata[t];if(i.data=e,!i.data.length)throw new Error("No model data");const a=i.vertexCount,r=i.faceCount,n=i.texturedFaceCount,h=new Int32Array(a),o=new Int32Array(a),l=new Int32Array(a),c=new Int32Array(r),u=new Int32Array(r),f=new Int32Array(r),p=new Int32Array(n),m=new Int32Array(n),g=new Int32Array(n);let y=null;i.vertexLabelsOffset>=0&&(y=new Int32Array(a));let C=null;i.faceInfosOffset>=0&&(C=new Int32Array(r));let T=null,w=0;i.facePrioritiesOffset>=0?T=new Int32Array(r):w=-i.facePrioritiesOffset-1;let S=null;i.faceAlphasOffset>=0&&(S=new Int32Array(r));let Z=null;i.faceLabelsOffset>=0&&(Z=new Int32Array(r));const A=new Int32Array(r),v=new s.Z(i.data);v.pos=i.vertexFlagsOffset;const I=new s.Z(i.data);I.pos=i.vertexXOffset;const O=new s.Z(i.data);O.pos=i.vertexYOffset;const b=new s.Z(i.data);b.pos=i.vertexZOffset;const L=new s.Z(i.data);L.pos=i.vertexLabelsOffset;let E,x,_,k=0,R=0,P=0;for(let e=0;e{this.maxY=0,this.radius=0,this.minY=0;for(let e=0;ethis.maxY&&(this.maxY=-i),i>this.minY&&(this.minY=i);const a=t*t+s*s;a>this.radius&&(this.radius=a)}this.radius=Math.sqrt(this.radius)+.99|0,this.minDepth=Math.sqrt(this.radius*this.radius+this.maxY*this.maxY)+.99|0,this.maxDepth=this.minDepth+(Math.sqrt(this.radius*this.radius+this.minY*this.minY)+.99|0)};calculateBoundsY=()=>{this.maxY=0,this.minY=0;for(let e=0;ethis.maxY&&(this.maxY=-t),t>this.minY&&(this.minY=t)}this.minDepth=Math.sqrt(this.radius*this.radius+this.maxY*this.maxY)+.99|0,this.maxDepth=this.minDepth+(Math.sqrt(this.radius*this.radius+this.minY*this.minY)+.99|0)};createLabelReferences=()=>{if(this.vertexLabel){const e=new Int32Array(256);let t=0;for(let i=0;it&&(t=s)}this.labelVertices=new o.to(t+1,null);for(let i=0;i<=t;i++)this.labelVertices[i]=new Int32Array(e[i]),e[i]=0;let i=0;for(;it&&(t=s)}this.labelFaces=new o.to(t+1,null);for(let i=0;i<=t;i++)this.labelFaces[i]=new Int32Array(e[i]),e[i]=0;let i=0;for(;i{if(-1!==e)if(i&&-1!==t){const s=n.Z.instances[e],a=n.Z.instances[t],r=s.base;d.baseX=0,d.baseY=0,d.baseZ=0;let h=0,o=i[h++];for(let e=0;eo;)o=i[h++];r&&r.types&&s.x&&s.y&&s.z&&r.labels&&(t!==o||0===r.types[t])&&this.applyTransform2(s.x[e],s.y[e],s.z[e],r.labels[t],r.types[t])}d.baseX=0,d.baseY=0,d.baseZ=0,h=0,o=i[h++];for(let e=0;eo;)o=i[h++];r&&r.types&&a.x&&a.y&&a.z&&r.labels&&(t===o||0===r.types[t])&&this.applyTransform2(a.x[e],a.y[e],a.z[e],r.labels[t],r.types[t])}}else this.applyTransform(e)};applyTransform=e=>{if(!this.labelVertices||-1===e||!n.Z.instances[e])return;const t=n.Z.instances[e],i=t.base;d.baseX=0,d.baseY=0,d.baseZ=0;for(let e=0;e{for(let e=0;e{const t=r.Z.sin[e],i=r.Z.cos[e];for(let e=0;e>16;this.vertexZ[e]=this.vertexY[e]*t+this.vertexZ[e]*i>>16,this.vertexY[e]=s}};translate=(e,t,i)=>{for(let s=0;s{if(this.faceColor)for(let i=0;i{for(let e=0;e{for(let s=0;s{const n=t*(0|Math.sqrt(i*i+s*s+a*a))>>8;if(this.faceColorA&&this.faceColorB&&this.faceColorC||(this.faceColorA=new Int32Array(this.faceCount),this.faceColorB=new Int32Array(this.faceCount),this.faceColorC=new Int32Array(this.faceCount)),!this.vertexNormal){this.vertexNormal=new o.to(this.vertexCount,null);for(let e=0;e8192||y>8192||C>8192||g<-8192||y<-8192||C<-8192;)g>>=1,y>>=1,C>>=1;let T=0|Math.sqrt(g*g+y*y+C*C);if(T<=0&&(T=1),g=256*g/T|0,y=256*y/T|0,C=256*C/T|0,this.faceInfo&&0!=(1&this.faceInfo[t])){const r=e+((i*g+s*y+a*C)/(n+(n/2|0))|0);this.faceColor&&(this.faceColorA[t]=d.mulColorLightness(this.faceColor[t],r,this.faceInfo[t]))}else{let e=this.vertexNormal[r];e&&(e.x+=g,e.y+=y,e.z+=C,e.w++),e=this.vertexNormal[h],e&&(e.x+=g,e.y+=y,e.z+=C,e.w++),e=this.vertexNormal[o],e&&(e.x+=g,e.y+=y,e.z+=C,e.w++)}}if(r)this.applyLighting(e,n,i,s,a);else{this.vertexNormalOriginal=new o.to(this.vertexCount,null);for(let e=0;e{for(let r=0;r{const o=r.Z.sin[e],l=r.Z.cos[e],c=r.Z.sin[t],u=r.Z.cos[t],f=r.Z.sin[i],p=r.Z.cos[i],m=r.Z.sin[s],g=r.Z.cos[s],y=n*m+h*g>>16;for(let s=0;s>16,w=w*p-T*f>>16,T=C),0!==e&&(C=w*l-S*o>>16,S=w*o+S*l>>16,w=C),0!==t&&(C=S*c+T*u>>16,S=S*u-T*c>>16,T=C),T+=a,w+=n,S+=h,C=w*g-S*m>>16,S=w*m+S*g>>16,w=C,d.vertexScreenX&&d.vertexScreenY&&d.vertexScreenZ&&(d.vertexScreenZ[s]=S-y,d.vertexScreenX[s]=r.Z.centerX+((T<<9)/S|0),d.vertexScreenY[s]=r.Z.centerY+((w<<9)/S|0)),this.texturedFaceCount>0&&d.vertexViewSpaceX&&d.vertexViewSpaceY&&d.vertexViewSpaceZ&&(d.vertexViewSpaceX[s]=T,d.vertexViewSpaceY[s]=w,d.vertexViewSpaceZ[s]=S)}try{this.draw2(!1,!1,0)}catch(e){}};draw=(e,t,i,s,n,h,o,l,c)=>{const u=l*n-h*s>>16,f=o*t+u*i>>16,p=this.radius*i>>16,m=f+p;if(m<=50||f>=3500)return;const g=l*s+h*n>>16;let y=g-this.radius<<9;if((y/m|0)>=a.Z.centerX2d)return;let C=g+this.radius<<9;if((C/m|0)<=-a.Z.centerX2d)return;const T=o*i-u*t>>16,w=this.radius*t>>16;let S=T+w<<9;if((S/m|0)<=-a.Z.centerY2d)return;let Z=T-(w+(this.maxY*i>>16))<<9;if((Z/m|0)>=a.Z.centerY2d)return;let A=f-(p+(this.maxY*t>>16))<=50,v=!1;if(c>0&&d.checkHover){let e=f-p;e<=50&&(e=50),g>0?(y=y/m|0,C=C/e|0):(C=C/m|0,y=y/e|0),T>0?(Z=Z/m|0,S=S/e|0):(S=S/m|0,Z=Z/e|0);const t=d.mouseX-r.Z.centerX,i=d.mouseY-r.Z.centerY;t>y&&tZ&&i>16,p=p*L-c*b>>16,c=r),c+=h,u+=o,p+=l,r=p*s+c*n>>16,p=p*n-c*s>>16,c=r,r=u*i-p*t>>16,p=u*t+p*i>>16,u=r,d.vertexScreenZ&&(d.vertexScreenZ[a]=p-f),p>=50&&d.vertexScreenX&&d.vertexScreenY?(d.vertexScreenX[a]=I+((c<<9)/p|0),d.vertexScreenY[a]=O+((u<<9)/p|0)):d.vertexScreenX&&(d.vertexScreenX[a]=-5e3,A=!0),(A||this.texturedFaceCount>0)&&d.vertexViewSpaceX&&d.vertexViewSpaceY&&d.vertexViewSpaceZ&&(d.vertexViewSpaceX[a]=c,d.vertexViewSpaceY[a]=u,d.vertexViewSpaceZ[a]=p)}try{this.draw2(A,v,c)}catch(e){}};draw2=(e,t,i,s=!1)=>{d.checkHoverFace&&(this.pickedFace=-1,this.pickedFaceDepth=-1);for(let e=0;ea.Z.boundX||l>a.Z.boundX||c>a.Z.boundX),d.tmpDepthFaces&&d.tmpDepthFaceCount){const e=((m+g+y)/3|0)+this.minDepth;d.tmpDepthFaces[e][d.tmpDepthFaceCount[e]++]=s,d.checkHoverFace&&this.pointWithinTriangle(d.mouseX,d.mouseY,u,f,p,o,l,c)&&this.pickedFaceDepth=0;e--){const t=d.tmpDepthFaceCount[e];if(!(t<=0)&&d.tmpDepthFaces){const i=d.tmpDepthFaces[e];for(let e=0;e=0;e--){const t=d.tmpDepthFaceCount[e];if(t>0&&d.tmpDepthFaces){const i=d.tmpDepthFaces[e];for(let s=0;s0||d.tmpPriorityFaceCount[2]>0)&&(r=(d.tmpPriorityDepthSum[1]+d.tmpPriorityDepthSum[2])/(d.tmpPriorityFaceCount[1]+d.tmpPriorityFaceCount[2])|0);let n=0;d.tmpPriorityFaceCount&&d.tmpPriorityDepthSum&&(d.tmpPriorityFaceCount[3]>0||d.tmpPriorityFaceCount[4]>0)&&(n=(d.tmpPriorityDepthSum[3]+d.tmpPriorityDepthSum[4])/(d.tmpPriorityFaceCount[3]+d.tmpPriorityFaceCount[4])|0);let h=0;if(d.tmpPriorityFaceCount&&d.tmpPriorityDepthSum&&(d.tmpPriorityFaceCount[6]>0||d.tmpPriorityFaceCount[8]>0)&&(h=(d.tmpPriorityDepthSum[6]+d.tmpPriorityDepthSum[8])/(d.tmpPriorityFaceCount[6]+d.tmpPriorityFaceCount[8])|0),d.tmpPriorityFaceCount&&d.tmpPriorityFaces){let e,t=0,i=d.tmpPriorityFaceCount[10],a=d.tmpPriorityFaces[10],o=d.tmpPriority10FaceDepth;t===i&&(t=0,i=d.tmpPriorityFaceCount[11],a=d.tmpPriorityFaces[11],o=d.tmpPriority11FaceDepth),e=tr;)this.drawFace(a[t++],s),t===i&&a!==d.tmpPriorityFaces[11]&&(t=0,i=d.tmpPriorityFaceCount[11],a=d.tmpPriorityFaces[11],o=d.tmpPriority11FaceDepth),e=tn;)this.drawFace(a[t++],s),t===i&&a!==d.tmpPriorityFaces[11]&&(t=0,i=d.tmpPriorityFaceCount[11],a=d.tmpPriorityFaces[11],o=d.tmpPriority11FaceDepth),e=th;)this.drawFace(a[t++],s),t===i&&a!==d.tmpPriorityFaces[11]&&(t=0,i=d.tmpPriorityFaceCount[11],a=d.tmpPriorityFaces[11],o=d.tmpPriority11FaceDepth),e=t{if(d.faceNearClipped&&d.faceNearClipped[e])return void this.drawNearClippedFace(e,t);const i=this.faceVertexA[e],s=this.faceVertexB[e],a=this.faceVertexC[e];let n;if(d.faceClippedX&&(r.Z.clipX=d.faceClippedX[e]),this.faceAlpha?r.Z.alpha=this.faceAlpha[e]:r.Z.alpha=0,n=this.faceInfo?3&this.faceInfo[e]:0,t&&d.vertexScreenX&&d.vertexScreenY&&this.faceColorA&&this.faceColorB&&this.faceColorC)r.Z.drawLine(d.vertexScreenX[i],d.vertexScreenY[i],d.vertexScreenX[s],d.vertexScreenY[s],r.Z.palette[this.faceColorA[e]]),r.Z.drawLine(d.vertexScreenX[s],d.vertexScreenY[s],d.vertexScreenX[a],d.vertexScreenY[a],r.Z.palette[this.faceColorB[e]]),r.Z.drawLine(d.vertexScreenX[a],d.vertexScreenY[a],d.vertexScreenX[i],d.vertexScreenY[i],r.Z.palette[this.faceColorC[e]]);else if(0===n&&this.faceColorA&&this.faceColorB&&this.faceColorC&&d.vertexScreenX&&d.vertexScreenY)r.Z.fillGouraudTriangle(d.vertexScreenX[i],d.vertexScreenX[s],d.vertexScreenX[a],d.vertexScreenY[i],d.vertexScreenY[s],d.vertexScreenY[a],this.faceColorA[e],this.faceColorB[e],this.faceColorC[e]);else if(1===n&&this.faceColorA&&d.vertexScreenX&&d.vertexScreenY)r.Z.fillTriangle(d.vertexScreenX[i],d.vertexScreenX[s],d.vertexScreenX[a],d.vertexScreenY[i],d.vertexScreenY[s],d.vertexScreenY[a],r.Z.palette[this.faceColorA[e]]);else if(2===n&&this.faceInfo&&this.faceColor&&this.faceColorA&&this.faceColorB&&this.faceColorC&&d.vertexScreenX&&d.vertexScreenY&&d.vertexViewSpaceX&&d.vertexViewSpaceY&&d.vertexViewSpaceZ){const t=this.faceInfo[e]>>2,n=this.texturedVertexA[t],h=this.texturedVertexB[t],o=this.texturedVertexC[t];r.Z.fillTexturedTriangle(d.vertexScreenX[i],d.vertexScreenX[s],d.vertexScreenX[a],d.vertexScreenY[i],d.vertexScreenY[s],d.vertexScreenY[a],this.faceColorA[e],this.faceColorB[e],this.faceColorC[e],d.vertexViewSpaceX[n],d.vertexViewSpaceY[n],d.vertexViewSpaceZ[n],d.vertexViewSpaceX[h],d.vertexViewSpaceX[o],d.vertexViewSpaceY[h],d.vertexViewSpaceY[o],d.vertexViewSpaceZ[h],d.vertexViewSpaceZ[o],this.faceColor[e])}else if(3===n&&this.faceInfo&&this.faceColor&&this.faceColorA&&d.vertexScreenX&&d.vertexScreenY&&d.vertexViewSpaceX&&d.vertexViewSpaceY&&d.vertexViewSpaceZ){const t=this.faceInfo[e]>>2,n=this.texturedVertexA[t],h=this.texturedVertexB[t],o=this.texturedVertexC[t];r.Z.fillTexturedTriangle(d.vertexScreenX[i],d.vertexScreenX[s],d.vertexScreenX[a],d.vertexScreenY[i],d.vertexScreenY[s],d.vertexScreenY[a],this.faceColorA[e],this.faceColorA[e],this.faceColorA[e],d.vertexViewSpaceX[n],d.vertexViewSpaceY[n],d.vertexViewSpaceZ[n],d.vertexViewSpaceX[h],d.vertexViewSpaceX[o],d.vertexViewSpaceY[h],d.vertexViewSpaceY[o],d.vertexViewSpaceZ[h],d.vertexViewSpaceZ[o],this.faceColor[e])}};drawNearClippedFace=(e,t=!1)=>{let i=0;if(d.vertexViewSpaceZ){const t=r.Z.centerX,s=r.Z.centerY,a=this.faceVertexA[e],n=this.faceVertexB[e],h=this.faceVertexC[e],o=d.vertexViewSpaceZ[a],l=d.vertexViewSpaceZ[n],c=d.vertexViewSpaceZ[h];if(o>=50&&d.vertexScreenX&&d.vertexScreenY&&this.faceColorA)d.clippedX[i]=d.vertexScreenX[a],d.clippedY[i]=d.vertexScreenY[a],d.clippedColor[i++]=this.faceColorA[e];else if(d.vertexViewSpaceX&&d.vertexViewSpaceY&&this.faceColorA){const u=d.vertexViewSpaceX[a],f=d.vertexViewSpaceY[a],p=this.faceColorA[e];if(c>=50&&this.faceColorC){const a=(50-o)*r.Z.reciprocal16[c-o];d.clippedX[i]=t+((u+((d.vertexViewSpaceX[h]-u)*a>>16)<<9)/50|0),d.clippedY[i]=s+((f+((d.vertexViewSpaceY[h]-f)*a>>16)<<9)/50|0),d.clippedColor[i++]=p+((this.faceColorC[e]-p)*a>>16)}if(l>=50&&this.faceColorB){const a=(50-o)*r.Z.reciprocal16[l-o];d.clippedX[i]=t+((u+((d.vertexViewSpaceX[n]-u)*a>>16)<<9)/50|0),d.clippedY[i]=s+((f+((d.vertexViewSpaceY[n]-f)*a>>16)<<9)/50|0),d.clippedColor[i++]=p+((this.faceColorB[e]-p)*a>>16)}}if(l>=50&&d.vertexScreenX&&d.vertexScreenY&&this.faceColorB)d.clippedX[i]=d.vertexScreenX[n],d.clippedY[i]=d.vertexScreenY[n],d.clippedColor[i++]=this.faceColorB[e];else if(d.vertexViewSpaceX&&d.vertexViewSpaceY&&this.faceColorB){const u=d.vertexViewSpaceX[n],f=d.vertexViewSpaceY[n],p=this.faceColorB[e];if(o>=50&&this.faceColorA){const n=(50-l)*r.Z.reciprocal16[o-l];d.clippedX[i]=t+((u+((d.vertexViewSpaceX[a]-u)*n>>16)<<9)/50|0),d.clippedY[i]=s+((f+((d.vertexViewSpaceY[a]-f)*n>>16)<<9)/50|0),d.clippedColor[i++]=p+((this.faceColorA[e]-p)*n>>16)}if(c>=50&&this.faceColorC){const a=(50-l)*r.Z.reciprocal16[c-l];d.clippedX[i]=t+((u+((d.vertexViewSpaceX[h]-u)*a>>16)<<9)/50|0),d.clippedY[i]=s+((f+((d.vertexViewSpaceY[h]-f)*a>>16)<<9)/50|0),d.clippedColor[i++]=p+((this.faceColorC[e]-p)*a>>16)}}if(c>=50&&d.vertexScreenX&&d.vertexScreenY&&this.faceColorC)d.clippedX[i]=d.vertexScreenX[h],d.clippedY[i]=d.vertexScreenY[h],d.clippedColor[i++]=this.faceColorC[e];else if(d.vertexViewSpaceX&&d.vertexViewSpaceY&&this.faceColorC){const u=d.vertexViewSpaceX[h],f=d.vertexViewSpaceY[h],p=this.faceColorC[e];if(l>=50&&this.faceColorB){const a=(50-c)*r.Z.reciprocal16[l-c];d.clippedX[i]=t+((u+((d.vertexViewSpaceX[n]-u)*a>>16)<<9)/50|0),d.clippedY[i]=s+((f+((d.vertexViewSpaceY[n]-f)*a>>16)<<9)/50|0),d.clippedColor[i++]=p+((this.faceColorB[e]-p)*a>>16)}if(o>=50&&this.faceColorA){const n=(50-c)*r.Z.reciprocal16[o-c];d.clippedX[i]=t+((u+((d.vertexViewSpaceX[a]-u)*n>>16)<<9)/50|0),d.clippedY[i]=s+((f+((d.vertexViewSpaceY[a]-f)*n>>16)<<9)/50|0),d.clippedColor[i++]=p+((this.faceColorA[e]-p)*n>>16)}}}const s=d.clippedX[0],n=d.clippedX[1],h=d.clippedX[2],o=d.clippedY[0],l=d.clippedY[1],c=d.clippedY[2];if(!((s-n)*(c-l)-(o-l)*(h-n)<=0))if(r.Z.clipX=!1,3===i){let i;if((s<0||n<0||h<0||s>a.Z.boundX||n>a.Z.boundX||h>a.Z.boundX)&&(r.Z.clipX=!0),i=this.faceInfo?3&this.faceInfo[e]:0,t)r.Z.drawLine(s,n,o,l,d.clippedColor[0]),r.Z.drawLine(n,h,l,c,d.clippedColor[1]),r.Z.drawLine(h,s,c,o,d.clippedColor[2]);else if(0===i)r.Z.fillGouraudTriangle(s,n,h,o,l,c,d.clippedColor[0],d.clippedColor[1],d.clippedColor[2]);else if(1===i&&this.faceColorA)r.Z.fillTriangle(s,n,h,o,l,c,r.Z.palette[this.faceColorA[e]]);else if(2===i&&this.faceInfo&&this.faceColor&&d.vertexViewSpaceX&&d.vertexViewSpaceY&&d.vertexViewSpaceZ){const t=this.faceInfo[e]>>2,i=this.texturedVertexA[t],a=this.texturedVertexB[t],u=this.texturedVertexC[t];r.Z.fillTexturedTriangle(s,n,h,o,l,c,d.clippedColor[0],d.clippedColor[1],d.clippedColor[2],d.vertexViewSpaceX[i],d.vertexViewSpaceY[i],d.vertexViewSpaceZ[i],d.vertexViewSpaceX[a],d.vertexViewSpaceX[u],d.vertexViewSpaceY[a],d.vertexViewSpaceY[u],d.vertexViewSpaceZ[a],d.vertexViewSpaceZ[u],this.faceColor[e])}else if(3===i&&this.faceInfo&&this.faceColor&&this.faceColorA&&d.vertexViewSpaceX&&d.vertexViewSpaceY&&d.vertexViewSpaceZ){const t=this.faceInfo[e]>>2,i=this.texturedVertexA[t],a=this.texturedVertexB[t],u=this.texturedVertexC[t];r.Z.fillTexturedTriangle(s,n,h,o,l,c,this.faceColorA[e],this.faceColorA[e],this.faceColorA[e],d.vertexViewSpaceX[i],d.vertexViewSpaceY[i],d.vertexViewSpaceZ[i],d.vertexViewSpaceX[a],d.vertexViewSpaceX[u],d.vertexViewSpaceY[a],d.vertexViewSpaceY[u],d.vertexViewSpaceZ[a],d.vertexViewSpaceZ[u],this.faceColor[e])}}else if(4===i){let i;if((s<0||n<0||h<0||s>a.Z.boundX||n>a.Z.boundX||h>a.Z.boundX||d.clippedX[3]<0||d.clippedX[3]>a.Z.boundX)&&(r.Z.clipX=!0),i=this.faceInfo?3&this.faceInfo[e]:0,t)r.Z.drawLine(s,n,o,l,d.clippedColor[0]),r.Z.drawLine(n,h,l,c,d.clippedColor[1]),r.Z.drawLine(h,d.clippedX[3],c,d.clippedY[3],d.clippedColor[2]),r.Z.drawLine(d.clippedX[3],s,d.clippedY[3],o,d.clippedColor[3]);else if(0===i)r.Z.fillGouraudTriangle(s,n,h,o,l,c,d.clippedColor[0],d.clippedColor[1],d.clippedColor[2]),r.Z.fillGouraudTriangle(s,h,d.clippedX[3],o,c,d.clippedY[3],d.clippedColor[0],d.clippedColor[2],d.clippedColor[3]);else if(1===i){if(this.faceColorA){const t=r.Z.palette[this.faceColorA[e]];r.Z.fillTriangle(s,n,h,o,l,c,t),r.Z.fillTriangle(s,h,d.clippedX[3],o,c,d.clippedY[3],t)}}else if(2===i&&this.faceInfo&&this.faceColor&&d.vertexViewSpaceX&&d.vertexViewSpaceY&&d.vertexViewSpaceZ){const t=this.faceInfo[e]>>2,i=this.texturedVertexA[t],a=this.texturedVertexB[t],u=this.texturedVertexC[t];r.Z.fillTexturedTriangle(s,n,h,o,l,c,d.clippedColor[0],d.clippedColor[1],d.clippedColor[2],d.vertexViewSpaceX[i],d.vertexViewSpaceY[i],d.vertexViewSpaceZ[i],d.vertexViewSpaceX[a],d.vertexViewSpaceX[u],d.vertexViewSpaceY[a],d.vertexViewSpaceY[u],d.vertexViewSpaceZ[a],d.vertexViewSpaceZ[u],this.faceColor[e]),r.Z.fillTexturedTriangle(s,h,d.clippedX[3],o,c,d.clippedY[3],d.clippedColor[0],d.clippedColor[2],d.clippedColor[3],d.vertexViewSpaceX[i],d.vertexViewSpaceY[i],d.vertexViewSpaceZ[i],d.vertexViewSpaceX[a],d.vertexViewSpaceX[u],d.vertexViewSpaceY[a],d.vertexViewSpaceY[u],d.vertexViewSpaceZ[a],d.vertexViewSpaceZ[u],this.faceColor[e])}else if(3===i&&this.faceInfo&&this.faceColor&&this.faceColorA&&d.vertexViewSpaceX&&d.vertexViewSpaceY&&d.vertexViewSpaceZ){const t=this.faceInfo[e]>>2,i=this.texturedVertexA[t],a=this.texturedVertexB[t],u=this.texturedVertexC[t];r.Z.fillTexturedTriangle(s,n,h,o,l,c,this.faceColorA[e],this.faceColorA[e],this.faceColorA[e],d.vertexViewSpaceX[i],d.vertexViewSpaceY[i],d.vertexViewSpaceZ[i],d.vertexViewSpaceX[a],d.vertexViewSpaceX[u],d.vertexViewSpaceY[a],d.vertexViewSpaceY[u],d.vertexViewSpaceZ[a],d.vertexViewSpaceZ[u],this.faceColor[e]),r.Z.fillTexturedTriangle(s,h,d.clippedX[3],o,c,d.clippedY[3],this.faceColorA[e],this.faceColorA[e],this.faceColorA[e],d.vertexViewSpaceX[i],d.vertexViewSpaceY[i],d.vertexViewSpaceZ[i],d.vertexViewSpaceX[a],d.vertexViewSpaceX[u],d.vertexViewSpaceY[a],d.vertexViewSpaceY[u],d.vertexViewSpaceZ[a],d.vertexViewSpaceZ[u],this.faceColor[e])}}};applyTransform2=(e,t,i,s,a)=>{if(!s)return;const n=s.length;if(0===a){let a=0;d.baseX=0,d.baseY=0,d.baseZ=0;for(let e=0;e0?(d.baseX=(d.baseX/a|0)+e,d.baseY=(d.baseY/a|0)+t,d.baseZ=(d.baseZ/a|0)+i):(d.baseX=e,d.baseY=t,d.baseZ=i)}else if(1===a)for(let a=0;a=this.labelVertices.length)continue;const n=this.labelVertices[r];if(n)for(let s=0;s=this.labelVertices.length)continue;const h=this.labelVertices[n];if(h)for(let s=0;s>16;this.vertexY[a]=this.vertexY[a]*u-this.vertexX[a]*c>>16,this.vertexX[a]=e}if(0!==n){c=r.Z.sin[n],u=r.Z.cos[n];const e=this.vertexY[a]*u-this.vertexZ[a]*c>>16;this.vertexZ[a]=this.vertexY[a]*c+this.vertexZ[a]*u>>16,this.vertexY[a]=e}if(0!==o){c=r.Z.sin[o],u=r.Z.cos[o];const e=this.vertexZ[a]*c+this.vertexX[a]*u>>16;this.vertexZ[a]=this.vertexZ[a]*u-this.vertexX[a]*c>>16,this.vertexX[a]=e}this.vertexX[a]+=d.baseX,this.vertexY[a]+=d.baseY,this.vertexZ[a]+=d.baseZ}}else if(3===a)for(let a=0;a=this.labelVertices.length)continue;const n=this.labelVertices[r];if(n)for(let s=0;s=this.labelFaces.length)continue;const a=this.labelFaces[i];if(a)for(let t=0;t255&&(this.faceAlpha[i]=255)}}};calculateBoundsAABB=()=>{this.maxY=0,this.radius=0,this.minY=0,this.minX=999999,this.maxX=-999999,this.maxZ=-99999,this.minZ=99999;for(let e=0;ethis.maxX&&(this.maxX=t),sthis.maxZ&&(this.maxZ=s),-i>this.maxY&&(this.maxY=-i),i>this.minY&&(this.minY=i);const a=t*t+s*s;a>this.radius&&(this.radius=a)}this.radius=0|Math.sqrt(this.radius),this.minDepth=0|Math.sqrt(this.radius*this.radius+this.maxY*this.maxY),this.maxDepth=this.minDepth+(0|Math.sqrt(this.radius*this.radius+this.minY*this.minY))};pointWithinTriangle=(e,t,i,s,a,r,n,h)=>!(ti&&t>s&&t>a||e{if(!(d.vertexScreenX&&d.vertexScreenY&&this.faceColorA&&this.faceColorB&&this.faceColorC))return;const t=this.faceVertexA[e],i=this.faceVertexB[e],s=this.faceVertexC[e];r.Z.drawLine(d.vertexScreenX[t],d.vertexScreenY[t],d.vertexScreenX[i],d.vertexScreenY[i],r.Z.palette[1e3]),r.Z.drawLine(d.vertexScreenX[i],d.vertexScreenY[i],d.vertexScreenX[s],d.vertexScreenY[s],r.Z.palette[1e3]),r.Z.drawLine(d.vertexScreenX[s],d.vertexScreenY[s],d.vertexScreenX[t],d.vertexScreenY[t],r.Z.palette[1e3])}}},6542:(e,t,i)=>{i.d(t,{Z:()=>h});var s=i(2991),a=i(2383),r=i(6327),n=i(5147);class h extends r.Z{pixels;width;height;cropX;cropY;cropW;cropH;constructor(e,t){super(),this.pixels=new Int32Array(e*t),this.width=this.cropW=e,this.height=this.cropH=t,this.cropX=this.cropY=0}static fromJpeg=async(e,t)=>{const i=e.read(t+".dat");if(!i)throw new Error(`${t} jpeg not found!`);const s=await(0,n.Y)(i),a=new h(s.width,s.height),r=a.pixels,o=s.data;for(let e=0;e{const s=new a.Z(e.read(t+".dat")),r=new a.Z(e.read("index.dat"));r.pos=s.g2;const n=r.g2,o=r.g2,l=[],c=r.g1-1;for(let e=0;es.data.length||r.pos>r.data.length)throw new Error;const d=r.g1,u=r.g1,f=r.g2,p=r.g2,m=new h(f,p);m.cropX=d,m.cropY=u,m.cropW=n,m.cropH=o;const g=r.g1;if(0===g){const e=m.width*m.height;for(let t=0;t{s.Z.bind(this.pixels,this.width,this.height)};draw=(e,t)=>{e|=0,t|=0;let i=(e+=this.cropX)+(t+=this.cropY)*s.Z.width2d,a=0,r=this.height,n=this.width,h=s.Z.width2d-n,o=0;if(ts.Z.bottom&&(r-=t+r-s.Z.bottom),es.Z.right){const t=e+n-s.Z.right;n-=t,o+=t,h+=t}n>0&&r>0&&this.copyImageDraw(n,r,this.pixels,a,o,s.Z.pixels,i,h)};drawAlpha=(e,t,i)=>{t|=0,i|=0;let a=(t+=this.cropX)+(i+=this.cropY)*s.Z.width2d,r=0,n=this.height,h=this.width,o=s.Z.width2d-h,l=0;if(is.Z.bottom&&(n-=i+n-s.Z.bottom),ts.Z.right){const e=t+h-s.Z.right;h-=e,l+=e,o+=e}h>0&&n>0&&this.copyPixelsAlpha(h,n,this.pixels,r,l,s.Z.pixels,a,o,e)};blitOpaque=(e,t)=>{e|=0,t|=0;let i=(e+=this.cropX)+(t+=this.cropY)*s.Z.width2d,a=0,r=this.height,n=this.width,h=s.Z.width2d-n,o=0;if(ts.Z.bottom&&(r-=t+r-s.Z.bottom),es.Z.right){const t=e+n-s.Z.right;n-=t,o+=t,h+=t}n>0&&r>0&&this.copyImageBlitOpaque(n,r,this.pixels,a,o,s.Z.pixels,i,h)};flipHorizontally=()=>{const e=this.pixels,t=this.width,i=this.height;for(let s=0;s{const e=this.pixels,t=this.width,i=this.height;for(let s=0;s<(i/2|0);s++)for(let a=0;a{for(let s=0;s>16&255;r+=e,r<1?r=1:r>255&&(r=255);let n=a>>8&255;n+=t,n<1?n=1:n>255&&(n=255);let h=255&a;h+=i,h<1?h=1:h>255&&(h=255),this.pixels[s]=(r<<16)+(n<<8)+h}}};crop=(e,t,i,a)=>{e|=0,t|=0,i|=0,a|=0;try{const r=this.width;let n=0,h=0;const o=this.cropW,l=this.cropH,c=(o<<16)/i|0,d=(l<<16)/a|0;e+=(this.cropX*i+o-1)/o|0,t+=(this.cropY*a+l-1)/l|0,this.cropX*i%o!=0&&(n=(o-this.cropX*i%o<<16)/i|0),this.cropY*a%l!=0&&(h=(l-this.cropY*a%l<<16)/a|0),i=i*(this.width-(n>>16))/o|0,a=a*(this.height-(h>>16))/l|0;let u=e+t*s.Z.width2d,f=s.Z.width2d-i;if(ts.Z.bottom&&(a-=t+a-s.Z.bottom),es.Z.right){const t=e+i-s.Z.right;i-=t,f+=t}this.scale(i,a,this.pixels,n,h,s.Z.pixels,f,u,r,c,d)}catch(e){console.error("error in sprite clipping routine")}};drawRotatedMasked=(e,t,i,a,r,n,h,o,l,c)=>{e|=0,t|=0,i|=0,a|=0;try{const d=-i/2|0,u=-a/2|0,f=65536*Math.sin(l/326.11)|0,p=65536*Math.cos(l/326.11)|0,m=f*c>>8,g=p*c>>8;let y=(h<<16)+u*m+d*g,C=u*g-d*m+(o<<16),T=e+t*s.Z.width2d;for(let e=0;e>16)+(h>>16)*this.width],a+=g,h-=m;y+=m,C+=g,T+=s.Z.width2d}}catch(e){}};drawMasked=(e,t,i)=>{e|=0,t|=0;let a=(e+=this.cropX)+(t+=this.cropY)*s.Z.width2d,r=0,n=this.height,h=this.width,o=s.Z.width2d-h,l=0;if(ts.Z.bottom&&(n-=t+n-s.Z.bottom),es.Z.right){const t=e+h-s.Z.right;h-=t,l+=t,o+=t}h>0&&n>0&&this.copyPixelsMasked(h,n,this.pixels,l,r,s.Z.pixels,a,o,i.pixels)};scale=(e,t,i,s,a,r,n,h,o,l,c)=>{try{const d=s;for(let u=-t;u<0;u++){const t=(a>>16)*o;for(let a=-e;a<0;a++){const e=i[(s>>16)+t];0===e?h++:r[h++]=e,s+=l}a+=c,s=d,h+=n}}catch(e){console.error("error in plot_scale")}};copyImageBlitOpaque=(e,t,i,s,a,r,n,h)=>{const o=-(e>>2);e=-(3&e);for(let l=-t;l<0;l++){for(let e=o;e<0;e++)r[n++]=i[s++],r[n++]=i[s++],r[n++]=i[s++],r[n++]=i[s++];for(let t=e;t<0;t++)r[n++]=i[s++];n+=h,s+=a}};copyPixelsAlpha=(e,t,i,s,a,r,n,h,o)=>{const l=256-o;for(let c=-t;c<0;c++){for(let t=-e;t<0;t++){const e=i[s++];if(0===e)n++;else{const t=r[n];r[n++]=((16711935&e)*o+(16711935&t)*l&4278255360)+((65280&e)*o+(65280&t)*l&16711680)>>8}}n+=h,s+=a}};copyImageDraw=(e,t,i,s,a,r,n,h)=>{const o=-(e>>2);e=-(3&e);for(let l=-t;l<0;l++){for(let e=o;e<0;e++){let e=i[s++];0===e?n++:r[n++]=e,e=i[s++],0===e?n++:r[n++]=e,e=i[s++],0===e?n++:r[n++]=e,e=i[s++],0===e?n++:r[n++]=e}for(let t=e;t<0;t++){const e=i[s++];0===e?n++:r[n++]=e}n+=h,s+=a}};copyPixelsMasked=(e,t,i,s,a,r,n,h,o)=>{const l=-(e>>2);e=-(3&e);for(let c=-t;c<0;c++){for(let e=l;e<0;e++){let e=i[a++];0!==e&&0===o[n]?r[n++]=e:n++,e=i[a++],0!==e&&0===o[n]?r[n++]=e:n++,e=i[a++],0!==e&&0===o[n]?r[n++]=e:n++,e=i[a++],0!==e&&0===o[n]?r[n++]=e:n++}for(let t=e;t<0;t++){const e=i[a++];0!==e&&0===o[n]?r[n++]=e:n++}n+=h,a+=s}}}},664:(e,t,i)=>{i.d(t,{Z:()=>n});var s=i(2991),a=i(2383),r=i(6327);class n extends r.Z{pixels;width;height;cropX;cropY;cropW;cropH;palette;constructor(e,t,i){super(),this.pixels=new Int8Array(e*t),this.width=this.cropW=e,this.height=this.cropH=t,this.cropX=this.cropY=0,this.palette=i}static fromArchive=(e,t,i=0)=>{const s=new a.Z(e.read(t+".dat")),r=new a.Z(e.read("index.dat"));r.pos=s.g2;const h=r.g2,o=r.g2,l=r.g1,c=new Int32Array(l);for(let e=1;es.data.length||r.pos>r.data.length)throw new Error;const d=r.g1,u=r.g1,f=r.g2,p=r.g2,m=new n(f,p,c);m.cropX=d,m.cropY=u,m.cropW=h,m.cropH=o;const g=m.pixels,y=r.g1;if(0===y){const e=m.width*m.height;for(let t=0;t{e|=0,t|=0;let i=(e+=this.cropX)+(t+=this.cropY)*s.Z.width2d,a=0,r=this.height,n=this.width,h=s.Z.width2d-n,o=0;if(ts.Z.bottom&&(r-=t+r-s.Z.bottom),es.Z.right){const t=e+n-s.Z.right;n-=t,o+=t,h+=t}n>0&&r>0&&this.copyImage(n,r,this.pixels,a,o,s.Z.pixels,i,h)};flipHorizontally=()=>{const e=this.pixels,t=this.width,i=this.height;for(let s=0;s{const e=this.pixels,t=this.width,i=this.height;for(let s=0;s<(i/2|0);s++)for(let a=0;a{for(let s=0;s>16&255;a+=e,a<0?a=0:a>255&&(a=255);let r=this.palette[s]>>8&255;r+=t,r<0?r=0:r>255&&(r=255);let n=255&this.palette[s];n+=i,n<0?n=0:n>255&&(n=255),this.palette[s]=(a<<16)+(r<<8)+n}};shrink=()=>{this.cropW|=0,this.cropH|=0,this.cropW/=2,this.cropH/=2,this.cropW|=0,this.cropH|=0;const e=new Int8Array(this.cropW*this.cropH);let t=0;for(let i=0;i>1)+(i+this.cropY>>1)*this.cropW]=this.pixels[t++];this.pixels=e,this.width=this.cropW,this.height=this.cropH,this.cropX=0,this.cropY=0};crop=()=>{if(this.width===this.cropW&&this.height===this.cropH)return;const e=new Int8Array(this.cropW*this.cropH);let t=0;for(let i=0;i{const o=-(e>>2);e=-(3&e);for(let l=-t;l<0;l++){for(let e=o;e<0;e++){let e=i[s++];0===e?n++:r[n++]=this.palette[255&e],e=i[s++],0===e?n++:r[n++]=this.palette[255&e],e=i[s++],0===e?n++:r[n++]=this.palette[255&e],e=i[s++],0===e?n++:r[n++]=this.palette[255&e]}for(let t=e;t<0;t++){const e=i[s++];0===e?n++:r[n++]=this.palette[255&e]}n+=h,s+=a}}}},4628:(e,t,i)=>{i.d(t,{Z:()=>o});var s=i(2991),a=i(2383),r=i(6327);class n{seed;constructor(e){this.seed=(0x5deece66dn^e)&(1n<<48n)-1n}setSeed=e=>{this.seed=(0x5deece66dn^e)&(1n<<48n)-1n};nextInt=()=>this.next(32);next=e=>(this.seed=0x5deece66dn*this.seed+0xbn&(1n<<48n)-1n,Number(this.seed)>>>48-e)}var h=i(312);class o extends r.Z{static CHARSET="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"£$%^&*()-_=+[{]};:'@#~,<.>/?\\| ";static CHARCODESET=[];static{for(let e=0;e<256;e++){let t=o.CHARSET.indexOf(String.fromCharCode(e));-1===t&&(t=74),o.CHARCODESET[e]=t}}charMask=[];charMaskWidth=new Int32Array(94);charMaskHeight=new Int32Array(94);charOffsetX=new Int32Array(94);charOffsetY=new Int32Array(94);charAdvance=new Int32Array(95);drawWidth=new Int32Array(256);random=new n(BigInt(Date.now()));height=0;static fromArchive=(e,t)=>{const i=new a.Z(e.read(t+".dat")),s=new a.Z(e.read("index.dat"));s.pos=i.g2+4;const r=s.g1;r>0&&(s.pos+=3*(r-1));const n=new o;for(let e=0;e<94;e++){n.charOffsetX[e]=s.g1,n.charOffsetY[e]=s.g1;const t=n.charMaskWidth[e]=s.g2,a=n.charMaskHeight[e]=s.g2,r=s.g1,h=t*a;if(n.charMask[e]=new Int8Array(h),0===r)for(let s=0;sn.height&&(n.height=a),n.charOffsetX[e]=1,n.charAdvance[e]=t+2;{let i=0;for(let s=a/7|0;s{if(!i)return;e|=0,t|=0;const a=i.length;t-=this.height;for(let r=0;r{e|=0,t|=0;const r=i.length;t-=this.height;for(let n=0;n{if(!e)return 0;const t=e.length;let i=0;for(let s=0;s{e|=0,t|=0,this.drawStringTaggable(e-this.stringWidth(i)/2,t,i,s,a)};drawStringCenter=(e,t,i,s)=>{i&&(e|=0,t|=0,this.drawString(e-this.stringWidth(i)/2,t,i,s))};drawStringTooltip=(e,t,i,s,a,r)=>{e|=0,t|=0,this.random.setSeed(BigInt(r));const n=192+(31&this.random.nextInt()),l=t-this.height;for(let t=0;t{e|=0,t|=0,a&&this.drawString(e-this.stringWidth(i)+1,t+1,i,h.Z.BLACK),this.drawString(e-this.stringWidth(i),t,i,s)};drawCenteredWave=(e,t,i,s,a)=>{if(!i)return;e|=0,t|=0,e-=this.stringWidth(i)/2|0;const r=t-this.height;for(let t=0;t{a|=0,r|=0;let h=(t|=0)+(i|=0)*s.Z.width2d,o=s.Z.width2d-a,l=0,c=0;if(i=s.Z.bottom&&(r-=i+r+1-s.Z.bottom),t=s.Z.right){const e=t+a+1-s.Z.right;a-=e,l+=e,o+=e}a>0&&r>0&&this.drawMask(a,r,e,c,l,s.Z.pixels,h,o,n)};drawCharAlpha=(e,t,i,a,r,n,h)=>{i|=0,a|=0;let o=(e|=0)+(t|=0)*s.Z.width2d,l=s.Z.width2d-i,c=0,d=0;if(t=s.Z.bottom&&(a-=t+a+1-s.Z.bottom),e=s.Z.right){const t=e+i+1-s.Z.right;i-=t,c+=t,l+=t}i>0&&a>0&&this.drawMaskAlpha(i,a,s.Z.pixels,o,l,h,d,c,r,n)};drawMask=(e,t,i,s,a,r,n,h,o)=>{const l=-((e|=0)>>2);e=-(3&e);for(let c=-(t|=0);c<0;c++){for(let e=l;e<0;e++)0===i[s++]?n++:r[n++]=o,0===i[s++]?n++:r[n++]=o,0===i[s++]?n++:r[n++]=o,0===i[s++]?n++:r[n++]=o;for(let t=e;t<0;t++)0===i[s++]?n++:r[n++]=o;n+=h,s+=a}};drawMaskAlpha=(e,t,i,s,a,r,n,h,o,l)=>{e|=0;const c=((16711935&o)*l&4278255360)+((65280&o)*l&16711680)>>8,d=256-l;for(let o=-(t|=0);o<0;o++){for(let t=-e;t<0;t++)if(0===r[n++])s++;else{const e=i[s];i[s++]=(((16711935&e)*d&4278255360)+((65280&e)*d&16711680)>>8)+c}s+=a,n+=h}};evaluateTag=e=>"red"===e?h.Z.RED:"gre"===e?h.Z.GREEN:"blu"===e?h.Z.BLUE:"yel"===e?h.Z.YELLOW:"cya"===e?h.Z.CYAN:"mag"===e?h.Z.MAGENTA:"whi"===e?h.Z.WHITE:"bla"===e?h.Z.BLACK:"lre"===e?h.Z.LIGHTRED:"dre"===e?h.Z.DARKRED:"dbl"===e?h.Z.DARKBLUE:"or1"===e?h.Z.ORANGE1:"or2"===e?h.Z.ORANGE2:"or3"===e?h.Z.ORANGE3:"gr1"===e?h.Z.GREEN1:"gr2"===e?h.Z.GREEN2:"gr3"===e?h.Z.GREEN3:h.Z.BLACK;split(e,t){if(0===e.length)return[e];const i=[];for(;e.length>0;){if(this.stringWidth(e)<=t&&-1===e.indexOf("|")){i.push(e);break}let s=e.length;for(let i=0;it)break;s=i}else if("|"===e[i]){s=i;break}i.push(e.substring(0,s)),e=e.substring(s+1)}return i}}},651:(e,t,i)=>{i.d(t,{Z:()=>r});var s=i(2991),a=i(6121);class r{image;width;height;ctx;pixels;constructor(e,t,i=a.E1){this.ctx=i,this.image=this.ctx.getImageData(0,0,e,t),this.pixels=new Int32Array(e*t),this.width=e,this.height=t,this.bind()}clear=()=>{this.pixels.fill(0)};bind=()=>{s.Z.bind(this.pixels,this.width,this.height)};draw=(e,t)=>{this.#e(),this.ctx.putImageData(this.image,e,t)};#e=()=>{const e=this.image.data;for(let t=0;t>16&255,e[s+1]=i>>8&255,e[s+2]=i>>0&255,e[s+3]=255}}}},2157:(e,t,i)=>{i.d(t,{Z:()=>r});var s=i(2383),a=i(9345);class r{static instances=[];static unpack=e=>{const t=new s.Z(e.read("base_head.dat")),i=new s.Z(e.read("base_type.dat")),n=new s.Z(e.read("base_label.dat")),h=t.g2;t.pos+=2;for(let e=0;e{i.d(t,{Z:()=>r});var s=i(2157),a=i(2383);class r{static instances=[];static unpack=e=>{const t=new a.Z(e.read("frame_head.dat")),i=new a.Z(e.read("frame_tran1.dat")),n=new a.Z(e.read("frame_tran2.dat")),h=new a.Z(e.read("frame_del.dat")),o=t.g2;t.pos+=2;const l=new Int32Array(500),c=new Int32Array(500),d=new Int32Array(500),u=new Int32Array(500);for(let e=0;e0){if(0!==f.types[e])for(let t=e-1;t>m;t--)if(0===f.types[t]){l[g]=t,c[g]=0,d[g]=0,u[g]=0,g++;break}l[g]=e;let i=0;3===f.types[l[g]]&&(i=128),c[g]=0==(1&t)?i:n.gsmart,d[g]=0==(2&t)?i:n.gsmart,u[g]=0==(4&t)?i:n.gsmart,m=e,g++}}a.length=g,a.bases=new Int32Array(g),a.x=new Int32Array(g),a.y=new Int32Array(g),a.z=new Int32Array(g);for(let e=0;e{var s;i.d(t,{Z:()=>a}),function(e){e[e.REBUILD_GETMAPS=150]="REBUILD_GETMAPS",e[e.IDLE_TIMER=70]="IDLE_TIMER",e[e.NO_TIMEOUT=108]="NO_TIMEOUT",e[e.EVENT_TRACKING=81]="EVENT_TRACKING",e[e.EVENT_CAMERA_POSITION=189]="EVENT_CAMERA_POSITION",e[e.ANTICHEAT_OPLOGIC1=7]="ANTICHEAT_OPLOGIC1",e[e.ANTICHEAT_OPLOGIC2=88]="ANTICHEAT_OPLOGIC2",e[e.ANTICHEAT_OPLOGIC3=30]="ANTICHEAT_OPLOGIC3",e[e.ANTICHEAT_OPLOGIC4=176]="ANTICHEAT_OPLOGIC4",e[e.ANTICHEAT_OPLOGIC5=220]="ANTICHEAT_OPLOGIC5",e[e.ANTICHEAT_OPLOGIC6=66]="ANTICHEAT_OPLOGIC6",e[e.ANTICHEAT_OPLOGIC7=17]="ANTICHEAT_OPLOGIC7",e[e.ANTICHEAT_OPLOGIC8=2]="ANTICHEAT_OPLOGIC8",e[e.ANTICHEAT_OPLOGIC9=238]="ANTICHEAT_OPLOGIC9",e[e.ANTICHEAT_CYCLELOGIC1=233]="ANTICHEAT_CYCLELOGIC1",e[e.ANTICHEAT_CYCLELOGIC2=146]="ANTICHEAT_CYCLELOGIC2",e[e.ANTICHEAT_CYCLELOGIC3=215]="ANTICHEAT_CYCLELOGIC3",e[e.ANTICHEAT_CYCLELOGIC4=236]="ANTICHEAT_CYCLELOGIC4",e[e.ANTICHEAT_CYCLELOGIC5=85]="ANTICHEAT_CYCLELOGIC5",e[e.ANTICHEAT_CYCLELOGIC6=219]="ANTICHEAT_CYCLELOGIC6",e[e.OPOBJ1=140]="OPOBJ1",e[e.OPOBJ2=40]="OPOBJ2",e[e.OPOBJ3=200]="OPOBJ3",e[e.OPOBJ4=178]="OPOBJ4",e[e.OPOBJ5=247]="OPOBJ5",e[e.OPOBJT=138]="OPOBJT",e[e.OPOBJU=239]="OPOBJU",e[e.OPNPC1=194]="OPNPC1",e[e.OPNPC2=8]="OPNPC2",e[e.OPNPC3=27]="OPNPC3",e[e.OPNPC4=113]="OPNPC4",e[e.OPNPC5=100]="OPNPC5",e[e.OPNPCT=134]="OPNPCT",e[e.OPNPCU=202]="OPNPCU",e[e.OPLOC1=245]="OPLOC1",e[e.OPLOC2=172]="OPLOC2",e[e.OPLOC3=96]="OPLOC3",e[e.OPLOC4=97]="OPLOC4",e[e.OPLOC5=116]="OPLOC5",e[e.OPLOCT=9]="OPLOCT",e[e.OPLOCU=75]="OPLOCU",e[e.OPPLAYER1=164]="OPPLAYER1",e[e.OPPLAYER2=53]="OPPLAYER2",e[e.OPPLAYER3=185]="OPPLAYER3",e[e.OPPLAYER4=206]="OPPLAYER4",e[e.OPPLAYERT=177]="OPPLAYERT",e[e.OPPLAYERU=248]="OPPLAYERU",e[e.OPHELD1=195]="OPHELD1",e[e.OPHELD2=71]="OPHELD2",e[e.OPHELD3=133]="OPHELD3",e[e.OPHELD4=157]="OPHELD4",e[e.OPHELD5=211]="OPHELD5",e[e.OPHELDT=48]="OPHELDT",e[e.OPHELDU=130]="OPHELDU",e[e.INV_BUTTON1=31]="INV_BUTTON1",e[e.INV_BUTTON2=59]="INV_BUTTON2",e[e.INV_BUTTON3=212]="INV_BUTTON3",e[e.INV_BUTTON4=38]="INV_BUTTON4",e[e.INV_BUTTON5=6]="INV_BUTTON5",e[e.IF_BUTTON=155]="IF_BUTTON",e[e.RESUME_PAUSEBUTTON=235]="RESUME_PAUSEBUTTON",e[e.CLOSE_MODAL=231]="CLOSE_MODAL",e[e.RESUME_P_COUNTDIALOG=237]="RESUME_P_COUNTDIALOG",e[e.TUTORIAL_CLICKSIDE=175]="TUTORIAL_CLICKSIDE",e[e.MOVE_OPCLICK=93]="MOVE_OPCLICK",e[e.BUG_REPORT=190]="BUG_REPORT",e[e.MOVE_MINIMAPCLICK=165]="MOVE_MINIMAPCLICK",e[e.INV_BUTTOND=159]="INV_BUTTOND",e[e.IGNORELIST_DEL=171]="IGNORELIST_DEL",e[e.IGNORELIST_ADD=79]="IGNORELIST_ADD",e[e.IF_PLAYERDESIGN=52]="IF_PLAYERDESIGN",e[e.CHAT_SETMODE=244]="CHAT_SETMODE",e[e.MESSAGE_PRIVATE=148]="MESSAGE_PRIVATE",e[e.FRIENDLIST_DEL=11]="FRIENDLIST_DEL",e[e.FRIENDLIST_ADD=118]="FRIENDLIST_ADD",e[e.CLIENT_CHEAT=4]="CLIENT_CHEAT",e[e.MESSAGE_PUBLIC=158]="MESSAGE_PUBLIC",e[e.MOVE_GAMECLICK=181]="MOVE_GAMECLICK"}(s||(s={}));const a=s},1812:(e,t,i)=>{i.d(t,{Z:()=>a});var s=i(1519);class a{socket;queue=[];buffer=void 0;remaining=0;offset=0;static openSocket=async e=>await new Promise(((t,i)=>{const s=e.host.startsWith("https"),a=s?"wss":"ws",r=e.host.substring(e.host.indexOf("//")+2),n=s?e.port+2:e.port+1,h=new WebSocket(`${a}://${r}:${n}`,"binary");h.binaryType="arraybuffer",h.addEventListener("open",(()=>{console.log("connection open!"),t(h)})),h.addEventListener("error",(()=>{console.log("connection error!"),i(h)}))}));constructor(e){e.onmessage=this.onmessage,e.onclose=this.onclose,e.onerror=this.onerror,this.socket=e}get host(){return this.socket.url.split("/")[2]}get port(){return parseInt(this.socket.url.split(":")[2],10)}get available(){return this.remaining}write=(e,t,i)=>{if(this.socket.readyState!==WebSocket.OPEN)throw new Error("Socket is not able to write!");const a=new Uint8Array(t);(0,s.fH)(e,i,a,0,t),this.socket.send(a)};read=async()=>{if(this.socket.readyState!==WebSocket.OPEN&&this.remaining<1)throw new Error("Socket is not able to read!");if(this.remaining<1)return await(0,s._v)(1),this.read();if(this.buffer||(this.buffer=this.queue.shift(),this.buffer&&(this.offset=0)),!this.buffer)return this.read();const e=255&this.buffer[this.offset];return this.offset++,this.remaining--,this.offset===this.buffer.length&&(this.buffer=void 0),e};readBytes=async(e,t,i)=>{if(this.socket.readyState!==WebSocket.OPEN&&this.remaining<1)throw new Error("Socket is not able to read!");if(!(i<1)){if(this.remaining<1)return await(0,s._v)(1),this.readBytes(e,t,i);for(let s=0;s{this.socket.readyState===WebSocket.OPEN&&this.socket.close()};clear=()=>{this.socket.readyState===WebSocket.OPEN&&this.socket.close(),this.queue.length=0,this.remaining=0,this.buffer=void 0,this.offset=0};onmessage=e=>{const t=new Int8Array(e.data);this.remaining+=t.length,this.queue.push(t)};onclose=e=>{console.log("connection close!")};onerror=e=>{console.log("connection error!")}}},8432:(e,t,i)=>{i.d(t,{Z:()=>s});class s{db;constructor(e){e.onerror=this.onerror,e.onclose=this.onclose,this.db=e}static openDatabase=async()=>await new Promise(((e,t)=>{const i=indexedDB.open("lostcity",1);i.onsuccess=t=>{const i=t.target;console.log("database success!"),e(i.result)},i.onupgradeneeded=e=>{e.target.result.createObjectStore("cache")},i.onerror=e=>{const i=e.target;console.error("database error!: ",i.error),t(i.result)}}));cacheload=async e=>await new Promise((t=>{const i=this.db.transaction("cache","readonly").objectStore("cache").get(e);i.onsuccess=()=>{t(i.result)},i.onerror=e=>{t(void 0)}}));cachesave=async(e,t)=>await new Promise(((i,s)=>{const a=this.db.transaction("cache","readwrite").objectStore("cache").put(t,e);a.onsuccess=()=>{i()},a.onerror=e=>{s()}}));onclose=e=>{console.log("database close!")};onerror=e=>{console.log("database error!")};genHash=e=>{const t=e.trim();let i=0;for(let e=0;e="A"&&s<="Z"?i+=s.charCodeAt(0)+1-65:s>="a"&&s<="z"?i+=s.charCodeAt(0)+1-97:s>="0"&&s<="9"&&(i+=s.charCodeAt(0)+27-48)}return i}}},7576:(e,t,i)=>{i.d(t,{Z:()=>s});class s{count=0;rsl=new Int32Array(256);mem=new Int32Array(256);a=0;b=0;c=0;constructor(e){for(let t=0;t{let e=2654435769,t=2654435769,i=2654435769,s=2654435769,a=2654435769,r=2654435769,n=2654435769,h=2654435769;for(let o=0;o<4;o++)e^=t<<11,s+=e,t+=i,t^=i>>>2,a+=t,i+=s,i^=s<<8,r+=i,s+=a,s^=a>>>16,n+=s,a+=r,a^=r<<10,h+=a,r+=n,r^=n>>>4,e+=r,n+=h,n^=h<<8,t+=n,h+=e,h^=e>>>9,i+=h,e+=t;for(let o=0;o<256;o+=8)e+=this.rsl[o],t+=this.rsl[o+1],i+=this.rsl[o+2],s+=this.rsl[o+3],a+=this.rsl[o+4],r+=this.rsl[o+5],n+=this.rsl[o+6],h+=this.rsl[o+7],e^=t<<11,s+=e,t+=i,t^=i>>>2,a+=t,i+=s,i^=s<<8,r+=i,s+=a,s^=a>>>16,n+=s,a+=r,a^=r<<10,h+=a,r+=n,r^=n>>>4,e+=r,n+=h,n^=h<<8,t+=n,h+=e,h^=e>>>9,i+=h,e+=t,this.mem[o]=e,this.mem[o+1]=t,this.mem[o+2]=i,this.mem[o+3]=s,this.mem[o+4]=a,this.mem[o+5]=r,this.mem[o+6]=n,this.mem[o+7]=h;for(let o=0;o<256;o+=8)e+=this.mem[o],t+=this.mem[o+1],i+=this.mem[o+2],s+=this.mem[o+3],a+=this.mem[o+4],r+=this.mem[o+5],n+=this.mem[o+6],h+=this.mem[o+7],e^=t<<11,s+=e,t+=i,t^=i>>>2,a+=t,i+=s,i^=s<<8,r+=i,s+=a,s^=a>>>16,n+=s,a+=r,a^=r<<10,h+=a,r+=n,r^=n>>>4,e+=r,n+=h,n^=h<<8,t+=n,h+=e,h^=e>>>9,i+=h,e+=t,this.mem[o]=e,this.mem[o+1]=t,this.mem[o+2]=i,this.mem[o+3]=s,this.mem[o+4]=a,this.mem[o+5]=r,this.mem[o+6]=n,this.mem[o+7]=h;this.isaac(),this.count=256};isaac=()=>{this.c++,this.b+=this.c;for(let e=0;e<256;e++){const t=this.mem[e],i=3&e;let s;0===i?this.a^=this.a<<13:1===i?this.a^=this.a>>>6:2===i?this.a^=this.a<<2:3===i&&(this.a^=this.a>>>16),this.a+=this.mem[e+128&255],this.mem[e]=s=this.mem[t>>>2&255]+this.a+this.b,this.rsl[e]=this.b=this.mem[s>>>8>>>2&255]+t}}}},2028:(e,t,i)=>{i.d(t,{Z:()=>r});var s=i(2383),a=i(5810);class r{static genHash=e=>{let t=0;e=e.toUpperCase();for(let i=0;i{const t=r.genHash(e),i=this.fileHash.indexOf(t);return-1===i?null:this.readIndex(i)};readIndex=e=>{if(e<0||e>=this.fileCount)return null;if(this.fileUnpacked[e])return this.fileUnpacked[e];const t=this.fileOffset[e],i=t+this.filePackedSize[e];if(this.compressedWhole){const s=Uint8Array.from(this.buffer.subarray(t,t+i));return this.fileUnpacked[e]=s,s}{const t=Uint8Array.from(a.Z.read(this.fileUnpackedSize[e],this.buffer,this.filePackedSize[e],this.fileOffset[e]));return this.fileUnpacked[e]=t,t}}}},2383:(e,t,i)=>{i.d(t,{Z:()=>n});var s=i(1519),a=i(9080),r=i(6327);class n extends r.Z{static CRC32_POLYNOMIAL=3988292384;static crctable=new Int32Array(256);static bitmask=new Uint32Array(33);static cacheMin=new a.Z;static cacheMid=new a.Z;static cacheMax=new a.Z;static cacheMinCount=0;static cacheMidCount=0;static cacheMaxCount=0;static{for(let e=0;e<32;e++)n.bitmask[e]=(1<>>1^n.CRC32_POLYNOMIAL:t>>>=1;n.crctable[e]=t}}static crc32=e=>{let t=4294967295;for(let i=0;i>>8^n.crctable[255&(t^e[i])];return~t};data;pos;bitPos=0;random=null;constructor(e){if(!e)throw new Error("Input src packet array was null!");super(),e instanceof Int8Array?this.data=new Uint8Array(e):this.data=e,this.pos=0}get length(){return this.data.length}get available(){return this.data.length-this.pos}static alloc=e=>{let t=null;return 0===e&&n.cacheMinCount>0?(n.cacheMinCount--,t=n.cacheMin.pollFront()):1===e&&n.cacheMidCount>0?(n.cacheMidCount--,t=n.cacheMid.pollFront()):2===e&&n.cacheMaxCount>0&&(n.cacheMaxCount--,t=n.cacheMax.pollFront()),t?(t.pos=0,t):new n(0===e?new Uint8Array(100):1===e?new Uint8Array(5e3):new Uint8Array(3e4))};release=()=>{this.pos=0,100===this.data.length&&n.cacheMinCount<1e3?(n.cacheMin.pushBack(this),n.cacheMinCount++):5e3===this.data.length&&n.cacheMidCount<250?(n.cacheMid.pushBack(this),n.cacheMidCount++):3e4===this.data.length&&n.cacheMaxCount<50&&(n.cacheMax.pushBack(this),n.cacheMaxCount++)};get g1(){return this.data[this.pos++]}get g1b(){return this.data[this.pos++]<<24>>24}get g2(){return this.data[this.pos++]<<8|this.data[this.pos++]}get g2b(){let e=this.data[this.pos++]<<8|this.data[this.pos++];return e>32767&&(e-=65536),e}get g3(){return this.data[this.pos++]<<16|this.data[this.pos++]<<8|this.data[this.pos++]}get g4(){return this.data[this.pos++]<<24|this.data[this.pos++]<<16|this.data[this.pos++]<<8|this.data[this.pos++]}get g8(){return(0xffffffffn&BigInt(this.g4))<<32n|0xffffffffn&BigInt(this.g4)}get gsmart(){return this.data[this.pos]<128?this.g1-64:this.g2-49152}get gsmarts(){return this.data[this.pos]<128?this.g1:this.g2-32768}get gjstr(){let e="";for(;10!==this.data[this.pos]&&this.pos{for(let s=t;s{this.data[this.pos++]=e+(this.random?.nextInt??0)&255};p1=e=>{this.data[this.pos++]=e};p2=e=>{this.data[this.pos++]=e>>>8,this.data[this.pos++]=e};ip2=e=>{this.data[this.pos++]=e,this.data[this.pos++]=e>>>8};p3=e=>{this.data[this.pos++]=e>>>16,this.data[this.pos++]=e>>>8,this.data[this.pos++]=e};p4=e=>{this.data[this.pos++]=e>>>24,this.data[this.pos++]=e>>>16,this.data[this.pos++]=e>>>8,this.data[this.pos++]=e};ip4=e=>{this.data[this.pos++]=e,this.data[this.pos++]=e>>>8,this.data[this.pos++]=e>>>16,this.data[this.pos++]=e>>>24};p8=e=>{this.p4(Number(e>>32n)),this.p4(Number(0xffffffffn&e))};pjstr=e=>{for(let t=0;t{for(let s=i;s{this.data[this.pos-e-1]=e};bits=()=>{this.bitPos=8*this.pos};bytes=()=>{this.pos=(this.bitPos+7)/8|0};gBit=e=>{let t=this.bitPos>>>3,i=8-(7&this.bitPos),s=0;for(this.bitPos+=e;e>i;i=8)s+=(this.data[t++]&n.bitmask[i])<>>i-e&n.bitmask[e],s};rsaenc=(e,t)=>{const i=new Uint8Array(this.pos);(0,s.fH)(this.data,0,i,0,this.pos);const a=(0,s.v3)(i),r=(0,s.yz)(a,t,e),n=(0,s.jk)(r);this.pos=0,this.p1(n.length),this.pdata(n,n.length,0)}}},741:(e,t,i)=>{i.d(t,{Z:()=>s});class s{static CLIENTPROT_SCRAMBLED=[95,218,67,50,253,222,194,60,101,128,8,251,92,111,24,33,223,66,232,59,227,113,153,105,126,98,167,102,177,238,62,190,147,23,150,151,156,144,193,155,81,0,198,22,137,210,179,16,168,170,32,181,248,141,58,87,208,106,180,191,221,241,40,176,196,154,65,145,230,78,30,161,188,41,14,129,18,199,47,247,225,34,51,10,159,75,12,56,61,31,39,91,46,242,134,5,122,123,209,228,104,195,21,3,11,44,107,172,6,186,110,215,205,103,27,185,124,77,252,117,86,115,127,207,52,79,43,97,219,116,169,7,118,162,108,36,20,233,88,135,80,19,42,237,57,152,71,9,250,17,4,119,234,130,26,200,189,163,254,245,197,171,220,235,140,244,184,94,211,231,99,246,121,212,112,204,63,148,83,178,1,255,131,13,183,142,236,45,55,35,243,136,37,85,100,160,38,224,146,174,82,48,109,132,125,90,143,138,240,173,165,164,192,175,29,74,28,114,213,73,64,206,76,139,96,2,229,15,93,25,239,202,49,70,214,201,72,203,68,89,69,157,216,217,249,120,226,84,149,187,54,53,158,166,182,133,0];static SERVERPROT_SIZES=[0,-2,4,6,-1,0,0,2,0,0,0,0,5,4,2,2,0,0,0,0,2,-2,2,14,0,6,3,0,4,0,0,0,3,0,0,0,0,0,0,0,0,-1,4,2,6,0,6,0,0,3,7,0,0,0,-1,0,0,0,0,4,0,0,0,0,0,0,0,0,1,15,0,0,0,0,6,0,2,0,0,0,2,0,0,0,1,0,0,4,0,0,0,0,0,0,0,0,0,0,-2,0,0,0,0,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,-2,0,0,2,0,0,0,2,9,0,0,0,0,0,4,0,0,0,3,7,9,0,0,0,0,0,0,0,0,0,-2,0,0,0,0,3,2,0,0,0,0,0,0,6,0,0,0,0,0,0,0,0,-2,2,0,0,0,0,0,6,0,0,0,2,0,2,0,0,0,-2,0,0,4,0,0,0,0,6,0,0,-2,-2,0,0,0,0,0,0,-2,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,-2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0]}},9782:(e,t,i)=>{var s;i.d(t,{Z:()=>a}),function(e){e[e.IF_OPENCHATMODAL=14]="IF_OPENCHATMODAL",e[e.IF_OPENMAINSIDEMODAL=28]="IF_OPENMAINSIDEMODAL",e[e.IF_CLOSE=129]="IF_CLOSE",e[e.IF_OPENSIDEOVERLAY=167]="IF_OPENSIDEOVERLAY",e[e.IF_OPENMAINMODAL=168]="IF_OPENMAINMODAL",e[e.IF_OPENSIDEMODAL=195]="IF_OPENSIDEMODAL",e[e.IF_SETCOLOUR=2]="IF_SETCOLOUR",e[e.IF_SETHIDE=26]="IF_SETHIDE",e[e.IF_SETOBJECT=46]="IF_SETOBJECT",e[e.IF_SHOWSIDE=84]="IF_SHOWSIDE",e[e.IF_SETMODEL=87]="IF_SETMODEL",e[e.IF_SETRECOL=103]="IF_SETRECOL",e[e.IF_SETANIM=146]="IF_SETANIM",e[e.IF_SETPLAYERHEAD=197]="IF_SETPLAYERHEAD",e[e.IF_SETTEXT=201]="IF_SETTEXT",e[e.IF_SETNPCHEAD=204]="IF_SETNPCHEAD",e[e.IF_SETPOSITION=209]="IF_SETPOSITION",e[e.TUTORIAL_FLASHSIDE=126]="TUTORIAL_FLASHSIDE",e[e.TUTORIAL_OPENCHAT=185]="TUTORIAL_OPENCHAT",e[e.UPDATE_INV_STOP_TRANSMIT=15]="UPDATE_INV_STOP_TRANSMIT",e[e.UPDATE_INV_FULL=98]="UPDATE_INV_FULL",e[e.UPDATE_INV_PARTIAL=213]="UPDATE_INV_PARTIAL",e[e.CAM_LOOKAT=3]="CAM_LOOKAT",e[e.CAM_SHAKE=13]="CAM_SHAKE",e[e.CAM_MOVETO=74]="CAM_MOVETO",e[e.CAM_RESET=239]="CAM_RESET",e[e.NPC_INFO=1]="NPC_INFO",e[e.PLAYER_INFO=184]="PLAYER_INFO",e[e.FINISH_TRACKING=133]="FINISH_TRACKING",e[e.ENABLE_TRACKING=226]="ENABLE_TRACKING",e[e.MESSAGE_GAME=4]="MESSAGE_GAME",e[e.UPDATE_IGNORELIST=21]="UPDATE_IGNORELIST",e[e.CHAT_FILTER_SETTINGS=32]="CHAT_FILTER_SETTINGS",e[e.MESSAGE_PRIVATE=41]="MESSAGE_PRIVATE",e[e.UPDATE_FRIENDLIST=152]="UPDATE_FRIENDLIST",e[e.UNSET_MAP_FLAG=19]="UNSET_MAP_FLAG",e[e.UPDATE_RUNWEIGHT=22]="UPDATE_RUNWEIGHT",e[e.HINT_ARROW=25]="HINT_ARROW",e[e.UPDATE_REBOOT_TIMER=43]="UPDATE_REBOOT_TIMER",e[e.UPDATE_STAT=44]="UPDATE_STAT",e[e.UPDATE_RUNENERGY=68]="UPDATE_RUNENERGY",e[e.RESET_ANIMS=136]="RESET_ANIMS",e[e.UPDATE_UID192=139]="UPDATE_UID192",e[e.LAST_LOGIN_INFO=140]="LAST_LOGIN_INFO",e[e.LOGOUT=142]="LOGOUT",e[e.P_COUNTDIALOG=243]="P_COUNTDIALOG",e[e.SET_MULTIWAY=254]="SET_MULTIWAY",e[e.DATA_LOC_DONE=20]="DATA_LOC_DONE",e[e.DATA_LAND_DONE=80]="DATA_LAND_DONE",e[e.DATA_LAND=132]="DATA_LAND",e[e.DATA_LOC=220]="DATA_LOC",e[e.REBUILD_NORMAL=237]="REBUILD_NORMAL",e[e.VARP_SMALL=150]="VARP_SMALL",e[e.VARP_LARGE=175]="VARP_LARGE",e[e.RESET_CLIENT_VARCACHE=193]="RESET_CLIENT_VARCACHE",e[e.SYNTH_SOUND=12]="SYNTH_SOUND",e[e.MIDI_SONG=54]="MIDI_SONG",e[e.MIDI_JINGLE=212]="MIDI_JINGLE",e[e.UPDATE_ZONE_PARTIAL_FOLLOWS=7]="UPDATE_ZONE_PARTIAL_FOLLOWS",e[e.UPDATE_ZONE_FULL_FOLLOWS=135]="UPDATE_ZONE_FULL_FOLLOWS",e[e.UPDATE_ZONE_PARTIAL_ENCLOSED=162]="UPDATE_ZONE_PARTIAL_ENCLOSED",e[e.LOC_MERGE=23]="LOC_MERGE",e[e.LOC_ANIM=42]="LOC_ANIM",e[e.OBJ_DEL=49]="OBJ_DEL",e[e.OBJ_REVEAL=50]="OBJ_REVEAL",e[e.LOC_ADD_CHANGE=59]="LOC_ADD_CHANGE",e[e.MAP_PROJANIM=69]="MAP_PROJANIM",e[e.LOC_DEL=76]="LOC_DEL",e[e.OBJ_COUNT=151]="OBJ_COUNT",e[e.MAP_ANIM=191]="MAP_ANIM",e[e.OBJ_ADD=223]="OBJ_ADD"}(s||(s={}));const a=s},6970:(e,t,i)=>{i.d(t,{Z:()=>h});class s{start=0;end=0;form=0;length=0;shapeDelta=null;shapePeak=null;threshold=0;position=0;delta=0;amplitude=0;ticks=0;read=e=>{this.form=e.g1,this.start=e.g4,this.end=e.g4,this.length=e.g1,this.shapeDelta=new Int32Array(this.length),this.shapePeak=new Int32Array(this.length);for(let t=0;t{this.threshold=0,this.position=0,this.delta=0,this.amplitude=0,this.ticks=0};evaluate=e=>(this.ticks>=this.threshold&&this.shapePeak&&this.shapeDelta&&(this.amplitude=this.shapePeak[this.position++]<<15,this.position>=this.length&&(this.position=this.length-1),this.threshold=this.shapeDelta[this.position]/65536*e|0,this.threshold>this.ticks&&(this.delta=((this.shapePeak[this.position]<<15)-this.amplitude)/(this.threshold-this.ticks)|0)),this.amplitude+=this.delta,this.ticks++,this.amplitude-this.delta>>15)}class a{static buffer=null;static noise=null;static sin=null;static tmpPhases=new Int32Array(5);static tmpDelays=new Int32Array(5);static tmpVolumes=new Int32Array(5);static tmpSemitones=new Int32Array(5);static tmpStarts=new Int32Array(5);frequencyBase=null;amplitudeBase=null;frequencyModRate=null;frequencyModRange=null;amplitudeModRate=null;amplitudeModRange=null;release=null;attack=null;harmonicVolume=new Int32Array(5);harmonicSemitone=new Int32Array(5);harmonicDelay=new Int32Array(5);start=0;length=500;reverbVolume=100;reverbDelay=0;static init=()=>{this.noise=new Int32Array(32768);for(let e=0;e<32768;e++)Math.random()>.5?this.noise[e]=1:this.noise[e]=-1;this.sin=new Int32Array(32768);for(let e=0;e<32768;e++)this.sin[e]=16384*Math.sin(e/5215.1903)|0;this.buffer=new Int32Array(220500)};generate=(e,t)=>{for(let t=0;t>1,n+=(t*s>>16)+r}if(this.amplitudeModRate&&this.amplitudeModRange){const t=this.amplitudeModRate.evaluate(e),i=this.amplitudeModRange.evaluate(e);c=c*(32768+(this.generate2(i,l,this.amplitudeModRate.form)>>1))>>15,l+=(t*h>>16)+o}for(let s=0;s<5;s++)if(0!==this.harmonicVolume[s]){const r=t+a.tmpDelays[s];r>15,a.tmpPhases[s],this.frequencyBase.form),a.tmpPhases[s]+=(i*a.tmpSemitones[s]>>16)+a.tmpStarts[s])}}if(this.release&&this.attack){this.release.reset(),this.attack.reset();let t=0,i=!0;for(let s=0;s>8):this.release.start+((this.release.end-this.release.start)*n>>8),t+=256,t>=h&&(t=0,i=!i),i&&(a.buffer[s]=0)}}if(this.reverbDelay>0&&this.reverbVolume>0){const t=this.reverbDelay*i;for(let i=t;i32767&&(a.buffer[t]=32767);return a.buffer};generate2=(e,t,i)=>1===i?(32767&t)<16384?e:-e:2===i?a.sin[32767&t]*e>>14:3===i?((32767&t)*e>>14)-e:4===i?a.noise[32767&(t/2607|0)]*e:0;read=e=>{this.frequencyBase=new s,this.frequencyBase.read(e),this.amplitudeBase=new s,this.amplitudeBase.read(e),0!==e.g1&&(e.pos--,this.frequencyModRate=new s,this.frequencyModRate.read(e),this.frequencyModRange=new s,this.frequencyModRange.read(e)),0!==e.g1&&(e.pos--,this.amplitudeModRate=new s,this.amplitudeModRate.read(e),this.amplitudeModRange=new s,this.amplitudeModRange.read(e)),0!==e.g1&&(e.pos--,this.release=new s,this.release.read(e),this.attack=new s,this.attack.read(e));for(let t=0;t<10;t++){const i=e.gsmarts;if(0===i)break;this.harmonicVolume[t]=i,this.harmonicSemitone[t]=e.gsmart,this.harmonicDelay[t]=e.gsmarts}this.reverbDelay=e.gsmarts,this.reverbVolume=e.gsmarts,this.length=e.g2,this.start=e.g2}}var r=i(2383),n=i(9345);class h{static delays=new Int32Array(1e3);static waveBytes=null;static waveBuffer=null;static tracks=new n.to(1e3,null);tones=new n.to(10,null);loopBegin=0;loopEnd=0;static unpack=e=>{const t=new r.Z(e.read("sounds.dat"));for(this.waveBytes=new Uint8Array(441e3),this.waveBuffer=new r.Z(this.waveBytes),a.init();;){const e=t.g2;if(65535===e)break;const i=new h;i.read(t),this.tracks[e]=i,this.delays[e]=i.trim()}};static generate=(e,t)=>{if(!this.tracks[e])return null;const i=this.tracks[e];return i?.getWave(t)??null};read=e=>{for(let t=0;t<10;t++)0!==e.g1&&(e.pos--,this.tones[t]=new a,this.tones[t]?.read(e));this.loopBegin=e.g2,this.loopEnd=e.g2};trim=()=>{let e=9999999;for(let t=0;t<10;t++)this.tones[t]&&(this.tones[t].start/20|0){const t=this.generate(e);return h.waveBuffer.pos=0,h.waveBuffer?.p4(1380533830),h.waveBuffer?.ip4(t+36),h.waveBuffer?.p4(1463899717),h.waveBuffer?.p4(1718449184),h.waveBuffer?.ip4(16),h.waveBuffer?.ip2(1),h.waveBuffer?.ip2(1),h.waveBuffer?.ip4(22050),h.waveBuffer?.ip4(22050),h.waveBuffer?.ip2(1),h.waveBuffer?.ip2(8),h.waveBuffer?.p4(1684108385),h.waveBuffer?.ip4(t),h.waveBuffer.pos+=t,h.waveBuffer};generate=e=>{let t=0;for(let e=0;e<10;e++)this.tones[e]&&this.tones[e].length+this.tones[e].start>t&&(t=this.tones[e].length+this.tones[e].start);if(0===t)return 0;let i=22050*t/1e3|0,s=22050*this.loopBegin/1e3|0,a=22050*this.loopEnd/1e3|0;(s<0||a<0||a>i||s>=a)&&(e=0);let r=i+(a-s)*(e-1);for(let e=44;e>8<<24>>24)}if(e>1){s+=44,a+=44,i+=44,r+=44;const t=r-i;for(let e=i-1;e>=a;e--)h.waveBytes&&(h.waveBytes[e+t]=h.waveBytes[e]);for(let t=1;t{i.d(t,{AK:()=>l,IY:()=>a,N$:()=>r,Nv:()=>o,nz:()=>n,to:()=>s,zi:()=>h});class s extends Array{constructor(e,t){super(e);for(let i=0;i{i.d(t,{Di:()=>r,GR:()=>a,_v:()=>s,fH:()=>n,jk:()=>o,v3:()=>h,yz:()=>l});const s=async e=>new Promise((t=>setTimeout(t,e))),a=async e=>new Int8Array(await(await fetch(e)).arrayBuffer()),r=async e=>(await fetch(e)).text(),n=(e,t,i,s,a)=>{for(;a--;)i[s++]=e[t++]},h=e=>{let t=0n;for(let i=0;i{const t=[];for(;e>0n;)t.unshift(Number(255n&e)),e>>=8n;return new Uint8Array(t)},l=(e,t,i)=>{let s=1n;for(;t>0n;)t%2n===1n&&(s=s*e%i),e=e*e%i,t>>=1n;return s}},9897:(e,t,i)=>{i.d(t,{Z:()=>a});var s=i(2383);class a{static PERIOD=new Uint16Array(["d","o","t"].join("").split("").map((e=>e.charCodeAt(0))));static AMPERSAT=new Uint16Array(["(","a",")"].join("").split("").map((e=>e.charCodeAt(0))));static SLASH=new Uint16Array(["s","l","a","s","h"].join("").split("").map((e=>e.charCodeAt(0))));static whitelist=["cook","cook's","cooks","seeks","sheet"];static tlds=[];static tldTypes=[];static bads=[];static badCombinations=[];static domains=[];static fragments=[];static unpack=e=>{const t=new s.Z(e.read("fragmentsenc.txt")),i=new s.Z(e.read("badenc.txt")),a=new s.Z(e.read("domainenc.txt")),r=new s.Z(e.read("tldlist.txt"));this.read(i,a,t,r)};static filter=e=>{const t=[...e];this.format(t);const i=t.join("").trim(),s=i.toLowerCase(),a=[...s];this.filterTlds(a),this.filterBadWords(a),this.filterDomains(a),this.filterFragments(a);for(let e=0;e{this.readBadWords(e),this.readDomains(t),this.readFragments(i),this.readTld(s)};static readTld=e=>{const t=e.g4;for(let i=0;ie.g1))};static readBadWords=e=>{const t=e.g4;for(let i=0;ie.g1));const t=new Array(e.g1).fill([]).map((()=>[e.g1b,e.g1b]));t.length>0&&(this.badCombinations[i]=t)}};static readDomains=e=>{const t=e.g4;for(let i=0;ie.g1))};static readFragments=e=>{const t=e.g4;for(let i=0;i{const t=[...e],i=[...e];this.filterBadCombinations(null,t,this.PERIOD),this.filterBadCombinations(null,i,this.SLASH);for(let s=0;s{for(let t=0;t<2;t++)for(let t=this.bads.length-1;t>=0;t--)this.filterBadCombinations(this.badCombinations[t],e,this.bads[t])};static filterDomains=e=>{const t=[...e],i=[...e];this.filterBadCombinations(null,t,this.AMPERSAT),this.filterBadCombinations(null,i,this.PERIOD);for(let s=this.domains.length-1;s>=0;s--)this.filterDomain(i,t,this.domains[s],e)};static filterFragments=e=>{for(let t=0;t=0&&a{if(this.isNumericalChars(e))return!0;const t=this.getInteger(e),i=this.fragments,s=i.length;if(t===i[0]||t===i[s-1])return!0;let a=0,r=s-1;for(;a<=r;){const e=(a+r)/2|0;if(t===i[e])return!0;t{if(e.length>6)return 0;let t=0;for(let i=0;i{for(let i=t;i=0;i++)if(this.isNumerical(e[i]))return i;return-1};static indexOfNonNumber=(e,t)=>{for(let i=e;i=0;i++)if(!this.isNumerical(t[i]))return i;return t.length};static getEmulatedDomainCharLen=(e,t,i)=>t===i||"o"===t&&"0"===i?1:"o"===t&&"("===i&&")"===e?2:"c"!==t||"("!==i&&"<"!==i&&"["!==i?"e"===t&&"€"===i||"s"===t&&"$"===i||"l"===t&&"i"===i?1:0:1;static filterDomain=(e,t,i,s)=>{const a=i.length,r=s.length;for(let n=0;n<=r-a;n++){const{matched:a,currentIndex:r}=this.findMatchingDomain(n,i,s);if(!a)continue;const h=this.prefixSymbolStatus(n,s,3,t,["@"]),o=this.suffixSymbolStatus(r-1,s,3,e,[".",","]);(h>2||o>2)&&this.maskChars(n,r,s)}};static findMatchingDomain=(e,t,i)=>{const s=t.length;let a=e,r=0;for(;a0)a+=o,r++;else{if(0===r)break;const i=this.getEmulatedDomainCharLen(h,String.fromCharCode(t[r-1]),n);if(i>0)a+=i,1===r&&e++;else{if(r>=s||!this.isSymbol(n))break;a++}}}return{matched:r>=s,currentIndex:a}};static filterBadCombinations=(e,t,i)=>{if(!(i.length>t.length))for(let s=0;s<=t.length-i.length;s++){let a=s;const{currentIndex:r,badIndex:n,hasSymbol:h,hasNumber:o,hasDigit:l}=this.processBadCharacters(t,i,a);a=r;let c=t[a],d=a+1=i.length)||o&&l)continue;let u,f=!0;if(h){let e=!1,i=!1;if((s-1<0||this.isSymbol(t[s-1])&&"'"!==t[s-1])&&(e=!0),(a>=t.length||this.isSymbol(t[a])&&"'"!==t[a])&&(i=!0),!e||!i){let i=!1;for(u=s-2,e&&(u=s);!i&&u=0&&(!this.isSymbol(t[u])||"'"===t[u])){const e=[];let s;for(s=0;s<3&&u+s=0&&(!this.isSymbol(t[u-1])||"'"===t[u-1])&&(a=!1),a&&!this.isBadFragment(e)&&(i=!0)}u++}i||(f=!1)}}else{c=" ",s-1>=0&&(c=t[s-1]),d=" ",a{let s=i,a=0,r=0,n=!1,h=!1,o=!1;for(;s=e.length||h&&o);){const l=e[s],c=s+10)1===d&&this.isNumerical(l)&&(h=!0),2===d&&(this.isNumerical(l)||this.isNumerical(c))&&(h=!0),s+=d,a++;else{if(0===a)break;let e;if((e=this.getEmulatedBadCharLen(c,String.fromCharCode(t[a-1]),l))>0)s+=e;else{if(a>=t.length||!this.isNotLowercaseAlpha(l))break;if(this.isSymbol(l)&&"'"!==l&&(n=!0),this.isNumerical(l)&&(o=!0),s++,r++,(100*r/(s-i)|0)>90)break}}}return{currentIndex:s,badIndex:a,hasSymbol:n,hasNumber:h,hasDigit:o}};static getEmulatedBadCharLen=(e,t,i)=>{if(t===i)return 1;if(t>="a"&&t<="m"){if("a"===t)return"4"!==i&&"@"!==i&&"^"!==i?"/"===i&&"\\"===e?2:0:1;if("b"===t)return"6"!==i&&"8"!==i?"1"===i&&"3"===e?2:0:1;if("c"===t)return"("!==i&&"<"!==i&&"{"!==i&&"["!==i?0:1;if("d"===t)return"["===i&&")"===e?2:0;if("e"===t)return"3"!==i&&"€"!==i?0:1;if("f"===t)return"p"===i&&"h"===e?2:"£"===i?1:0;if("g"===t)return"9"!==i&&"6"!==i?0:1;if("h"===t)return"#"===i?1:0;if("i"===t)return"y"!==i&&"l"!==i&&"j"!==i&&"1"!==i&&"!"!==i&&":"!==i&&";"!==i&&"|"!==i?0:1;if("j"===t)return 0;if("k"===t)return 0;if("l"===t)return"1"!==i&&"|"!==i&&"i"!==i?0:1;if("m"===t)return 0}if(t>="n"&&t<="z"){if("n"===t)return 0;if("o"===t)return"0"!==i&&"*"!==i?"("===i&&")"===e||"["===i&&"]"===e||"{"===i&&"}"===e||"<"===i&&">"===e?2:0:1;if("p"===t)return 0;if("q"===t)return 0;if("r"===t)return 0;if("s"===t)return"5"!==i&&"z"!==i&&"$"!==i&&"2"!==i?0:1;if("t"===t)return"7"!==i&&"+"!==i?0:1;if("u"===t)return"v"===i?1:"\\"===i&&"/"===e||"\\"===i&&"|"===e||"|"===i&&"/"===e?2:0;if("v"===t)return"\\"===i&&"/"===e||"\\"===i&&"|"===e||"|"===i&&"/"===e?2:0;if("w"===t)return"v"===i&&"v"===e?2:0;if("x"===t)return")"===i&&"("===e||"}"===i&&"{"===e||"]"===i&&"["===e||">"===i&&"<"===e?2:0;if("y"===t)return 0;if("z"===t)return 0}return t>="0"&&t<="9"?"0"===t?"o"===i||"O"===i?1:"("===i&&")"===e||"{"===i&&"}"===e||"["===i&&"]"===e?2:0:"1"===t&&"l"===i?1:0:","===t?"."===i?1:0:"."===t?","===i?1:0:"!"===t&&"i"===i?1:0};static comboMatches=(e,t,i)=>{let s=0,a=t.length-1;for(;s<=a;){const r=(s+a)/2|0;if(t[r][0]===e&&t[r][1]===i)return!0;ethis.isLowercaseAlpha(e)?e.charCodeAt(0)+1-"a".charCodeAt(0):"'"===e?28:this.isNumerical(e)?e.charCodeAt(0)+29-"0".charCodeAt(0):27;static filterTld=(e,t,i,s,a)=>{if(!(s.length>i.length))for(let r=0;r<=i.length-s.length;r++){const{currentIndex:n,tldIndex:h}=this.processTlds(i,s,r);if(h0&&c>0&&(o=!0),2===t&&(l>2&&c>0||l>0&&c>2)&&(o=!0),3===t&&l>0&&c>2&&(o=!0),!o)continue;let d,u=r,f=n-1,p=!1;if(l>2){if(4===l)for(p=!1,d=r-1;d>=0;d--)if(p){if("*"!==a[d])break;u=d}else"*"===a[d]&&(u=d,p=!0);for(p=!1,d=u-1;d>=0;d--)if(p){if(this.isSymbol(i[d]))break;u=d}else this.isSymbol(i[d])||(p=!0,u=d)}if(c>2){if(4===c)for(p=!1,d=f+1;d{let s=0;for(;i0)i+=n,s++;else{if(0===s)break;let e;if((e=this.getEmulatedDomainCharLen(r,String.fromCharCode(t[s-1]),a))>0)i+=e;else{if(!this.isSymbol(a))break;i++}}}return{currentIndex:i,tldIndex:s}};static isSymbol=e=>!this.isAlpha(e)&&!this.isNumerical(e);static isNotLowercaseAlpha=e=>!this.isLowercaseAlpha(e)||"v"===e||"x"===e||"j"===e||"q"===e||"z"===e;static isAlpha=e=>this.isLowercaseAlpha(e)||this.isUppercaseAlpha(e);static isNumerical=e=>e>="0"&&e<="9";static isLowercaseAlpha=e=>e>="a"&&e<="z";static isUppercaseAlpha=e=>e>="A"&&e<="Z";static isNumericalChars=e=>{for(let t=0;t{for(let s=e;s{let i=0;for(let s=t-1;s>=0&&this.isSymbol(e[s]);s--)"*"===e[s]&&i++;return i};static maskedCountForwards=(e,t)=>{let i=0;for(let s=t+1;s(a?this.maskedCountBackwards(t,i):this.maskedCountForwards(t,i))>=s?4:this.isSymbol(a?e[i-1]:e[i+1])?1:0;static prefixSymbolStatus=(e,t,i,s,a)=>{if(0===e)return 2;for(let i=e-1;i>=0&&this.isSymbol(t[i]);i--)if(a.includes(t[i]))return 3;return this.maskedCharsStatus(t,s,e,i,!0)};static suffixSymbolStatus=(e,t,i,s,a)=>{if(e+1===t.length)return 2;for(let i=e+1;i{let t=0;for(let i=0;ie>=" "&&e<=""||" "===e||"\n"===e||"\t"===e||"£"===e||"€"===e;static replaceUppercases=(e,t)=>{for(let i=0;i{let t=!0;for(let i=0;i{i.d(t,{Z:()=>s});class s{static TABLE=[" ","e","t","a","o","i","h","n","s","r","d","l","u","m","w","c","y","f","g","p","b","v","k","x","j","q","z","0","1","2","3","4","5","6","7","8","9"," ","!","?",".",",",":",";","(",")","-","&","*","\\","'","@","#","+","=","£","$","%",'"',"[","]"];static charBuffer=[];static unpack=(e,t)=>{let i,s=0,a=-1;for(let r=0;r>4&15,-1!==a?(this.charBuffer[s++]=this.TABLE[(a<<4)+i-195],a=-1):i<13?this.charBuffer[s++]=this.TABLE[i]:a=i,i=15&t,-1!==a?(this.charBuffer[s++]=this.TABLE[(a<<4)+i-195],a=-1):i<13?this.charBuffer[s++]=this.TABLE[i]:a=i}let r=!0;for(let e=0;e="a"&&t<="z"&&(this.charBuffer[e]=t.toUpperCase(),r=!1),"."!==t&&"!"!==t||(r=!0)}return this.charBuffer.slice(0,s).join("")};static pack=(e,t)=>{t.length>80&&(t=t.substring(0,80)),t=t.toLowerCase();let i=-1;for(let s=0;s12&&(r+=195),-1===i?r<13?i=r:e.p1(r):r<13?(e.p1((i<<4)+r),i=-1):(e.p1((i<<4)+(r>>4)),i=15&r)}-1!==i&&e.p1(i<<4)}}},5810:(e,t,i)=>{i.d(t,{Z:()=>a});var s=i(937);class a{static bz2=null;static state=null;static load=async e=>{const t=new WebAssembly.Module(e),i=await(0,s._)(t,{env:void 0});this.bz2=i,this.state=i.newBzip2State()};static read=(e,t,i,s)=>{if(!this.bz2||!this.state)throw new Error("bz2 not found!!");return this.bz2.read(e,t,i,s,this.state)}}},3584:(e,t,i)=>{let s;async function a(e,t){r(t);try{const t=await window.audioContext.decodeAudioData(Uint8Array.from(e).buffer);let i=window.audioContext.createBufferSource();i.buffer=t,i.connect(s),i.start()}catch(e){console.log(e)}}function r(e){s||(s=window.audioContext.createGain(),s.connect(window.audioContext.destination)),s.gain.value=e/256}function n(e,t){window._tinyMidiPlay&&window._tinyMidiPlay(e,t/256)}function h(e){window._tinyMidiVolume&&window._tinyMidiVolume(e/256)}function o(){window._tinyMidiStop&&window._tinyMidiStop()}i.d(t,{Q6:()=>n,mQ:()=>r,nu:()=>h,tb:()=>o,w3:()=>a})},937:(e,t,i)=>{async function s(e,t={}){const i={env:Object.assign(Object.create(globalThis),t.env||{},{abort(e,t,i,s){e=n(e>>>0),t=n(t>>>0),i>>>=0,s>>>=0,(()=>{throw Error(`${e} in ${t}:${i}:${s}`)})()}})},{exports:s}=await WebAssembly.instantiate(e,i),a=s.memory||t.env.memory,r=Object.setPrototypeOf({newBzip2State(){return(e=s.newBzip2State()>>>0)?{stream:l(Int8Array,w(e+0)),decompressed:l(Int8Array,w(e+4)),next_in:T(e+8),avail_in:T(e+12),total_in_lo32:T(e+16),total_in_hi32:T(e+20),next_out:T(e+24),avail_out:T(e+28),total_out_lo32:T(e+32),total_out_hi32:T(e+36),state_out_ch:C(e+40),state_out_len:T(e+44),blockRandomized:0!=C(e+48),bsBuff:T(e+52),bsLive:T(e+56),currBlockNo:T(e+60),origPtr:T(e+64),tPos:T(e+68),k0:T(e+72),c_nblock_used:T(e+76),nInUse:T(e+80),save_nblock:T(e+84),unzftab:d(T,2,w(e+88)),cftab:d(T,2,w(e+92)),cftabCopy:d(T,2,w(e+96)),inUse:d((e=>0!=C(e)),0,w(e+100)),inUse16:d((e=>0!=C(e)),0,w(e+104)),seqToUnseq:d(C,0,w(e+108)),mtfa:d(C,0,w(e+112)),mtfbase:d(T,2,w(e+116)),selector:d(C,0,w(e+120)),selectorMtf:d(C,0,w(e+124)),len:h((e=>d(C,0,w(e))),2,w(e+128)),limit:h((e=>d(T,2,w(e))),2,w(e+132)),base:h((e=>d(T,2,w(e))),2,w(e+136)),perm:h((e=>d(T,2,w(e))),2,w(e+140)),minLens:d(T,2,w(e+144))}:null;var e},read(e,t,i,a,r){t=function(e){if(e){const t=f.get(e);t?f.set(e,t+1):f.set(s.__pin(e),1)}return e}(c(Int8Array,6,0,t)||p()),r=function(e){if(null==e)return 0;const t=s.__pin(s.__new(148,5));return y(t+0,c(Int8Array,6,0,e.stream)||p()),y(t+4,c(Int8Array,6,0,e.decompressed)||p()),y(t+8,e.next_in),y(t+12,e.avail_in),y(t+16,e.total_in_lo32),y(t+20,e.total_in_hi32),y(t+24,e.next_out),y(t+28,e.avail_out),y(t+32,e.total_out_lo32),y(t+36,e.total_out_hi32),g(t+40,e.state_out_ch),y(t+44,e.state_out_len),g(t+48,e.blockRandomized?1:0),y(t+52,e.bsBuff),y(t+56,e.bsLive),y(t+60,e.currBlockNo),y(t+64,e.origPtr),y(t+68,e.tPos),y(t+72,e.k0),y(t+76,e.c_nblock_used),y(t+80,e.nInUse),y(t+84,e.save_nblock),y(t+88,u(y,4,2,e.unzftab,Int32Array)||p()),y(t+92,u(y,4,2,e.cftab,Int32Array)||p()),y(t+96,u(y,4,2,e.cftabCopy,Int32Array)||p()),y(t+100,u(g,7,0,e.inUse,Uint8Array)||p()),y(t+104,u(g,7,0,e.inUse16,Uint8Array)||p()),y(t+108,u(g,8,0,e.seqToUnseq,Uint8Array)||p()),y(t+112,u(g,8,0,e.mtfa,Uint8Array)||p()),y(t+116,u(y,4,2,e.mtfbase,Int32Array)||p()),y(t+120,u(g,8,0,e.selector,Uint8Array)||p()),y(t+124,u(g,8,0,e.selectorMtf,Uint8Array)||p()),y(t+128,o(((e,t)=>{y(e,u(g,8,0,t,Uint8Array)||p())}),9,2,e.len)||p()),y(t+132,o(((e,t)=>{y(e,u(y,4,2,t,Int32Array)||p())}),10,2,e.limit)||p()),y(t+136,o(((e,t)=>{y(e,u(y,4,2,t,Int32Array)||p())}),10,2,e.base)||p()),y(t+140,o(((e,t)=>{y(e,u(y,4,2,t,Int32Array)||p())}),10,2,e.perm)||p()),y(t+144,u(y,4,2,e.minLens,Int32Array)||p()),s.__unpin(t),t}(r)||p();try{return l(Int8Array,s.read(e,t,i,a,r)>>>0)}finally{!function(e){if(e){const t=f.get(e);if(1===t)s.__unpin(e),f.delete(e);else{if(!t)throw Error(`invalid refcount '${t}' for reference '${e}'`);f.set(e,t-1)}}}(t)}}},s);function n(e){if(!e)return null;const t=e+new Uint32Array(a.buffer)[e-4>>>2]>>>1,i=new Uint16Array(a.buffer);let s=e>>>1,r="";for(;t-s>1024;)r+=String.fromCharCode(...i.subarray(s,s+=1024));return r+String.fromCharCode(...i.subarray(s,t))}function h(e,t,i){if(!i)return null;const s=w(i+4),a=m.getUint32(i+12,!0),r=new Array(a);for(let i=0;i>>0));return r}function o(e,t,i,a){if(null==a)return 0;const r=a.length,n=s.__pin(s.__new(r<>>0,h=s.__pin(s.__new(16,t))>>>0;y(h+0,n),m.setUint32(h+4,n,!0),m.setUint32(h+8,r<>>0),a[t]);return s.__unpin(n),s.__unpin(h),h}function l(e,t){return t?new e(a.buffer,w(t+4),m.getUint32(t+8,!0)/e.BYTES_PER_ELEMENT).slice():null}function c(e,t,i,r){if(null==r)return 0;const n=r.length,h=s.__pin(s.__new(n<>>0,o=s.__new(12,t)>>>0;return y(o+0,h),m.setUint32(o+4,h,!0),m.setUint32(o+8,n<>>t,a=new Array(s);for(let r=0;r>>0));return a}function u(e,t,i,r,n){if(null==r)return 0;const h=r.length,o=s.__pin(s.__new(h<>>0;if(n)new n(a.buffer,o,h).set(r);else for(let t=0;t>>0),r[t]);return s.__unpin(o),o}const f=new Map;function p(){throw TypeError("value must not be null")}let m=new DataView(a.buffer);function g(e,t){try{m.setUint8(e,t,!0)}catch{m=new DataView(a.buffer),m.setUint8(e,t,!0)}}function y(e,t){try{m.setUint32(e,t,!0)}catch{m=new DataView(a.buffer),m.setUint32(e,t,!0)}}function C(e){try{return m.getUint8(e,!0)}catch{return m=new DataView(a.buffer),m.getUint8(e,!0)}}function T(e){try{return m.getInt32(e,!0)}catch{return m=new DataView(a.buffer),m.getInt32(e,!0)}}function w(e){try{return m.getUint32(e,!0)}catch{return m=new DataView(a.buffer),m.getUint32(e,!0)}}return r}i.d(t,{_:()=>s})},1527:(e,t,i)=>{var s=i(1928);!function(){window.AudioContext=window.AudioContext||window.webkitAudioContext,window.AudioContext&&(window.audioContext=new window.AudioContext);var e=function(t){if(window.audioContext){var i=window.audioContext.createBuffer(1,1,22050),s=window.audioContext.createBufferSource();s.buffer=i,s.connect(window.audioContext.destination),s.start?s.start(0):s.play?s.play(0):s.noteOn&&s.noteOn(0)}document.removeEventListener("touchstart",e),document.removeEventListener("touchend",e),document.removeEventListener("click",e)};document.addEventListener("touchstart",e),document.addEventListener("touchend",e),document.addEventListener("click",e)}(),(async()=>{let e=new Float32Array,t=window.audioContext.createGain();t.gain.value=.1,t.connect(window.audioContext.destination);let i=window.audioContext.currentTime,a=[];const r=new s.Z({renderInterval:30,onPCMData:t=>{let i=new Float32Array(t.buffer),s=new Float32Array(e.length+i.length);s.set(e,0),s.set(i,e.length),e=s},onRenderEnd:e=>{},bufferSize:102400});await r.init();const n=await fetch("./SCC1_Florestan.sf2"),h=new Uint8Array(await n.arrayBuffer());function o(){if(!window.audioContext||!e.length)return;let s=window.audioContext.createBufferSource();const r=e.length/2,n=window.audioContext.createBuffer(2,r,44100);for(let t=0;t<2;t++){const i=n.getChannelData(t);let s=t;for(let t=0;t{if(l&&clearInterval(l),e=new Float32Array,a.length){let e=t.gain.value;t.gain.value=0,a.forEach((e=>{e.stop(window.audioContext.currentTime)})),a=[],t.gain.value=e}},window._tinyMidiVolume=(e=1)=>{t.gain.value=e},window._tinyMidiPlay=async(e,t=1)=>{e&&(await window._tinyMidiStop(),-1!=t&&window._tinyMidiVolume(t),i=window.audioContext.currentTime,l=setInterval(o,250),r.render(e))}})()},1928:(e,t,i)=>{i.d(t,{Z:()=>a});var s=i(1885);const a=class{constructor(e={}){this.wasmModule=void 0,this.soundfontBufferPtr=0,this.soundfontPtr=0,this.midiBufferPtr=0,this.renderInterval=e.renderInterval||100,this.sampleRate=e.sampleRate||44100,this.channels=e.channels||2,this.gain=e.gain||0,e.bufferSize?this.bufferSize=e.bufferSize:this.setBufferDuration(1),this.onPCMData=e.onPCMData||(()=>{}),this.onRenderEnd=e.onRenderEnd||(()=>{}),this.renderTimer=void 0,this.test=0}async init(){if(!this.wasmModule){if("undefined"!=typeof process){const{dirname:e}=await import("path"),{createRequire:t}=await import("module");globalThis.__dirname=e("file:///home/runner/work/Client2/Client2/src/js/vendor/tinymidipcm/index.js"),globalThis.require=t("file:///home/runner/work/Client2/Client2/src/js/vendor/tinymidipcm/index.js")}this.wasmModule=await(0,s.Z)(),this.pcmBufferPtr=this.wasmModule._malloc(this.bufferSize),this.msecsPtr=this.wasmModule._malloc(8)}}setBufferDuration(e){this.bufferSize=4*this.sampleRate*this.channels*e}ensureInitialized(){if(!this.wasmModule)throw new Error(`${this.constructor.name} not initalized. call .init()`)}setSoundfont(e){this.ensureInitialized();const{_malloc:t,_free:i,_tsf_load_memory:s,_tsf_set_output:a,_tsf_channel_set_bank_preset:r,_tsf_set_max_voices:n,_tsf_channel_set_presetnumber:h}=this.wasmModule;i(this.soundfontBufferPtr),this.soundfontBufferPtr=t(e.length),this.wasmModule.HEAPU8.set(e,this.soundfontBufferPtr),this.soundfontPtr=s(this.soundfontBufferPtr,e.length),a(this.soundfontPtr,2===this.channels?0:2,this.sampleRate,this.gain)}getPCMBuffer(){this.ensureInitialized();const e=new Uint8Array(this.bufferSize);return e.set(this.wasmModule.HEAPU8.subarray(this.pcmBufferPtr,this.pcmBufferPtr+this.bufferSize)),e}getMIDIMessagePtr(e){const{_malloc:t,_free:i,_tml_load_memory:s}=this.wasmModule;return i(this.midiBufferPtr),this.midiBufferPtr=t(e.length),this.wasmModule.HEAPU8.set(e,this.midiBufferPtr),s(this.midiBufferPtr,e.length)}renderMIDIMessage(e){const{_midi_render:t}=this.wasmModule;return t(this.soundfontPtr,e,this.channels,this.sampleRate,this.pcmBufferPtr,this.bufferSize,this.msecsPtr)}render(e){if(this.ensureInitialized(),!this.soundfontPtr)throw new Error("no soundfont buffer set. call .setSoundfont");window.clearTimeout(this.renderTimer);const{setValue:t,getValue:i}=this.wasmModule;t(this.msecsPtr,0,"double"),this.wasmModule._tsf_reset(this.soundfontPtr),this.wasmModule._tsf_channel_set_bank_preset(this.soundfontPtr,9,128,0),e[0]==="R".charCodeAt(0)&&(e=e.slice(20));let s=this.getMIDIMessagePtr(e);const a=()=>{s=this.renderMIDIMessage(s);const e=this.getPCMBuffer();this.onPCMData(e),s?this.renderTimer=setTimeout(a,this.renderInterval):this.onRenderEnd(i(this.msecsPtr,"double"))};this.renderTimer=setTimeout(a,16)}}},5621:(e,t,i)=>{e.exports=i.p+"9f86b5397894e28b5ae2.wasm"},1885:(e,t,i)=>{var s;i.d(t,{Z:()=>a});const a=(s="file:///home/runner/work/Client2/Client2/src/js/vendor/tinymidipcm/tinymidipcm.mjs",function(e){var t,a,r=void 0!==(e=e||{})?e:{};r.ready=new Promise((function(e,i){t=e,a=i})),["_tsf_load_memory","_tsf_set_output","_tsf_channel_set_bank_preset","_tsf_set_max_voices","_tsf_channel_set_presetnumber","_tsf_reset","_tsf_close","_tml_load_memory","_midi_render","_malloc","_realloc","_free","_fflush","onRuntimeInitialized"].forEach((e=>{Object.getOwnPropertyDescriptor(r.ready,e)||Object.defineProperty(r.ready,e,{get:()=>V("You are getting "+e+" on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js"),set:()=>V("You are setting "+e+" on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")})}));var n=Object.assign({},r),h=[],o="object"==typeof window,l="function"==typeof importScripts,c="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,d=!o&&!c&&!l;if(r.ENVIRONMENT)throw new Error("Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)");var u,f,p,m="";if(c){if("undefined"==typeof process||!process.release||"node"!==process.release.name)throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");var g,y;m=l?require("path").dirname(m)+"/":__dirname+"/";var C=()=>{y||(g=require("fs"),y=require("path"))};u=(e,t)=>(C(),e=y.normalize(e),g.readFileSync(e,t?void 0:"utf8")),p=e=>{var t=u(e,!0);return t.buffer||(t=new Uint8Array(t)),P(t.buffer),t},f=(e,t,i)=>{C(),e=y.normalize(e),g.readFile(e,(function(e,s){e?i(e):t(s.buffer)}))},process.argv.length>1&&process.argv[1].replace(/\\/g,"/"),h=process.argv.slice(2),process.on("uncaughtException",(function(e){if(!(e instanceof se))throw e})),process.on("unhandledRejection",(function(e){throw e})),r.inspect=function(){return"[Emscripten Module object]"}}else if(d){if("object"==typeof process&&"function"==typeof require||"object"==typeof window||"function"==typeof importScripts)throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");"undefined"!=typeof read&&(u=function(e){return read(e)}),p=function(e){let t;return"function"==typeof readbuffer?new Uint8Array(readbuffer(e)):(t=read(e,"binary"),P("object"==typeof t),t)},f=function(e,t,i){setTimeout((()=>t(p(e))),0)},"undefined"!=typeof scriptArgs?h=scriptArgs:void 0!==arguments&&(h=arguments),"undefined"!=typeof print&&("undefined"==typeof console&&(console={}),console.log=print,console.warn=console.error="undefined"!=typeof printErr?printErr:print)}else{if(!o&&!l)throw new Error("environment detection error");if(l?m=self.location.href:"undefined"!=typeof document&&document.currentScript&&(m=document.currentScript.src),s&&(m=s),m=0!==m.indexOf("blob:")?m.substr(0,m.replace(/[?#].*/,"").lastIndexOf("/")+1):"","object"!=typeof window&&"function"!=typeof importScripts)throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");u=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},l&&(p=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),f=(e,t,i)=>{var s=new XMLHttpRequest;s.open("GET",e,!0),s.responseType="arraybuffer",s.onload=()=>{200==s.status||0==s.status&&s.response?t(s.response):i()},s.onerror=i,s.send(null)}}r.print||console.log.bind(console);var T,w,S,Z=r.printErr||console.warn.bind(console);function A(e,t){Object.getOwnPropertyDescriptor(r,e)||Object.defineProperty(r,e,{configurable:!0,get:function(){V("Module."+e+" has been replaced with plain "+t+" (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)")}})}function v(e){return"FS_createPath"===e||"FS_createDataFile"===e||"FS_createPreloadedFile"===e||"FS_unlink"===e||"addRunDependency"===e||"FS_createLazyFile"===e||"FS_createDevice"===e||"removeRunDependency"===e}Object.assign(r,n),n=null,T="fetchSettings",Object.getOwnPropertyDescriptor(r,T)&&V("`Module."+T+"` was supplied but `"+T+"` not included in INCOMING_MODULE_JS_API"),r.arguments&&(h=r.arguments),A("arguments","arguments_"),r.thisProgram&&r.thisProgram,A("thisProgram","thisProgram"),r.quit&&r.quit,A("quit","quit_"),P(void 0===r.memoryInitializerPrefixURL,"Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead"),P(void 0===r.pthreadMainPrefixURL,"Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead"),P(void 0===r.cdInitializerPrefixURL,"Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead"),P(void 0===r.filePackagePrefixURL,"Module.filePackagePrefixURL option was removed, use Module.locateFile instead"),P(void 0===r.read,"Module.read option was removed (modify read_ in JS)"),P(void 0===r.readAsync,"Module.readAsync option was removed (modify readAsync in JS)"),P(void 0===r.readBinary,"Module.readBinary option was removed (modify readBinary in JS)"),P(void 0===r.setWindowTitle,"Module.setWindowTitle option was removed (modify setWindowTitle in JS)"),P(void 0===r.TOTAL_MEMORY,"Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY"),A("read","read_"),A("readAsync","readAsync"),A("readBinary","readBinary"),A("setWindowTitle","setWindowTitle"),P(!d,"shell environment detected but not enabled at build time. Add 'shell' to `-sENVIRONMENT` to enable."),r.wasmBinary&&(w=r.wasmBinary),A("wasmBinary","wasmBinary"),r.noExitRuntime,A("noExitRuntime","noExitRuntime"),"object"!=typeof WebAssembly&&V("no native wasm support detected");var I,O,b,L,E,x,_,k,R=!1;function P(e,t){e||V("Assertion failed"+(t?": "+t:""))}function M(e){I=e,r.HEAP8=O=new Int8Array(e),r.HEAP16=L=new Int16Array(e),r.HEAP32=E=new Int32Array(e),r.HEAPU8=b=new Uint8Array(e),r.HEAPU16=new Uint16Array(e),r.HEAPU32=x=new Uint32Array(e),r.HEAPF32=_=new Float32Array(e),r.HEAPF64=k=new Float64Array(e)}"undefined"!=typeof TextDecoder&&new TextDecoder("utf8");var N=5242880;r.TOTAL_STACK&&P(N===r.TOTAL_STACK,"the stack size can no longer be determined at runtime");var B=r.INITIAL_MEMORY||16777216;function D(){if(!R){var e=ce(),t=x[e>>2],i=x[e+4>>2];34821223==t&&2310721022==i||V("Stack overflow! Stack cookie has been overwritten at 0x"+e.toString(16)+", expected hex dwords 0x89BACDFE and 0x2135467, but received 0x"+i.toString(16)+" 0x"+t.toString(16)),1668509029!==x[0]&&V("Runtime error: The application has corrupted its heap memory area (address zero)!")}}A("INITIAL_MEMORY","INITIAL_MEMORY"),P(B>=N,"INITIAL_MEMORY should be larger than TOTAL_STACK, was "+B+"! (TOTAL_STACK="+N+")"),P("undefined"!=typeof Int32Array&&"undefined"!=typeof Float64Array&&null!=Int32Array.prototype.subarray&&null!=Int32Array.prototype.set,"JS engine does not provide full typed array support"),P(!r.wasmMemory,"Use of `wasmMemory` detected. Use -sIMPORTED_MEMORY to define wasmMemory externally"),P(16777216==B,"Detected runtime INITIAL_MEMORY setting. Use -sIMPORTED_MEMORY to define wasmMemory dynamically"),function(){var e=new Int16Array(1),t=new Int8Array(e.buffer);if(e[0]=25459,115!==t[0]||99!==t[1])throw"Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)"}();var Y=[],X=[],F=[],H=!1;P(Math.imul,"This browser does not support Math.imul(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),P(Math.fround,"This browser does not support Math.fround(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),P(Math.clz32,"This browser does not support Math.clz32(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),P(Math.trunc,"This browser does not support Math.trunc(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill");var W=0,z=null,U=null,G={};function V(e){r.onAbort&&r.onAbort(e),Z(e="Aborted("+e+")"),R=!0;var t=new WebAssembly.RuntimeError(e);throw a(t),t}var q={error:function(){V("Filesystem support (FS) was not included. The problem is that you are using files from JS, but files were not used from C/C++, so filesystem support was not auto-included. You can force-include filesystem support with -sFORCE_FILESYSTEM")},init:function(){q.error()},createDataFile:function(){q.error()},createPreloadedFile:function(){q.error()},createLazyFile:function(){q.error()},open:function(){q.error()},mkdev:function(){q.error()},registerDevice:function(){q.error()},analyzePath:function(){q.error()},loadFilesFromDB:function(){q.error()},ErrnoError:function(){q.error()}};r.FS_createDataFile=q.createDataFile,r.FS_createPreloadedFile=q.createPreloadedFile;var j,K,J,Q;function $(e){return e.startsWith("data:application/octet-stream;base64,")}function ee(e){return e.startsWith("file://")}function te(e,t){return function(){var i=e,s=t;return t||(s=r.asm),P(H,"native function `"+i+"` called before runtime initialization"),s[e]||P(s[e],"exported native function `"+i+"` not found"),s[e].apply(null,arguments)}}function ie(e){try{if(e==j&&w)return new Uint8Array(w);if(p)return p(e);throw"both async and sync fetching of the wasm failed"}catch(e){V(e)}}function se(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}function ae(e){for(;e.length>0;)e.shift()(r)}function re(e){re.shown||(re.shown={}),re.shown[e]||(re.shown[e]=1,c&&(e="warning: "+e),Z(e))}function ne(e){try{return S.grow(e-I.byteLength+65535>>>16),M(S.buffer),1}catch(t){Z("emscripten_realloc_buffer: Attempted to grow heap from "+I.byteLength+" bytes to "+e+" bytes, but got error: "+t)}}r.locateFile?$(j="tinymidipcm.wasm")||(K=j,j=r.locateFile?r.locateFile(K,m):m+K):j=new URL(i(5621),i.b).toString();var he,oe={emscripten_memcpy_big:function(e,t,i){b.copyWithin(e,t,t+i)},emscripten_resize_heap:function(e){var t=b.length;P((e>>>=0)>t);var i,s=2147483648;if(e>s)return Z("Cannot enlarge memory, asked to go up to "+e+" bytes, but the limit is "+s+" bytes!"),!1;for(var a=1;a<=4;a*=2){var r=t*(1+.2/a);r=Math.min(r,e+100663296);var n=Math.min(s,(i=Math.max(e,r))+(65536-i%65536)%65536);if(ne(n))return!0}return Z("Failed to grow the heap from "+t+" bytes to "+n+" bytes, not enough memory!"),!1}},le=(function(){var e,t={env:oe,wasi_snapshot_preview1:oe};function i(e,t){var i,s=e.exports;r.asm=s,P(S=r.asm.memory,"memory not found in wasm exports"),M(S.buffer),P(r.asm.__indirect_function_table,"table not found in wasm exports"),i=r.asm.__wasm_call_ctors,X.unshift(i),function(e){if(W--,r.monitorRunDependencies&&r.monitorRunDependencies(W),e?(P(G[e]),delete G[e]):Z("warning: run dependency removed without ID"),0==W&&(null!==z&&(clearInterval(z),z=null),U)){var t=U;U=null,t()}}("wasm-instantiate")}e="wasm-instantiate",W++,r.monitorRunDependencies&&r.monitorRunDependencies(W),e?(P(!G[e]),G[e]=1,null===z&&"undefined"!=typeof setInterval&&(z=setInterval((function(){if(R)return clearInterval(z),void(z=null);var e=!1;for(var t in G)e||(e=!0,Z("still waiting on run dependencies:")),Z("dependency: "+t);e&&Z("(end of list)")}),1e4))):Z("warning: run dependency added without ID");var s=r;function n(e){P(r===s,"the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?"),s=null,i(e.instance)}function h(e){return function(){if(!w&&(o||l)){if("function"==typeof fetch&&!ee(j))return fetch(j,{credentials:"same-origin"}).then((function(e){if(!e.ok)throw"failed to load wasm binary file at '"+j+"'";return e.arrayBuffer()})).catch((function(){return ie(j)}));if(f)return new Promise((function(e,t){f(j,(function(t){e(new Uint8Array(t))}),t)}))}return Promise.resolve().then((function(){return ie(j)}))}().then((function(e){return WebAssembly.instantiate(e,t)})).then((function(e){return e})).then(e,(function(e){Z("failed to asynchronously prepare wasm: "+e),ee(j)&&Z("warning: Loading from a file URI ("+j+") is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing"),V(e)}))}if(r.instantiateWasm)try{return r.instantiateWasm(t,i)}catch(e){Z("Module.instantiateWasm callback failed with error: "+e),a(e)}(w||"function"!=typeof WebAssembly.instantiateStreaming||$(j)||ee(j)||c||"function"!=typeof fetch?h(n):fetch(j,{credentials:"same-origin"}).then((function(e){return WebAssembly.instantiateStreaming(e,t).then(n,(function(e){return Z("wasm streaming compile failed: "+e),Z("falling back to ArrayBuffer instantiation"),h(n)}))}))).catch(a)}(),r.___wasm_call_ctors=te("__wasm_call_ctors"),r._malloc=te("malloc"),r._free=te("free"),r._tsf_load_memory=te("tsf_load_memory"),r._tsf_close=te("tsf_close"),r._tsf_reset=te("tsf_reset"),r._tsf_set_output=te("tsf_set_output"),r._tsf_set_max_voices=te("tsf_set_max_voices"),r._realloc=te("realloc"),r._tsf_channel_set_presetnumber=te("tsf_channel_set_presetnumber"),r._tsf_channel_set_bank_preset=te("tsf_channel_set_bank_preset"),r._tml_load_memory=te("tml_load_memory"),r._midi_render=te("midi_render"),r.___errno_location=te("__errno_location"),r._fflush=te("fflush"),r._emscripten_stack_init=function(){return(le=r._emscripten_stack_init=r.asm.emscripten_stack_init).apply(null,arguments)}),ce=(r._emscripten_stack_get_free=function(){return(r._emscripten_stack_get_free=r.asm.emscripten_stack_get_free).apply(null,arguments)},r._emscripten_stack_get_base=function(){return(r._emscripten_stack_get_base=r.asm.emscripten_stack_get_base).apply(null,arguments)},r._emscripten_stack_get_end=function(){return(ce=r._emscripten_stack_get_end=r.asm.emscripten_stack_get_end).apply(null,arguments)});function de(e){function i(){he||(he=!0,r.calledRun=!0,R||(P(!H),H=!0,D(),ae(X),t(r),r.onRuntimeInitialized&&r.onRuntimeInitialized(),P(!r._main,'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]'),function(){if(D(),r.postRun)for("function"==typeof r.postRun&&(r.postRun=[r.postRun]);r.postRun.length;)e=r.postRun.shift(),F.unshift(e);var e;ae(F)}()))}var s;e=e||h,W>0||(le(),P(0==(3&(s=ce()))),x[s>>2]=34821223,x[s+4>>2]=2310721022,x[0]=1668509029,function(){if(r.preRun)for("function"==typeof r.preRun&&(r.preRun=[r.preRun]);r.preRun.length;)e=r.preRun.shift(),Y.unshift(e);var e;ae(Y)}(),W>0||(r.setStatus?(r.setStatus("Running..."),setTimeout((function(){setTimeout((function(){r.setStatus("")}),1),i()}),1)):i(),D()))}if(r.stackSave=te("stackSave"),r.stackRestore=te("stackRestore"),r.stackAlloc=te("stackAlloc"),r.setValue=function(e,t,i="i8"){switch(i.endsWith("*")&&(i="*"),i){case"i1":case"i8":O[e>>0]=t;break;case"i16":L[e>>1]=t;break;case"i32":E[e>>2]=t;break;case"i64":Q=[t>>>0,(J=t,+Math.abs(J)>=1?J>0?(0|Math.min(+Math.floor(J/4294967296),4294967295))>>>0:~~+Math.ceil((J-+(~~J>>>0))/4294967296)>>>0:0)],E[e>>2]=Q[0],E[e+4>>2]=Q[1];break;case"float":_[e>>2]=t;break;case"double":k[e>>3]=t;break;case"*":x[e>>2]=t;break;default:V("invalid type for setValue: "+i)}},r.getValue=function(e,t="i8"){switch(t.endsWith("*")&&(t="*"),t){case"i1":case"i8":return O[e>>0];case"i16":return L[e>>1];case"i32":case"i64":return E[e>>2];case"float":return _[e>>2];case"double":return k[e>>3];case"*":return x[e>>2];default:V("invalid type for getValue: "+t)}return null},["run","UTF8ArrayToString","UTF8ToString","stringToUTF8Array","stringToUTF8","lengthBytesUTF8","addOnPreRun","addOnInit","addOnPreMain","addOnExit","addOnPostRun","addRunDependency","removeRunDependency","FS_createFolder","FS_createPath","FS_createDataFile","FS_createPreloadedFile","FS_createLazyFile","FS_createLink","FS_createDevice","FS_unlink","getLEB","getFunctionTables","alignFunctionTables","registerFunctions","prettyPrint","getCompilerSetting","print","printErr","callMain","abort","keepRuntimeAlive","wasmMemory","stackAlloc","stackSave","stackRestore","getTempRet0","setTempRet0","writeStackCookie","checkStackCookie","ptrToString","zeroMemory","stringToNewUTF8","exitJS","getHeapMax","emscripten_realloc_buffer","ENV","ERRNO_CODES","ERRNO_MESSAGES","setErrNo","inetPton4","inetNtop4","inetPton6","inetNtop6","readSockaddr","writeSockaddr","DNS","getHostByName","Protocols","Sockets","getRandomDevice","warnOnce","traverseStack","UNWIND_CACHE","convertPCtoSourceLocation","readAsmConstArgsArray","readAsmConstArgs","mainThreadEM_ASM","jstoi_q","jstoi_s","getExecutableName","listenOnce","autoResumeAudioContext","dynCallLegacy","getDynCaller","dynCall","handleException","runtimeKeepalivePush","runtimeKeepalivePop","callUserCallback","maybeExit","safeSetTimeout","asmjsMangle","asyncLoad","alignMemory","mmapAlloc","writeI53ToI64","writeI53ToI64Clamped","writeI53ToI64Signaling","writeI53ToU64Clamped","writeI53ToU64Signaling","readI53FromI64","readI53FromU64","convertI32PairToI53","convertI32PairToI53Checked","convertU32PairToI53","getCFunc","ccall","cwrap","uleb128Encode","sigToWasmTypes","generateFuncType","convertJsFunctionToWasm","freeTableIndexes","functionsInTableMap","getEmptyTableSlot","updateTableMap","addFunction","removeFunction","reallyNegative","unSign","strLen","reSign","formatString","PATH","PATH_FS","intArrayFromString","intArrayToString","AsciiToString","stringToAscii","UTF16Decoder","UTF16ToString","stringToUTF16","lengthBytesUTF16","UTF32ToString","stringToUTF32","lengthBytesUTF32","allocateUTF8","allocateUTF8OnStack","writeStringToMemory","writeArrayToMemory","writeAsciiToMemory","SYSCALLS","getSocketFromFD","getSocketAddress","JSEvents","registerKeyEventCallback","specialHTMLTargets","maybeCStringToJsString","findEventTarget","findCanvasEventTarget","getBoundingClientRect","fillMouseEventData","registerMouseEventCallback","registerWheelEventCallback","registerUiEventCallback","registerFocusEventCallback","fillDeviceOrientationEventData","registerDeviceOrientationEventCallback","fillDeviceMotionEventData","registerDeviceMotionEventCallback","screenOrientation","fillOrientationChangeEventData","registerOrientationChangeEventCallback","fillFullscreenChangeEventData","registerFullscreenChangeEventCallback","JSEvents_requestFullscreen","JSEvents_resizeCanvasForFullscreen","registerRestoreOldStyle","hideEverythingExceptGivenElement","restoreHiddenElements","setLetterbox","currentFullscreenStrategy","restoreOldWindowedStyle","softFullscreenResizeWebGLRenderTarget","doRequestFullscreen","fillPointerlockChangeEventData","registerPointerlockChangeEventCallback","registerPointerlockErrorEventCallback","requestPointerLock","fillVisibilityChangeEventData","registerVisibilityChangeEventCallback","registerTouchEventCallback","fillGamepadEventData","registerGamepadEventCallback","registerBeforeUnloadEventCallback","fillBatteryEventData","battery","registerBatteryEventCallback","setCanvasElementSize","getCanvasElementSize","demangle","demangleAll","jsStackTrace","stackTrace","ExitStatus","getEnvStrings","checkWasiClock","flush_NO_FILESYSTEM","dlopenMissingError","createDyncallWrapper","setImmediateWrapped","clearImmediateWrapped","polyfillSetImmediate","uncaughtExceptionCount","exceptionLast","exceptionCaught","ExceptionInfo","exception_addRef","exception_decRef","Browser","setMainLoop","wget","FS","MEMFS","TTY","PIPEFS","SOCKFS","_setNetworkCallback","tempFixedLengthArray","miniTempWebGLFloatBuffers","heapObjectForWebGLType","heapAccessShiftForWebGLHeap","GL","emscriptenWebGLGet","computeUnpackAlignedImageSize","emscriptenWebGLGetTexPixelData","emscriptenWebGLGetUniform","webglGetUniformLocation","webglPrepareUniformLocationsBeforeFirstUse","webglGetLeftBracePos","emscriptenWebGLGetVertexAttrib","writeGLArray","AL","SDL_unicode","SDL_ttfContext","SDL_audio","SDL","SDL_gfx","GLUT","EGL","GLFW_Window","GLFW","GLEW","IDBStore","runAndAbortIfError","ALLOC_NORMAL","ALLOC_STACK","allocate"].forEach((function(e){Object.getOwnPropertyDescriptor(r,e)||Object.defineProperty(r,e,{configurable:!0,get:function(){var t="'"+e+"' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)";v(e)&&(t+=". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you"),V(t)}})})),["ptrToString","zeroMemory","stringToNewUTF8","exitJS","setErrNo","inetPton4","inetNtop4","inetPton6","inetNtop6","readSockaddr","writeSockaddr","getHostByName","getRandomDevice","traverseStack","convertPCtoSourceLocation","readAsmConstArgs","mainThreadEM_ASM","jstoi_q","jstoi_s","getExecutableName","listenOnce","autoResumeAudioContext","dynCallLegacy","getDynCaller","dynCall","runtimeKeepalivePush","runtimeKeepalivePop","callUserCallback","maybeExit","safeSetTimeout","asmjsMangle","asyncLoad","alignMemory","mmapAlloc","writeI53ToI64","writeI53ToI64Clamped","writeI53ToI64Signaling","writeI53ToU64Clamped","writeI53ToU64Signaling","readI53FromI64","readI53FromU64","convertI32PairToI53","convertI32PairToI53Checked","convertU32PairToI53","getCFunc","ccall","cwrap","uleb128Encode","sigToWasmTypes","generateFuncType","convertJsFunctionToWasm","getEmptyTableSlot","updateTableMap","addFunction","removeFunction","reallyNegative","unSign","strLen","reSign","formatString","intArrayFromString","intArrayToString","AsciiToString","stringToAscii","UTF16ToString","stringToUTF16","lengthBytesUTF16","UTF32ToString","stringToUTF32","lengthBytesUTF32","allocateUTF8","allocateUTF8OnStack","writeStringToMemory","writeAsciiToMemory","getSocketFromFD","getSocketAddress","registerKeyEventCallback","maybeCStringToJsString","findEventTarget","findCanvasEventTarget","getBoundingClientRect","fillMouseEventData","registerMouseEventCallback","registerWheelEventCallback","registerUiEventCallback","registerFocusEventCallback","fillDeviceOrientationEventData","registerDeviceOrientationEventCallback","fillDeviceMotionEventData","registerDeviceMotionEventCallback","screenOrientation","fillOrientationChangeEventData","registerOrientationChangeEventCallback","fillFullscreenChangeEventData","registerFullscreenChangeEventCallback","JSEvents_requestFullscreen","JSEvents_resizeCanvasForFullscreen","registerRestoreOldStyle","hideEverythingExceptGivenElement","restoreHiddenElements","setLetterbox","softFullscreenResizeWebGLRenderTarget","doRequestFullscreen","fillPointerlockChangeEventData","registerPointerlockChangeEventCallback","registerPointerlockErrorEventCallback","requestPointerLock","fillVisibilityChangeEventData","registerVisibilityChangeEventCallback","registerTouchEventCallback","fillGamepadEventData","registerGamepadEventCallback","registerBeforeUnloadEventCallback","fillBatteryEventData","battery","registerBatteryEventCallback","setCanvasElementSize","getCanvasElementSize","getEnvStrings","checkWasiClock","flush_NO_FILESYSTEM","createDyncallWrapper","setImmediateWrapped","clearImmediateWrapped","polyfillSetImmediate","ExceptionInfo","exception_addRef","exception_decRef","setMainLoop","_setNetworkCallback","heapObjectForWebGLType","heapAccessShiftForWebGLHeap","emscriptenWebGLGet","computeUnpackAlignedImageSize","emscriptenWebGLGetTexPixelData","emscriptenWebGLGetUniform","webglGetUniformLocation","webglPrepareUniformLocationsBeforeFirstUse","webglGetLeftBracePos","emscriptenWebGLGetVertexAttrib","writeGLArray","SDL_unicode","SDL_ttfContext","SDL_audio","GLFW_Window","runAndAbortIfError","ALLOC_NORMAL","ALLOC_STACK","allocate"].forEach((function(e){"undefined"==typeof globalThis||Object.getOwnPropertyDescriptor(globalThis,e)||Object.defineProperty(globalThis,e,{configurable:!0,get:function(){var t="`"+e+"` is a library symbol and not included by default; add it to your library.js __deps or to DEFAULT_LIBRARY_FUNCS_TO_INCLUDE on the command line";v(e)&&(t+=". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you"),re(t)}})})),U=function e(){he||de(),he||(U=e)},r.preInit)for("function"==typeof r.preInit&&(r.preInit=[r.preInit]);r.preInit.length>0;)r.preInit.pop()();return de(),e.ready})}},r={};function n(e){var t=r[e];if(void 0!==t)return t.exports;var i=r[e]={exports:{}};return a[e](i,i.exports,n),i.exports}n.m=a,e="function"==typeof Symbol?Symbol("webpack queues"):"__webpack_queues__",t="function"==typeof Symbol?Symbol("webpack exports"):"__webpack_exports__",i="function"==typeof Symbol?Symbol("webpack error"):"__webpack_error__",s=e=>{e&&e.d<1&&(e.d=1,e.forEach((e=>e.r--)),e.forEach((e=>e.r--?e.r++:e())))},n.a=(a,r,n)=>{var h;n&&((h=[]).d=-1);var o,l,c,d=new Set,u=a.exports,f=new Promise(((e,t)=>{c=t,l=e}));f[t]=u,f[e]=e=>(h&&e(h),d.forEach(e),f.catch((e=>{}))),a.exports=f,r((a=>{var r;o=(a=>a.map((a=>{if(null!==a&&"object"==typeof a){if(a[e])return a;if(a.then){var r=[];r.d=0,a.then((e=>{n[t]=e,s(r)}),(e=>{n[i]=e,s(r)}));var n={};return n[e]=e=>e(r),n}}var h={};return h[e]=e=>{},h[t]=a,h})))(a);var n=()=>o.map((e=>{if(e[i])throw e[i];return e[t]})),l=new Promise((t=>{(r=()=>t(n)).r=0;var i=e=>e!==h&&!d.has(e)&&(d.add(e),e&&!e.d&&(r.r++,e.push(r)));o.map((t=>t[e](i)))}));return r.r?l:n()}),(e=>(e?c(f[i]=e):l(u),s(h)))),h&&h.d<0&&(h.d=0)},n.d=(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.p="/Client2/",n.b=document.baseURI||self.location.href,n(1979)})(); \ No newline at end of file +(()=>{"use strict";var e,t,i,s,a={3099:(e,t,i)=>{i.d(t,{K:()=>k});var s=i(2790),a=i(8078),r=i(2028),n=i(2383),h=i(1995),o=(i(1527),i(9080)),l=i(7221),c=i(3909),d=i(3693),u=i(4191),f=i(9345),p=i(6121),m=i(2991),g=i(1840),y=i(312),C=i(9178),w=i(8067),T=i(8934),S=i(8809),Z=i(1519),A=i(5810),v=i(3584),I=i(7958),O=i(2441),b=i(8056),L=i(551),E=i(1089),x=i(2157),_=i(8762);class k extends h.Z{static clientversion=225;static nodeId=10;static portOffset=0;static members=!0;static lowMemory=!1;static serverAddress="";static httpAddress="";static showDebug=!1;static githubRepository="https://raw.githubusercontent.com/2004scape/Server/main";static exponent=58778699976184461502525193738213253649000149147835990136706041084440742975821n;static modulus=7162900525229798032761816791230527296329313291232324290237849263501208207972894053929065636522363163621000728841182238772712427862772219676577293600221789n;static updateCounter=0;static update2Counter=0;static sidebarInputCounter=0;static opHeld1Counter=0;static opLoc4Counter=0;static opNpc5Counter=0;static drawCounter=0;static opHeld4Counter=0;static opLoc5Counter=0;static opNpc3Counter=0;static opHeld9Counter=0;static opPlayer2Counter=0;static updatePlayersCounter=0;static ifButton5Counter=0;static updateLocCounter=0;static setHighMemory=()=>{l.Z.lowMemory=!1,a.Z.lowMemory=!1,k.lowMemory=!1,c.Z.lowMemory=!1};static setLowMemory=()=>{l.Z.lowMemory=!0,a.Z.lowMemory=!0,k.lowMemory=!0,c.Z.lowMemory=!0};MAX_PLAYER_COUNT=2048;LOCAL_PLAYER_INDEX=2047;alreadyStarted=!1;errorStarted=!1;errorLoading=!1;errorHost=!1;db=null;loopCycle=0;ingame=!1;archiveChecksums=[];stream=null;in=n.Z.alloc(1);out=n.Z.alloc(1);loginout=n.Z.alloc(1);serverSeed=0n;idleNetCycles=0;idleTimeout=0;systemUpdateTimer=0;randomIn=null;packetType=0;packetSize=0;lastPacketType0=0;lastPacketType1=0;lastPacketType2=0;titleArchive=null;redrawTitleBackground=!0;titleScreenState=0;titleLoginField=0;imageTitle2=null;imageTitle3=null;imageTitle4=null;imageTitle0=null;imageTitle1=null;imageTitle5=null;imageTitle6=null;imageTitle7=null;imageTitle8=null;imageTitlebox=null;imageTitlebutton=null;loginMessage0="";loginMessage1="";username="";password="";fontPlain11=null;fontPlain12=null;fontBold12=null;fontQuill8=null;imageRunes=[];flameActive=!1;imageFlamesLeft=null;imageFlamesRight=null;flameBuffer1=null;flameBuffer0=null;flameBuffer3=null;flameBuffer2=null;flameGradient=null;flameGradient0=null;flameGradient1=null;flameGradient2=null;flameLineOffset=new Int32Array(256);flameCycle0=0;flameGradientCycle0=0;flameGradientCycle1=0;flamesInterval=null;areaSidebar=null;areaMapback=null;areaViewport=null;areaChatback=null;areaBackbase1=null;areaBackbase2=null;areaBackhmid1=null;areaBackleft1=null;areaBackleft2=null;areaBackright1=null;areaBackright2=null;areaBacktop1=null;areaBacktop2=null;areaBackvmid1=null;areaBackvmid2=null;areaBackvmid3=null;areaBackhmid2=null;areaChatbackOffsets=null;areaSidebarOffsets=null;areaViewportOffsets=null;compassMaskLineOffsets=new Int32Array(33);compassMaskLineLengths=new Int32Array(33);minimapMaskLineOffsets=new Int32Array(151);minimapMaskLineLengths=new Int32Array(151);imageInvback=null;imageChatback=null;imageMapback=null;imageBackbase1=null;imageBackbase2=null;imageBackhmid1=null;imageSideicons=new f.to(13,null);imageMinimap=null;imageCompass=null;imageMapscene=new f.to(50,null);imageMapfunction=new f.to(50,null);imageHitmarks=new f.to(20,null);imageHeadicons=new f.to(20,null);imageMapflag=null;imageCrosses=new f.to(8,null);imageMapdot0=null;imageMapdot1=null;imageMapdot2=null;imageMapdot3=null;imageScrollbar0=null;imageScrollbar1=null;imageRedstone1=null;imageRedstone2=null;imageRedstone3=null;imageRedstone1h=null;imageRedstone2h=null;imageRedstone1v=null;imageRedstone2v=null;imageRedstone3v=null;imageRedstone1hv=null;imageRedstone2hv=null;genderButtonImage0=null;genderButtonImage1=null;activeMapFunctions=new f.to(1e3,null);redrawSidebar=!1;redrawChatback=!1;redrawSideicons=!1;redrawPrivacySettings=!1;viewportInterfaceId=-1;dragCycles=0;crossMode=0;crossCycle=0;crossX=0;crossY=0;overrideChat=0;menuVisible=!1;menuArea=0;menuX=0;menuY=0;menuWidth=0;menuHeight=0;menuSize=0;menuOption=[];sidebarInterfaceId=-1;chatInterfaceId=-1;chatInterface=new s.Z;chatScrollHeight=78;chatScrollOffset=0;ignoreCount=0;ignoreName37=[];hintType=0;hintNpc=0;hintOffsetX=0;hintOffsetZ=0;hintPlayer=0;hintTileX=0;hintTileZ=0;hintHeight=0;skillExperience=[];skillLevel=[];skillBaseLevel=[];levelExperience=[];modalMessage=null;flashingTab=-1;selectedTab=3;tabInterfaceId=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1];publicChatSetting=0;privateChatSetting=0;tradeChatSetting=0;scrollGrabbed=!1;scrollInputPadding=0;showSocialInput=!1;socialMessage="";socialInput="";socialAction=0;chatbackInput="";chatbackInputOpen=!1;stickyChatInterfaceId=-1;messageText=new f.to(100,null);messageSender=new f.to(100,null);messageType=new Int32Array(100);messageIds=new Int32Array(100);privateMessageCount=0;splitPrivateChat=0;chatEffects=0;chatTyped="";viewportHoveredInterfaceIndex=0;sidebarHoveredInterfaceIndex=0;chatHoveredInterfaceIndex=0;objDragInterfaceId=0;objDragSlot=0;objDragArea=0;objGrabX=0;objGrabY=0;objDragCycles=0;objGrabThreshold=!1;objSelected=0;objSelectedSlot=0;objSelectedInterface=0;objInterface=0;objSelectedName=null;selectedArea=0;selectedItem=0;selectedInterface=0;selectedCycle=0;pressedContinueOption=!1;varps=[];varCache=[];spellSelected=0;activeSpellId=0;activeSpellFlags=0;spellCaption=null;mouseButtonsOption=0;menuAction=new Int32Array(500);menuParamA=new Int32Array(500);menuParamB=new Int32Array(500);menuParamC=new Int32Array(500);hoveredSlotParentId=0;hoveredSlot=0;lastHoveredInterfaceId=0;reportAbuseInput="";reportAbuseMuteOption=!1;reportAbuseInterfaceID=-1;lastAddress=0;daysSinceLastLogin=0;daysSinceRecoveriesChanged=0;unreadMessages=0;activeMapFunctionCount=0;activeMapFunctionX=new Int32Array(1e3);activeMapFunctionZ=new Int32Array(1e3);scene=null;sceneState=0;sceneDelta=0;sceneCycle=0;flagSceneTileX=0;flagSceneTileZ=0;cutscene=!1;cameraOffsetCycle=0;cameraAnticheatOffsetX=0;cameraAnticheatOffsetZ=0;cameraAnticheatAngle=0;cameraOffsetXModifier=2;cameraOffsetZModifier=2;cameraOffsetYawModifier=1;cameraModifierCycle=new Int32Array(5);cameraModifierEnabled=new f.to(5,!1);cameraModifierJitter=new Int32Array(5);cameraModifierWobbleScale=new Int32Array(5);cameraModifierWobbleSpeed=new Int32Array(5);cameraX=0;cameraY=0;cameraZ=0;cameraPitch=0;cameraYaw=0;cameraPitchClamp=0;minimapOffsetCycle=0;minimapAnticheatAngle=0;minimapZoom=0;minimapZoomModifier=1;minimapAngleModifier=2;minimapLevel=-1;baseX=0;baseZ=0;sceneCenterZoneX=0;sceneCenterZoneZ=0;sceneBaseTileX=0;sceneBaseTileZ=0;sceneMapLandData=null;sceneMapLocData=null;sceneMapIndex=null;mapLastBaseX=0;mapLastBaseZ=0;textureBuffer=new Int8Array(16384);levelCollisionMap=new f.to(d.Z.LEVELS,null);currentLevel=0;cameraMovedWrite=0;orbitCameraPitch=128;orbitCameraYaw=0;orbitCameraYawVelocity=0;orbitCameraPitchVelocity=0;orbitCameraX=0;orbitCameraZ=0;levelHeightmap=null;levelTileFlags=null;tileLastOccupiedCycle=new f.Nv(d.Z.SIZE,d.Z.SIZE);projectX=0;projectY=0;cutsceneDstLocalTileX=0;cutsceneDstLocalTileZ=0;cutsceneDstHeight=0;cutsceneRotateSpeed=0;cutsceneRotateAcceleration=0;cutsceneSrcLocalTileX=0;cutsceneSrcLocalTileZ=0;cutsceneSrcHeight=0;cutsceneMoveSpeed=0;cutsceneMoveAcceleration=0;players=new f.to(this.MAX_PLAYER_COUNT,null);playerCount=0;playerIds=new Int32Array(this.MAX_PLAYER_COUNT);entityUpdateCount=0;entityRemovalCount=0;entityUpdateIds=new Int32Array(this.MAX_PLAYER_COUNT);entityRemovalIds=new Int32Array(1e3);playerAppearanceBuffer=new f.to(this.MAX_PLAYER_COUNT,null);npcs=new f.to(8192,null);npcCount=0;npcIds=new Int32Array(8192);projectiles=new o.Z;spotanims=new o.Z;locList=new o.Z;temporaryLocs=new o.Z;levelObjStacks=new f.N$(d.Z.LEVELS,d.Z.SIZE,d.Z.SIZE,null);spawnedLocations=new o.Z;bfsStepX=new Int32Array(4e3);bfsStepZ=new Int32Array(4e3);bfsDirection=new Int32Array(d.Z.SIZE*d.Z.SIZE);bfsCost=new Int32Array(d.Z.SIZE*d.Z.SIZE);tryMoveNearest=0;localPlayer=null;energy=0;inMultizone=0;localPid=-1;weightCarried=0;heartbeatTimer=0;wildernessLevel=0;worldLocationState=0;rights=!1;designGenderMale=!0;updateDesignModel=!1;designIdentikits=new Int32Array(7);designColors=new Int32Array(5);friendCount=0;chatCount=0;static MAX_CHATS=50;chatX=new Int32Array(k.MAX_CHATS);chatY=new Int32Array(k.MAX_CHATS);chatHeight=new Int32Array(k.MAX_CHATS);chatWidth=new Int32Array(k.MAX_CHATS);chatColors=new Int32Array(k.MAX_CHATS);chatStyles=new Int32Array(k.MAX_CHATS);chatTimers=new Int32Array(k.MAX_CHATS);chats=new f.to(k.MAX_CHATS,null);friendName=new f.to(100,null);friendName37=new BigInt64Array(100);friendWorld=new Int32Array(100);socialName37=null;waveCount=0;waveEnabled=!0;waveIds=new Int32Array(50);waveLoops=new Int32Array(50);waveDelay=new Int32Array(50);waveVolume=192;lastWaveId=-1;lastWaveLoops=-1;lastWaveLength=0;lastWaveStartTime=0;nextMusicDelay=0;midiActive=!0;currentMidi=null;midiCrc=0;midiSize=0;midiVolume=192;unload=()=>{try{this.stream&&this.stream.close()}catch(e){}this.stream=null,(0,v.tb)(),this.out=null,this.loginout=null,this.in=null,this.sceneMapIndex=null,this.sceneMapLandData=null,this.sceneMapLocData=null,this.levelHeightmap=null,this.levelTileFlags=null,this.scene=null,this.levelCollisionMap=null,this.bfsDirection=null,this.bfsCost=null,this.bfsStepX=null,this.bfsStepZ=null,this.textureBuffer=null,this.areaSidebar=null,this.areaMapback=null,this.areaViewport=null,this.areaChatback=null,this.areaBackbase1=null,this.areaBackbase2=null,this.areaBackhmid1=null,this.areaBackleft1=null,this.areaBackleft2=null,this.areaBackright1=null,this.areaBackright2=null,this.areaBacktop1=null,this.areaBacktop2=null,this.areaBackvmid1=null,this.areaBackvmid2=null,this.areaBackvmid3=null,this.areaBackhmid2=null,this.imageInvback=null,this.imageMapback=null,this.imageChatback=null,this.imageBackbase1=null,this.imageBackbase2=null,this.imageBackhmid1=null,this.imageSideicons=null,this.imageRedstone1=null,this.imageRedstone2=null,this.imageRedstone3=null,this.imageRedstone1h=null,this.imageRedstone2h=null,this.imageRedstone1v=null,this.imageRedstone2v=null,this.imageRedstone3v=null,this.imageRedstone1hv=null,this.imageRedstone2hv=null,this.imageCompass=null,this.imageHitmarks=null,this.imageHeadicons=null,this.imageCrosses=null,this.imageMapdot0=null,this.imageMapdot1=null,this.imageMapdot2=null,this.imageMapdot3=null,this.imageMapscene=null,this.imageMapfunction=null,this.tileLastOccupiedCycle=null,this.players=null,this.playerIds=null,this.entityUpdateIds=null,this.playerAppearanceBuffer=null,this.entityRemovalIds=null,this.npcs=null,this.npcIds=null,this.levelObjStacks=null,this.spawnedLocations=null,this.temporaryLocs=null,this.projectiles=null,this.spotanims=null,this.locList=null,this.menuParamB=null,this.menuParamC=null,this.menuAction=null,this.menuParamA=null,this.menuOption=null,this.varps=null,this.activeMapFunctionX=null,this.activeMapFunctionZ=null,this.activeMapFunctions=null,this.imageMinimap=null,this.friendName=null,this.friendName37=null,this.friendWorld=null,this.imageTitle0=null,this.imageTitle1=null,this.imageTitle2=null,this.imageTitle3=null,this.imageTitle4=null,this.imageTitle5=null,this.imageTitle6=null,this.imageTitle7=null,this.imageTitle8=null,this.unloadTitle(),I.Z.unload(),O.Z.unload(),g.Z.unload(),b.Z.instances=null,S.Z.instances=null,s.Z.instances=null,w.Z.instances=null,L.Z.instances=null,L.Z.modelCache=null,E.Z.instances=null,this.drawArea=null,u.Z.modelCache=null,a.Z.unload(),l.Z.unload(),C.Z.unload(),x.Z.instances=[],_.Z.instances=[]};unloadTitle=()=>{this.flameActive=!1,this.flamesInterval&&(clearInterval(this.flamesInterval),this.flamesInterval=null),this.imageTitlebox=null,this.imageTitlebutton=null,this.imageRunes=[],this.flameGradient=null,this.flameGradient0=null,this.flameGradient1=null,this.flameGradient2=null,this.flameBuffer0=null,this.flameBuffer1=null,this.flameBuffer3=null,this.flameBuffer2=null,this.imageFlamesLeft=null,this.imageFlamesRight=null};loadArchive=async(e,t,i,s)=>{let a=5,h=await(this.db?.cacheload(e));if(h&&n.Z.crc32(h)!==i&&(h=void 0),h)return new r.Z(h);for(;!h;){await this.showProgress(s,`Requesting ${t}`);try{h=await(0,Z.GR)(`${k.httpAddress}/${e}${i}`)}catch(e){h=void 0;for(let e=a;e>0;e--)await this.showProgress(s,`Error loading - Will retry in ${e} secs.`),await(0,Z._v)(1e3);a*=2,a>60&&(a=60)}}return await(this.db?.cachesave(e,h)),new r.Z(h)};setMidi=async(e,t,i)=>{let s=await(this.db?.cacheload(e+".mid"));if(s&&12345678!==t&&n.Z.crc32(s)!==t&&(s=void 0),!s)try{s=await(0,Z.GR)(`${k.httpAddress}/${e}_${t}.mid`),i!==s.length&&(s=s.slice(0,i))}catch(e){}if(!s)return;await(this.db?.cachesave(e+".mid",s));const a=new n.Z(Uint8Array.from(s)).g4,r=A.Z.read(a,s,i,4);(0,v.Q6)(r,this.midiVolume)};drawError=()=>{if(p.E1.fillStyle="black",p.E1.fillRect(0,0,this.width,this.height),this.setFramerate(1),this.errorLoading){this.flameActive=!1,p.E1.font="bold 16px helvetica, sans-serif",p.E1.textAlign="left",p.E1.fillStyle="yellow";let e=35;p.E1.fillText("Sorry, an error has occured whilst loading RuneScape",30,e),e+=50,p.E1.fillStyle="white",p.E1.fillText("To fix this try the following (in order):",30,e),e+=50,p.E1.font="bold 12px helvetica, sans-serif",p.E1.fillText("1: Try closing ALL open web-browser windows, and reloading",30,e),e+=30,p.E1.fillText("2: Try clearing your web-browsers cache from tools->internet options",30,e),e+=30,p.E1.fillText("3: Try using a different game-world",30,e),e+=30,p.E1.fillText("4: Try rebooting your computer",30,e),e+=30,p.E1.fillText("5: Try selecting a different version of Java from the play-game menu",30,e)}if(this.errorHost&&(this.flameActive=!1,p.E1.font="bold 20px helvetica, sans-serif",p.E1.textAlign="left",p.E1.fillStyle="white",p.E1.fillText("Error - unable to load game!",50,50),p.E1.fillText("To play RuneScape make sure you play from",50,100),p.E1.fillText("https://2004scape.org",50,150)),this.errorStarted){this.flameActive=!1,p.E1.font="bold 13px helvetica, sans-serif",p.E1.textAlign="left",p.E1.fillStyle="yellow";let e=35;p.E1.fillText("Error a copy of RuneScape already appears to be loaded",30,e),e+=50,p.E1.fillStyle="white",p.E1.fillText("To fix this try the following (in order):",30,e),e+=50,p.E1.font="bold 12px helvetica, sans-serif",p.E1.fillText("1: Try closing ALL open web-browser windows, and reloading",30,e),e+=30,p.E1.fillText("2: Try rebooting your computer, and reloading",30,e)}};executeInterfaceScript=e=>{if(!e.scriptComparator)return!1;for(let t=0;t=s)return!1}else if(3===e.scriptComparator[t]){if(i<=s)return!1}else if(4===e.scriptComparator[t]){if(i===s)return!1}else if(i!==s)return!1}return!0};drawScrollbar=(e,t,i,s,a)=>{this.imageScrollbar0?.draw(e,t),this.imageScrollbar1?.draw(e,t+a-16),m.Z.fillRect(e,t+16,16,a-32,y.Z.SCROLLBAR_TRACK);let r=(a-32)*a/s|0;r<8&&(r=8);const n=(a-r-32)*i/(s-a)|0;m.Z.fillRect(e,t+n+16,16,r,y.Z.SCROLLBAR_GRIP_FOREGROUND),m.Z.drawVerticalLine(e,t+n+16,y.Z.SCROLLBAR_GRIP_HIGHLIGHT,r),m.Z.drawVerticalLine(e+1,t+n+16,y.Z.SCROLLBAR_GRIP_HIGHLIGHT,r),m.Z.drawHorizontalLine(e,t+n+16,y.Z.SCROLLBAR_GRIP_HIGHLIGHT,16),m.Z.drawHorizontalLine(e,t+n+17,y.Z.SCROLLBAR_GRIP_HIGHLIGHT,16),m.Z.drawVerticalLine(e+15,t+n+16,y.Z.SCROLLBAR_GRIP_LOWLIGHT,r),m.Z.drawVerticalLine(e+14,t+n+17,y.Z.SCROLLBAR_GRIP_LOWLIGHT,r-1),m.Z.drawHorizontalLine(e,t+n+r+15,y.Z.SCROLLBAR_GRIP_LOWLIGHT,16),m.Z.drawHorizontalLine(e+1,t+n+r+14,y.Z.SCROLLBAR_GRIP_LOWLIGHT,15)};updateInterfaceAnimation=(e,t)=>{let i=!1;const a=s.Z.instances[e];if(!a.childId)return!1;for(let e=0;es.delay[r.seqFrame];)r.seqCycle-=s.delay[r.seqFrame]+1,r.seqFrame++,r.seqFrame>=s.frameCount&&(r.seqFrame-=s.replayoff,(r.seqFrame<0||r.seqFrame>=s.frameCount)&&(r.seqFrame=0)),i=!0}}}return i};drawInterface=(e,t,i,r,n=!1)=>{if(0!==e.type||!e.childId||e.hide&&this.viewportHoveredInterfaceIndex!==e.id&&this.sidebarHoveredInterfaceIndex!==e.id&&this.chatHoveredInterfaceIndex!==e.id)return;const h=m.Z.left,o=m.Z.top,l=m.Z.right,c=m.Z.bottom;m.Z.setBounds(t,i,t+e.width,i+e.height);const d=e.childId.length;for(let h=0;h0&&this.updateInterfaceContent(c),c.type===s.Z.TYPE_LAYER)c.scrollPosition>c.scroll-c.height&&(c.scrollPosition=c.scroll-c.height),c.scrollPosition<0&&(c.scrollPosition=0),this.drawInterface(c,o,l,c.scrollPosition,n),c.scroll>c.height&&this.drawScrollbar(o+c.width,l,c.scrollPosition,c.scroll,c.height);else if(c.type===s.Z.TYPE_INV){let e=0;for(let t=0;t0){let t=0,i=0;const r=c.invSlotObjId[e]-1;if(s>=-32&&s<=512&&a>=-32&&a<=334||0!==this.objDragArea&&this.objDragSlot===e){const n=g.Z.getIcon(r,c.invSlotObjCount[e]);if(0!==this.objDragArea&&this.objDragSlot===e&&this.objDragInterfaceId===c.id?(t=this.mouseX-this.objGrabX,i=this.mouseY-this.objGrabY,t<5&&t>-5&&(t=0),i<5&&i>-5&&(i=0),this.objDragCycles<5&&(t=0,i=0),n.drawAlpha(128,s+t,a+i)):0!==this.selectedArea&&this.selectedItem===e&&this.selectedInterface===c.id?n.drawAlpha(128,s,a):n.draw(s,a),33===n.cropW||1!==c.invSlotObjCount[e]){const r=c.invSlotObjCount[e];this.fontPlain11?.drawString(s+t+1,a+10+i,this.formatObjCount(r),y.Z.BLACK),this.fontPlain11?.drawString(s+t,a+9+i,this.formatObjCount(r),y.Z.YELLOW)}}}else if(c.invSlotSprite&&e<20){const t=c.invSlotSprite[e];t?.draw(s,a)}e++}}else if(c.type===s.Z.TYPE_RECT)c.fill?m.Z.fillRect(o,l,c.width,c.height,c.colour):m.Z.drawRect(o,l,c.width,c.height,c.colour);else if(c.type===s.Z.TYPE_TEXT){const e=c.font;let t=c.colour,i=c.text;if(this.chatHoveredInterfaceIndex!==c.id&&this.sidebarHoveredInterfaceIndex!==c.id&&this.viewportHoveredInterfaceIndex!==c.id||0===c.overColour||(t=c.overColour),this.executeInterfaceScript(c)&&(t=c.activeColour,c.activeText&&c.activeText.length>0&&(i=c.activeText)),c.buttonType===s.Z.BUTTON_CONTINUE&&this.pressedContinueOption&&(i="Please wait...",t=c.colour),!e||!i)continue;for(let s=l+e.height;i.length>0;s+=e.height){if(-1!==i.indexOf("%")){for(;;){const e=i.indexOf("%1");if(-1===e)break;i=i.substring(0,e)+this.getIntString(this.executeClientscript1(c,0))+i.substring(e+2)}for(;;){const e=i.indexOf("%2");if(-1===e)break;i=i.substring(0,e)+this.getIntString(this.executeClientscript1(c,1))+i.substring(e+2)}for(;;){const e=i.indexOf("%3");if(-1===e)break;i=i.substring(0,e)+this.getIntString(this.executeClientscript1(c,2))+i.substring(e+2)}for(;;){const e=i.indexOf("%4");if(-1===e)break;i=i.substring(0,e)+this.getIntString(this.executeClientscript1(c,3))+i.substring(e+2)}for(;;){const e=i.indexOf("%5");if(-1===e)break;i=i.substring(0,e)+this.getIntString(this.executeClientscript1(c,4))+i.substring(e+2)}}const a=i.indexOf("\\n");let r;-1!==a?(r=i.substring(0,a),i=i.substring(a+2)):(r=i,i=""),c.center?e.drawStringTaggableCenter(o+(c.width/2|0),s,r,t,c.shadowed):e.drawStringTaggable(o,s,r,t,c.shadowed)}}else if(c.type===s.Z.TYPE_GRAPHIC){let e;e=this.executeInterfaceScript(c)?c.activeGraphic:c.graphic,e?.draw(o,l)}else if(c.type===s.Z.TYPE_MODEL){const e=a.Z.centerX,t=a.Z.centerY;a.Z.centerX=o+(c.width/2|0),a.Z.centerY=l+(c.height/2|0);const i=a.Z.sin[c.xan]*c.zoom>>16,s=a.Z.cos[c.xan]*c.zoom>>16,r=this.executeInterfaceScript(c);let n;n=r?c.activeAnim:c.anim;let h=null;if(-1===n)h=c.getModel(-1,-1,r);else{const e=w.Z.instances[n];e.frames&&e.iframes&&(h=c.getModel(e.frames[c.seqFrame],e.iframes[c.seqFrame],r))}h&&h.drawSimple(0,c.yan,0,c.xan,0,i,s),a.Z.centerX=e,a.Z.centerY=t}else if(c.type===s.Z.TYPE_INV_TEXT){const e=c.font;if(!e||!c.invSlotObjId||!c.invSlotObjCount)continue;let t=0;for(let i=0;i0){const a=g.Z.get(c.invSlotObjId[t]-1);let r=a.name;if((a.stackable||1!==c.invSlotObjCount[t])&&(r=r+" x"+this.formatObjCountTagged(c.invSlotObjCount[t])),!r)continue;const n=o+s*(c.marginX+115),h=l+i*(c.marginY+12);c.center?e.drawStringTaggableCenter(n+(c.width/2|0),h,r,c.colour,c.shadowed):e.drawStringTaggable(n,h,r,c.colour,c.shadowed)}t++}}}m.Z.setBounds(h,o,l,c)};updateInterfaceContent=e=>{let t=e.clientCode;if(t>=s.Z.CC_FRIENDS_START&&t<=s.Z.CC_FRIENDS_END)t--,t>=this.friendCount?(e.text="",e.buttonType=0):(e.text=this.friendName[t],e.buttonType=1);else if(t>=s.Z.CC_FRIENDS_UPDATE_START&&t<=s.Z.CC_FRIENDS_UPDATE_END)t-=s.Z.CC_FRIENDS_UPDATE_START,t>=this.friendCount?(e.text="",e.buttonType=0):(0===this.friendWorld[t]?e.text="@red@Offline":this.friendWorld[t]===k.nodeId?e.text="@gre@World-"+(this.friendWorld[t]-9):e.text="@yel@World-"+(this.friendWorld[t]-9),e.buttonType=1);else if(t===s.Z.CC_FRIENDS_SIZE)e.scroll=15*this.friendCount+20,e.scroll<=e.height&&(e.scroll=e.height+1);else if(t>=s.Z.CC_IGNORES_START&&t<=s.Z.CC_IGNORES_END)t-=s.Z.CC_IGNORES_START,t>=this.ignoreCount?(e.text="",e.buttonType=0):(e.text=T.Z.formatName(T.Z.fromBase37(this.ignoreName37[t])),e.buttonType=1);else if(t===s.Z.CC_IGNORES_SIZE)e.scroll=15*this.ignoreCount+20,e.scroll<=e.height&&(e.scroll=e.height+1);else if(t===s.Z.CC_DESIGN_PREVIEW){if(e.xan=150,e.yan=2047&(256*Math.sin(this.loopCycle/40)|0),this.updateDesignModel){this.updateDesignModel=!1;const t=new f.to(7,null);let i=0;for(let e=0;e<7;e++){const s=this.designIdentikits[e];s>=0&&(t[i++]=S.Z.instances[s].getModel())}const s=C.Z.modelFromModels(t,i);for(let e=0;e<5;e++)0!==this.designColors[e]&&(s.recolor(u.Z.DESIGN_BODY_COLOR[e][0],u.Z.DESIGN_BODY_COLOR[e][this.designColors[e]]),1===e&&s.recolor(u.Z.DESIGN_HAIR_COLOR[0],u.Z.DESIGN_HAIR_COLOR[this.designColors[e]]));if(this.localPlayer){const t=w.Z.instances[this.localPlayer.seqStandId].frames;t&&(s.createLabelReferences(),s.applyTransform(t[0]),s.calculateNormals(64,850,-30,-50,-30,!0),e.model=s)}}}else if(t===s.Z.CC_SWITCH_TO_MALE)this.genderButtonImage0||(this.genderButtonImage0=e.graphic,this.genderButtonImage1=e.activeGraphic),this.designGenderMale?e.graphic=this.genderButtonImage1:e.graphic=this.genderButtonImage0;else if(t===s.Z.CC_SWITCH_TO_FEMALE)this.genderButtonImage0||(this.genderButtonImage0=e.graphic,this.genderButtonImage1=e.activeGraphic),this.designGenderMale?e.graphic=this.genderButtonImage0:e.graphic=this.genderButtonImage1;else if(t===s.Z.CC_REPORT_INPUT)e.text=this.reportAbuseInput,this.loopCycle%20<10?e.text=e.text+"|":e.text=e.text+" ";else if(t===s.Z.CC_MOD_MUTE)this.rights?this.reportAbuseMuteOption?(e.colour=y.Z.RED,e.text="Moderator option: Mute player for 48 hours: "):(e.colour=y.Z.WHITE,e.text="Moderator option: Mute player for 48 hours: "):e.text="";else if(t===s.Z.CC_LAST_LOGIN_INFO||t===s.Z.CC_LAST_LOGIN_INFO2)if(0===this.lastAddress)e.text="";else{let t;t=0===this.daysSinceLastLogin?"earlier today":1===this.daysSinceLastLogin?"yesterday":this.daysSinceLastLogin+" days ago",e.text="You last logged in "+t+" from: "+T.Z.formatIPv4(this.lastAddress)}else if(t===s.Z.CC_UNREAD_MESSAGES)0===this.unreadMessages&&(e.text="0 unread messages",e.colour=y.Z.YELLOW),1===this.unreadMessages&&(e.text="1 unread message",e.colour=y.Z.GREEN),this.unreadMessages>1&&(e.text=this.unreadMessages+" unread messages",e.colour=y.Z.GREEN);else if(t===s.Z.CC_RECOVERY1)if(201===this.daysSinceRecoveriesChanged)e.text="";else if(200===this.daysSinceRecoveriesChanged)e.text="You have not yet set any password recovery questions.";else{let t;t=0===this.daysSinceRecoveriesChanged?"Earlier today":1===this.daysSinceRecoveriesChanged?"Yesterday":this.daysSinceRecoveriesChanged+" days ago",e.text=t+" you changed your recovery questions"}else t===s.Z.CC_RECOVERY2?201===this.daysSinceRecoveriesChanged?e.text="":200===this.daysSinceRecoveriesChanged?e.text="We strongly recommend you do so now to secure your account.":e.text="If you do not remember making this change then cancel it immediately":t===s.Z.CC_RECOVERY3&&(201===this.daysSinceRecoveriesChanged?e.text="":(this.daysSinceRecoveriesChanged,e.text="Do this from the 'account management' area on our front webpage"))};executeClientscript1=(e,t)=>{if(!e.scripts||t>=e.scripts.length)return-2;try{const i=e.scripts[t];if(!i)return-1;let a=0,r=0;for(;;){const e=i[r++];if(0===e)return a;if(1===e)a+=this.skillLevel[i[r++]];else if(2===e)a+=this.skillBaseLevel[i[r++]];else if(3===e)a+=this.skillExperience[i[r++]];else if(4===e){const e=s.Z.instances[i[r++]],t=i[r++]+1;if(e.invSlotObjId&&e.invSlotObjCount)for(let i=0;ie<999999999?String(e):"*";formatObjCountTagged=e=>{let t=String(e);for(let e=t.length-3;e>0;e-=3)t=t.substring(0,e)+","+t.substring(e);return t.length>8?t="@gre@"+t.substring(0,t.length-8)+" million @whi@("+t+")":t.length>4&&(t="@cya@"+t.substring(0,t.length-4)+"K @whi@("+t+")")," "+t};formatObjCount=e=>e<1e5?String(e):e<1e7?(e/1e3|0)+"K":(e/1e6|0)+"M"}},1803:(e,t,i)=>{i.d(t,{O:()=>n});var s=i(1995),a=i(3099),r=i(1519);async function n(){const e=window.location.hostname,t=window.location.protocol.startsWith("https");0===s.Z.getParameter("world").length&&s.Z.setParameter("world","1"),0===s.Z.getParameter("detail").length&&s.Z.setParameter("detail","high"),0===s.Z.getParameter("method").length&&s.Z.setParameter("method","0"),"localhost"===e&&"0"===s.Z.getParameter("world")?(a.K.serverAddress="http://localhost",a.K.httpAddress="http://localhost",a.K.portOffset=0):await async function(e){const t=await h(e,parseInt(s.Z.getParameter("world"),10)),i=new URL(t.address);a.K.nodeId=10+t.id-1,a.K.serverAddress=`${i.protocol}//${i.hostname}`,a.K.httpAddress=`${i.protocol}//${i.hostname}:${i.port}`,e||(a.K.serverAddress=a.K.serverAddress.replace("https:","http:")),a.K.portOffset=t.portOffset,a.K.members=!0===t?.members}(t),"low"===s.Z.getParameter("detail")?a.K.setLowMemory():a.K.setHighMemory()}async function h(e,t,i=0){if(i>=10)throw new Error("could not find world to connect!");const s=e?"https:":"http:";let a;try{a=JSON.parse(await(0,r.Di)(`${s}//2004scape.org/api/v1/worldlist`))}catch(s){return await(0,r._v)(1e3),h(e,t,++i)}return a.find((e=>e.id===t))||h(e,t,10)}},1979:(e,t,i)=>{i.a(e,(async(e,t)=>{try{var s=i(8067),a=i(7958),r=i(1840),n=i(2441),h=i(8809),o=i(551),l=i(1089),c=i(2790),d=i(651),u=i(2991),f=i(8078),p=i(664),m=i(6542),g=i(4628),y=i(9178),C=i(312),w=i(2383),T=i(1812),S=i(741),Z=i(7576),A=i(8432),v=i(9782),I=i(9995),O=i(9897),b=i(6054),L=i(6970),E=(i(1527),i(5810)),x=i(9080),_=i(8934),k=i(6884),R=i(7221),P=i(3909),M=i(3714),N=i(1908),B=i(5534),D=i(6150),Y=i(7396),X=i(3693),F=i(8603),H=i(4191),W=i(1353),z=i(7973),U=i(682),G=i(1810),V=i(5659),j=i(3584),q=i(1519),K=i(9345),J=i(3099),Q=i(2157),$=i(8762),ee=i(8056),te=i(1803);class e extends J.K{load=async()=>{if(this.alreadyStarted)this.errorStarted=!0;else{this.alreadyStarted=!0;try{await this.showProgress(10,"Connecting to fileserver"),await E.Z.load(await(await fetch("bz2.wasm")).arrayBuffer()),this.db=new A.Z(await A.Z.openDatabase());const e=new w.Z(new Uint8Array(await(0,q.GR)(`${J.K.httpAddress}/crc`)));for(let t=0;t<9;t++)this.archiveChecksums[t]=e.g4;J.K.lowMemory||await this.setMidi("scape_main",12345678,4e4);const t=await this.loadArchive("title","title screen",this.archiveChecksums[1],10);this.titleArchive=t,this.fontPlain11=g.Z.fromArchive(t,"p11"),this.fontPlain12=g.Z.fromArchive(t,"p12"),this.fontBold12=g.Z.fromArchive(t,"b12"),this.fontQuill8=g.Z.fromArchive(t,"q8"),await this.loadTitleBackground(),this.loadTitleImages();const i=await this.loadArchive("config","config",this.archiveChecksums[2],15),u=await this.loadArchive("interface","interface",this.archiveChecksums[3],20),C=await this.loadArchive("media","2d graphics",this.archiveChecksums[4],30),T=await this.loadArchive("models","3d graphics",this.archiveChecksums[5],40),S=await this.loadArchive("textures","textures",this.archiveChecksums[6],60),Z=await this.loadArchive("wordenc","chat system",this.archiveChecksums[7],65),v=await this.loadArchive("sounds","sound effects",this.archiveChecksums[8],70);this.levelTileFlags=new K.zi(X.Z.LEVELS,X.Z.SIZE,X.Z.SIZE),this.levelHeightmap=new K.AK(X.Z.LEVELS,X.Z.SIZE+1,X.Z.SIZE+1),this.levelHeightmap&&(this.scene=new R.Z(this.levelHeightmap,X.Z.SIZE,X.Z.LEVELS,X.Z.SIZE));for(let e=0;e34||e>34))999===t&&(t=s);else if(999!==t){i=s;break}this.minimapMaskLineOffsets[e-9]=t-21,this.minimapMaskLineLengths[e-9]=i-t}f.Z.init3D(479,96),this.areaChatbackOffsets=f.Z.lineOffset,f.Z.init3D(190,261),this.areaSidebarOffsets=f.Z.lineOffset,f.Z.init3D(512,334),this.areaViewportOffsets=f.Z.lineOffset;const z=new Int32Array(9);for(let e=0;e<9;e++){const t=32*e+128+15,i=3*t+600,s=f.Z.sin[t];z[e]=i*s>>16}R.Z.init(512,334,500,800,z),O.Z.unpack(Z),this.initializeLevelExperience()}catch(e){console.error(e),this.errorLoading=!0}}};update=async()=>{this.errorStarted||this.errorLoading||this.errorHost||(this.loopCycle++,this.ingame?await this.updateGame():await this.updateTitleScreen())};draw=async()=>{this.errorStarted||this.errorLoading||this.errorHost?this.drawError():(this.ingame?this.drawGame():await this.drawTitleScreen(),this.dragCycles=0)};refresh=()=>{this.redrawTitleBackground=!0};showProgress=async(e,t)=>{console.log(`${e}%: ${t}`),await this.loadTitle(),this.titleArchive?(this.imageTitle4?.bind(),this.fontBold12?.drawStringCenter(180,54,"RuneScape is loading - please wait...",C.Z.WHITE),u.Z.drawRect(28,62,304,34,C.Z.PROGRESS_RED),u.Z.drawRect(29,63,302,32,C.Z.BLACK),u.Z.fillRect(30,64,3*e,30,C.Z.PROGRESS_RED),u.Z.fillRect(30+3*e,64,300-3*e,30,C.Z.BLACK),this.fontBold12?.drawStringCenter(180,85,t,C.Z.WHITE),this.imageTitle4?.draw(214,186),this.redrawTitleBackground&&(this.redrawTitleBackground=!1,this.flameActive||(this.imageTitle0?.draw(0,0),this.imageTitle1?.draw(661,0)),this.imageTitle2?.draw(128,0),this.imageTitle3?.draw(214,386),this.imageTitle5?.draw(0,265),this.imageTitle6?.draw(574,265),this.imageTitle7?.draw(128,186),this.imageTitle8?.draw(574,186)),await(0,q._v)(5)):await super.showProgress(e,t)};runFlames=()=>{this.flameActive&&(this.updateFlames(),this.updateFlames(),this.drawFlames())};loadTitle=async()=>{this.imageTitle2||(this.drawArea=null,this.areaChatback=null,this.areaMapback=null,this.areaSidebar=null,this.areaViewport=null,this.areaBackbase1=null,this.areaBackbase2=null,this.areaBackhmid1=null,this.imageTitle0=new d.Z(128,265),u.Z.clear(),this.imageTitle1=new d.Z(128,265),u.Z.clear(),this.imageTitle2=new d.Z(533,186),u.Z.clear(),this.imageTitle3=new d.Z(360,146),u.Z.clear(),this.imageTitle4=new d.Z(360,200),u.Z.clear(),this.imageTitle5=new d.Z(214,267),u.Z.clear(),this.imageTitle6=new d.Z(215,267),u.Z.clear(),this.imageTitle7=new d.Z(86,79),u.Z.clear(),this.imageTitle8=new d.Z(87,79),u.Z.clear(),this.titleArchive&&(await this.loadTitleBackground(),this.loadTitleImages()),this.redrawTitleBackground=!0)};loadTitleBackground=async()=>{if(!this.titleArchive)return;const e=await m.Z.fromJpeg(this.titleArchive,"title");this.imageTitle0?.bind(),e.blitOpaque(0,0),this.imageTitle1?.bind(),e.blitOpaque(-661,0),this.imageTitle2?.bind(),e.blitOpaque(-128,0),this.imageTitle3?.bind(),e.blitOpaque(-214,-386),this.imageTitle4?.bind(),e.blitOpaque(-214,-186),this.imageTitle5?.bind(),e.blitOpaque(0,-265),this.imageTitle6?.bind(),e.blitOpaque(-128,-186),this.imageTitle7?.bind(),e.blitOpaque(-128,-186),this.imageTitle8?.bind(),e.blitOpaque(-574,-186),e.flipHorizontally(),this.imageTitle0?.bind(),e.blitOpaque(394,0),this.imageTitle1?.bind(),e.blitOpaque(-267,0),this.imageTitle2?.bind(),e.blitOpaque(266,0),this.imageTitle3?.bind(),e.blitOpaque(180,-386),this.imageTitle4?.bind(),e.blitOpaque(180,-186),this.imageTitle5?.bind(),e.blitOpaque(394,-265),this.imageTitle6?.bind(),e.blitOpaque(-180,-265),this.imageTitle7?.bind(),e.blitOpaque(212,-186),this.imageTitle8?.bind(),e.blitOpaque(-180,-186);const t=m.Z.fromArchive(this.titleArchive,"logo");this.imageTitle2?.bind(),t.draw((this.width/2|0)-(t.width/2|0)-128,18)};updateFlameBuffer=e=>{if(this.flameBuffer0&&this.flameBuffer1){this.flameBuffer0.fill(0);for(let e=0;e<5e3;e++){const e=128*Math.random()*256|0;this.flameBuffer0[e]=256*Math.random()|0}for(let e=0;e<20;e++){for(let e=1;e<255;e++)for(let t=1;t<127;t++){const i=t+(e<<7);this.flameBuffer1[i]=(this.flameBuffer0[i-1]+this.flameBuffer0[i+1]+this.flameBuffer0[i-128]+this.flameBuffer0[i+128])/4|0}const e=this.flameBuffer0;this.flameBuffer0=this.flameBuffer1,this.flameBuffer1=e}if(e){let t=0;for(let i=0;i{if(this.titleArchive){this.imageTitlebox=p.Z.fromArchive(this.titleArchive,"titlebox"),this.imageTitlebutton=p.Z.fromArchive(this.titleArchive,"titlebutton");for(let e=0;e<12;e++)this.imageRunes[e]=p.Z.fromArchive(this.titleArchive,"runes",e);this.imageFlamesLeft=new m.Z(128,265),this.imageFlamesRight=new m.Z(128,265),this.imageTitle0&&(0,q.fH)(this.imageTitle0.pixels,0,this.imageFlamesLeft.pixels,0,33920),this.imageTitle1&&(0,q.fH)(this.imageTitle1.pixels,0,this.imageFlamesRight.pixels,0,33920),this.flameGradient0=new Int32Array(256);for(let e=0;e<64;e++)this.flameGradient0[e]=262144*e;for(let e=0;e<64;e++)this.flameGradient0[e+64]=1024*e+C.Z.RED;for(let e=0;e<64;e++)this.flameGradient0[e+128]=4*e+C.Z.YELLOW;for(let e=0;e<64;e++)this.flameGradient0[e+192]=C.Z.WHITE;this.flameGradient1=new Int32Array(256);for(let e=0;e<64;e++)this.flameGradient1[e]=1024*e;for(let e=0;e<64;e++)this.flameGradient1[e+64]=4*e+C.Z.GREEN;for(let e=0;e<64;e++)this.flameGradient1[e+128]=262144*e+C.Z.CYAN;for(let e=0;e<64;e++)this.flameGradient1[e+192]=C.Z.WHITE;this.flameGradient2=new Int32Array(256);for(let e=0;e<64;e++)this.flameGradient2[e]=4*e;for(let e=0;e<64;e++)this.flameGradient2[e+64]=262144*e+C.Z.BLUE;for(let e=0;e<64;e++)this.flameGradient2[e+128]=1024*e+C.Z.MAGENTA;for(let e=0;e<64;e++)this.flameGradient2[e+192]=C.Z.WHITE;this.flameGradient=new Int32Array(256),this.flameBuffer0=new Int32Array(32768),this.flameBuffer1=new Int32Array(32768),this.updateFlameBuffer(null),this.flameBuffer3=new Int32Array(32768),this.flameBuffer2=new Int32Array(32768),this.showProgress(10,"Connecting to fileserver").then((()=>{this.flameActive||(this.flameActive=!0,this.flamesInterval=setInterval(this.runFlames,35))}))}};updateTitleScreen=async()=>{if(0===this.titleScreenState){let e=(this.width/2|0)-80,t=20+(this.height/2|0);t+=20,1===this.mouseClickButton&&this.mouseClickX>=e-75&&this.mouseClickX<=e+75&&this.mouseClickY>=t-20&&this.mouseClickY<=t+20&&(this.titleScreenState=3,this.titleLoginField=0),e=80+(this.width/2|0),1===this.mouseClickButton&&this.mouseClickX>=e-75&&this.mouseClickX<=e+75&&this.mouseClickY>=t-20&&this.mouseClickY<=t+20&&(this.loginMessage0="",this.loginMessage1="Enter your username & password.",this.titleScreenState=2,this.titleLoginField=0)}else if(2===this.titleScreenState){let e=(this.height/2|0)-40;e+=30,e+=25,1===this.mouseClickButton&&this.mouseClickY>=e-15&&this.mouseClickY=e-15&&this.mouseClickY=t-75&&this.mouseClickX<=t+75&&this.mouseClickY>=i-20&&this.mouseClickY<=i+20&&await this.login(this.username,this.password,!1),t=80+(this.width/2|0),1===this.mouseClickButton&&this.mouseClickX>=t-75&&this.mouseClickX<=t+75&&this.mouseClickY>=i-20&&this.mouseClickY<=i+20&&(this.titleScreenState=0,this.username="",this.password="");;){const e=this.pollKey();if(-1===e)return;let t=!1;for(let i=0;i0&&(this.username=this.username.substring(0,this.username.length-1)),9!==e&&10!==e&&13!==e||(this.titleLoginField=1),t&&(this.username=this.username+String.fromCharCode(e)),this.username.length>12&&(this.username=this.username.substring(0,12))):1===this.titleLoginField&&(8===e&&this.password.length>0&&(this.password=this.password.substring(0,this.password.length-1)),9!==e&&10!==e&&13!==e||(this.titleLoginField=0),t&&(this.password=this.password+String.fromCharCode(e)),this.password.length>20&&(this.password=this.password.substring(0,20)))}}else if(3===this.titleScreenState){const e=this.width/2|0;let t=50+(this.height/2|0);t+=20,1===this.mouseClickButton&&this.mouseClickX>=e-75&&this.mouseClickX<=e+75&&this.mouseClickY>=t-20&&this.mouseClickY<=t+20&&(this.titleScreenState=0)}};drawTitleScreen=async()=>{if(await this.loadTitle(),this.imageTitle4?.bind(),this.imageTitlebox?.draw(0,0),0===this.titleScreenState){let e=180,t=80;this.fontBold12?.drawStringTaggableCenter(e,t,"Welcome to RuneScape",C.Z.YELLOW,!0),e=100,t=120,this.imageTitlebutton?.draw(e-73,t-20),this.fontBold12?.drawStringTaggableCenter(e,t+5,"New user",C.Z.WHITE,!0),e=260,this.imageTitlebutton?.draw(e-73,t-20),this.fontBold12?.drawStringTaggableCenter(e,t+5,"Existing User",C.Z.WHITE,!0)}else if(2===this.titleScreenState){let e=100,t=60;this.loginMessage0.length>0?(this.fontBold12?.drawStringTaggableCenter(180,t-15,this.loginMessage0,C.Z.YELLOW,!0),this.fontBold12?.drawStringTaggableCenter(180,t,this.loginMessage1,C.Z.YELLOW,!0),t+=30):(this.fontBold12?.drawStringTaggableCenter(180,t-7,this.loginMessage1,C.Z.YELLOW,!0),t+=30),this.fontBold12?.drawStringTaggable(90,t,`Username: ${this.username}${0===this.titleLoginField&&this.loopCycle%40<20?"@yel@|":""}`,C.Z.WHITE,!0),t+=15,this.fontBold12?.drawStringTaggable(92,t,`Password: ${_.Z.toAsterisks(this.password)}${1===this.titleLoginField&&this.loopCycle%40<20?"@yel@|":""}`,C.Z.WHITE,!0),t=150,this.imageTitlebutton?.draw(e-73,t-20),this.fontBold12?.drawStringTaggableCenter(e,t+5,"Login",C.Z.WHITE,!0),e=260,this.imageTitlebutton?.draw(e-73,t-20),this.fontBold12?.drawStringTaggableCenter(e,t+5,"Cancel",C.Z.WHITE,!0)}else if(3===this.titleScreenState){this.fontBold12?.drawStringTaggableCenter(180,40,"Create a free account",C.Z.YELLOW,!0);const e=180;let t=65;this.fontBold12?.drawStringTaggableCenter(180,t,"To create a new account you need to",C.Z.WHITE,!0),t+=15,this.fontBold12?.drawStringTaggableCenter(180,t,"go back to the main RuneScape webpage",C.Z.WHITE,!0),t+=15,this.fontBold12?.drawStringTaggableCenter(180,t,"and choose the red 'create account'",C.Z.WHITE,!0),t+=15,this.fontBold12?.drawStringTaggableCenter(180,t,"button at the top right of that page.",C.Z.WHITE,!0),t=150,this.imageTitlebutton?.draw(e-73,t-20),this.fontBold12?.drawStringTaggableCenter(e,t+5,"Cancel",C.Z.WHITE,!0)}this.imageTitle4?.draw(214,186),this.redrawTitleBackground&&(this.redrawTitleBackground=!1,this.imageTitle2?.draw(128,0),this.imageTitle3?.draw(214,386),this.imageTitle5?.draw(0,265),this.imageTitle6?.draw(574,265),this.imageTitle7?.draw(128,186),this.imageTitle8?.draw(574,186))};login=async(e,t,i)=>{try{i||(this.loginMessage0="",this.loginMessage1="Connecting to server...",await this.drawTitleScreen()),this.stream=new T.Z(await T.Z.openSocket({host:J.K.serverAddress,port:43594+J.K.portOffset})),await(this.stream?.readBytes(this.in.data,0,8)),this.in.pos=0,this.serverSeed=this.in.g8;const s=new Int32Array([Math.floor(99999999*Math.random()),Math.floor(99999999*Math.random()),Number(this.serverSeed>>32n),Number(this.serverSeed&BigInt(4294967295))]);this.out.pos=0,this.out.p1(10),this.out.p4(s[0]),this.out.p4(s[1]),this.out.p4(s[2]),this.out.p4(s[3]),this.out.p4(0),this.out.pjstr(e),this.out.pjstr(t),this.out.rsaenc(J.K.modulus,J.K.exponent),this.loginout.pos=0,i?this.loginout.p1(18):this.loginout.p1(16),this.loginout.p1(this.out.pos+36+1+1),this.loginout.p1(J.K.clientversion),this.loginout.p1(J.K.lowMemory?1:0);for(let e=0;e<9;e++)this.loginout.p4(this.archiveChecksums[e]);this.loginout.pdata(this.out.data,this.out.pos,0),this.out.random=new Z.Z(s);for(let e=0;e<4;e++)s[e]+=50;this.randomIn=new Z.Z(s),this.stream?.write(this.loginout.data,this.loginout.pos);const a=await this.stream.read();if(1===a)return await(0,q._v)(2e3),void await this.login(e,t,i);if(2===a||18===a){this.rights=18===a,k.Z.setDisabled(),this.ingame=!0,this.out.pos=0,this.in.pos=0,this.packetType=-1,this.lastPacketType0=-1,this.lastPacketType1=-1,this.lastPacketType2=-1,this.packetSize=0,this.idleNetCycles=0,this.systemUpdateTimer=0,this.idleTimeout=0,this.hintType=0,this.menuSize=0,this.menuVisible=!1,this.idleCycles=0;for(let e=0;e<100;e++)this.messageText[e]=null;this.objSelected=0,this.spellSelected=0,this.sceneState=0,this.waveCount=0,this.cameraAnticheatOffsetX=(100*Math.random()|0)-50,this.cameraAnticheatOffsetZ=(110*Math.random()|0)-55,this.cameraAnticheatAngle=(80*Math.random()|0)-40,this.minimapAnticheatAngle=(120*Math.random()|0)-60,this.minimapZoom=(30*Math.random()|0)-20,this.orbitCameraYaw=(20*Math.random()|0)-10&2047,this.minimapLevel=-1,this.flagSceneTileX=0,this.flagSceneTileZ=0,this.playerCount=0,this.npcCount=0;for(let e=0;e{if(null!==this.players){this.systemUpdateTimer>1&&this.systemUpdateTimer--,this.idleTimeout>0&&this.idleTimeout--;for(let e=0;e<5&&await this.read();e++);if(this.ingame){for(let e=0;ethis.lastWaveStartTime+(this.lastWaveLength/22|0)&&(this.lastWaveLength=t.pos,this.lastWaveStartTime=Date.now(),this.lastWaveId=this.waveIds[e],this.lastWaveLoops=this.waveLoops[e],await(0,j.w3)(t.data.slice(0,t.pos),this.waveVolume))}catch(e){console.error(e)}this.waveCount--;for(let t=e;t0&&(this.nextMusicDelay-=20,this.nextMusicDelay<0&&(this.nextMusicDelay=0),0===this.nextMusicDelay&&this.midiActive&&!J.K.lowMemory&&this.currentMidi&&await this.setMidi(this.currentMidi,this.midiCrc,this.midiSize));const e=k.Z.flush();if(e&&(this.out.p1isaac(I.Z.EVENT_TRACKING),this.out.p2(e.pos),this.out.pdata(e.data,e.pos,0),e.release()),this.idleNetCycles++,this.idleNetCycles>750&&await this.tryReconnect(),this.updatePlayers(),this.updateNpcs(),this.updateEntityChats(),this.updateTemporaryLocs(),(1===this.actionKey[1]||1===this.actionKey[2]||1===this.actionKey[3]||1===this.actionKey[4])&&this.cameraMovedWrite++>5&&(this.cameraMovedWrite=0,this.out.p1isaac(I.Z.EVENT_CAMERA_POSITION),this.out.p2(this.orbitCameraPitch),this.out.p2(this.orbitCameraYaw),this.out.p1(this.minimapAnticheatAngle),this.out.p1(this.minimapZoom)),this.sceneDelta++,0!==this.crossMode&&(this.crossCycle+=20,this.crossCycle>=400&&(this.crossMode=0)),0!==this.selectedArea&&(this.selectedCycle++,this.selectedCycle>=15&&(2===this.selectedArea&&(this.redrawSidebar=!0),3===this.selectedArea&&(this.redrawChatback=!0),this.selectedArea=0)),0!==this.objDragArea&&(this.objDragCycles++,(this.mouseX>this.objGrabX+5||this.mouseXthis.objGrabY+5||this.mouseY=5){if(this.hoveredSlotParentId=-1,this.handleInput(),this.hoveredSlotParentId===this.objDragInterfaceId&&this.hoveredSlot!==this.objDragSlot){const e=c.Z.instances[this.objDragInterfaceId];if(e.invSlotObjId){const t=e.invSlotObjId[this.hoveredSlot];e.invSlotObjId[this.hoveredSlot]=e.invSlotObjId[this.objDragSlot],e.invSlotObjId[this.objDragSlot]=t}if(e.invSlotObjCount){const t=e.invSlotObjCount[this.hoveredSlot];e.invSlotObjCount[this.hoveredSlot]=e.invSlotObjCount[this.objDragSlot],e.invSlotObjCount[this.objDragSlot]=t}this.out.p1isaac(I.Z.INV_BUTTOND),this.out.p2(this.objDragInterfaceId),this.out.p2(this.objDragSlot),this.out.p2(this.hoveredSlot)}}else(1===this.mouseButtonsOption||this.isAddFriendOption(this.menuSize-1))&&this.menuSize>2?this.showContextMenu():this.menuSize>0&&await this.useMenuOption(this.menuSize-1);this.selectedCycle=10,this.mouseClickButton=0}if(J.K.updateCounter++,J.K.updateCounter>127&&(J.K.updateCounter=0,this.out.p1isaac(I.Z.ANTICHEAT_CYCLELOGIC3),this.out.p3(4991788)),-1!==R.Z.clickTileX&&this.localPlayer){const e=R.Z.clickTileX,t=R.Z.clickTileZ,i=this.tryMove(this.localPlayer.pathTileX[0],this.localPlayer.pathTileZ[0],e,t,0,0,0,0,0,0,!0);R.Z.clickTileX=-1,i&&(this.crossX=this.mouseClickX,this.crossY=this.mouseClickY,this.crossMode=1,this.crossCycle=0)}1===this.mouseClickButton&&this.modalMessage&&(this.modalMessage=null,this.redrawChatback=!0,this.mouseClickButton=0),await this.handleMouseInput(),this.handleMinimapInput(),this.handleTabInput(),this.handleChatSettingsInput(),1!==this.mouseButton&&1!==this.mouseClickButton||this.dragCycles++,2===this.sceneState&&this.updateOrbitCamera(),2===this.sceneState&&this.cutscene&&this.applyCutscene();for(let e=0;e<5;e++)this.cameraModifierCycle[e]++;if(await this.handleInputKey(),this.idleCycles++,this.idleCycles>4500&&(this.idleTimeout=250,this.idleCycles-=500,this.out.p1isaac(I.Z.IDLE_TIMER)),this.cameraOffsetCycle++,this.cameraOffsetCycle>500){this.cameraOffsetCycle=0;const e=8*Math.random()|0;1==(1&e)&&(this.cameraAnticheatOffsetX+=this.cameraOffsetXModifier),2==(2&e)&&(this.cameraAnticheatOffsetZ+=this.cameraOffsetZModifier),4==(4&e)&&(this.cameraAnticheatAngle+=this.cameraOffsetYawModifier)}if(this.cameraAnticheatOffsetX<-50&&(this.cameraOffsetXModifier=2),this.cameraAnticheatOffsetX>50&&(this.cameraOffsetXModifier=-2),this.cameraAnticheatOffsetZ<-55&&(this.cameraOffsetZModifier=2),this.cameraAnticheatOffsetZ>55&&(this.cameraOffsetZModifier=-2),this.cameraAnticheatAngle<-40&&(this.cameraOffsetYawModifier=1),this.cameraAnticheatAngle>40&&(this.cameraOffsetYawModifier=-1),this.minimapOffsetCycle++,this.minimapOffsetCycle>500){this.minimapOffsetCycle=0;const e=8*Math.random()|0;1==(1&e)&&(this.minimapAnticheatAngle+=this.minimapAngleModifier),2==(2&e)&&(this.minimapZoom+=this.minimapZoomModifier)}this.minimapAnticheatAngle<-60&&(this.minimapAngleModifier=2),this.minimapAnticheatAngle>60&&(this.minimapAngleModifier=-2),this.minimapZoom<-20&&(this.minimapZoomModifier=1),this.minimapZoom>10&&(this.minimapZoomModifier=-1),J.K.update2Counter++,J.K.update2Counter>110&&(J.K.update2Counter=0,this.out.p1isaac(I.Z.ANTICHEAT_CYCLELOGIC4),this.out.p4(0)),this.heartbeatTimer++,this.heartbeatTimer>50&&this.out.p1isaac(I.Z.NO_TIMEOUT);try{this.stream&&this.out.pos>0&&(this.stream.write(this.out.data,this.out.pos),this.out.pos=0,this.heartbeatTimer=0)}catch(e){console.log(e),await this.tryReconnect()}}}};drawGame=()=>{if(null===this.players)return;this.redrawTitleBackground&&(this.redrawTitleBackground=!1,this.areaBackleft1?.draw(0,11),this.areaBackleft2?.draw(0,375),this.areaBackright1?.draw(729,5),this.areaBackright2?.draw(752,231),this.areaBacktop1?.draw(0,0),this.areaBacktop2?.draw(561,0),this.areaBackvmid1?.draw(520,11),this.areaBackvmid2?.draw(520,231),this.areaBackvmid3?.draw(501,375),this.areaBackhmid2?.draw(0,345),this.redrawSidebar=!0,this.redrawChatback=!0,this.redrawSideicons=!0,this.redrawPrivacySettings=!0,2!==this.sceneState&&(this.areaViewport?.draw(8,11),this.areaMapback?.draw(561,5))),2===this.sceneState&&this.drawScene(),this.menuVisible&&1===this.menuArea&&(this.redrawSidebar=!0);let e=!1;if(-1!==this.sidebarInterfaceId&&(e=this.updateInterfaceAnimation(this.sidebarInterfaceId,this.sceneDelta),e&&(this.redrawSidebar=!0)),2===this.selectedArea&&(this.redrawSidebar=!0),2===this.objDragArea&&(this.redrawSidebar=!0),this.redrawSidebar&&(this.drawSidebar(),this.redrawSidebar=!1),-1===this.chatInterfaceId){this.chatInterface.scrollPosition=this.chatScrollHeight-this.chatScrollOffset-77,this.mouseX>453&&this.mouseX<565&&this.mouseY>350&&this.handleScrollInput(this.mouseX-22,this.mouseY-375,this.chatScrollHeight,77,!1,463,0,this.chatInterface);let e=this.chatScrollHeight-this.chatInterface.scrollPosition-77;e<0&&(e=0),e>this.chatScrollHeight-77&&(e=this.chatScrollHeight-77),this.chatScrollOffset!==e&&(this.chatScrollOffset=e,this.redrawChatback=!0)}-1!==this.chatInterfaceId&&(e=this.updateInterfaceAnimation(this.chatInterfaceId,this.sceneDelta),e&&(this.redrawChatback=!0)),3===this.selectedArea&&(this.redrawChatback=!0),3===this.objDragArea&&(this.redrawChatback=!0),this.modalMessage&&(this.redrawChatback=!0),this.menuVisible&&2===this.menuArea&&(this.redrawChatback=!0),this.redrawChatback&&(this.drawChatback(),this.redrawChatback=!1),2===this.sceneState&&(this.drawMinimap(),this.areaMapback?.draw(561,5)),-1!==this.flashingTab&&(this.redrawSideicons=!0),this.redrawSideicons&&(-1!==this.flashingTab&&this.flashingTab===this.selectedTab&&(this.flashingTab=-1,this.out.p1isaac(I.Z.TUTORIAL_CLICKSIDE),this.out.p1(this.selectedTab)),this.redrawSideicons=!1,this.areaBackhmid1?.bind(),this.imageBackhmid1?.draw(0,0),-1===this.sidebarInterfaceId&&(-1!==this.tabInterfaceId[this.selectedTab]&&(0===this.selectedTab?this.imageRedstone1?.draw(29,30):1===this.selectedTab?this.imageRedstone2?.draw(59,29):2===this.selectedTab?this.imageRedstone2?.draw(87,29):3===this.selectedTab?this.imageRedstone3?.draw(115,29):4===this.selectedTab?this.imageRedstone2h?.draw(156,29):5===this.selectedTab?this.imageRedstone2h?.draw(184,29):6===this.selectedTab&&this.imageRedstone1h?.draw(212,30)),-1!==this.tabInterfaceId[0]&&(0!==this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[0]?.draw(35,34),-1!==this.tabInterfaceId[1]&&(1!==this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[1]?.draw(59,32),-1!==this.tabInterfaceId[2]&&(2!==this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[2]?.draw(86,32),-1!==this.tabInterfaceId[3]&&(3!==this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[3]?.draw(121,33),-1!==this.tabInterfaceId[4]&&(4!==this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[4]?.draw(157,34),-1!==this.tabInterfaceId[5]&&(5!==this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[5]?.draw(185,32),-1!==this.tabInterfaceId[6]&&(6!==this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[6]?.draw(212,34)),this.areaBackhmid1?.draw(520,165),this.areaBackbase2?.bind(),this.imageBackbase2?.draw(0,0),-1===this.sidebarInterfaceId&&(-1!==this.tabInterfaceId[this.selectedTab]&&(7===this.selectedTab?this.imageRedstone1v?.draw(49,0):8===this.selectedTab?this.imageRedstone2v?.draw(81,0):9===this.selectedTab?this.imageRedstone2v?.draw(108,0):10===this.selectedTab?this.imageRedstone3v?.draw(136,1):11===this.selectedTab?this.imageRedstone2hv?.draw(178,0):12===this.selectedTab?this.imageRedstone2hv?.draw(205,0):13===this.selectedTab&&this.imageRedstone1hv?.draw(233,0)),-1!==this.tabInterfaceId[8]&&(8!==this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[7]?.draw(80,2),-1!==this.tabInterfaceId[9]&&(9!==this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[8]?.draw(107,3),-1!==this.tabInterfaceId[10]&&(10!==this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[9]?.draw(142,4),-1!==this.tabInterfaceId[11]&&(11!==this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[10]?.draw(179,2),-1!==this.tabInterfaceId[12]&&(12!==this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[11]?.draw(206,2),-1!==this.tabInterfaceId[13]&&(13!==this.flashingTab||this.loopCycle%20<10)&&this.imageSideicons[12]?.draw(230,2)),this.areaBackbase2?.draw(501,492),this.areaViewport?.bind()),this.redrawPrivacySettings&&(this.redrawPrivacySettings=!1,this.areaBackbase1?.bind(),this.imageBackbase1?.draw(0,0),this.fontPlain12?.drawStringTaggableCenter(57,33,"Public chat",C.Z.WHITE,!0),0===this.publicChatSetting&&this.fontPlain12?.drawStringTaggableCenter(57,46,"On",C.Z.GREEN,!0),1===this.publicChatSetting&&this.fontPlain12?.drawStringTaggableCenter(57,46,"Friends",C.Z.YELLOW,!0),2===this.publicChatSetting&&this.fontPlain12?.drawStringTaggableCenter(57,46,"Off",C.Z.RED,!0),3===this.publicChatSetting&&this.fontPlain12?.drawStringTaggableCenter(57,46,"Hide",C.Z.CYAN,!0),this.fontPlain12?.drawStringTaggableCenter(186,33,"Private chat",C.Z.WHITE,!0),0===this.privateChatSetting&&this.fontPlain12?.drawStringTaggableCenter(186,46,"On",C.Z.GREEN,!0),1===this.privateChatSetting&&this.fontPlain12?.drawStringTaggableCenter(186,46,"Friends",C.Z.YELLOW,!0),2===this.privateChatSetting&&this.fontPlain12?.drawStringTaggableCenter(186,46,"Off",C.Z.RED,!0),this.fontPlain12?.drawStringTaggableCenter(326,33,"Trade/duel",C.Z.WHITE,!0),0===this.tradeChatSetting&&this.fontPlain12?.drawStringTaggableCenter(326,46,"On",C.Z.GREEN,!0),1===this.tradeChatSetting&&this.fontPlain12?.drawStringTaggableCenter(326,46,"Friends",C.Z.YELLOW,!0),2===this.tradeChatSetting&&this.fontPlain12?.drawStringTaggableCenter(326,46,"Off",C.Z.RED,!0),this.fontPlain12?.drawStringTaggableCenter(462,38,"Report abuse",C.Z.WHITE,!0),this.areaBackbase1?.draw(0,471),this.areaViewport?.bind()),this.sceneDelta=0};drawScene=()=>{if(this.sceneCycle++,this.pushPlayers(),this.pushNpcs(),this.pushProjectiles(),this.pushSpotanims(),this.pushLocs(),!this.cutscene){let e=this.orbitCameraPitch;(this.cameraPitchClamp/256|0)>e&&(e=this.cameraPitchClamp/256|0),this.cameraModifierEnabled[4]&&this.cameraModifierWobbleScale[4]+128>e&&(e=this.cameraModifierWobbleScale[4]+128);const t=this.orbitCameraYaw+this.cameraAnticheatAngle&2047;if(this.localPlayer&&this.orbitCamera(this.orbitCameraX,this.getHeightmapY(this.currentLevel,this.localPlayer.x,this.localPlayer.z)-50,this.orbitCameraZ,t,e,3*e+600),J.K.drawCounter++,J.K.drawCounter>1802){J.K.drawCounter=0,this.out.p1isaac(I.Z.ANTICHEAT_CYCLELOGIC2),this.out.p1(0);const e=this.out.pos;this.out.p2(29711),this.out.p1(70),this.out.p1(256*Math.random()|0),this.out.p1(242),this.out.p1(186),this.out.p1(39),this.out.p1(61),0==(2*Math.random()|0)&&this.out.p1(13),0==(2*Math.random()|0)&&this.out.p2(57856),this.out.p2(65536*Math.random()|0),this.out.psize1(this.out.pos-e)}}let e;e=this.cutscene?this.getTopLevelCutscene():this.getTopLevel();const t=this.cameraX,i=this.cameraY,s=this.cameraZ,a=this.cameraPitch,r=this.cameraYaw;let n;for(let e=0;e<5;e++)this.cameraModifierEnabled[e]&&(n=Math.random()*(2*this.cameraModifierJitter[e]+1)-this.cameraModifierJitter[e]+Math.sin(this.cameraModifierCycle[e]*(this.cameraModifierWobbleSpeed[e]/100))*this.cameraModifierWobbleScale[e]|0,0===e&&(this.cameraX+=n),1===e&&(this.cameraY+=n),2===e&&(this.cameraZ+=n),3===e&&(this.cameraYaw=this.cameraYaw+n&2047),4===e&&(this.cameraPitch+=n,this.cameraPitch<128&&(this.cameraPitch=128),this.cameraPitch>383&&(this.cameraPitch=383)));n=f.Z.cycle,y.Z.checkHover=!0,y.Z.pickedCount=0,y.Z.mouseX=this.mouseX-8,y.Z.mouseY=this.mouseY-11,u.Z.clear(),this.scene?.draw(this.cameraX,this.cameraY,this.cameraZ,e,this.cameraYaw,this.cameraPitch,this.loopCycle),this.scene?.clearTemporaryLocs(),this.draw2DEntityElements(),this.drawTileHint(),J.K.showDebug&&this.drawDebug(),this.updateTextures(n),this.draw3DEntityElements(),this.areaViewport?.draw(8,11),this.cameraX=t,this.cameraY=i,this.cameraZ=s,this.cameraPitch=a,this.cameraYaw=r};clearCaches=()=>{a.Z.modelCacheStatic?.clear(),a.Z.modelCacheDynamic?.clear(),n.Z.modelCache?.clear(),r.Z.modelCache?.clear(),r.Z.iconCache?.clear(),H.Z.modelCache?.clear(),o.Z.modelCache?.clear()};projectFromEntity=(e,t)=>{this.projectFromGround(e.x,t,e.z)};projectFromGround=(e,t,i)=>{if(e<128||i<128||e>13056||i>13056)return this.projectX=-1,void(this.projectY=-1);const s=this.getHeightmapY(this.currentLevel,e,i)-t;this.project(e,s,i)};project=(e,t,i)=>{let s=e-this.cameraX,a=t-this.cameraY,r=i-this.cameraZ;const n=f.Z.sin[this.cameraPitch],h=f.Z.cos[this.cameraPitch],o=f.Z.sin[this.cameraYaw],l=f.Z.cos[this.cameraYaw];let c=r*o+s*l>>16;r=r*l-s*o>>16,s=c,c=a*h-r*n>>16,r=a*n+r*h>>16,a=c,r>=50?(this.projectX=f.Z.centerX+((s<<9)/r|0),this.projectY=f.Z.centerY+((a<<9)/r|0)):(this.projectX=-1,this.projectY=-1)};draw2DEntityElements=()=>{this.chatCount=0;for(let e=-1;e-1))for(let e=0;e<8;e++)0!=(s.headicons&1<=0&&10===this.hintType&&this.hintPlayer===this.playerIds[e]&&(this.projectFromEntity(t,t.height+15),this.projectX>-1&&this.imageHeadicons[7]&&this.imageHeadicons[7].draw(this.projectX-12,this.projectY-i))}else 1===this.hintType&&this.hintNpc===this.npcIds[e-this.playerCount]&&this.loopCycle%20<10&&(this.projectFromEntity(t,t.height+15),this.projectX>-1&&this.imageHeadicons[2]&&this.imageHeadicons[2].draw(this.projectX-12,this.projectY-28));if(t.chat&&(e>=this.playerCount||0===this.publicChatSetting||3===this.publicChatSetting||1===this.publicChatSetting&&this.isFriend(t.name))&&(this.projectFromEntity(t,t.height),this.projectX>-1&&this.chatCountthis.loopCycle+100&&(this.projectFromEntity(t,t.height+15),this.projectX>-1)){let e=30*t.health/t.totalHealth|0;e>30&&(e=30),u.Z.fillRect(this.projectX-15,this.projectY-3,e,5,C.Z.GREEN),u.Z.fillRect(this.projectX-15+e,this.projectY-3,30-e,5,C.Z.RED)}t.combatCycle>this.loopCycle+330&&(this.projectFromEntity(t,t.height/2|0),this.projectX>-1&&this.imageHitmarks[t.damageType]&&(this.imageHitmarks[t.damageType].draw(this.projectX-12,this.projectY-12),this.fontPlain11?.drawStringCenter(this.projectX,this.projectY+4,t.damage.toString(),C.Z.BLACK),this.fontPlain11?.drawStringCenter(this.projectX-1,this.projectY+3,t.damage.toString(),C.Z.WHITE)))}}for(let e=0;ethis.chatY[n]-this.chatHeight[n]&&i-athis.chatX[n]-this.chatWidth[n]&&this.chatY[n]-this.chatHeight[n]{2===this.hintType&&this.imageHeadicons[2]&&(this.projectFromGround((this.hintTileX-this.sceneBaseTileX<<7)+this.hintOffsetX,2*this.hintHeight,(this.hintTileZ-this.sceneBaseTileZ<<7)+this.hintOffsetZ),this.projectX>-1&&this.loopCycle%20<10&&this.imageHeadicons[2].draw(this.projectX-12,this.projectY-28))};drawDebug=()=>{const e=507;let t=20;this.fontPlain11?.drawStringRight(e,t,`FPS: ${this.fps}`,C.Z.YELLOW,!0),t+=13,this.fontPlain11?.drawStringRight(e,t,`Speed: ${this.ms.toFixed(4)} ms`,C.Z.YELLOW,!0),t+=13,this.fontPlain11?.drawStringRight(e,t,`Average: ${this.msAvg.toFixed(4)} ms`,C.Z.YELLOW,!0),t+=13,this.fontPlain11?.drawStringRight(e,t,`Slowest: ${this.slowestMS.toFixed(4)} ms`,C.Z.YELLOW,!0),t+=13,this.fontPlain11?.drawStringRight(e,t,`Occluders: ${R.Z.activeOccluderCount}`,C.Z.YELLOW,!0)};draw3DEntityElements=()=>{if(this.drawPrivateMessages(),1===this.crossMode&&this.imageCrosses[this.crossCycle/100|0]?.draw(this.crossX-8-8,this.crossY-8-11),2===this.crossMode&&this.imageCrosses[4+(this.crossCycle/100|0)]?.draw(this.crossX-8-8,this.crossY-8-11),-1!==this.viewportInterfaceId&&(this.updateInterfaceAnimation(this.viewportInterfaceId,this.sceneDelta),this.drawInterface(c.Z.instances[this.viewportInterfaceId],0,0,0)),this.drawWildyLevel(),this.menuVisible?0===this.menuArea&&this.drawMenu():(this.handleInput(),this.drawTooltip()),1===this.inMultizone&&(this.wildernessLevel>0||1===this.worldLocationState?this.imageHeadicons[1]?.draw(472,258):this.imageHeadicons[1]?.draw(472,296)),this.wildernessLevel>0&&(this.imageHeadicons[0]?.draw(472,296),this.fontPlain12?.drawStringCenter(484,329,"Level: "+this.wildernessLevel,C.Z.YELLOW)),1===this.worldLocationState&&(this.imageHeadicons[6]?.draw(472,296),this.fontPlain12?.drawStringCenter(484,329,"Arena",C.Z.YELLOW)),0!==this.systemUpdateTimer){let e=this.systemUpdateTimer/50|0;const t=e/60|0;e%=60,e<10?this.fontPlain12?.drawString(4,329,"System update in: "+t+":0"+e,C.Z.YELLOW):this.fontPlain12?.drawString(4,329,"System update in: "+t+":"+e,C.Z.YELLOW)}};drawPrivateMessages=()=>{if(0===this.splitPrivateChat)return;const e=this.fontPlain12;let t=0;0!==this.systemUpdateTimer&&(t=1);for(let i=0;i<100;i++){if(!this.messageText[i])continue;const s=this.messageType[i];let a;if((3===s||7===s)&&(7===s||0===this.privateChatSetting||1===this.privateChatSetting&&this.isFriend(this.messageSender[i]))&&(a=329-13*t,e?.drawString(4,a,"From "+this.messageSender[i]+": "+this.messageText[i],C.Z.BLACK),e?.drawString(4,a-1,"From "+this.messageSender[i]+": "+this.messageText[i],C.Z.CYAN),t++,t>=5))return;if(5===s&&this.privateChatSetting<2&&(a=329-13*t,e?.drawString(4,a,this.messageText[i],C.Z.BLACK),e?.drawString(4,a-1,this.messageText[i],C.Z.CYAN),t++,t>=5))return;if(6===s&&this.privateChatSetting<2&&(a=329-13*t,e?.drawString(4,a,"To "+this.messageSender[i]+": "+this.messageText[i],C.Z.BLACK),e?.drawString(4,a-1,"To "+this.messageSender[i]+": "+this.messageText[i],C.Z.CYAN),t++,t>=5))return}};drawWildyLevel=()=>{if(!this.localPlayer)return;const e=(this.localPlayer.x>>7)+this.sceneBaseTileX,t=(this.localPlayer.z>>7)+this.sceneBaseTileZ;if(this.wildernessLevel=e>=2944&&e<3392&&t>=3520&&t<6400?1+((t-3520)/8|0):e>=2944&&e<3392&&t>=9920&&t<12800?1+((t-9920)/8|0):0,this.worldLocationState=0,e>=3328&&e<3392&&t>=3200&&t<3264){const i=63&e,s=63&t;(i>=4&&i<=29&&s>=44&&s<=58||i>=36&&i<=61&&s>=44&&s<=58||i>=4&&i<=29&&s>=25&&s<=39||i>=36&&i<=61&&s>=25&&s<=39||i>=4&&i<=29&&s>=6&&s<=20||i>=36&&i<=61&&s>=6&&s<=20)&&(this.worldLocationState=1)}0===this.worldLocationState&&e>=3328&&e<=3393&&t>=3203&&t<=3325&&(this.worldLocationState=2),this.overrideChat=0,(e>=3053&&e<=3156&&t>=3056&&t<=3136||e>=3072&&e<=3118&&t>=9492&&t<=9535)&&(this.overrideChat=1),1===this.overrideChat&&e>=3139&&e<=3199&&t>=3008&&t<=3062&&(this.overrideChat=0)};drawSidebar=()=>{this.areaSidebar?.bind(),this.areaSidebarOffsets&&(f.Z.lineOffset=this.areaSidebarOffsets),this.imageInvback?.draw(0,0),-1!==this.sidebarInterfaceId?this.drawInterface(c.Z.instances[this.sidebarInterfaceId],0,0,0):-1!==this.tabInterfaceId[this.selectedTab]&&this.drawInterface(c.Z.instances[this.tabInterfaceId[this.selectedTab]],0,0,0),this.menuVisible&&1===this.menuArea&&this.drawMenu(),this.areaSidebar?.draw(562,231),this.areaViewport?.bind(),this.areaViewportOffsets&&(f.Z.lineOffset=this.areaViewportOffsets)};drawChatback=()=>{if(this.areaChatback?.bind(),this.areaChatbackOffsets&&(f.Z.lineOffset=this.areaChatbackOffsets),this.imageChatback?.draw(0,0),this.showSocialInput)this.fontBold12?.drawStringCenter(239,40,this.socialMessage,C.Z.BLACK),this.fontBold12?.drawStringCenter(239,60,this.socialInput+"*",C.Z.DARKBLUE);else if(this.chatbackInputOpen)this.fontBold12?.drawStringCenter(239,40,"Enter amount:",C.Z.BLACK),this.fontBold12?.drawStringCenter(239,60,this.chatbackInput+"*",C.Z.DARKBLUE);else if(this.modalMessage)this.fontBold12?.drawStringCenter(239,40,this.modalMessage,C.Z.BLACK),this.fontBold12?.drawStringCenter(239,60,"Click to continue",C.Z.DARKBLUE);else if(-1!==this.chatInterfaceId)this.drawInterface(c.Z.instances[this.chatInterfaceId],0,0,0);else if(-1===this.stickyChatInterfaceId){const e=this.fontPlain12;let t=0;u.Z.setBounds(0,0,463,77);for(let i=0;i<100;i++){const s=this.messageText[i];if(!s)continue;const a=this.messageType[i],r=this.chatScrollOffset+70-14*t;0===a&&(r>0&&r<110&&e?.drawString(4,r,s,C.Z.BLACK),t++),1===a&&(r>0&&r<110&&(e?.drawString(4,r,this.messageSender[i]+":",C.Z.WHITE),e?.drawString(e.stringWidth(this.messageSender[i])+12,r,s,C.Z.BLUE)),t++),2===a&&(0===this.publicChatSetting||1===this.publicChatSetting&&this.isFriend(this.messageSender[i]))&&(r>0&&r<110&&(e?.drawString(4,r,this.messageSender[i]+":",C.Z.BLACK),e?.drawString(e.stringWidth(this.messageSender[i])+12,r,s,C.Z.BLUE)),t++),3!==a&&7!==a||0!==this.splitPrivateChat||!(7===a||0===this.privateChatSetting||1===this.privateChatSetting&&this.isFriend(this.messageSender[i]))||(r>0&&r<110&&(e?.drawString(4,r,"From "+this.messageSender[i]+":",C.Z.BLACK),e?.drawString(e.stringWidth("From "+this.messageSender[i])+12,r,s,C.Z.DARKRED)),t++),4===a&&(0===this.tradeChatSetting||1===this.tradeChatSetting&&this.isFriend(this.messageSender[i]))&&(r>0&&r<110&&e?.drawString(4,r,this.messageSender[i]+" "+this.messageText[i],C.Z.TRADE_MESSAGE),t++),5===a&&0===this.splitPrivateChat&&this.privateChatSetting<2&&(r>0&&r<110&&e?.drawString(4,r,s,C.Z.DARKRED),t++),6===a&&0===this.splitPrivateChat&&this.privateChatSetting<2&&(r>0&&r<110&&(e?.drawString(4,r,"To "+this.messageSender[i]+":",C.Z.BLACK),e?.drawString(e.stringWidth("To "+this.messageSender[i])+12,r,s,C.Z.DARKRED)),t++),8===a&&(0===this.tradeChatSetting||1===this.tradeChatSetting&&this.isFriend(this.messageSender[i]))&&(r>0&&r<110&&e?.drawString(4,r,this.messageSender[i]+" "+this.messageText[i],C.Z.DUEL_MESSAGE),t++)}u.Z.resetBounds(),this.chatScrollHeight=14*t+7,this.chatScrollHeight<78&&(this.chatScrollHeight=78),this.drawScrollbar(463,0,this.chatScrollHeight-this.chatScrollOffset-77,this.chatScrollHeight,77),e?.drawString(4,90,_.Z.formatName(this.username)+":",C.Z.BLACK),e?.drawString(e.stringWidth(this.username+": ")+6,90,this.chatTyped+"*",C.Z.BLUE),u.Z.drawHorizontalLine(0,77,C.Z.BLACK,479)}else this.drawInterface(c.Z.instances[this.stickyChatInterfaceId],0,0,0);this.menuVisible&&2===this.menuArea&&this.drawMenu(),this.areaChatback?.draw(22,375),this.areaViewport?.bind(),this.areaViewportOffsets&&(f.Z.lineOffset=this.areaViewportOffsets)};drawMinimap=()=>{if(this.areaMapback?.bind(),!this.localPlayer)return;const e=this.orbitCameraYaw+this.minimapAnticheatAngle&2047;let t=48+(this.localPlayer.x/32|0),i=464-(this.localPlayer.z/32|0);this.imageMinimap?.drawRotatedMasked(21,9,146,151,this.minimapMaskLineOffsets,this.minimapMaskLineLengths,t,i,e,this.minimapZoom+256),this.imageCompass?.drawRotatedMasked(0,0,33,33,this.compassMaskLineOffsets,this.compassMaskLineLengths,25,25,this.orbitCameraYaw,256);for(let e=0;e{if(!t)return;const s=this.orbitCameraYaw+this.minimapAnticheatAngle&2047,a=i*i+e*e;if(a>6400)return;let r=f.Z.sin[s],n=f.Z.cos[s];r=256*r/(this.minimapZoom+256)|0,n=256*n/(this.minimapZoom+256)|0;const h=e*r+i*n>>16,o=e*n-i*r>>16;a>2500&&this.imageMapback?t.drawMasked(h+94-(t.cropW/2|0),83-o-(t.cropH/2|0),this.imageMapback):t.draw(h+94-(t.cropW/2|0),83-o-(t.cropH/2|0))};createMinimap=e=>{if(!this.imageMinimap)return;const t=this.imageMinimap.pixels,i=t.length;for(let e=0;e>14&32767;const s=a.Z.get(i).mapfunction;if(s<0)continue;let r=e,n=t;if(22!==s&&29!==s&&34!==s&&36!==s&&46!==s&&47!==s&&48!==s){const i=X.Z.SIZE,s=X.Z.SIZE,a=this.levelCollisionMap[this.currentLevel];if(a){const h=a.flags;for(let a=0;a<10;a++){const a=4*Math.random()|0;0===a&&r>0&&r>e-3&&(h[X.Z.index(r-1,n)]&F.Z.BLOCK_WEST)===F.Z.OPEN&&r--,1===a&&r0&&n>t-3&&(h[X.Z.index(r,n-1)]&F.Z.BLOCK_SOUTH)===F.Z.OPEN&&n--,3===a&&n{if(!this.scene||!this.imageMinimap)return;let n=this.scene.getWallBitset(i,e,t);if(0!==n){const h=this.scene.getInfo(i,e,t,n),o=h>>6&3,l=31&h;let c=s;n>0&&(c=r);const d=this.imageMinimap.pixels,u=4*e+512*(103-t)*4+24624,f=n>>14&32767,p=a.Z.get(f);if(-1===p.mapscene)l!==N.Z.WALL_STRAIGHT&&l!==N.Z.WALL_L||(o===B.Z.WEST?(d[u]=c,d[u+512]=c,d[u+1024]=c,d[u+1536]=c):o===B.Z.NORTH?(d[u]=c,d[u+1]=c,d[u+2]=c,d[u+3]=c):o===B.Z.EAST?(d[u+3]=c,d[u+3+512]=c,d[u+3+1024]=c,d[u+3+1536]=c):o===B.Z.SOUTH&&(d[u+1536]=c,d[u+1536+1]=c,d[u+1536+2]=c,d[u+1536+3]=c)),l===N.Z.WALL_SQUARE_CORNER&&(o===B.Z.WEST?d[u]=c:o===B.Z.NORTH?d[u+3]=c:o===B.Z.EAST?d[u+3+1536]=c:o===B.Z.SOUTH&&(d[u+1536]=c)),l===N.Z.WALL_L&&(o===B.Z.SOUTH?(d[u]=c,d[u+512]=c,d[u+1024]=c,d[u+1536]=c):o===B.Z.WEST?(d[u]=c,d[u+1]=c,d[u+2]=c,d[u+3]=c):o===B.Z.NORTH?(d[u+3]=c,d[u+3+512]=c,d[u+3+1024]=c,d[u+3+1536]=c):o===B.Z.EAST&&(d[u+1536]=c,d[u+1536+1]=c,d[u+1536+2]=c,d[u+1536+3]=c));else{const i=this.imageMapscene[p.mapscene];if(i){const s=(4*p.width-i.width)/2|0,a=(4*p.length-i.height)/2|0;i.draw(4*e+48+s,4*(X.Z.SIZE-t-p.length)+a+48)}}}if(n=this.scene.getLocBitset(i,e,t),0!==n){const s=this.scene.getInfo(i,e,t,n),r=s>>6&3,h=31&s,o=n>>14&32767,l=a.Z.get(o);if(-1!==l.mapscene){const i=this.imageMapscene[l.mapscene];if(i){const s=(4*l.width-i.width)/2|0,a=(4*l.length-i.height)/2|0;i.draw(4*e+48+s,4*(X.Z.SIZE-t-l.length)+a+48)}}else if(h===N.Z.WALL_DIAGONAL){let i=15658734;n>0&&(i=15597568);const s=this.imageMinimap.pixels,a=4*e+512*(X.Z.SIZE-1-t)*4+24624;r===B.Z.WEST||r===B.Z.EAST?(s[a+1536]=i,s[a+1024+1]=i,s[a+512+2]=i,s[a+3]=i):(s[a]=i,s[a+512+1]=i,s[a+1024+2]=i,s[a+1536+3]=i)}}if(n=this.scene.getGroundDecorationBitset(i,e,t),0!==n){const i=a.Z.get(n>>14&32767);if(-1!==i.mapscene){const s=this.imageMapscene[i.mapscene];if(s){const a=(4*i.width-s.width)/2|0,r=(4*i.length-s.height)/2|0;s.draw(4*e+48+a,4*(X.Z.SIZE-t-i.length)+r+48)}}}};drawTooltip=()=>{if(this.menuSize<2&&0===this.objSelected&&0===this.spellSelected)return;let e;e=1===this.objSelected&&this.menuSize<2?"Use "+this.objSelectedName+" with...":1===this.spellSelected&&this.menuSize<2?this.spellCaption+"...":this.menuOption[this.menuSize-1],this.menuSize>2&&(e=e+"@whi@ / "+(this.menuSize-2)+" more options"),this.fontBold12?.drawStringTooltip(4,15,e,C.Z.WHITE,!0,this.loopCycle/1e3|0)};drawMenu=()=>{const e=this.menuX,t=this.menuY,i=this.menuWidth,s=this.menuHeight,a=C.Z.OPTIONS_MENU;u.Z.fillRect(e,t,i,s,a),u.Z.fillRect(e+1,t+1,i-2,16,C.Z.BLACK),u.Z.drawRect(e+1,t+18,i-2,s-19,C.Z.BLACK),this.fontBold12?.drawString(e+3,t+14,"Choose Option",a);let r=this.mouseX,n=this.mouseY;0===this.menuArea&&(r-=8,n-=11),1===this.menuArea&&(r-=562,n-=231),2===this.menuArea&&(r-=22,n-=375);for(let s=0;se&&ra-13&&n{if(0!==this.objDragArea)return;let e=this.mouseClickButton;if(1===this.spellSelected&&this.mouseClickX>=520&&this.mouseClickY>=165&&this.mouseClickX<=788&&this.mouseClickY<=230&&(e=0),this.menuVisible){if(1!==e){let e=this.mouseX,t=this.mouseY;0===this.menuArea?(e-=8,t-=11):1===this.menuArea?(e-=562,t-=231):2===this.menuArea&&(e-=22,t-=375),(ethis.menuX+this.menuWidth+10||tthis.menuY+this.menuHeight+10)&&(this.menuVisible=!1,1===this.menuArea&&(this.redrawSidebar=!0),2===this.menuArea&&(this.redrawChatback=!0))}if(1===e){const e=this.menuX,t=this.menuY,i=this.menuWidth;let s=this.mouseClickX,a=this.mouseClickY;0===this.menuArea?(s-=8,a-=11):1===this.menuArea?(s-=562,a-=231):2===this.menuArea&&(s-=22,a-=375);let r=-1;for(let n=0;ne&&sh-13&&a0){const e=this.menuAction[this.menuSize-1];if(602===e||596===e||22===e||892===e||415===e||405===e||38===e||422===e||478===e||347===e||188===e){const e=this.menuParamB[this.menuSize-1],t=this.menuParamC[this.menuSize-1];if(c.Z.instances[t].draggable)return this.objGrabThreshold=!1,this.objDragCycles=0,this.objDragInterfaceId=t,this.objDragSlot=e,this.objDragArea=2,this.objGrabX=this.mouseClickX,this.objGrabY=this.mouseClickY,c.Z.instances[t].layer===this.viewportInterfaceId&&(this.objDragArea=1),void(c.Z.instances[t].layer===this.chatInterfaceId&&(this.objDragArea=3))}}if(1===e&&(1===this.mouseButtonsOption||this.isAddFriendOption(this.menuSize-1))&&this.menuSize>2&&(e=2),1===e&&this.menuSize>0&&await this.useMenuOption(this.menuSize-1),2!==e||this.menuSize<=0)return;this.showContextMenu()}};handleMinimapInput=()=>{if(1===this.mouseClickButton&&this.localPlayer){let e=this.mouseClickX-21-561,t=this.mouseClickY-9-5;if(e>=0&&t>=0&&e<146&&t<151){e-=73,t-=75;const i=this.orbitCameraYaw+this.minimapAnticheatAngle&2047;let s=f.Z.sin[i],a=f.Z.cos[i];s=s*(this.minimapZoom+256)>>8,a=a*(this.minimapZoom+256)>>8;const r=t*s+e*a>>11,n=t*a-e*s>>11,h=this.localPlayer.x+r>>7,o=this.localPlayer.z-n>>7;this.tryMove(this.localPlayer.pathTileX[0],this.localPlayer.pathTileZ[0],h,o,1,0,0,0,0,0,!0)&&(this.out.p1(e),this.out.p1(t),this.out.p2(this.orbitCameraYaw),this.out.p1(57),this.out.p1(this.minimapAnticheatAngle),this.out.p1(this.minimapZoom),this.out.p1(89),this.out.p2(this.localPlayer.x),this.out.p2(this.localPlayer.z),this.out.p1(this.tryMoveNearest),this.out.p1(63))}}};isAddFriendOption=e=>{if(e<0)return!1;let t=this.menuAction[e];return t>=2e3&&(t-=2e3),406===t};useMenuOption=async e=>{if(e<0)return;this.chatbackInputOpen&&(this.chatbackInputOpen=!1,this.redrawChatback=!0);let t=this.menuAction[e];const i=this.menuParamA[e],s=this.menuParamB[e],n=this.menuParamC[e];if(t>=2e3&&(t-=2e3),903===t||363===t){let i=this.menuOption[e];const s=i.indexOf("@whi@");if(-1!==s){i=i.substring(s+5).trim();const e=_.Z.formatName(_.Z.fromBase37(_.Z.toBase37(i)));let a=!1;for(let i=0;i=90&&this.out.p1isaac(I.Z.ANTICHEAT_OPLOGIC5),this.out.p1isaac(I.Z.OPHELD4)):347===t?this.out.p1isaac(I.Z.OPHELD5):422===t?this.out.p1isaac(I.Z.OPHELD3):405===t?(J.K.opHeld4Counter+=i,J.K.opHeld4Counter>=97&&(this.out.p1isaac(I.Z.ANTICHEAT_OPLOGIC3),this.out.p3(14953816)),this.out.p1isaac(I.Z.OPHELD1)):38===t&&this.out.p1isaac(I.Z.OPHELD2),this.out.p2(i),this.out.p2(s),this.out.p2(n),this.selectedCycle=0,this.selectedInterface=n,this.selectedItem=s,this.selectedArea=2,c.Z.instances[n].layer===this.viewportInterfaceId&&(this.selectedArea=1),c.Z.instances[n].layer===this.chatInterfaceId&&(this.selectedArea=3);else if(728===t||542===t||6===t||963===t||245===t){const e=this.npcs[i];e&&this.localPlayer&&(this.tryMove(this.localPlayer.pathTileX[0],this.localPlayer.pathTileZ[0],e.pathTileX[0],e.pathTileZ[0],2,1,1,0,0,0,!1),this.crossX=this.mouseClickX,this.crossY=this.mouseClickY,this.crossMode=2,this.crossCycle=0,542===t?this.out.p1isaac(I.Z.OPNPC2):6===t?(0==(3&i)&&J.K.opNpc3Counter++,J.K.opNpc3Counter>=124&&(this.out.p1isaac(I.Z.ANTICHEAT_OPLOGIC2),this.out.p4(0)),this.out.p1isaac(I.Z.OPNPC3)):963===t?this.out.p1isaac(I.Z.OPNPC4):728===t?this.out.p1isaac(I.Z.OPNPC1):245===t&&(0==(3&i)&&J.K.opNpc5Counter++,J.K.opNpc5Counter>=85&&(this.out.p1isaac(I.Z.ANTICHEAT_OPLOGIC4),this.out.p2(39596)),this.out.p1isaac(I.Z.OPNPC5)),this.out.p2(i))}else if(217===t)this.localPlayer&&(this.tryMove(this.localPlayer.pathTileX[0],this.localPlayer.pathTileZ[0],s,n,2,0,0,0,0,0,!1)||this.tryMove(this.localPlayer.pathTileX[0],this.localPlayer.pathTileZ[0],s,n,2,1,1,0,0,0,!1),this.crossX=this.mouseClickX,this.crossY=this.mouseClickY,this.crossMode=2,this.crossCycle=0,this.out.p1isaac(I.Z.OPOBJU),this.out.p2(s+this.sceneBaseTileX),this.out.p2(n+this.sceneBaseTileZ),this.out.p2(i),this.out.p2(this.objInterface),this.out.p2(this.objSelectedSlot),this.out.p2(this.objSelectedInterface));else if(1175===t){const e=i>>14&32767,t=a.Z.get(e);let s;s=t.desc?t.desc:"It's a "+t.name+".",this.addMessage(0,s,"")}else if(285===t)this.interactWithLoc(I.Z.OPLOC1,s,n,i);else if(881===t)this.out.p1isaac(I.Z.OPHELDU),this.out.p2(i),this.out.p2(s),this.out.p2(n),this.out.p2(this.objInterface),this.out.p2(this.objSelectedSlot),this.out.p2(this.objSelectedInterface),this.selectedCycle=0,this.selectedInterface=n,this.selectedItem=s,this.selectedArea=2,c.Z.instances[n].layer===this.viewportInterfaceId&&(this.selectedArea=1),c.Z.instances[n].layer===this.chatInterfaceId&&(this.selectedArea=3);else if(391===t)this.out.p1isaac(I.Z.OPHELDT),this.out.p2(i),this.out.p2(s),this.out.p2(n),this.out.p2(this.activeSpellId),this.selectedCycle=0,this.selectedInterface=n,this.selectedItem=s,this.selectedArea=2,c.Z.instances[n].layer===this.viewportInterfaceId&&(this.selectedArea=1),c.Z.instances[n].layer===this.chatInterfaceId&&(this.selectedArea=3);else if(660===t)this.menuVisible?this.scene?.click(s-8,n-11):this.scene?.click(this.mouseClickX-8,this.mouseClickY-11);else{if(188===t)return this.objSelected=1,this.objSelectedSlot=s,this.objSelectedInterface=n,this.objInterface=i,this.objSelectedName=r.Z.get(i).name,void(this.spellSelected=0);if(44===t)this.pressedContinueOption||(this.out.p1isaac(I.Z.RESUME_PAUSEBUTTON),this.out.p2(n),this.pressedContinueOption=!0);else if(1773===t){const e=r.Z.get(i);let t;t=n>=1e5?n+" x "+e.name:e.desc?e.desc:"It's a "+e.name+".",this.addMessage(0,t,"")}else if(900===t){const e=this.npcs[i];e&&this.localPlayer&&(this.tryMove(this.localPlayer.pathTileX[0],this.localPlayer.pathTileZ[0],e.pathTileX[0],e.pathTileZ[0],2,1,1,0,0,0,!1),this.crossX=this.mouseClickX,this.crossY=this.mouseClickY,this.crossMode=2,this.crossCycle=0,this.out.p1isaac(I.Z.OPNPCU),this.out.p2(i),this.out.p2(this.objInterface),this.out.p2(this.objSelectedSlot),this.out.p2(this.objSelectedInterface))}else if(1373===t||1544===t||151===t||1101===t){const e=this.players[i];e&&this.localPlayer&&(this.tryMove(this.localPlayer.pathTileX[0],this.localPlayer.pathTileZ[0],e.pathTileX[0],e.pathTileZ[0],2,1,1,0,0,0,!1),this.crossX=this.mouseClickX,this.crossY=this.mouseClickY,this.crossMode=2,this.crossCycle=0,1101===t?this.out.p1isaac(I.Z.OPPLAYER1):151===t?(J.K.opPlayer2Counter++,J.K.opPlayer2Counter>=90&&(this.out.p1isaac(I.Z.ANTICHEAT_OPLOGIC8),this.out.p2(31114)),this.out.p1isaac(I.Z.OPPLAYER2)):1373===t?this.out.p1isaac(I.Z.OPPLAYER4):1544===t&&this.out.p1isaac(I.Z.OPPLAYER3),this.out.p2(i))}else if(265===t){const e=this.npcs[i];e&&this.localPlayer&&(this.tryMove(this.localPlayer.pathTileX[0],this.localPlayer.pathTileZ[0],e.pathTileX[0],e.pathTileZ[0],2,1,1,0,0,0,!1),this.crossX=this.mouseClickX,this.crossY=this.mouseClickY,this.crossMode=2,this.crossCycle=0,this.out.p1isaac(I.Z.OPNPCT),this.out.p2(i),this.out.p2(this.activeSpellId))}else if(679===t){const t=this.menuOption[e],i=t.indexOf("@whi@");if(-1!==i){const e=_.Z.toBase37(t.substring(i+5).trim());let s=-1;for(let t=0;t0&&(this.redrawChatback=!0,this.chatbackInputOpen=!1,this.showSocialInput=!0,this.socialInput="",this.socialAction=3,this.socialName37=this.friendName37[s],this.socialMessage="Enter message to send to "+this.friendName[s])}}else if(55===t)this.interactWithLoc(I.Z.OPLOCT,s,n,i)&&this.out.p2(this.activeSpellId);else if(224===t||993===t||99===t||746===t||877===t)this.localPlayer&&(this.tryMove(this.localPlayer.pathTileX[0],this.localPlayer.pathTileZ[0],s,n,2,0,0,0,0,0,!1)||this.tryMove(this.localPlayer.pathTileX[0],this.localPlayer.pathTileZ[0],s,n,2,1,1,0,0,0,!1),this.crossX=this.mouseClickX,this.crossY=this.mouseClickY,this.crossMode=2,this.crossCycle=0,224===t?this.out.p1isaac(I.Z.OPOBJ1):746===t?this.out.p1isaac(I.Z.OPOBJ4):877===t?this.out.p1isaac(I.Z.OPOBJ5):99===t?this.out.p1isaac(I.Z.OPOBJ3):993===t&&this.out.p1isaac(I.Z.OPOBJ2),this.out.p2(s+this.sceneBaseTileX),this.out.p2(n+this.sceneBaseTileZ),this.out.p2(i));else if(1607===t){const e=this.npcs[i];if(e&&e.type){let t;t=e.type.desc?e.type.desc:"It's a "+e.type.name+".",this.addMessage(0,t,"")}}else if(504===t)this.interactWithLoc(I.Z.OPLOC2,s,n,i);else{if(930===t){const e=c.Z.instances[n];this.spellSelected=1,this.activeSpellId=n,this.activeSpellFlags=e.actionTarget,this.objSelected=0;let t=e.actionVerb;t&&-1!==t.indexOf(" ")&&(t=t.substring(0,t.indexOf(" ")));let i=e.actionVerb;return i&&-1!==i.indexOf(" ")&&(i=i.substring(i.indexOf(" ")+1)),this.spellCaption=t+" "+e.action+" "+i,void(16===this.activeSpellFlags&&(this.redrawSidebar=!0,this.selectedTab=3,this.redrawSideicons=!0))}if(951===t){const e=c.Z.instances[n];let t=!0;e.clientCode>0&&(t=this.handleInterfaceAction(e)),t&&(this.out.p1isaac(I.Z.IF_BUTTON),this.out.p2(n))}else if(602===t||596===t||22===t||892===t||415===t)22===t?this.out.p1isaac(I.Z.INV_BUTTON3):415===t?(0==(3&n)&&J.K.ifButton5Counter++,J.K.ifButton5Counter>=55&&(this.out.p1isaac(I.Z.ANTICHEAT_OPLOGIC7),this.out.p4(0)),this.out.p1isaac(I.Z.INV_BUTTON5)):602===t?this.out.p1isaac(I.Z.INV_BUTTON1):892===t?(0==(3&s)&&J.K.opHeld9Counter++,J.K.opHeld9Counter>=130&&(this.out.p1isaac(I.Z.ANTICHEAT_OPLOGIC9),this.out.p1(177)),this.out.p1isaac(I.Z.INV_BUTTON4)):596===t&&this.out.p1isaac(I.Z.INV_BUTTON2),this.out.p2(i),this.out.p2(s),this.out.p2(n),this.selectedCycle=0,this.selectedInterface=n,this.selectedItem=s,this.selectedArea=2,c.Z.instances[n].layer===this.viewportInterfaceId&&(this.selectedArea=1),c.Z.instances[n].layer===this.chatInterfaceId&&(this.selectedArea=3);else if(581===t)0==(3&i)&&J.K.opLoc4Counter++,J.K.opLoc4Counter>=99&&(this.out.p1isaac(I.Z.ANTICHEAT_OPLOGIC1),this.out.p4(0)),this.interactWithLoc(I.Z.OPLOC4,s,n,i);else if(965===t)this.localPlayer&&(this.tryMove(this.localPlayer.pathTileX[0],this.localPlayer.pathTileZ[0],s,n,2,0,0,0,0,0,!1)||this.tryMove(this.localPlayer.pathTileX[0],this.localPlayer.pathTileZ[0],s,n,2,1,1,0,0,0,!1),this.crossX=this.mouseClickX,this.crossY=this.mouseClickY,this.crossMode=2,this.crossCycle=0,this.out.p1isaac(I.Z.OPOBJT),this.out.p2(s+this.sceneBaseTileX),this.out.p2(n+this.sceneBaseTileZ),this.out.p2(i),this.out.p2(this.activeSpellId));else if(1501===t)J.K.opLoc5Counter+=this.sceneBaseTileZ,J.K.opLoc5Counter>=92&&(this.out.p1isaac(I.Z.ANTICHEAT_OPLOGIC6),this.out.p4(0)),this.interactWithLoc(I.Z.OPLOC5,s,n,i);else if(364===t)this.interactWithLoc(I.Z.OPLOC3,s,n,i);else if(1102===t){const e=r.Z.get(i);let t;t=e.desc?e.desc:"It's a "+e.name+".",this.addMessage(0,t,"")}else if(960===t){this.out.p1isaac(I.Z.IF_BUTTON),this.out.p2(n);const e=c.Z.instances[n];if(e.scripts&&e.scripts[0]&&5===e.scripts[0][0]){const t=e.scripts[0][1];e.scriptOperand&&this.varps[t]!==e.scriptOperand[0]&&(this.varps[t]=e.scriptOperand[0],await this.updateVarp(t),this.redrawSidebar=!0)}}else if(34===t){const t=this.menuOption[e],i=t.indexOf("@whi@");if(-1!==i){this.closeInterfaces(),this.reportAbuseInput=t.substring(i+5).trim(),this.reportAbuseMuteOption=!1;for(let e=0;e{const t=e.clientCode;if(t===c.Z.CC_ADD_FRIEND&&(this.redrawChatback=!0,this.chatbackInputOpen=!1,this.showSocialInput=!0,this.socialInput="",this.socialAction=1,this.socialMessage="Enter name of friend to add to list"),t===c.Z.CC_DEL_FRIEND&&(this.redrawChatback=!0,this.chatbackInputOpen=!1,this.showSocialInput=!0,this.socialInput="",this.socialAction=2,this.socialMessage="Enter name of friend to delete from list"),t===c.Z.CC_LOGOUT)return this.idleTimeout=250,!0;if(t===c.Z.CC_ADD_IGNORE&&(this.redrawChatback=!0,this.chatbackInputOpen=!1,this.showSocialInput=!0,this.socialInput="",this.socialAction=4,this.socialMessage="Enter name of player to add to list"),t===c.Z.CC_DEL_IGNORE&&(this.redrawChatback=!0,this.chatbackInputOpen=!1,this.showSocialInput=!0,this.socialInput="",this.socialAction=5,this.socialMessage="Enter name of player to delete from list"),t>=c.Z.CC_CHANGE_HEAD_L&&t<=c.Z.CC_CHANGE_FEET_R){const e=(t-300)/2|0,i=1&t;let s=this.designIdentikits[e];if(-1!==s)for(;;)if(0===i&&(s--,s<0&&(s=h.Z.count-1)),1===i&&(s++,s>=h.Z.count&&(s=0)),!h.Z.instances[s].disable&&h.Z.instances[s].type===e+(this.designGenderMale?0:7)){this.designIdentikits[e]=s,this.updateDesignModel=!0;break}}if(t>=c.Z.CC_RECOLOUR_HAIR_L&&t<=c.Z.CC_RECOLOUR_SKIN_R){const e=(t-314)/2|0,i=1&t;let s=this.designColors[e];0===i&&(s--,s<0&&(s=H.Z.DESIGN_BODY_COLOR[e].length-1)),1===i&&(s++,s>=H.Z.DESIGN_BODY_COLOR[e].length&&(s=0)),this.designColors[e]=s,this.updateDesignModel=!0}if(t!==c.Z.CC_SWITCH_TO_MALE||this.designGenderMale||(this.designGenderMale=!0,this.validateCharacterDesign()),t===c.Z.CC_SWITCH_TO_FEMALE&&this.designGenderMale&&(this.designGenderMale=!1,this.validateCharacterDesign()),t===c.Z.CC_ACCEPT_DESIGN){this.out.p1isaac(I.Z.IF_PLAYERDESIGN),this.out.p1(this.designGenderMale?0:1);for(let e=0;e<7;e++)this.out.p1(this.designIdentikits[e]);for(let e=0;e<5;e++)this.out.p1(this.designColors[e]);return!0}return t===c.Z.CC_MOD_MUTE&&(this.reportAbuseMuteOption=!this.reportAbuseMuteOption),t>=c.Z.CC_REPORT_RULE1&&t<=c.Z.CC_REPORT_RULE12&&(this.closeInterfaces(),this.reportAbuseInput.length>0&&(this.out.p1isaac(I.Z.BUG_REPORT),this.out.p8(_.Z.toBase37(this.reportAbuseInput)),this.out.p1(t-601),this.out.p1(this.reportAbuseMuteOption?1:0))),!1};validateCharacterDesign=()=>{this.updateDesignModel=!0;for(let e=0;e<7;e++){this.designIdentikits[e]=-1;for(let t=0;t{if(!this.localPlayer||!this.scene)return!1;const r=s>>14&32767,n=this.scene.getInfo(this.currentLevel,t,i,s);if(-1===n)return!1;const h=31&n,o=n>>6&3;if(h===N.Z.CENTREPIECE_STRAIGHT||h===N.Z.CENTREPIECE_DIAGONAL||h===N.Z.GROUND_DECOR){const e=a.Z.get(r);let s,n;o===B.Z.WEST||o===B.Z.EAST?(s=e.width,n=e.length):(s=e.length,n=e.width);let h=e.forceapproach;0!==o&&(h=(h<>4-o)),this.tryMove(this.localPlayer.pathTileX[0],this.localPlayer.pathTileZ[0],t,i,2,s,n,0,0,h,!1)}else this.tryMove(this.localPlayer.pathTileX[0],this.localPlayer.pathTileZ[0],t,i,2,0,0,o,h+1,0,!1);return this.crossX=this.mouseClickX,this.crossY=this.mouseClickY,this.crossMode=2,this.crossCycle=0,this.out.p1isaac(e),this.out.p2(t+this.sceneBaseTileX),this.out.p2(i+this.sceneBaseTileZ),this.out.p2(r),!0};handleTabInput=()=>{1===this.mouseClickButton&&(this.mouseClickX>=549&&this.mouseClickX<=583&&this.mouseClickY>=195&&this.mouseClickY<231&&-1!==this.tabInterfaceId[0]?(this.redrawSidebar=!0,this.selectedTab=0,this.redrawSideicons=!0):this.mouseClickX>=579&&this.mouseClickX<=609&&this.mouseClickY>=194&&this.mouseClickY<231&&-1!==this.tabInterfaceId[1]?(this.redrawSidebar=!0,this.selectedTab=1,this.redrawSideicons=!0):this.mouseClickX>=607&&this.mouseClickX<=637&&this.mouseClickY>=194&&this.mouseClickY<231&&-1!==this.tabInterfaceId[2]?(this.redrawSidebar=!0,this.selectedTab=2,this.redrawSideicons=!0):this.mouseClickX>=635&&this.mouseClickX<=679&&this.mouseClickY>=194&&this.mouseClickY<229&&-1!==this.tabInterfaceId[3]?(this.redrawSidebar=!0,this.selectedTab=3,this.redrawSideicons=!0):this.mouseClickX>=676&&this.mouseClickX<=706&&this.mouseClickY>=194&&this.mouseClickY<231&&-1!==this.tabInterfaceId[4]?(this.redrawSidebar=!0,this.selectedTab=4,this.redrawSideicons=!0):this.mouseClickX>=704&&this.mouseClickX<=734&&this.mouseClickY>=194&&this.mouseClickY<231&&-1!==this.tabInterfaceId[5]?(this.redrawSidebar=!0,this.selectedTab=5,this.redrawSideicons=!0):this.mouseClickX>=732&&this.mouseClickX<=766&&this.mouseClickY>=195&&this.mouseClickY<231&&-1!==this.tabInterfaceId[6]?(this.redrawSidebar=!0,this.selectedTab=6,this.redrawSideicons=!0):this.mouseClickX>=550&&this.mouseClickX<=584&&this.mouseClickY>=492&&this.mouseClickY<528&&-1!==this.tabInterfaceId[7]?(this.redrawSidebar=!0,this.selectedTab=7,this.redrawSideicons=!0):this.mouseClickX>=582&&this.mouseClickX<=612&&this.mouseClickY>=492&&this.mouseClickY<529&&-1!==this.tabInterfaceId[8]?(this.redrawSidebar=!0,this.selectedTab=8,this.redrawSideicons=!0):this.mouseClickX>=609&&this.mouseClickX<=639&&this.mouseClickY>=492&&this.mouseClickY<529&&-1!==this.tabInterfaceId[9]?(this.redrawSidebar=!0,this.selectedTab=9,this.redrawSideicons=!0):this.mouseClickX>=637&&this.mouseClickX<=681&&this.mouseClickY>=493&&this.mouseClickY<528&&-1!==this.tabInterfaceId[10]?(this.redrawSidebar=!0,this.selectedTab=10,this.redrawSideicons=!0):this.mouseClickX>=679&&this.mouseClickX<=709&&this.mouseClickY>=492&&this.mouseClickY<529&&-1!==this.tabInterfaceId[11]?(this.redrawSidebar=!0,this.selectedTab=11,this.redrawSideicons=!0):this.mouseClickX>=706&&this.mouseClickX<=736&&this.mouseClickY>=492&&this.mouseClickY<529&&-1!==this.tabInterfaceId[12]?(this.redrawSidebar=!0,this.selectedTab=12,this.redrawSideicons=!0):this.mouseClickX>=734&&this.mouseClickX<=768&&this.mouseClickY>=492&&this.mouseClickY<528&&-1!==this.tabInterfaceId[13]&&(this.redrawSidebar=!0,this.selectedTab=13,this.redrawSideicons=!0),J.K.sidebarInputCounter++,J.K.sidebarInputCounter>150&&(J.K.sidebarInputCounter=0,this.out.p1isaac(I.Z.ANTICHEAT_CYCLELOGIC1),this.out.p1(43)))};handleInputKey=async()=>{for(;;){let e;do{for(;;){if(e=this.pollKey(),-1===e)return;if(-1!==this.viewportInterfaceId&&this.viewportInterfaceId===this.reportAbuseInterfaceID){8===e&&this.reportAbuseInput.length>0&&(this.reportAbuseInput=this.reportAbuseInput.substring(0,this.reportAbuseInput.length-1));break}if(this.showSocialInput){if(e>=32&&e<=122&&this.socialInput.length<80&&(this.socialInput=this.socialInput+String.fromCharCode(e),this.redrawChatback=!0),8===e&&this.socialInput.length>0&&(this.socialInput=this.socialInput.substring(0,this.socialInput.length-1),this.redrawChatback=!0),13===e||10===e){let e;if(this.showSocialInput=!1,this.redrawChatback=!0,1===this.socialAction&&(e=_.Z.toBase37(this.socialInput),this.addFriend(e)),2===this.socialAction&&this.friendCount>0&&(e=_.Z.toBase37(this.socialInput),this.removeFriend(e)),3===this.socialAction&&this.socialInput.length>0&&this.socialName37){this.out.p1isaac(I.Z.MESSAGE_PRIVATE),this.out.p1(0);const e=this.out.pos;this.out.p8(this.socialName37),b.Z.pack(this.out,this.socialInput),this.out.psize1(this.out.pos-e),this.socialInput=_.Z.toSentenceCase(this.socialInput),this.socialInput=O.Z.filter(this.socialInput),this.addMessage(6,this.socialInput,_.Z.formatName(_.Z.fromBase37(this.socialName37))),2===this.privateChatSetting&&(this.privateChatSetting=1,this.redrawPrivacySettings=!0,this.out.p1isaac(I.Z.CHAT_SETMODE),this.out.p1(this.publicChatSetting),this.out.p1(this.privateChatSetting),this.out.p1(this.tradeChatSetting))}4===this.socialAction&&this.ignoreCount<100&&(e=_.Z.toBase37(this.socialInput),this.addIgnore(e)),5===this.socialAction&&this.ignoreCount>0&&(e=_.Z.toBase37(this.socialInput),this.removeIgnore(e))}}else if(this.chatbackInputOpen){if(e>=48&&e<=57&&this.chatbackInput.length<10&&(this.chatbackInput=this.chatbackInput+String.fromCharCode(e),this.redrawChatback=!0),8===e&&this.chatbackInput.length>0&&(this.chatbackInput=this.chatbackInput.substring(0,this.chatbackInput.length-1),this.redrawChatback=!0),13===e||10===e){if(this.chatbackInput.length>0){let e=0;try{e=parseInt(this.chatbackInput,10)}catch(e){}this.out.p1isaac(I.Z.RESUME_P_COUNTDIALOG),this.out.p4(e)}this.chatbackInputOpen=!1,this.redrawChatback=!0}}else if(-1===this.chatInterfaceId&&(e>=32&&e<=122&&this.chatTyped.length<80&&(this.chatTyped=this.chatTyped+String.fromCharCode(e),this.redrawChatback=!0),8===e&&this.chatTyped.length>0&&(this.chatTyped=this.chatTyped.substring(0,this.chatTyped.length-1),this.redrawChatback=!0),(13===e||10===e)&&this.chatTyped.length>0)){if("::clientdrop"===this.chatTyped)await this.tryReconnect();else if("::noclip"===this.chatTyped)for(let e=0;e122)&&(e<65||e>90)&&(e<48||e>57)&&32!==e);this.reportAbuseInput.length<12&&(this.reportAbuseInput=this.reportAbuseInput+String.fromCharCode(e))}};handleChatSettingsInput=()=>{if(1===this.mouseClickButton)if(this.mouseClickX>=8&&this.mouseClickX<=108&&this.mouseClickY>=490&&this.mouseClickY<=522)this.publicChatSetting=(this.publicChatSetting+1)%4,this.redrawPrivacySettings=!0,this.redrawChatback=!0,this.out.p1isaac(I.Z.CHAT_SETMODE),this.out.p1(this.publicChatSetting),this.out.p1(this.privateChatSetting),this.out.p1(this.tradeChatSetting);else if(this.mouseClickX>=137&&this.mouseClickX<=237&&this.mouseClickY>=490&&this.mouseClickY<=522)this.privateChatSetting=(this.privateChatSetting+1)%3,this.redrawPrivacySettings=!0,this.redrawChatback=!0,this.out.p1isaac(I.Z.CHAT_SETMODE),this.out.p1(this.publicChatSetting),this.out.p1(this.privateChatSetting),this.out.p1(this.tradeChatSetting);else if(this.mouseClickX>=275&&this.mouseClickX<=375&&this.mouseClickY>=490&&this.mouseClickY<=522)this.tradeChatSetting=(this.tradeChatSetting+1)%3,this.redrawPrivacySettings=!0,this.redrawChatback=!0,this.out.p1isaac(I.Z.CHAT_SETMODE),this.out.p1(this.publicChatSetting),this.out.p1(this.privateChatSetting),this.out.p1(this.tradeChatSetting);else if(this.mouseClickX>=416&&this.mouseClickX<=516&&this.mouseClickY>=490&&this.mouseClickY<=522){this.closeInterfaces(),this.reportAbuseInput="",this.reportAbuseMuteOption=!1;for(let e=0;e{if(this.scrollGrabbed?this.scrollInputPadding=32:this.scrollInputPadding=0,this.scrollGrabbed=!1,e>=r&&e=n&&t=r&&e=n+s-16&&t=r-this.scrollInputPadding&&e=n+16&&t0){let e=(s-32)*s/i|0;e<8&&(e=8);const r=t-n-(e/2|0)-16,o=s-e-32;h.scrollPosition=(i-s)*r/o|0,a&&(this.redrawSidebar=!0),this.scrollGrabbed=!0}};prepareGameScreen=()=>{this.areaChatback||(this.unloadTitle(),this.drawArea=null,this.imageTitle2=null,this.imageTitle3=null,this.imageTitle4=null,this.imageTitle0=null,this.imageTitle1=null,this.imageTitle5=null,this.imageTitle6=null,this.imageTitle7=null,this.imageTitle8=null,this.areaChatback=new d.Z(479,96),this.areaMapback=new d.Z(168,160),u.Z.clear(),this.imageMapback?.draw(0,0),this.areaSidebar=new d.Z(190,261),this.areaViewport=new d.Z(512,334),u.Z.clear(),this.areaBackbase1=new d.Z(501,61),this.areaBackbase2=new d.Z(288,40),this.areaBackhmid1=new d.Z(269,66),this.redrawTitleBackground=!0)};isFriend=e=>{if(!e)return!1;for(let t=0;t{if(0n===e)return;if(this.friendCount>=100)return void this.addMessage(0,"Your friends list is full. Max of 100 hit","");const t=_.Z.formatName(_.Z.fromBase37(e));for(let i=0;i{if(0n!==e)for(let t=0;t{if(0n===e)return;if(this.ignoreCount>=100)return void this.addMessage(0,"Your ignore list is full. Max of 100 hit","");const t=_.Z.formatName(_.Z.fromBase37(e));for(let i=0;i{if(0n!==e)for(let t=0;t{const i=this.levelObjStacks[this.currentLevel][e][t];if(!i)return void this.scene?.removeObjStack(this.currentLevel,e,t);let s=-99999999,a=null;for(let e=i.peekFront();e;e=i.prev()){const t=r.Z.get(e.index);let i=t.cost;t.stackable&&(i*=e.count+1),i>s&&(s=i,a=e)}if(!a)return;i.pushFront(a);let n=-1,h=-1,o=0,l=0;for(let e=i.peekFront();e;e=i.prev())e.index!==a.index&&-1===n&&(n=e.index,o=e.count),e.index!==a.index&&e.index!==n&&-1===h&&(h=e.index,l=e.count);let c=null;-1!==n&&(c=r.Z.get(n).getInterfaceModel(o));let d=null;-1!==h&&(d=r.Z.get(h).getInterfaceModel(l));const u=e+(t<<7)+1610612736|0,f=r.Z.get(a.index);this.scene?.addObjStack(e,t,this.getHeightmapY(this.currentLevel,128*e+64,128*t+64),this.currentLevel,u,f.getInterfaceModel(a.count),d,c)};addLoc=(e,t,i,s,r,n,h)=>{if(t<1||i<1||t>102||i>102)return;if(J.K.lowMemory&&e!==this.currentLevel)return;if(!this.scene)return;let o=0;if(h===M.Z.WALL&&(o=this.scene.getWallBitset(e,t,i)),h===M.Z.WALL_DECOR&&(o=this.scene.getWallDecorationBitset(e,i,t)),h===M.Z.GROUND&&(o=this.scene.getLocBitset(e,t,i)),h===M.Z.GROUND_DECOR&&(o=this.scene.getGroundDecorationBitset(e,t,i)),0!==o){const s=this.scene.getInfo(e,t,i,o),r=o>>14&32767,n=31&s,l=s>>6;if(h===M.Z.WALL){this.scene?.removeWall(e,t,i,1);const s=a.Z.get(r);s.blockwalk&&this.levelCollisionMap[e]?.removeWall(t,i,n,l,s.blockrange)}if(h===M.Z.WALL_DECOR&&this.scene?.removeWallDecoration(e,t,i),h===M.Z.GROUND){this.scene.removeLoc(e,t,i);const s=a.Z.get(r);if(t+s.width>X.Z.SIZE-1||i+s.width>X.Z.SIZE-1||t+s.length>X.Z.SIZE-1||i+s.length>X.Z.SIZE-1)return;s.blockwalk&&this.levelCollisionMap[e]?.removeLoc(t,i,s.width,s.length,l,s.blockrange)}if(h===M.Z.GROUND_DECOR){this.scene?.removeGroundDecoration(e,t,i);const s=a.Z.get(r);s.blockwalk&&s.active&&this.levelCollisionMap[e]?.removeFloor(t,i)}}if(s>=0){let a=e;this.levelTileFlags&&e<3&&2==(2&this.levelTileFlags[1][t][i])&&(a=e+1),P.Z.addLoc(e,t,i,this.scene,this.levelHeightmap,this.locList,this.levelCollisionMap[e],s,n,r,a)}};closeInterfaces=()=>{this.out.p1isaac(I.Z.CLOSE_MODAL),-1!==this.sidebarInterfaceId&&(this.sidebarInterfaceId=-1,this.redrawSidebar=!0,this.pressedContinueOption=!1,this.redrawSideicons=!0),-1!==this.chatInterfaceId&&(this.chatInterfaceId=-1,this.redrawChatback=!0,this.pressedContinueOption=!1),this.viewportInterfaceId=-1};tryReconnect=async()=>{if(this.idleTimeout>0)await this.logout();else{this.areaViewport?.bind(),this.fontPlain12?.drawStringCenter(257,144,"Connection lost",C.Z.BLACK),this.fontPlain12?.drawStringCenter(256,143,"Connection lost",C.Z.WHITE),this.fontPlain12?.drawStringCenter(257,159,"Please wait - attempting to reestablish",C.Z.BLACK),this.fontPlain12?.drawStringCenter(256,158,"Please wait - attempting to reestablish",C.Z.WHITE),this.areaViewport?.draw(8,11),this.flagSceneTileX=0;const e=this.stream;this.ingame=!1,await this.login(this.username,this.password,!0),this.ingame||await this.logout(),e?.close()}};logout=async()=>{this.stream&&this.stream.close(),this.stream=null,this.ingame=!1,this.titleScreenState=0,this.username="",this.password="",k.Z.setDisabled(),this.clearCaches(),this.scene?.reset();for(let e=0;e{if(!this.stream)return!1;try{let e=this.stream.available;if(0===e)return!1;if(-1===this.packetType&&(await this.stream.readBytes(this.in.data,0,1),this.packetType=255&this.in.data[0],this.randomIn&&(this.packetType=this.packetType-this.randomIn.nextInt&255),this.packetSize=S.Z.SERVERPROT_SIZES[this.packetType],e--),-1===this.packetSize){if(e<=0)return!1;await this.stream.readBytes(this.in.data,0,1),this.packetSize=255&this.in.data[0],e--}if(-2===this.packetSize){if(e<=1)return!1;await this.stream.readBytes(this.in.data,0,2),this.in.pos=0,this.packetSize=this.in.g2,e-=2}if(e0&&this.addMessage(5,i+" has logged in.",""),0===t&&this.addMessage(5,i+" has logged out.","")),i=null;break}i&&this.friendCount<100&&(this.friendName37[this.friendCount]=e,this.friendName[this.friendCount]=i,this.friendWorld[this.friendCount]=t,this.friendCount++,this.redrawSidebar=!0);let s=!1;for(;!s;){s=!0;for(let e=0;e=0&&s>=0&&i=X.Z.SIZE||e.z>=X.Z.SIZE)&&e.unlink();return 0!==this.flagSceneTileX&&(this.flagSceneTileX-=a,this.flagSceneTileZ-=r),this.cutscene=!1,this.packetType=-1,!0}if(this.packetType===v.Z.IF_SETPLAYERHEAD)return c.Z.instances[this.in.g2].model=this.localPlayer?.getHeadModel()||null,this.packetType=-1,!0;if(this.packetType===v.Z.HINT_ARROW)return this.hintType=this.in.g1,1===this.hintType&&(this.hintNpc=this.in.g2),this.hintType>=2&&this.hintType<=6&&(2===this.hintType&&(this.hintOffsetX=64,this.hintOffsetZ=64),3===this.hintType&&(this.hintOffsetX=0,this.hintOffsetZ=64),4===this.hintType&&(this.hintOffsetX=128,this.hintOffsetZ=64),5===this.hintType&&(this.hintOffsetX=64,this.hintOffsetZ=0),6===this.hintType&&(this.hintOffsetX=64,this.hintOffsetZ=128),this.hintType=2,this.hintTileX=this.in.g2,this.hintTileZ=this.in.g2,this.hintHeight=this.in.g1),10===this.hintType&&(this.hintPlayer=this.in.g2),this.packetType=-1,!0;if(this.packetType===v.Z.MIDI_SONG){const e=this.in.gjstr,t=this.in.g4,i=this.in.g4;return e!==this.currentMidi&&this.midiActive&&!J.K.lowMemory&&await this.setMidi(e,t,i),this.currentMidi=e,this.midiCrc=t,this.midiSize=i,this.nextMusicDelay=0,this.packetType=-1,!0}if(this.packetType===v.Z.LOGOUT)return await this.logout(),this.packetType=-1,!1;if(this.packetType===v.Z.DATA_LOC_DONE){const e=this.in.g1,t=this.in.g1;let i=-1;if(this.sceneMapIndex)for(let s=0;s=100&&(this.cameraX=128*this.cutsceneSrcLocalTileX+64,this.cameraZ=128*this.cutsceneSrcLocalTileZ+64,this.cameraY=this.getHeightmapY(this.currentLevel,this.cutsceneSrcLocalTileX,this.cutsceneSrcLocalTileZ)-this.cutsceneSrcHeight),this.packetType=-1,!0;if(this.packetType===v.Z.UPDATE_ZONE_FULL_FOLLOWS){this.baseX=this.in.g1,this.baseZ=this.in.g1;for(let e=this.baseX;e=this.baseX&&e.x=this.baseZ&&e.z1?this.addMessage(7,a,_.Z.formatName(_.Z.fromBase37(e))):this.addMessage(3,a,_.Z.formatName(_.Z.fromBase37(e)))}catch(e){}return this.packetType=-1,!0}if(this.packetType===v.Z.RESET_CLIENT_VARCACHE){for(let e=0;e=100){const e=128*this.cutsceneDstLocalTileX+64,t=128*this.cutsceneDstLocalTileZ+64,i=this.getHeightmapY(this.currentLevel,this.cutsceneDstLocalTileX,this.cutsceneDstLocalTileZ)-this.cutsceneDstHeight,s=e-this.cameraX,a=i-this.cameraY,r=t-this.cameraZ,n=0|Math.sqrt(s*s+r*r);this.cameraPitch=2047&(325.949*Math.atan2(a,n)|0),this.cameraYaw=2047&(-325.949*Math.atan2(s,r)|0),this.cameraPitch<128&&(this.cameraPitch=128),this.cameraPitch>383&&(this.cameraPitch=383)}return this.packetType=-1,!0}if(this.packetType===v.Z.IF_SHOWSIDE)return this.selectedTab=this.in.g1,this.redrawSidebar=!0,this.redrawSideicons=!0,this.packetType=-1,!0;if(this.packetType===v.Z.MESSAGE_GAME){const e=this.in.gjstr;let t;if(e.endsWith(":tradereq:")){const i=e.substring(0,e.indexOf(":"));t=_.Z.toBase37(i);let s=!1;for(let e=0;e>10&31,s=t>>5&31,a=31&t;return c.Z.instances[e].colour=(i<<19)+(s<<11)+(a<<3),this.packetType=-1,!0}if(this.packetType===v.Z.RESET_ANIMS){for(let e=0;e=this.levelExperience[i]&&(this.skillBaseLevel[e]=i+2);return this.packetType=-1,!0}if(this.packetType===v.Z.UPDATE_ZONE_PARTIAL_ENCLOSED){for(this.baseX=this.in.g1,this.baseZ=this.in.g1;this.in.pos=0&&e{try{this.minimapLevel=-1,this.temporaryLocs.clear(),this.locList.clear(),this.spotanims.clear(),this.projectiles.clear(),f.Z.clearTexels(),this.clearCaches(),this.scene?.reset();for(let e=0;e>8,i=255&this.sceneMapIndex[e];if(33===t&&i>=71&&i<=73){P.Z.lowMemory=!1;break}}if(J.K.lowMemory?this.scene?.setMinLevel(this.currentLevel):this.scene?.setMinLevel(0),this.sceneMapIndex&&this.sceneMapLandData){this.out.p1isaac(I.Z.NO_TIMEOUT);for(let i=0;i>8)-this.sceneBaseTileX,s=64*(255&this.sceneMapIndex[i])-this.sceneBaseTileZ,a=this.sceneMapLandData[i];if(a){const i=new w.Z(new Uint8Array(a)).g4,r=E.Z.read(i,a,a.length-4,4);e.readLandscape(8*(this.sceneCenterZoneX-6),8*(this.sceneCenterZoneZ-6),t,s,r)}else this.sceneCenterZoneZ<800&&e.clearLandscape(s,t,64,64)}}if(this.sceneMapIndex&&this.sceneMapLocData){this.out.p1isaac(I.Z.NO_TIMEOUT);for(let i=0;i>8)-this.sceneBaseTileX,n=64*(255&this.sceneMapIndex[i])-this.sceneBaseTileZ;e.readLocs(this.scene,this.locList,this.levelCollisionMap,a,r,n)}}}this.out.p1isaac(I.Z.NO_TIMEOUT),e.build(this.scene,this.levelCollisionMap),this.areaViewport?.bind(),this.out.p1isaac(I.Z.NO_TIMEOUT);for(let e=this.locList.peekFront();e;e=this.locList.prev())2===(this.levelTileFlags&&2&this.levelTileFlags[1][e.heightmapNE][e.heightmapNW])&&(e.heightmapSW--,e.heightmapSW<0&&e.unlink());for(let e=0;e{const t=c.Z.instances[e];if(t.childId)for(let e=0;e{let e=0;for(let t=0;t<99;t++){const i=t+1;e+=i+300*Math.pow(2,i/7)|0,this.levelExperience[t]=e/4|0}};addMessage=(e,t,i)=>{0===e&&-1!==this.stickyChatInterfaceId&&(this.modalMessage=t,this.mouseClickButton=0),-1===this.chatInterfaceId&&(this.redrawChatback=!0);for(let e=99;e>0;e--)this.messageType[e]=this.messageType[e-1],this.messageSender[e]=this.messageSender[e-1],this.messageText[e]=this.messageText[e-1];this.messageType[0]=e,this.messageSender[0]=i,this.messageText[0]=t};updateVarp=async e=>{const t=l.Z.instances[e].clientcode;if(0!==t){const i=this.varps[e];if(1===t&&(1===i&&f.Z.setBrightness(.9),2===i&&f.Z.setBrightness(.8),3===i&&f.Z.setBrightness(.7),4===i&&f.Z.setBrightness(.6),r.Z.iconCache?.clear(),this.redrawTitleBackground=!0),3===t){const e=this.midiActive;0===i&&(this.midiVolume=256,(0,j.nu)(256),this.midiActive=!0),1===i&&(this.midiVolume=192,(0,j.nu)(192),this.midiActive=!0),2===i&&(this.midiVolume=128,(0,j.nu)(128),this.midiActive=!0),3===i&&(this.midiVolume=64,(0,j.nu)(64),this.midiActive=!0),4===i&&(this.midiActive=!1),this.midiActive!==e&&(this.midiActive&&this.currentMidi?await this.setMidi(this.currentMidi,this.midiCrc,this.midiSize):(0,j.tb)(),this.nextMusicDelay=0)}4===t&&(0===i&&(this.waveVolume=256,(0,j.mQ)(256),this.waveEnabled=!0),1===i&&(this.waveVolume=192,(0,j.mQ)(192),this.waveEnabled=!0),2===i&&(this.waveVolume=128,(0,j.mQ)(128),this.waveEnabled=!0),3===i&&(this.waveVolume=64,(0,j.mQ)(64),this.waveEnabled=!0),4===i&&(this.waveEnabled=!1)),5===t&&(this.mouseButtonsOption=i),6===t&&(this.chatEffects=i),8===t&&(this.splitPrivateChat=i,this.redrawChatback=!0)}};handleChatMouseInput=(e,t)=>{let i=0;for(let e=0;e<100;e++){if(!this.messageText[e])continue;const s=this.messageType[e],a=this.chatScrollOffset+70+4-14*i;if(a<-20)break;0===s&&i++,1!==s&&2!==s||!(1===s||0===this.publicChatSetting||1===this.publicChatSetting&&this.isFriend(this.messageSender[e]))||(t>a-14&&t<=a&&this.localPlayer&&this.messageSender[e]!==this.localPlayer.name&&(this.rights&&(this.menuOption[this.menuSize]="Report abuse @whi@"+this.messageSender[e],this.menuAction[this.menuSize]=34,this.menuSize++),this.menuOption[this.menuSize]="Add ignore @whi@"+this.messageSender[e],this.menuAction[this.menuSize]=436,this.menuSize++,this.menuOption[this.menuSize]="Add friend @whi@"+this.messageSender[e],this.menuAction[this.menuSize]=406,this.menuSize++),i++),3!==s&&7!==s||0!==this.splitPrivateChat||!(7===s||0===this.privateChatSetting||1===this.privateChatSetting&&this.isFriend(this.messageSender[e]))||(t>a-14&&t<=a&&(this.rights&&(this.menuOption[this.menuSize]="Report abuse @whi@"+this.messageSender[e],this.menuAction[this.menuSize]=34,this.menuSize++),this.menuOption[this.menuSize]="Add ignore @whi@"+this.messageSender[e],this.menuAction[this.menuSize]=436,this.menuSize++,this.menuOption[this.menuSize]="Add friend @whi@"+this.messageSender[e],this.menuAction[this.menuSize]=406,this.menuSize++),i++),4===s&&(0===this.tradeChatSetting||1===this.tradeChatSetting&&this.isFriend(this.messageSender[e]))&&(t>a-14&&t<=a&&(this.menuOption[this.menuSize]="Accept trade @whi@"+this.messageSender[e],this.menuAction[this.menuSize]=903,this.menuSize++),i++),(5===s||6===s)&&0===this.splitPrivateChat&&this.privateChatSetting<2&&i++,8===s&&(0===this.tradeChatSetting||1===this.tradeChatSetting&&this.isFriend(this.messageSender[e]))&&(t>a-14&&t<=a&&(this.menuOption[this.menuSize]="Accept duel @whi@"+this.messageSender[e],this.menuAction[this.menuSize]=363,this.menuSize++),i++)}};handlePrivateChatInput=e=>{if(0==this.splitPrivateChat)return;let t=0;0!=this.systemUpdateTimer&&(t=1);for(let i=0;i<100;i++)if(null!=this.messageText[i]){const s=this.messageType[i];if((3==s||7==s)&&(7==s||0==this.privateChatSetting||1==this.privateChatSetting&&this.isFriend(this.messageSender[i]))){const s=329-13*t;if(this.mouseX>8&&this.mouseX<520&&e-11>s-10&&e-11<=s+3&&(this.rights&&(this.menuOption[this.menuSize]="Report abuse @whi@"+this.messageSender[i],this.menuAction[this.menuSize]=2034,this.menuSize++),this.menuOption[this.menuSize]="Add ignore @whi@"+this.messageSender[i],this.menuAction[this.menuSize]=2436,this.menuSize++,this.menuOption[this.menuSize]="Add friend @whi@"+this.messageSender[i],this.menuAction[this.menuSize]=2406,this.menuSize++),t++,t>=5)return}if((5==s||6==s)&&this.privateChatSetting<2&&(t++,t>=5))return}};handleInterfaceInput=(e,t,i,s,a,n)=>{if(0!==e.type||!e.childId||e.hide||ts+e.width||i>a+e.height||!e.childX||!e.childY)return;const h=e.childId.length;for(let o=0;o=0||0!==d.overColour)&&t>=h&&i>=l&&t=0?this.lastHoveredInterfaceId=d.overLayer:this.lastHoveredInterfaceId=d.id),0===d.type)this.handleInterfaceInput(d,t,i,h,l,d.scrollPosition),d.scroll>d.height&&this.handleScrollInput(t,i,d.scroll,d.height,!0,h+d.width,l,d);else if(2===d.type){let e=0;for(let s=0;s=n+32||i>=o+32){e++;continue}if(this.hoveredSlot=e,this.hoveredSlotParentId=d.id,!d.invSlotObjId||d.invSlotObjId[e]<=0){e++;continue}const c=r.Z.get(d.invSlotObjId[e]-1);if(1===this.objSelected&&d.interactable)d.id===this.objSelectedInterface&&e===this.objSelectedSlot||(this.menuOption[this.menuSize]="Use "+this.objSelectedName+" with @lre@"+c.name,this.menuAction[this.menuSize]=881,this.menuParamA[this.menuSize]=c.index,this.menuParamB[this.menuSize]=e,this.menuParamC[this.menuSize]=d.id,this.menuSize++);else if(1===this.spellSelected&&d.interactable)16==(16&this.activeSpellFlags)&&(this.menuOption[this.menuSize]=this.spellCaption+" @lre@"+c.name,this.menuAction[this.menuSize]=391,this.menuParamA[this.menuSize]=c.index,this.menuParamB[this.menuSize]=e,this.menuParamC[this.menuSize]=d.id,this.menuSize++);else{if(d.interactable)for(let t=4;t>=3;t--)c.iops&&c.iops[t]?(this.menuOption[this.menuSize]=c.iops[t]+" @lre@"+c.name,3===t?this.menuAction[this.menuSize]=478:4===t&&(this.menuAction[this.menuSize]=347),this.menuParamA[this.menuSize]=c.index,this.menuParamB[this.menuSize]=e,this.menuParamC[this.menuSize]=d.id,this.menuSize++):4===t&&(this.menuOption[this.menuSize]="Drop @lre@"+c.name,this.menuAction[this.menuSize]=347,this.menuParamA[this.menuSize]=c.index,this.menuParamB[this.menuSize]=e,this.menuParamC[this.menuSize]=d.id,this.menuSize++);if(d.usable&&(this.menuOption[this.menuSize]="Use @lre@"+c.name,this.menuAction[this.menuSize]=188,this.menuParamA[this.menuSize]=c.index,this.menuParamB[this.menuSize]=e,this.menuParamC[this.menuSize]=d.id,this.menuSize++),d.interactable&&c.iops)for(let t=2;t>=0;t--)c.iops[t]&&(this.menuOption[this.menuSize]=c.iops[t]+" @lre@"+c.name,0===t?this.menuAction[this.menuSize]=405:1===t?this.menuAction[this.menuSize]=38:2===t&&(this.menuAction[this.menuSize]=422),this.menuParamA[this.menuSize]=c.index,this.menuParamB[this.menuSize]=e,this.menuParamC[this.menuSize]=d.id,this.menuSize++);if(d.iops)for(let t=4;t>=0;t--)d.iops[t]&&(this.menuOption[this.menuSize]=d.iops[t]+" @lre@"+c.name,0===t?this.menuAction[this.menuSize]=602:1===t?this.menuAction[this.menuSize]=596:2===t?this.menuAction[this.menuSize]=22:3===t?this.menuAction[this.menuSize]=892:4===t&&(this.menuAction[this.menuSize]=415),this.menuParamA[this.menuSize]=c.index,this.menuParamB[this.menuSize]=e,this.menuParamC[this.menuSize]=d.id,this.menuSize++);this.menuOption[this.menuSize]="Examine @lre@"+c.name,this.menuAction[this.menuSize]=1773,this.menuParamA[this.menuSize]=c.index,d.invSlotObjCount&&(this.menuParamC[this.menuSize]=d.invSlotObjCount[e]),this.menuSize++}e++}}else if(t>=h&&i>=l&&t{let t=e.clientCode;return t>=c.Z.CC_FRIENDS_START&&t<=c.Z.CC_FRIENDS_UPDATE_END?(t>=c.Z.CC_FRIENDS_UPDATE_START?t-=c.Z.CC_FRIENDS_UPDATE_START:t--,this.menuOption[this.menuSize]="Remove @whi@"+this.friendName[t],this.menuAction[this.menuSize]=557,this.menuSize++,this.menuOption[this.menuSize]="Message @whi@"+this.friendName[t],this.menuAction[this.menuSize]=679,this.menuSize++,!0):t>=c.Z.CC_IGNORES_START&&t<=c.Z.CC_IGNORES_END&&(this.menuOption[this.menuSize]="Remove @whi@"+e.text,this.menuAction[this.menuSize]=556,this.menuSize++,!0)};handleViewportOptions=()=>{0===this.objSelected&&0===this.spellSelected&&(this.menuOption[this.menuSize]="Walk here",this.menuAction[this.menuSize]=660,this.menuParamB[this.menuSize]=this.mouseX,this.menuParamC[this.menuSize]=this.mouseY,this.menuSize++);let e=-1;for(let t=0;t>7&127,h=i>>29&3,o=i>>14&32767;if(i!==e){if(e=i,2===h&&this.scene&&this.scene.getInfo(this.currentLevel,s,n,i)>=0){const e=a.Z.get(o);if(1===this.objSelected)this.menuOption[this.menuSize]="Use "+this.objSelectedName+" with @cya@"+e.name,this.menuAction[this.menuSize]=450,this.menuParamA[this.menuSize]=i,this.menuParamB[this.menuSize]=s,this.menuParamC[this.menuSize]=n,this.menuSize++;else if(1!==this.spellSelected){if(e.ops)for(let t=4;t>=0;t--)e.ops[t]&&(this.menuOption[this.menuSize]=e.ops[t]+" @cya@"+e.name,0===t&&(this.menuAction[this.menuSize]=285),1===t&&(this.menuAction[this.menuSize]=504),2===t&&(this.menuAction[this.menuSize]=364),3===t&&(this.menuAction[this.menuSize]=581),4===t&&(this.menuAction[this.menuSize]=1501),this.menuParamA[this.menuSize]=i,this.menuParamB[this.menuSize]=s,this.menuParamC[this.menuSize]=n,this.menuSize++);this.menuOption[this.menuSize]="Examine @cya@"+e.name,this.menuAction[this.menuSize]=1175,this.menuParamA[this.menuSize]=i,this.menuParamB[this.menuSize]=s,this.menuParamC[this.menuSize]=n,this.menuSize++}else 4==(4&this.activeSpellFlags)&&(this.menuOption[this.menuSize]=this.spellCaption+" @cya@"+e.name,this.menuAction[this.menuSize]=55,this.menuParamA[this.menuSize]=i,this.menuParamB[this.menuSize]=s,this.menuParamC[this.menuSize]=n,this.menuSize++)}if(1===h){const e=this.npcs[o];if(e&&e.type&&1===e.type.size&&64==(127&e.x)&&64==(127&e.z))for(let t=0;t=0;i--)e.ops&&e.ops[i]?(this.menuOption[this.menuSize]=e.ops[i]+" @lre@"+e.name,0===i&&(this.menuAction[this.menuSize]=224),1===i&&(this.menuAction[this.menuSize]=993),2===i&&(this.menuAction[this.menuSize]=99),3===i&&(this.menuAction[this.menuSize]=746),4===i&&(this.menuAction[this.menuSize]=877),this.menuParamA[this.menuSize]=t.index,this.menuParamB[this.menuSize]=s,this.menuParamC[this.menuSize]=n,this.menuSize++):2===i&&(this.menuOption[this.menuSize]="Take @lre@"+e.name,this.menuAction[this.menuSize]=99,this.menuParamA[this.menuSize]=t.index,this.menuParamB[this.menuSize]=s,this.menuParamC[this.menuSize]=n,this.menuSize++);this.menuOption[this.menuSize]="Examine @lre@"+e.name,this.menuAction[this.menuSize]=1102,this.menuParamA[this.menuSize]=t.index,this.menuParamB[this.menuSize]=s,this.menuParamC[this.menuSize]=n,this.menuSize++}else 1==(1&this.activeSpellFlags)&&(this.menuOption[this.menuSize]=this.spellCaption+" @lre@"+e.name,this.menuAction[this.menuSize]=965,this.menuParamA[this.menuSize]=t.index,this.menuParamB[this.menuSize]=s,this.menuParamC[this.menuSize]=n,this.menuSize++)}}}}};addNpcOptions=(e,t,i,s)=>{if(this.menuSize>=400)return;let a=e.name;if(0!==e.vislevel&&this.localPlayer&&(a=a+this.getCombatLevelColorTag(this.localPlayer.combatLevel,e.vislevel)+" (level-"+e.vislevel+")"),1===this.objSelected)this.menuOption[this.menuSize]="Use "+this.objSelectedName+" with @yel@"+a,this.menuAction[this.menuSize]=900,this.menuParamA[this.menuSize]=t,this.menuParamB[this.menuSize]=i,this.menuParamC[this.menuSize]=s,this.menuSize++;else if(1!==this.spellSelected){let r;if(e.ops)for(r=4;r>=0;r--)e.ops[r]&&"attack"!==e.ops[r]?.toLowerCase()&&(this.menuOption[this.menuSize]=e.ops[r]+" @yel@"+a,0===r?this.menuAction[this.menuSize]=728:1===r?this.menuAction[this.menuSize]=542:2===r?this.menuAction[this.menuSize]=6:3===r?this.menuAction[this.menuSize]=963:4===r&&(this.menuAction[this.menuSize]=245),this.menuParamA[this.menuSize]=t,this.menuParamB[this.menuSize]=i,this.menuParamC[this.menuSize]=s,this.menuSize++);if(e.ops)for(r=4;r>=0;r--)if(e.ops[r]&&"attack"===e.ops[r]?.toLowerCase()){let n=0;this.localPlayer&&e.vislevel>this.localPlayer.combatLevel&&(n=2e3),this.menuOption[this.menuSize]=e.ops[r]+" @yel@"+a,0===r?this.menuAction[this.menuSize]=n+728:1===r?this.menuAction[this.menuSize]=n+542:2===r?this.menuAction[this.menuSize]=n+6:3===r?this.menuAction[this.menuSize]=n+963:4===r&&(this.menuAction[this.menuSize]=n+245),this.menuParamA[this.menuSize]=t,this.menuParamB[this.menuSize]=i,this.menuParamC[this.menuSize]=s,this.menuSize++}this.menuOption[this.menuSize]="Examine @yel@"+a,this.menuAction[this.menuSize]=1607,this.menuParamA[this.menuSize]=t,this.menuParamB[this.menuSize]=i,this.menuParamC[this.menuSize]=s,this.menuSize++}else 2==(2&this.activeSpellFlags)&&(this.menuOption[this.menuSize]=this.spellCaption+" @yel@"+a,this.menuAction[this.menuSize]=265,this.menuParamA[this.menuSize]=t,this.menuParamB[this.menuSize]=i,this.menuParamC[this.menuSize]=s,this.menuSize++)};addPlayerOptions=(e,t,i,s)=>{if(e===this.localPlayer||this.menuSize>=400)return;let a=null;this.localPlayer&&(a=e.name+this.getCombatLevelColorTag(this.localPlayer.combatLevel,e.combatLevel)+" (level-"+e.combatLevel+")"),1===this.objSelected?(this.menuOption[this.menuSize]="Use "+this.objSelectedName+" with @whi@"+a,this.menuAction[this.menuSize]=367,this.menuParamA[this.menuSize]=t,this.menuParamB[this.menuSize]=i,this.menuParamC[this.menuSize]=s,this.menuSize++):1!==this.spellSelected?(this.menuOption[this.menuSize]="Follow @whi@"+a,this.menuAction[this.menuSize]=1544,this.menuParamA[this.menuSize]=t,this.menuParamB[this.menuSize]=i,this.menuParamC[this.menuSize]=s,this.menuSize++,0===this.overrideChat&&(this.menuOption[this.menuSize]="Trade with @whi@"+a,this.menuAction[this.menuSize]=1373,this.menuParamA[this.menuSize]=t,this.menuParamB[this.menuSize]=i,this.menuParamC[this.menuSize]=s,this.menuSize++),this.wildernessLevel>0&&(this.menuOption[this.menuSize]="Attack @whi@"+a,this.localPlayer&&this.localPlayer.combatLevel>=e.combatLevel?this.menuAction[this.menuSize]=151:this.menuAction[this.menuSize]=2151,this.menuParamA[this.menuSize]=t,this.menuParamB[this.menuSize]=i,this.menuParamC[this.menuSize]=s,this.menuSize++),1===this.worldLocationState&&(this.menuOption[this.menuSize]="Fight @whi@"+a,this.menuAction[this.menuSize]=151,this.menuParamA[this.menuSize]=t,this.menuParamB[this.menuSize]=i,this.menuParamC[this.menuSize]=s,this.menuSize++),2===this.worldLocationState&&(this.menuOption[this.menuSize]="Duel-with @whi@"+a,this.menuAction[this.menuSize]=1101,this.menuParamA[this.menuSize]=t,this.menuParamB[this.menuSize]=i,this.menuParamC[this.menuSize]=s,this.menuSize++)):8==(8&this.activeSpellFlags)&&(this.menuOption[this.menuSize]=this.spellCaption+" @whi@"+a,this.menuAction[this.menuSize]=651,this.menuParamA[this.menuSize]=t,this.menuParamB[this.menuSize]=i,this.menuParamC[this.menuSize]=s,this.menuSize++);for(let e=0;e{const i=e-t;return i<-9?"@red@":i<-6?"@or3@":i<-3?"@or2@":i<0?"@or1@":i>9?"@gre@":i>6?"@gr3@":i>3?"@gr2@":i>0?"@gr1@":"@yel@"};handleInput=()=>{if(0===this.objDragArea){this.menuOption[0]="Cancel",this.menuAction[0]=1252,this.menuSize=1,this.handlePrivateChatInput(this.mouseY),this.lastHoveredInterfaceId=0,this.mouseX>8&&this.mouseY>11&&this.mouseX<520&&this.mouseY<345&&(-1===this.viewportInterfaceId?this.handleViewportOptions():this.handleInterfaceInput(c.Z.instances[this.viewportInterfaceId],this.mouseX,this.mouseY,8,11,0)),this.lastHoveredInterfaceId!==this.viewportHoveredInterfaceIndex&&(this.viewportHoveredInterfaceIndex=this.lastHoveredInterfaceId),this.lastHoveredInterfaceId=0,this.mouseX>562&&this.mouseY>231&&this.mouseX<752&&this.mouseY<492&&(-1!==this.sidebarInterfaceId?this.handleInterfaceInput(c.Z.instances[this.sidebarInterfaceId],this.mouseX,this.mouseY,562,231,0):-1!==this.tabInterfaceId[this.selectedTab]&&this.handleInterfaceInput(c.Z.instances[this.tabInterfaceId[this.selectedTab]],this.mouseX,this.mouseY,562,231,0)),this.lastHoveredInterfaceId!==this.sidebarHoveredInterfaceIndex&&(this.redrawSidebar=!0,this.sidebarHoveredInterfaceIndex=this.lastHoveredInterfaceId),this.lastHoveredInterfaceId=0,this.mouseX>22&&this.mouseY>375&&this.mouseX<431&&this.mouseY<471&&(-1===this.chatInterfaceId?this.handleChatMouseInput(this.mouseX-22,this.mouseY-375):this.handleInterfaceInput(c.Z.instances[this.chatInterfaceId],this.mouseX,this.mouseY,22,375,0)),-1!==this.chatInterfaceId&&this.lastHoveredInterfaceId!==this.chatHoveredInterfaceIndex&&(this.redrawChatback=!0,this.chatHoveredInterfaceIndex=this.lastHoveredInterfaceId);let e=!1;for(;!e;){e=!0;for(let t=0;t1e3){const i=this.menuOption[t];this.menuOption[t]=this.menuOption[t+1],this.menuOption[t+1]=i;const s=this.menuAction[t];this.menuAction[t]=this.menuAction[t+1],this.menuAction[t+1]=s;const a=this.menuParamB[t];this.menuParamB[t]=this.menuParamB[t+1],this.menuParamB[t+1]=a;const r=this.menuParamC[t];this.menuParamC[t]=this.menuParamC[t+1],this.menuParamC[t+1]=r;const n=this.menuParamA[t];this.menuParamA[t]=this.menuParamA[t+1],this.menuParamA[t+1]=n,e=!1}}}};showContextMenu=()=>{let e=0;if(this.fontBold12){let t;e=this.fontBold12.stringWidth("Choose Option");for(let i=0;ie&&(e=t)}e+=8;const t=15*this.menuSize+21;let i,s;this.mouseClickX>8&&this.mouseClickY>11&&this.mouseClickX<520&&this.mouseClickY<345&&(i=this.mouseClickX-(e/2|0)-8,i+e>512?i=512-e:i<0&&(i=0),s=this.mouseClickY-11,s+t>334?s=334-t:s<0&&(s=0),this.menuVisible=!0,this.menuArea=0,this.menuX=i,this.menuY=s,this.menuWidth=e,this.menuHeight=15*this.menuSize+22),this.mouseClickX>562&&this.mouseClickY>231&&this.mouseClickX<752&&this.mouseClickY<492&&(i=this.mouseClickX-(e/2|0)-562,i<0?i=0:i+e>190&&(i=190-e),s=this.mouseClickY-231,s<0?s=0:s+t>261&&(s=261-t),this.menuVisible=!0,this.menuArea=1,this.menuX=i,this.menuY=s,this.menuWidth=e,this.menuHeight=15*this.menuSize+22),this.mouseClickX>22&&this.mouseClickY>375&&this.mouseClickX<501&&this.mouseClickY<471&&(i=this.mouseClickX-(e/2|0)-22,i<0?i=0:i+e>479&&(i=479-e),s=this.mouseClickY-375,s<0?s=0:s+t>96&&(s=96-t),this.menuVisible=!0,this.menuArea=2,this.menuX=i,this.menuY=s,this.menuWidth=e,this.menuHeight=15*this.menuSize+22)};tryMove=(e,t,i,s,a,r,n,h,o,l,c)=>{const d=this.levelCollisionMap[this.currentLevel];if(!d)return!1;const u=X.Z.SIZE,f=X.Z.SIZE;for(let e=0;e0&&0===this.bfsDirection[t]&&(S[t]&F.Z.BLOCK_WEST)===F.Z.OPEN&&(this.bfsStepX[y]=p-1,this.bfsStepZ[y]=m,y=(y+1)%T,this.bfsDirection[t]=2,this.bfsCost[t]=e),t=X.Z.index(p+1,m),p0&&0===this.bfsDirection[t]&&(S[t]&F.Z.BLOCK_SOUTH)===F.Z.OPEN&&(this.bfsStepX[y]=p,this.bfsStepZ[y]=m-1,y=(y+1)%T,this.bfsDirection[t]=1,this.bfsCost[t]=e),t=X.Z.index(p,m+1),m0&&m>0&&0===this.bfsDirection[t]&&0==(S[t]&F.Z.BLOCK_SOUTH_WEST)&&(S[X.Z.index(p-1,m)]&F.Z.BLOCK_WEST)===F.Z.OPEN&&(S[X.Z.index(p,m-1)]&F.Z.BLOCK_SOUTH)===F.Z.OPEN&&(this.bfsStepX[y]=p-1,this.bfsStepZ[y]=m-1,y=(y+1)%T,this.bfsDirection[t]=3,this.bfsCost[t]=e),t=X.Z.index(p+1,m-1),p0&&0===this.bfsDirection[t]&&0==(S[t]&F.Z.BLOCK_SOUTH_EAST)&&(S[X.Z.index(p+1,m)]&F.Z.BLOCK_EAST)===F.Z.OPEN&&(S[X.Z.index(p,m-1)]&F.Z.BLOCK_SOUTH)===F.Z.OPEN&&(this.bfsStepX[y]=p+1,this.bfsStepZ[y]=m-1,y=(y+1)%T,this.bfsDirection[t]=9,this.bfsCost[t]=e),t=X.Z.index(p-1,m+1),p>0&&m=0&&i>=0&&a0){T=Math.min(C,25),C--;const e=this.bfsStepX[C],t=this.bfsStepZ[C];0===a?(this.out.p1isaac(I.Z.MOVE_GAMECLICK),this.out.p1(T+T+3)):1===a?(this.out.p1isaac(I.Z.MOVE_MINIMAPCLICK),this.out.p1(T+T+3+14)):2===a&&(this.out.p1isaac(I.Z.MOVE_OPCLICK),this.out.p1(T+T+3)),1===this.actionKey[5]?this.out.p1(1):this.out.p1(0),this.out.p2(e+this.sceneBaseTileX),this.out.p2(t+this.sceneBaseTileZ),this.flagSceneTileX=this.bfsStepX[0],this.flagSceneTileZ=this.bfsStepZ[0];for(let i=1;i{this.entityRemovalCount=0,this.entityUpdateCount=0,this.readLocalPlayer(e),this.readPlayers(e),this.readNewPlayers(e,t),this.readPlayerUpdates(e);for(let e=0;e{if(e.bits(),0!==e.gBit(1)){const t=e.gBit(2);if(0===t)this.entityUpdateIds[this.entityUpdateCount++]=this.LOCAL_PLAYER_INDEX;else if(1===t){const t=e.gBit(3);this.localPlayer?.step(!1,t),1===e.gBit(1)&&(this.entityUpdateIds[this.entityUpdateCount++]=this.LOCAL_PLAYER_INDEX)}else if(2===t){const t=e.gBit(3);this.localPlayer?.step(!0,t);const i=e.gBit(3);this.localPlayer?.step(!0,i),1===e.gBit(1)&&(this.entityUpdateIds[this.entityUpdateCount++]=this.LOCAL_PLAYER_INDEX)}else if(3===t){this.currentLevel=e.gBit(2);const t=e.gBit(7),i=e.gBit(7),s=e.gBit(1);this.localPlayer?.move(1===s,t,i),1===e.gBit(1)&&(this.entityUpdateIds[this.entityUpdateCount++]=this.LOCAL_PLAYER_INDEX)}}};readPlayers=e=>{const t=e.gBit(8);if(tthis.playerCount)throw new Error(`eek! ${this.username} Too many players`);this.playerCount=0;for(let i=0;i{let i;for(;e.bitPos+10<8*t&&(i=e.gBit(11),2047!==i);){if(!this.players[i]){this.players[i]=new H.Z;const e=this.playerAppearanceBuffer[i];e&&this.players[i]?.read(e)}this.playerIds[this.playerCount++]=i;const t=this.players[i];t&&(t.cycle=this.loopCycle);let s=e.gBit(5);s>15&&(s-=32);let a=e.gBit(5);a>15&&(a-=32);const r=e.gBit(1);this.localPlayer&&t?.move(1===r,this.localPlayer.pathTileX[0]+s,this.localPlayer.pathTileZ[0]+a),1===e.gBit(1)&&(this.entityUpdateIds[this.entityUpdateCount++]=i)}e.bytes()};readPlayerUpdates=e=>{for(let t=0;t{if(e.lastMask=i,e.lastMaskCycle=this.loopCycle,1==(1&i)){const i=a.g1,s=new Uint8Array(i),r=new w.Z(s);a.gdata(i,0,s),this.playerAppearanceBuffer[t]=r,e.read(r)}if(2==(2&i)){let t=a.g2;65535===t&&(t=-1),t===e.primarySeqId&&(e.primarySeqLoop=0);const i=a.g1;(-1===t||-1===e.primarySeqId||s.Z.instances[t].priority>s.Z.instances[e.primarySeqId].priority||0===s.Z.instances[e.primarySeqId].priority)&&(e.primarySeqId=t,e.primarySeqFrame=0,e.primarySeqCycle=0,e.primarySeqDelay=i,e.primarySeqLoop=0)}if(4==(4&i)&&(e.targetId=a.g2,65535===e.targetId&&(e.targetId=-1)),8==(8&i)&&(e.chat=a.gjstr,e.chatColor=0,e.chatStyle=0,e.chatTimer=150,e.name&&this.addMessage(2,e.chat,e.name)),16==(16&i)&&(e.damage=a.g1,e.damageType=a.g1,e.combatCycle=this.loopCycle+400,e.health=a.g1,e.totalHealth=a.g1),32==(32&i)&&(e.targetTileX=a.g2,e.targetTileZ=a.g2,e.lastFaceX=e.targetTileX,e.lastFaceZ=e.targetTileZ),64==(64&i)){const t=a.g2,i=a.g1,s=a.g1,r=a.pos;if(e.name){const r=_.Z.toBase37(e.name);let n=!1;if(i<=1)for(let e=0;e>8,e.chatStyle=255&t,e.chatTimer=150,i>1?this.addMessage(1,n,e.name):this.addMessage(2,n,e.name)}catch(e){}}a.pos=r+s}if(256==(256&i)){e.spotanimId=a.g2;const t=a.g4;e.spotanimOffset=t>>16,e.spotanimLastCycle=this.loopCycle+(65535&t),e.spotanimFrame=0,e.spotanimCycle=0,e.spotanimLastCycle>this.loopCycle&&(e.spotanimFrame=-1),65535===e.spotanimId&&(e.spotanimId=-1)}512==(512&i)&&(e.forceMoveStartSceneTileX=a.g1,e.forceMoveStartSceneTileZ=a.g1,e.forceMoveEndSceneTileX=a.g1,e.forceMoveEndSceneTileZ=a.g1,e.forceMoveEndCycle=a.g2+this.loopCycle,e.forceMoveStartCycle=a.g2+this.loopCycle,e.forceMoveFaceDirection=a.g1,e.pathLength=0,e.pathTileX[0]=e.forceMoveEndSceneTileX,e.pathTileZ[0]=e.forceMoveEndSceneTileZ)};readNpcInfo=(e,t)=>{this.entityRemovalCount=0,this.entityUpdateCount=0,this.readNpcs(e),this.readNewNpcs(e,t),this.readNpcUpdates(e);for(let e=0;e{e.bits();const t=e.gBit(8);if(tthis.npcCount)throw new Error(`eek! ${this.username} Too many npc!`);this.npcCount=0;for(let i=0;i{for(;e.bitPos+21<8*t;){const t=e.gBit(13);if(8191===t)break;this.npcs[t]||(this.npcs[t]=new W.Z);const i=this.npcs[t];this.npcIds[this.npcCount++]=t,i?(i.cycle=this.loopCycle,i.type=n.Z.get(e.gBit(11)),i.size=i.type.size,i.seqWalkId=i.type.walkanim,i.seqTurnAroundId=i.type.walkanim_b,i.seqTurnLeftId=i.type.walkanim_r,i.seqTurnRightId=i.type.walkanim_l,i.seqStandId=i.type.readyanim):e.gBit(11);let s=e.gBit(5);s>15&&(s-=32);let a=e.gBit(5);a>15&&(a-=32),this.localPlayer&&i?.move(!1,this.localPlayer.pathTileX[0]+s,this.localPlayer.pathTileZ[0]+a),1===e.gBit(1)&&(this.entityUpdateIds[this.entityUpdateCount++]=t)}e.bytes()};readNpcUpdates=e=>{for(let t=0;ts.Z.instances[a.primarySeqId].priority||0===s.Z.instances[a.primarySeqId].priority)&&(a.primarySeqId=t,a.primarySeqFrame=0,a.primarySeqCycle=0,a.primarySeqDelay=i,a.primarySeqLoop=0)}if(4==(4&r)&&(a.targetId=e.g2,65535===a.targetId&&(a.targetId=-1)),8==(8&r)&&(a.chat=e.gjstr,a.chatTimer=100),16==(16&r)&&(a.damage=e.g1,a.damageType=e.g1,a.combatCycle=this.loopCycle+400,a.health=e.g1,a.totalHealth=e.g1),32==(32&r)&&(a.type=n.Z.get(e.g2),a.seqWalkId=a.type.walkanim,a.seqTurnAroundId=a.type.walkanim_b,a.seqTurnLeftId=a.type.walkanim_r,a.seqTurnRightId=a.type.walkanim_l,a.seqStandId=a.type.readyanim),64==(64&r)){a.spotanimId=e.g2;const t=e.g4;a.spotanimOffset=t>>16,a.spotanimLastCycle=this.loopCycle+(65535&t),a.spotanimFrame=0,a.spotanimCycle=0,a.spotanimLastCycle>this.loopCycle&&(a.spotanimFrame=-1),65535===a.spotanimId&&(a.spotanimId=-1)}128==(128&r)&&(a.targetTileX=e.g2,a.targetTileZ=e.g2,a.lastFaceX=a.targetTileX,a.lastFaceZ=a.targetTileZ)}};updatePlayers=()=>{for(let e=-1;e1406){J.K.updatePlayersCounter=0,this.out.p1isaac(I.Z.ANTICHEAT_CYCLELOGIC6),this.out.p1(0);const e=this.out.pos;this.out.p1(162),this.out.p1(22),0==(2*Math.random()|0)&&this.out.p1(84),this.out.p2(31824),this.out.p2(13490),0==(2*Math.random()|0)&&this.out.p1(123),0==(2*Math.random()|0)&&this.out.p1(134),this.out.p1(100),this.out.p1(94),this.out.p2(35521),this.out.psize1(this.out.pos-e)}};updateEntity=e=>{(e.x<128||e.z<128||e.x>=13184||e.z>=13184)&&(e.primarySeqId=-1,e.spotanimId=-1,e.forceMoveEndCycle=0,e.forceMoveStartCycle=0,e.x=128*e.pathTileX[0]+64*e.size,e.z=128*e.pathTileZ[0]+64*e.size,e.pathLength=0),e===this.localPlayer&&(e.x<1536||e.z<1536||e.x>=11776||e.z>=11776)&&(e.primarySeqId=-1,e.spotanimId=-1,e.forceMoveEndCycle=0,e.forceMoveStartCycle=0,e.x=128*e.pathTileX[0]+64*e.size,e.z=128*e.pathTileZ[0]+64*e.size,e.pathLength=0),e.forceMoveEndCycle>this.loopCycle?this.updateForceMovement(e):e.forceMoveStartCycle>=this.loopCycle?this.startForceMovement(e):this.updateMovement(e),this.updateFacingDirection(e),this.updateSequences(e)};pushPlayers=()=>{if(this.localPlayer){this.localPlayer.x>>7===this.flagSceneTileX&&this.localPlayer.z>>7===this.flagSceneTileZ&&(this.flagSceneTileX=0);for(let e=-1;e50||this.playerCount>200)&&-1!==e&&t.secondarySeqId===t.seqStandId;const s=t.x>>7,a=t.z>>7;if(!(s<0||s>=X.Z.SIZE||a<0||a>=X.Z.SIZE))if(!t.locModel||this.loopCycle=t.locStopCycle){if(64==(127&t.x)&&64==(127&t.z)){if(this.tileLastOccupiedCycle[s][a]===this.sceneCycle)continue;this.tileLastOccupiedCycle[s][a]=this.sceneCycle}t.y=this.getHeightmapY(this.currentLevel,t.x,t.z),this.scene?.addTemporary(this.currentLevel,t.x,t.y,t.z,null,t,i,t.yaw,60,t.seqStretches)}else t.lowMemory=!1,t.y=this.getHeightmapY(this.currentLevel,t.x,t.z),this.scene?.addTemporary2(this.currentLevel,t.x,t.y,t.z,t.minTileX,t.minTileZ,t.maxTileX,t.maxTileZ,null,t,i,t.yaw)}}};updateNpcs=()=>{for(let e=0;e{for(let e=0;e>7,a=t.z>>7;if(!(s<0||s>=X.Z.SIZE||a<0||a>=X.Z.SIZE)){if(1===t.size&&64==(127&t.x)&&64==(127&t.z)){if(this.tileLastOccupiedCycle[s][a]===this.sceneCycle)continue;this.tileLastOccupiedCycle[s][a]=this.sceneCycle}this.scene?.addTemporary(this.currentLevel,t.x,this.getHeightmapY(this.currentLevel,t.x,t.z),t.z,null,t,i,t.yaw,64*(t.size-1)+60,t.seqStretches)}}};pushProjectiles=()=>{for(let e=this.projectiles.peekFront();e;e=this.projectiles.prev())if(e.level!==this.currentLevel||this.loopCycle>e.lastCycle)e.unlink();else if(this.loopCycle>=e.startCycle){if(e.target>0){const t=this.npcs[e.target-1];t&&e.updateVelocity(t.x,this.getHeightmapY(e.level,t.x,t.z)-e.offsetY,t.z,this.loopCycle)}if(e.target<0){const t=-e.target-1;let i;i=t===this.localPid?this.localPlayer:this.players[t],i&&e.updateVelocity(i.x,this.getHeightmapY(e.level,i.x,i.z)-e.offsetY,i.z,this.loopCycle)}e.update(this.sceneDelta),this.scene?.addTemporary(this.currentLevel,0|e.x,0|e.y,0|e.z,null,e,-1,e.yaw,60,!1)}};pushSpotanims=()=>{for(let e=this.spotanims.peekFront();e;e=this.spotanims.prev())e.level!==this.currentLevel||e.seqComplete?e.unlink():this.loopCycle>=e.startCycle&&(e.update(this.sceneDelta),e.seqComplete?e.unlink():this.scene?.addTemporary(e.level,e.x,e.y,e.z,null,e,-1,0,60,!1))};pushLocs=()=>{for(let e=this.locList.peekFront();e;e=this.locList.prev()){let t=!1;if(e.seqCycle+=this.sceneDelta,-1===e.seqFrame&&(e.seqFrame=0,t=!0),e.seq.delay)for(;e.seqCycle>e.seq.delay[e.seqFrame];)if(e.seqCycle-=e.seq.delay[e.seqFrame]+1,e.seqFrame++,t=!0,e.seqFrame>=e.seq.frameCount&&(e.seqFrame-=e.seq.replayoff,e.seqFrame<0||e.seqFrame>=e.seq.frameCount)){e.unlink(),t=!1;break}if(t&&this.scene){const t=e.heightmapSW,i=e.heightmapNE,s=e.heightmapNW;let r=0;if(0===e.heightmapSE?r=this.scene.getWallBitset(t,i,s):1===e.heightmapSE?r=this.scene.getWallDecorationBitset(t,s,i):2===e.heightmapSE?r=this.scene.getLocBitset(t,i,s):3===e.heightmapSE&&(r=this.scene.getGroundDecorationBitset(t,i,s)),this.levelHeightmap&&0!==r&&(r>>14&32767)===e.index){const n=this.levelHeightmap[t][i][s],h=this.levelHeightmap[t][i+1][s],o=this.levelHeightmap[t][i+1][s+1],l=this.levelHeightmap[t][i][s+1],c=a.Z.get(e.index);let d=-1;if(-1!==e.seqFrame&&e.seq.frames&&(d=e.seq.frames[e.seqFrame]),2===e.heightmapSE){const e=this.scene.getInfo(t,i,s,r);let a=31&e;const u=e>>6;a===N.Z.CENTREPIECE_DIAGONAL&&(a=N.Z.CENTREPIECE_STRAIGHT),this.scene?.setLocModel(t,i,s,c.getModel(a,u,n,h,o,l,d))}else if(1===e.heightmapSE)this.scene?.setWallDecorationModel(t,i,s,c.getModel(N.Z.WALLDECOR_STRAIGHT_NOOFFSET,0,n,h,o,l,d));else if(0===e.heightmapSE){const e=this.scene.getInfo(t,i,s,r),a=31&e,u=e>>6;if(a===N.Z.WALL_L){const e=u+1&3;this.scene?.setWallModels(i,s,t,c.getModel(N.Z.WALL_L,u+4,n,h,o,l,d),c.getModel(N.Z.WALL_L,e,n,h,o,l,d))}else this.scene?.setWallModel(t,i,s,c.getModel(a,u,n,h,o,l,d))}else if(3===e.heightmapSE){const e=this.scene.getInfo(t,i,s,r)>>6;this.scene?.setGroundDecorationModel(t,i,s,c.getModel(N.Z.GROUND_DECOR,e,n,h,o,l,d))}}else e.unlink()}}};updateEntityChats=()=>{for(let e=-1;e0&&(i.chatTimer--,0===i.chatTimer&&(i.chat=null))}for(let e=0;e0&&(i.chatTimer--,0===i.chatTimer&&(i.chat=null))}};updateTemporaryLocs=()=>{if(2===this.sceneState){for(let e=this.temporaryLocs.peekFront();e;e=this.temporaryLocs.prev())this.loopCycle>=e.lastCycle&&(this.addLoc(e.plane,e.x,e.z,e.locIndex,e.angle,e.shape,e.layer),e.unlink());J.K.updateLocCounter++,J.K.updateLocCounter>85&&(J.K.updateLocCounter=0,this.out.p1isaac(I.Z.ANTICHEAT_CYCLELOGIC5))}};updateForceMovement=e=>{const t=e.forceMoveEndCycle-this.loopCycle,i=128*e.forceMoveStartSceneTileX+64*e.size,s=128*e.forceMoveStartSceneTileZ+64*e.size;e.x+=(i-e.x)/t|0,e.z+=(s-e.z)/t|0,e.seqTrigger=0,0==e.forceMoveFaceDirection&&(e.dstYaw=1024),1==e.forceMoveFaceDirection&&(e.dstYaw=1536),2==e.forceMoveFaceDirection&&(e.dstYaw=0),3==e.forceMoveFaceDirection&&(e.dstYaw=512)};startForceMovement=e=>{if(e.forceMoveStartCycle==this.loopCycle||-1==e.primarySeqId||0!=e.primarySeqDelay||e.primarySeqCycle+1>s.Z.instances[e.primarySeqId].delay[e.primarySeqFrame]){const t=e.forceMoveStartCycle-e.forceMoveEndCycle,i=this.loopCycle-e.forceMoveEndCycle,s=128*e.forceMoveStartSceneTileX+64*e.size,a=128*e.forceMoveStartSceneTileZ+64*e.size,r=128*e.forceMoveEndSceneTileX+64*e.size,n=128*e.forceMoveEndSceneTileZ+64*e.size;e.x=(s*(t-i)+r*i)/t|0,e.z=(a*(t-i)+n*i)/t|0}e.seqTrigger=0,0==e.forceMoveFaceDirection&&(e.dstYaw=1024),1==e.forceMoveFaceDirection&&(e.dstYaw=1536),2==e.forceMoveFaceDirection&&(e.dstYaw=0),3==e.forceMoveFaceDirection&&(e.dstYaw=512),e.yaw=e.dstYaw};updateFacingDirection=e=>{if(-1!==e.targetId&&e.targetId<32768){const t=this.npcs[e.targetId];if(t){const i=e.x-t.x,s=e.z-t.z;0===i&&0===s||(e.dstYaw=2047&(325.949*Math.atan2(i,s)|0))}}if(e.targetId>=32768){let t=e.targetId-32768;t===this.localPid&&(t=this.LOCAL_PLAYER_INDEX);const i=this.players[t];if(i){const t=e.x-i.x,s=e.z-i.z;0===t&&0===s||(e.dstYaw=2047&(325.949*Math.atan2(t,s)|0))}}if((0!==e.targetTileX||0!==e.targetTileZ)&&(0===e.pathLength||e.seqTrigger>0)){const t=e.x-64*(e.targetTileX-this.sceneBaseTileX-this.sceneBaseTileX),i=e.z-64*(e.targetTileZ-this.sceneBaseTileZ-this.sceneBaseTileZ);0===t&&0===i||(e.dstYaw=2047&(325.949*Math.atan2(t,i)|0)),e.targetTileX=0,e.targetTileZ=0}const t=e.dstYaw-e.yaw&2047;if(0!==t&&(t<32||t>2016?e.yaw=e.dstYaw:t>1024?e.yaw-=32:e.yaw+=32,e.yaw&=2047,e.secondarySeqId===e.seqStandId&&e.yaw!==e.dstYaw)){if(-1!==e.seqTurnId)return void(e.secondarySeqId=e.seqTurnId);e.secondarySeqId=e.seqWalkId}};updateSequences=e=>{let t;if(e.seqStretches=!1,-1!==e.secondarySeqId&&(t=s.Z.instances[e.secondarySeqId],e.secondarySeqCycle++,t.delay&&e.secondarySeqFramet.delay[e.secondarySeqFrame]&&(e.secondarySeqCycle=0,e.secondarySeqFrame++),e.secondarySeqFrame>=t.frameCount&&(e.secondarySeqCycle=0,e.secondarySeqFrame=0)),-1!==e.primarySeqId&&0===e.primarySeqDelay){for(t=s.Z.instances[e.primarySeqId],e.primarySeqCycle++;t.delay&&e.primarySeqFramet.delay[e.primarySeqFrame];)e.primarySeqCycle-=t.delay[e.primarySeqFrame],e.primarySeqFrame++;e.primarySeqFrame>=t.frameCount&&(e.primarySeqFrame-=t.replayoff,e.primarySeqLoop++,e.primarySeqLoop>=t.replaycount&&(e.primarySeqId=-1),(e.primarySeqFrame<0||e.primarySeqFrame>=t.frameCount)&&(e.primarySeqId=-1)),e.seqStretches=t.stretches}if(e.primarySeqDelay>0&&e.primarySeqDelay--,-1!==e.spotanimId&&this.loopCycle>=e.spotanimLastCycle){for(e.spotanimFrame<0&&(e.spotanimFrame=0),t=o.Z.instances[e.spotanimId].seq,e.spotanimCycle++;t&&t.delay&&e.spotanimFramet.delay[e.spotanimFrame];)e.spotanimCycle-=t.delay[e.spotanimFrame],e.spotanimFrame++;t&&e.spotanimFrame>=t.frameCount&&(e.spotanimFrame<0||e.spotanimFrame>=t.frameCount)&&(e.spotanimId=-1)}};updateMovement=e=>{if(e.secondarySeqId=e.seqStandId,0===e.pathLength)return void(e.seqTrigger=0);if(-1!==e.primarySeqId&&0===e.primarySeqDelay&&!s.Z.instances[e.primarySeqId].labelGroups)return void e.seqTrigger++;const t=e.x,i=e.z,a=128*e.pathTileX[e.pathLength-1]+64*e.size,r=128*e.pathTileZ[e.pathLength-1]+64*e.size;if(a-t<=256&&a-t>=-256&&r-i<=256&&r-i>=-256){e.dstYaw=tr?1792:1536:t>a?ir?256:512:i1024&&(s-=2048);let n=e.seqTurnAroundId;s>=-256&&s<=256?n=e.seqWalkId:s>=256&&s<768?n=e.seqTurnRightId:s>=-768&&s<=-256&&(n=e.seqTurnLeftId),-1===n&&(n=e.seqWalkId),e.secondarySeqId=n;let h=4;e.yaw!==e.dstYaw&&-1===e.targetId&&(h=2),e.pathLength>2&&(h=6),e.pathLength>3&&(h=8),e.seqTrigger>0&&e.pathLength>1&&(h=8,e.seqTrigger--),e.pathRunning[e.pathLength-1]&&(h<<=1),h>=8&&e.secondarySeqId===e.seqWalkId&&-1!==e.seqRunId&&(e.secondarySeqId=e.seqRunId),ta&&(e.x=a)):t>a&&(e.x-=h,e.xr&&(e.z=r)):i>r&&(e.z-=h,e.z{let e=3;if(this.cameraPitch<310&&this.localPlayer){let t=this.cameraX>>7,i=this.cameraZ>>7;const s=this.localPlayer.x>>7,a=this.localPlayer.z>>7;let r,n,h,o;if(this.levelTileFlags&&0!=(4&this.levelTileFlags[this.currentLevel][t][i])&&(e=this.currentLevel),r=s>t?s-t:t-s,n=a>i?a-i:i-a,r>n)for(h=65536*n/r|0,o=32768;t!==s;)ts&&t--,this.levelTileFlags&&0!=(4&this.levelTileFlags[this.currentLevel][t][i])&&(e=this.currentLevel),o+=h,o>=65536&&(o-=65536,ia&&i--,this.levelTileFlags&&0!=(4&this.levelTileFlags[this.currentLevel][t][i])&&(e=this.currentLevel));else for(h=65536*r/n|0,o=32768;i!==a;)ia&&i--,this.levelTileFlags&&0!=(4&this.levelTileFlags[this.currentLevel][t][i])&&(e=this.currentLevel),o+=h,o>=65536&&(o-=65536,ts&&t--,this.levelTileFlags&&0!=(4&this.levelTileFlags[this.currentLevel][t][i])&&(e=this.currentLevel))}return this.localPlayer&&this.levelTileFlags&&0!=(4&this.levelTileFlags[this.currentLevel][this.localPlayer.x>>7][this.localPlayer.z>>7])&&(e=this.currentLevel),e};getTopLevelCutscene=()=>this.levelTileFlags?this.getHeightmapY(this.currentLevel,this.cameraX,this.cameraZ)-this.cameraY>=800||0==(4&this.levelTileFlags[this.currentLevel][this.cameraX>>7][this.cameraZ>>7])?3:this.currentLevel:0;getHeightmapY=(e,t,i)=>{if(!this.levelHeightmap)return 0;const s=Math.min(t>>7,X.Z.SIZE-1),a=Math.min(i>>7,X.Z.SIZE-1);let r=e;e<3&&this.levelTileFlags&&2==(2&this.levelTileFlags[1][s][a])&&(r=e+1);const n=127&t,h=127&i;return(this.levelHeightmap[r][s][a]*(128-n)+this.levelHeightmap[r][s+1][a]*n>>7)*(128-h)+(this.levelHeightmap[r][s][a+1]*(128-n)+this.levelHeightmap[r][s+1][a+1]*n>>7)*h>>7};orbitCamera=(e,t,i,s,a,r)=>{const n=2048-a&2047,h=2048-s&2047;let o,l,c,d=0,u=0,p=r;0!==n&&(o=f.Z.sin[n],l=f.Z.cos[n],c=u*l-r*o>>16,p=u*o+r*l>>16,u=c),0!==h&&(o=f.Z.sin[h],l=f.Z.cos[h],c=p*o+d*l>>16,p=p*l-d*o>>16,d=c),this.cameraX=e-d,this.cameraY=t-u,this.cameraZ=i-p,this.cameraPitch=a,this.cameraYaw=s};updateOrbitCamera=()=>{if(!this.localPlayer)return;const e=this.localPlayer.x+this.cameraAnticheatOffsetX,t=this.localPlayer.z+this.cameraAnticheatOffsetZ;(this.orbitCameraX-e<-500||this.orbitCameraX-e>500||this.orbitCameraZ-t<-500||this.orbitCameraZ-t>500)&&(this.orbitCameraX=e,this.orbitCameraZ=t),this.orbitCameraX!==e&&(this.orbitCameraX+=(e-this.orbitCameraX)/16|0),this.orbitCameraZ!==t&&(this.orbitCameraZ+=(t-this.orbitCameraZ)/16|0),1===this.actionKey[1]?this.orbitCameraYawVelocity+=(-this.orbitCameraYawVelocity-24)/2|0:1===this.actionKey[2]?this.orbitCameraYawVelocity+=(24-this.orbitCameraYawVelocity)/2|0:this.orbitCameraYawVelocity=this.orbitCameraYawVelocity/2|0,1===this.actionKey[3]?this.orbitCameraPitchVelocity+=(12-this.orbitCameraPitchVelocity)/2|0:1===this.actionKey[4]?this.orbitCameraPitchVelocity+=(-this.orbitCameraPitchVelocity-12)/2|0:this.orbitCameraPitchVelocity=this.orbitCameraPitchVelocity/2|0,this.orbitCameraYaw=2047&(this.orbitCameraYaw+this.orbitCameraYawVelocity/2|0),this.orbitCameraPitch+=this.orbitCameraPitchVelocity/2|0,this.orbitCameraPitch<128&&(this.orbitCameraPitch=128),this.orbitCameraPitch>383&&(this.orbitCameraPitch=383);const i=this.orbitCameraX>>7,s=this.orbitCameraZ>>7,a=this.getHeightmapY(this.currentLevel,this.orbitCameraX,this.orbitCameraZ);let r=0;if(this.levelHeightmap&&i>3&&s>3&&i<100&&s<100)for(let e=i-4;e<=i+4;e++)for(let t=s-4;t<=s+4;t++){let i=this.currentLevel;i<3&&this.levelTileFlags&&2==(2&this.levelTileFlags[1][e][t])&&i++;const s=a-this.levelHeightmap[i][e][t];s>r&&(r=s)}let n=192*r;n>98048&&(n=98048),n<32768&&(n=32768),n>this.cameraPitchClamp?this.cameraPitchClamp+=(n-this.cameraPitchClamp)/24|0:n{let e=128*this.cutsceneSrcLocalTileX+64,t=128*this.cutsceneSrcLocalTileZ+64,i=this.getHeightmapY(this.currentLevel,this.cutsceneSrcLocalTileX,this.cutsceneSrcLocalTileZ)-this.cutsceneSrcHeight;this.cameraXe&&(this.cameraX=e)),this.cameraX>e&&(this.cameraX-=this.cutsceneMoveSpeed+((this.cameraX-e)*this.cutsceneMoveAcceleration/1e3|0),this.cameraXi&&(this.cameraY=i)),this.cameraY>i&&(this.cameraY-=this.cutsceneMoveSpeed+((this.cameraY-i)*this.cutsceneMoveAcceleration/1e3|0),this.cameraYt&&(this.cameraZ=t)),this.cameraZ>t&&(this.cameraZ-=this.cutsceneMoveSpeed+((this.cameraZ-t)*this.cutsceneMoveAcceleration/1e3|0),this.cameraZ383&&(h=383),this.cameraPitchh&&(this.cameraPitch=h)),this.cameraPitch>h&&(this.cameraPitch-=this.cutsceneRotateSpeed+((this.cameraPitch-h)*this.cutsceneRotateAcceleration/1e3|0),this.cameraPitch1024&&(l-=2048),l<-1024&&(l+=2048),l>0&&(this.cameraYaw+=this.cutsceneRotateSpeed+(l*this.cutsceneRotateAcceleration/1e3|0),this.cameraYaw&=2047),l<0&&(this.cameraYaw-=this.cutsceneRotateSpeed+(-l*this.cutsceneRotateAcceleration/1e3|0),this.cameraYaw&=2047);let c=o-this.cameraYaw;c>1024&&(c-=2048),c<-1024&&(c+=2048),(c<0&&l>0||c>0&&l<0)&&(this.cameraYaw=o)};readZonePacket=(e,t)=>{const i=e.g1;let r=this.baseX+(i>>4&7),n=this.baseZ+(7&i);if(t===v.Z.LOC_ADD_CHANGE||t===v.Z.LOC_DEL){const i=e.g1,s=i>>2,a=3&i,h=N.m.layer(s);let o;if(o=t===v.Z.LOC_DEL?-1:e.g2,r>=0&&n>=0&&r>14&32767,s=31&e,a=e>>6}e=new D.Z(this.currentLevel,h,r,n,0,B.Z.WEST,N.Z.WALL_STRAIGHT,i,a,s),this.spawnedLocations.pushBack(e)}e&&(e.locIndex=o,e.shape=s,e.angle=a),this.addLoc(this.currentLevel,r,n,o,a,s,h)}}else if(t===v.Z.LOC_ANIM){const t=e.g1>>2,i=N.m.layer(t),a=e.g2;if(r>=0&&n>=0&&r>14&32767,this.currentLevel,i,r,n,s.Z.instances[a],!1);this.locList.pushBack(t)}}}else if(t===v.Z.OBJ_ADD){const t=e.g2,i=e.g2;if(r>=0&&n>=0&&r=0&&n>=0&&r=0&&n>=0&&r=0&&i>=0&&t=0&&n>=0&&r=0&&n>=0&&r>2,s=3&t,h=N.m.layer(i),o=e.g2,l=e.g2,c=e.g2,d=e.g2;let u,f=e.g1b,p=e.g1b,m=e.g1b,g=e.g1b;if(u=d===this.localPid?this.localPlayer:this.players[d],u&&this.levelHeightmap){const e=new Y.Z(this.currentLevel,h,r,n,-1,s,i,l+this.loopCycle);this.temporaryLocs.pushBack(e);const t=new Y.Z(this.currentLevel,h,r,n,o,s,i,c+this.loopCycle);this.temporaryLocs.pushBack(t);const d=this.levelHeightmap[this.currentLevel][r][n],y=this.levelHeightmap[this.currentLevel][r+1][n],C=this.levelHeightmap[this.currentLevel][r+1][n+1],w=this.levelHeightmap[this.currentLevel][r][n+1],T=a.Z.get(o);u.locStartCycle=l+this.loopCycle,u.locStopCycle=c+this.loopCycle,u.locModel=T.getModel(i,s,d,y,C,w,-1);let S,Z=T.width,A=T.length;s!==B.Z.NORTH&&s!==B.Z.SOUTH||(Z=T.length,A=T.width),u.locOffsetX=128*r+64*Z,u.locOffsetZ=128*n+64*A,u.locOffsetY=this.getHeightmapY(this.currentLevel,u.locOffsetX,u.locOffsetZ),f>m&&(S=f,f=m,m=S),p>g&&(S=p,p=g,g=S),u.minTileX=r+f,u.maxTileX=r+m,u.minTileZ=n+p,u.maxTileZ=n+g}}else if(t===v.Z.OBJ_COUNT){const t=e.g2,i=e.g2,s=e.g2;if(r>=0&&n>=0&&r{if(!J.K.lowMemory){if(f.Z.textureCycle[17]>=e){const e=f.Z.textures[17];if(!e)return;const t=e.width*e.height-1,i=e.width*this.sceneDelta*2,s=e.pixels,a=this.textureBuffer;for(let e=0;e<=t;e++)a[e]=s[e-i&t];e.pixels=a,this.textureBuffer=s,f.Z.pushTexture(17)}if(f.Z.textureCycle[24]>=e){const e=f.Z.textures[24];if(!e)return;const t=e.width*e.height-1,i=e.width*this.sceneDelta*2,s=e.pixels,a=this.textureBuffer;for(let e=0;e<=t;e++)a[e]=s[e-i&t];e.pixels=a,this.textureBuffer=s,f.Z.pushTexture(24)}}};updateFlames=()=>{if(this.flameBuffer3&&this.flameBuffer2&&this.flameBuffer0&&this.flameLineOffset){for(let e=10;e<117;e++)(100*Math.random()|0)<50&&(this.flameBuffer3[e+32512]=255);for(let e=0;e<100;e++){const e=2+(124*Math.random()|0)+(128+(128*Math.random()|0)<<7);this.flameBuffer3[e]=192}for(let e=1;e<255;e++)for(let t=1;t<127;t++){const i=t+(e<<7);this.flameBuffer2[i]=(this.flameBuffer3[i-1]+this.flameBuffer3[i+1]+this.flameBuffer3[i-128]+this.flameBuffer3[i+128])/4|0}this.flameCycle0+=128,this.flameCycle0>this.flameBuffer0.length&&(this.flameCycle0-=this.flameBuffer0.length,this.updateFlameBuffer(this.imageRunes[12*Math.random()|0]));for(let e=1;e<255;e++)for(let t=1;t<127;t++){const i=t+(e<<7);let s=this.flameBuffer2[i+128]-(this.flameBuffer0[i+this.flameCycle0&this.flameBuffer0.length-1]/5|0);s<0&&(s=0),this.flameBuffer3[i]=s}for(let e=0;e<255;e++)this.flameLineOffset[e]=this.flameLineOffset[e+1];if(this.flameLineOffset[255]=16*Math.sin(this.loopCycle/14)+14*Math.sin(this.loopCycle/15)+12*Math.sin(this.loopCycle/16)|0,this.flameGradientCycle0>0&&(this.flameGradientCycle0-=4),this.flameGradientCycle1>0&&(this.flameGradientCycle1-=4),0===this.flameGradientCycle0&&0===this.flameGradientCycle1){const e=2e3*Math.random()|0;0===e?this.flameGradientCycle0=1024:1===e&&(this.flameGradientCycle1=1024)}}};mix=(e,t,i)=>{const s=256-t;return((16711935&e)*s+(16711935&i)*t&4278255360)+((65280&e)*s+(65280&i)*t&16711680)>>8};drawFlames=()=>{if(!(this.flameGradient&&this.flameGradient0&&this.flameGradient1&&this.flameGradient2&&this.flameLineOffset&&this.flameBuffer3))return;const e=256;if(this.flameGradientCycle0>0)for(let e=0;e<256;e++)this.flameGradientCycle0>768?this.flameGradient[e]=this.mix(this.flameGradient0[e],1024-this.flameGradientCycle0,this.flameGradient1[e]):this.flameGradientCycle0>256?this.flameGradient[e]=this.flameGradient1[e]:this.flameGradient[e]=this.mix(this.flameGradient1[e],256-this.flameGradientCycle0,this.flameGradient0[e]);else if(this.flameGradientCycle1>0)for(let e=0;e<256;e++)this.flameGradientCycle1>768?this.flameGradient[e]=this.mix(this.flameGradient0[e],1024-this.flameGradientCycle1,this.flameGradient2[e]):this.flameGradientCycle1>256?this.flameGradient[e]=this.flameGradient2[e]:this.flameGradient[e]=this.mix(this.flameGradient2[e],256-this.flameGradientCycle1,this.flameGradient0[e]);else for(let e=0;e<256;e++)this.flameGradient[e]=this.flameGradient0[e];for(let e=0;e<33920;e++)this.imageTitle0&&this.imageFlamesLeft&&(this.imageTitle0.pixels[e]=this.imageFlamesLeft.pixels[e]);let t=0,i=1152;for(let s=1;s<255;s++){let a=22+(this.flameLineOffset[s]*(e-s)/e|0);a<0&&(a=0),t+=a;for(let e=a;e<128;e++){let e=this.flameBuffer3[t++];if(0===e)i++;else{const t=e,s=256-e;if(e=this.flameGradient[e],this.imageTitle0){const a=this.imageTitle0.pixels[i];this.imageTitle0.pixels[i++]=((16711935&e)*t+(16711935&a)*s&4278255360)+((65280&e)*t+(65280&a)*s&16711680)>>8}}}i+=a}this.imageTitle0?.draw(0,0);for(let e=0;e<33920;e++)this.imageTitle1&&this.imageFlamesRight&&(this.imageTitle1.pixels[e]=this.imageFlamesRight.pixels[e]);t=0,i=1176;for(let s=1;s<255;s++){const a=this.flameLineOffset[s]*(e-s)/e|0,r=103-a;i+=a;for(let e=0;e>8}}}t+=128-r,i+=128-r-a}this.imageTitle1?.draw(661,0)}}console.log(`RS2 user client - release #${J.K.clientversion}`),await(0,te.O)(),(new e).run().then((()=>{})),t()}catch(e){t(e)}}),1)},1995:(e,t,i)=>{i.d(t,{Z:()=>l});var s=i(651),a=i(8078),r=i(1519),n=i(9839),h=i(6884),o=i(6121);class l{static getParameter(e){return new URLSearchParams(window.location.search).get(e)??""}static setParameter(e,t){const i=new URL(window.location.toString());i.searchParams.set(e,t),window.history.pushState(null,"",i.toString())}slowestMS=0;averageMS=[];averageIndexMS=0;drawArea=null;state=0;deltime=20;mindel=1;otim=[];fps=0;fpos=0;frameTime=[];redrawScreen=!0;resizeToFit=!1;idleCycles=0;mouseButton=0;mouseX=0;mouseY=0;mouseClickButton=0;mouseClickX=0;mouseClickY=0;actionKey=[];keyQueue=[];keyQueueReadPos=0;keyQueueWritePos=0;constructor(e=!1){o.E1.fillStyle="black",o.E1.fillRect(0,0,o.JQ.width,o.JQ.height),this.resizeToFit=e,this.resizeToFit?this.resize(window.innerWidth,window.innerHeight):this.resize(o.JQ.width,o.JQ.height)}get width(){return o.JQ.width}get height(){return o.JQ.height}resize(e,t){o.JQ.width=e,o.JQ.height=t,this.drawArea=new s.Z(e,t),a.Z.init2D()}async run(){window.addEventListener("resize",(()=>{this.resizeToFit&&this.resize(window.innerWidth,window.innerHeight)}),!1),window.addEventListener("keydown",this.keyPressed),window.addEventListener("keyup",this.keyReleased),window.addEventListener("mousedown",this.mousePressed),window.addEventListener("mouseup",this.mouseReleased),window.addEventListener("mouseenter",this.mouseEntered),window.addEventListener("mouseleave",this.mouseExited),window.addEventListener("mousemove",this.mouseMoved),window.addEventListener("focusin",this.focusGained),window.addEventListener("focusout",this.focusLost),window.addEventListener("beforeunload",this.unload),o.JQ.oncontextmenu=e=>{e.preventDefault()},await this.showProgress(0,"Loading..."),await this.load();for(let e=0;e<10;e++)this.otim[e]=Date.now();let e,t=0,i=256,s=1,a=0;for(;this.state>=0;){if(this.state>0&&(this.state--,0===this.state))return void this.shutdown();const n=i,h=s;i=300,s=1,e=Date.now();const o=this.otim[t];if(0===o?(i=n,s=h):e>o&&(i=2560*this.deltime/(e-o)|0),i<25?i=25:i>256&&(i=256,s=this.deltime-(e-o)/10|0),this.otim[t]=e,t=(t+1)%10,s>1)for(let e=0;e<10;e++)0!==this.otim[e]&&(this.otim[e]+=s);for(s0&&(this.fps=1e3*i/(256*this.deltime)|0);const l=performance.now();this.redrawScreen&&this.refresh(),await this.draw(),this.frameTime[this.fpos]=(performance.now()-l)/1e3,this.fpos=(this.fpos+1)%this.frameTime.length}-1===this.state&&this.shutdown()}shutdown(){this.state=-2,this.unload()}setFramerate(e){this.deltime=1e3/e|0}start(){this.state>=0&&(this.state=0)}stop(){this.state>=0&&(this.state=4e3/this.deltime|0)}destroy(){this.state=-1}async load(){}async update(){}unload(){}async draw(){}refresh(){}async showProgress(e,t){const i=this.width,s=this.height;this.redrawScreen&&(o.E1.fillStyle="black",o.E1.fillRect(0,0,i,s),this.redrawScreen=!1);const a=s/2-18;o.E1.fillStyle="rgb(140, 17, 17)",o.E1.rect((i/2|0)-152,a,304,34),o.E1.fillRect((i/2|0)-150,a+2,3*e,30),o.E1.fillStyle="black",o.E1.fillRect((i/2|0)-150+3*e,a+2,300-3*e,30),o.E1.font="bold 13px helvetica, sans-serif",o.E1.textAlign="center",o.E1.fillStyle="white",o.E1.fillText(t,i/2|0,a+22),await(0,r._v)(5)}keyPressed=e=>{const t=e.key;n.v.includes(t)&&e.preventDefault(),this.idleCycles=0;const i=n.n[t];if(!i)return void console.error(`Unhandled key ${t}`);const s=i.key;let a=i.ch;a<30&&(a=0),37===s?a=1:39===s?a=2:38===s?a=3:40===s?a=4:17===s?a=5:8===s||127===s?a=8:9===s?a=9:10===s?a=10:s>=112&&s<=123?a=s+1008-112:36===s?a=1e3:35===s?a=1001:33===s?a=1002:34===s&&(a=1003),a>0&&a<128&&(this.actionKey[a]=1),a>4&&(this.keyQueue[this.keyQueueWritePos]=a,this.keyQueueWritePos=this.keyQueueWritePos+1&127),h.Z.enabled&&h.Z.keyPressed(a)};keyReleased=e=>{const t=e.key;n.v.includes(t)&&e.preventDefault(),this.idleCycles=0;const i=n.n[t];if(!i)return void console.error(`Unhandled key ${t}`);const s=i.key;let a=i.ch;a<30&&(a=0),37===s?a=1:39===s?a=2:38===s?a=3:40===s?a=4:17===s?a=5:8===s||127===s?a=8:9===s?a=9:10===s?a=10:s>=112&&s<=123?a=s+1008-112:36===s?a=1e3:35===s?a=1001:33===s?a=1002:34===s&&(a=1003),a>0&&a<128&&(this.actionKey[a]=0),h.Z.enabled&&h.Z.keyReleased(a)};pollKey(){let e=-1;return this.keyQueueWritePos!==this.keyQueueReadPos&&(e=this.keyQueue[this.keyQueueReadPos],this.keyQueueReadPos=this.keyQueueReadPos+1&127),e}mousePressed=e=>{let t=e.x,i=e.y;const{top:s,left:a}=this.getInsets;t-=a,i-=s;const r=o.JQ.getBoundingClientRect();t*=o.JQ.width/r.width,i*=o.JQ.height/r.height,t|=0,i|=0,this.idleCycles=0,this.mouseClickX=t,this.mouseClickY=i,2===e.buttons?(this.mouseClickButton=2,this.mouseButton=2):1===e.buttons&&(this.mouseClickButton=1,this.mouseButton=1),h.Z.enabled};mouseReleased=e=>{this.idleCycles=0,this.mouseButton=0,h.Z.enabled};mouseEntered=e=>{h.Z.enabled&&h.Z.mouseEntered()};mouseExited=e=>{h.Z.enabled&&h.Z.mouseExited()};mouseMoved=e=>{let t=e.x,i=e.y;const{top:s,left:a}=this.getInsets;t-=a,i-=s;const r=o.JQ.getBoundingClientRect();t*=o.JQ.width/r.width,i*=o.JQ.height/r.height,t|=0,i|=0,this.idleCycles=0,this.mouseX=t,this.mouseY=i,h.Z.enabled&&h.Z.mouseMoved(t,i)};focusGained=e=>{this.redrawScreen=!0,this.refresh(),h.Z.enabled&&h.Z.focusGained()};focusLost=e=>{h.Z.enabled&&h.Z.focusLost()};get ms(){const e=this.frameTime.length;let t=0;for(let i=0;ithis.slowestMS&&(this.slowestMS=i),this.averageMS[this.averageIndexMS]=i,this.averageIndexMS=(this.averageIndexMS+1)%250,i}get msAvg(){return this.averageMS.reduce(((e,t)=>e+t),0)/250}get getInsets(){const e=o.JQ.getBoundingClientRect(),t=window.getComputedStyle(o.JQ),i=parseFloat(t.paddingLeft||"0"),s=parseFloat(t.paddingTop||"0"),a=parseFloat(t.borderLeftWidth||"0"),r=parseFloat(t.borderTopWidth||"0"),n=e.left+a+i;return{top:e.top+r+s,left:n}}}},6884:(e,t,i)=>{i.d(t,{Z:()=>a});var s=i(2383);class a{static enabled=!1;static outBuffer=null;static oldBuffer=null;static lastTime=0;static trackedCount=0;static lastMoveTime=0;static lastX=0;static lastY=0;static setEnabled=()=>{this.outBuffer=s.Z.alloc(1),this.oldBuffer=null,this.lastTime=Date.now(),this.enabled=!0};static setDisabled=()=>{this.enabled=!1,this.outBuffer=null};static flush=()=>{let e=null;return this.oldBuffer&&this.enabled&&(e=this.oldBuffer),this.oldBuffer=null,e};static stop=()=>{let e=null;return this.outBuffer&&this.outBuffer.pos>0&&this.enabled&&(e=this.outBuffer),this.setDisabled(),e};static mousePressed=(e,t,i)=>{if(!(this.enabled&&e>=0&&e<789&&t>=0&&t<532))return;this.trackedCount++;const s=Date.now();let a=(s-this.lastTime)/10|0;a>250&&(a=250),this.lastTime=s,this.ensureCapacity(5),1===i?this.outBuffer?.p1(1):this.outBuffer?.p1(2),this.outBuffer?.p1(a),this.outBuffer?.p3(e+(t<<10))};static mouseReleased=e=>{if(!this.enabled)return;this.trackedCount++;const t=Date.now();let i=(t-this.lastTime)/10|0;i>250&&(i=250),this.lastTime=t,this.ensureCapacity(2),1===e?this.outBuffer?.p1(3):this.outBuffer?.p1(4),this.outBuffer?.p1(i)};static mouseMoved=(e,t)=>{if(!(this.enabled&&e>=0&&e<789&&t>=0&&t<532))return;const i=Date.now();if(i-this.lastMoveTime>=50){this.lastMoveTime=i,this.trackedCount++;let s=(i-this.lastTime)/10|0;s>250&&(s=250),this.lastTime=i,e-this.lastX<8&&e-this.lastX>=-8&&t-this.lastY<8&&t-this.lastY>=-8?(this.ensureCapacity(3),this.outBuffer?.p1(5),this.outBuffer?.p1(s),this.outBuffer?.p1(e+(t-this.lastY+8<<4)+8-this.lastX)):e-this.lastX<128&&e-this.lastX>=-128&&t-this.lastY<128&&t-this.lastY>=-128?(this.ensureCapacity(4),this.outBuffer?.p1(6),this.outBuffer?.p1(s),this.outBuffer?.p1(e+128-this.lastX),this.outBuffer?.p1(t+128-this.lastY)):(this.ensureCapacity(5),this.outBuffer?.p1(7),this.outBuffer?.p1(s),this.outBuffer?.p3(e+(t<<10))),this.lastX=e,this.lastY=t}};static keyPressed=e=>{if(!this.enabled)return;this.trackedCount++;const t=Date.now();let i=(t-this.lastTime)/10|0;i>250&&(i=250),this.lastTime=t,1e3===e?e=11:1001===e?e=12:1002===e?e=14:1003===e?e=15:e>=1008&&(e-=992),this.ensureCapacity(3),this.outBuffer?.p1(8),this.outBuffer?.p1(i),this.outBuffer?.p1(e)};static keyReleased=e=>{if(!this.enabled)return;this.trackedCount++;const t=Date.now();let i=(t-this.lastTime)/10|0;i>250&&(i=250),this.lastTime=t,1e3===e?e=11:1001===e?e=12:1002===e?e=14:1003===e?e=15:e>=1008&&(e-=992),this.ensureCapacity(3),this.outBuffer?.p1(9),this.outBuffer?.p1(i),this.outBuffer?.p1(e)};static focusGained=()=>{if(!this.enabled)return;this.trackedCount++;const e=Date.now();let t=(e-this.lastTime)/10|0;t>250&&(t=250),this.lastTime=e,this.ensureCapacity(2),this.outBuffer?.p1(10),this.outBuffer?.p1(t)};static focusLost=()=>{if(!this.enabled)return;this.trackedCount++;const e=Date.now();let t=(e-this.lastTime)/10|0;t>250&&(t=250),this.lastTime=e,this.ensureCapacity(2),this.outBuffer?.p1(11),this.outBuffer?.p1(t)};static mouseEntered=()=>{if(!this.enabled)return;this.trackedCount++;const e=Date.now();let t=(e-this.lastTime)/10|0;t>250&&(t=250),this.lastTime=e,this.ensureCapacity(2),this.outBuffer?.p1(12),this.outBuffer?.p1(t)};static mouseExited=()=>{if(!this.enabled)return;this.trackedCount++;const e=Date.now();let t=(e-this.lastTime)/10|0;t>250&&(t=250),this.lastTime=e,this.ensureCapacity(2),this.outBuffer?.p1(13),this.outBuffer?.p1(t)};static ensureCapacity=e=>{if(this.outBuffer&&this.outBuffer.pos+e>=500){const e=this.outBuffer;this.outBuffer=s.Z.alloc(1),this.oldBuffer=e}}}},9839:(e,t,i)=>{i.d(t,{n:()=>s,v:()=>a});const s={Backspace:{key:8,ch:8},Enter:{key:10,ch:10},Shift:{key:16,ch:65535},Escape:{key:27,ch:27},Tab:{key:9,ch:9},CapsLock:{key:20,ch:65535}," ":{key:32,ch:32},Control:{key:17,ch:65535},Alt:{key:18,ch:65535},Meta:{key:524,ch:65535},ArrowLeft:{key:37,ch:65535},ArrowRight:{key:39,ch:65535},ArrowUp:{key:38,ch:65535},ArrowDown:{key:40,ch:65535},Insert:{key:155,ch:65535},Home:{key:36,ch:65535},PageUp:{key:33,ch:65535},Delete:{key:127,ch:127},End:{key:35,ch:65535},PageDown:{key:34,ch:65535},"`":{key:192,ch:96},"~":{key:192,ch:126},"!":{key:49,ch:33},"@":{key:50,ch:64},"#":{key:51,ch:35},$:{key:52,ch:36},"%":{key:53,ch:37},"^":{key:54,ch:94},"&":{key:55,ch:38},"*":{key:56,ch:42},"(":{key:57,ch:40},")":{key:48,ch:41},"-":{key:45,ch:45},_:{key:45,ch:95},"=":{key:61,ch:61},"+":{key:61,ch:43},"[":{key:91,ch:91},"{":{key:91,ch:123},"]":{key:93,ch:93},"}":{key:93,ch:125},"\\":{key:92,ch:92},"|":{key:92,ch:124},";":{key:59,ch:59},":":{key:59,ch:58},"'":{key:222,ch:39},'"':{key:222,ch:34},",":{key:44,ch:44},"<":{key:44,ch:60},".":{key:46,ch:46},">":{key:46,ch:62},"/":{key:47,ch:47},"?":{key:47,ch:63},F1:{key:112,ch:65535},F2:{key:113,ch:65535},F3:{key:114,ch:65535},F4:{key:115,ch:65535},F5:{key:116,ch:65535},F6:{key:117,ch:65535},F7:{key:118,ch:65535},F8:{key:119,ch:65535},F9:{key:120,ch:65535},F10:{key:121,ch:65535},F11:{key:122,ch:65535},F12:{key:123,ch:65535},0:{key:48,ch:48},1:{key:49,ch:49},2:{key:50,ch:50},3:{key:51,ch:51},4:{key:52,ch:52},5:{key:53,ch:53},6:{key:54,ch:54},7:{key:55,ch:55},8:{key:56,ch:56},9:{key:57,ch:57},a:{key:65,ch:97},b:{key:66,ch:98},c:{key:67,ch:99},d:{key:68,ch:100},e:{key:69,ch:101},f:{key:70,ch:102},g:{key:71,ch:103},h:{key:72,ch:104},i:{key:73,ch:105},j:{key:74,ch:106},k:{key:75,ch:107},l:{key:76,ch:108},m:{key:77,ch:109},n:{key:78,ch:110},o:{key:79,ch:111},p:{key:80,ch:112},q:{key:81,ch:113},r:{key:82,ch:114},s:{key:83,ch:115},t:{key:84,ch:116},u:{key:85,ch:117},v:{key:86,ch:118},w:{key:87,ch:119},x:{key:88,ch:120},y:{key:89,ch:121},z:{key:90,ch:122},A:{key:65,ch:65},B:{key:66,ch:66},C:{key:67,ch:67},D:{key:68,ch:68},E:{key:69,ch:69},F:{key:70,ch:70},G:{key:71,ch:71},H:{key:72,ch:72},I:{key:73,ch:73},J:{key:74,ch:74},K:{key:75,ch:75},L:{key:76,ch:76},M:{key:77,ch:77},N:{key:78,ch:78},O:{key:79,ch:79},P:{key:80,ch:80},Q:{key:81,ch:81},R:{key:82,ch:82},S:{key:83,ch:83},T:{key:84,ch:84},U:{key:85,ch:85},V:{key:86,ch:86},W:{key:87,ch:87},X:{key:88,ch:88},Y:{key:89,ch:89},Z:{key:90,ch:90}},a=["Tab","F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","ArrowLeft","ArrowRight","ArrowUp","ArrowDown"]},2790:(e,t,i)=>{i.d(t,{Z:()=>c});var s=i(2383),a=i(9178),r=i(5542),n=i(6542),h=i(8934),o=i(9345),l=i(2991);class c{static instances=[];static imageCache=null;static modelCache=null;static TYPE_LAYER=0;static TYPE_UNUSED=1;static TYPE_INV=2;static TYPE_RECT=3;static TYPE_TEXT=4;static TYPE_GRAPHIC=5;static TYPE_MODEL=6;static TYPE_INV_TEXT=7;static BUTTON_OK=1;static BUTTON_TARGET=2;static BUTTON_CLOSE=3;static BUTTON_TOGGLE=4;static BUTTON_SELECT=5;static BUTTON_CONTINUE=6;static CC_FRIENDS_START=1;static CC_FRIENDS_END=100;static CC_FRIENDS_UPDATE_START=101;static CC_FRIENDS_UPDATE_END=200;static CC_ADD_FRIEND=201;static CC_DEL_FRIEND=202;static CC_FRIENDS_SIZE=203;static CC_LOGOUT=205;static CC_CHANGE_HEAD_L=300;static CC_CHANGE_HEAD_R=301;static CC_CHANGE_JAW_L=302;static CC_CHANGE_JAW_R=303;static CC_CHANGE_TORSO_L=304;static CC_CHANGE_TORSO_R=305;static CC_CHANGE_ARMS_L=306;static CC_CHANGE_ARMS_R=307;static CC_CHANGE_HANDS_L=308;static CC_CHANGE_HANDS_R=309;static CC_CHANGE_LEGS_L=310;static CC_CHANGE_LEGS_R=311;static CC_CHANGE_FEET_L=312;static CC_CHANGE_FEET_R=313;static CC_RECOLOUR_HAIR_L=314;static CC_RECOLOUR_HAIR_R=315;static CC_RECOLOUR_TORSO_L=316;static CC_RECOLOUR_TORSO_R=317;static CC_RECOLOUR_LEGS_L=318;static CC_RECOLOUR_LEGS_R=319;static CC_RECOLOUR_FEET_L=320;static CC_RECOLOUR_FEET_R=321;static CC_RECOLOUR_SKIN_L=322;static CC_RECOLOUR_SKIN_R=323;static CC_SWITCH_TO_MALE=324;static CC_SWITCH_TO_FEMALE=325;static CC_ACCEPT_DESIGN=326;static CC_DESIGN_PREVIEW=327;static CC_IGNORES_START=401;static CC_IGNORES_END=500;static CC_ADD_IGNORE=501;static CC_DEL_IGNORE=502;static CC_IGNORES_SIZE=503;static CC_REPORT_INPUT=600;static CC_REPORT_RULE1=601;static CC_REPORT_RULE2=602;static CC_REPORT_RULE3=603;static CC_REPORT_RULE4=604;static CC_REPORT_RULE5=605;static CC_REPORT_RULE6=606;static CC_REPORT_RULE7=607;static CC_REPORT_RULE8=608;static CC_REPORT_RULE9=609;static CC_REPORT_RULE10=610;static CC_REPORT_RULE11=611;static CC_REPORT_RULE12=612;static CC_MOD_MUTE=613;static CC_LAST_LOGIN_INFO=650;static CC_UNREAD_MESSAGES=651;static CC_RECOVERY1=652;static CC_RECOVERY2=653;static CC_RECOVERY3=654;static CC_LAST_LOGIN_INFO2=655;static unpack=(e,t,i)=>{this.imageCache=new r.Z(5e4),this.modelCache=new r.Z(5e4);const a=new s.Z(e.read("data"));let n=-1;for(a.pos+=2;a.pos0){s.scriptComparator=new Uint8Array(r),s.scriptOperand=new Uint16Array(r);for(let e=0;e0){s.scripts=new o.to(h,null);for(let e=0;e0){const a=i.lastIndexOf(",");s.invSlotSprite[e]=this.getImage(t,i.substring(0,a),parseInt(i.substring(a+1),10))}}s.iops=new o.to(5,null);for(let e=0;e<5;e++){const t=a.gjstr;s.iops[e]=t,0===t.length&&(s.iops[e]=null)}}if(s.type===c.TYPE_RECT&&(s.fill=1===a.g1),s.type===c.TYPE_TEXT||s.type===c.TYPE_UNUSED){s.center=1===a.g1;const e=a.g1;i&&(s.font=i[e]),s.shadowed=1===a.g1}if(s.type===c.TYPE_TEXT&&(s.text=a.gjstr,s.activeText=a.gjstr),s.type!==c.TYPE_UNUSED&&s.type!==c.TYPE_RECT&&s.type!==c.TYPE_TEXT||(s.colour=a.g4),s.type!==c.TYPE_RECT&&s.type!==c.TYPE_TEXT||(s.activeColour=a.g4,s.overColour=a.g4),s.type===c.TYPE_GRAPHIC){const e=a.gjstr;if(e.length>0){const i=e.lastIndexOf(",");s.graphic=this.getImage(t,e.substring(0,i),parseInt(e.substring(i+1),10))}const i=a.gjstr;if(i.length>0){const e=i.lastIndexOf(",");s.activeGraphic=this.getImage(t,i.substring(0,e),parseInt(i.substring(e+1),10))}}if(s.type===c.TYPE_MODEL){const e=a.g1;0!==e&&(s.model=this.getModel((e-1<<8)+a.g1));const t=a.g1;0!==t&&(s.activeModel=this.getModel((t-1<<8)+a.g1)),s.anim=a.g1,0===s.anim?s.anim=-1:s.anim=(s.anim-1<<8)+a.g1,s.activeAnim=a.g1,0===s.activeAnim?s.activeAnim=-1:s.activeAnim=(s.activeAnim-1<<8)+a.g1,s.zoom=a.g2,s.xan=a.g2,s.yan=a.g2}if(s.type===c.TYPE_INV_TEXT){s.invSlotObjId=new Int32Array(s.width*s.height),s.invSlotObjCount=new Int32Array(s.width*s.height),s.center=1===a.g1;const e=a.g1;i&&(s.font=i[e]),s.shadowed=1===a.g1,s.colour=a.g4,s.marginX=a.g2b,s.marginY=a.g2b,s.interactable=1===a.g1,s.iops=new o.to(5,null);for(let e=0;e<5;e++){const t=a.gjstr;s.iops[e]=t,0===t.length&&(s.iops[e]=null)}}s.buttonType!==c.BUTTON_TARGET&&s.type!==c.TYPE_INV||(s.actionVerb=a.gjstr,s.action=a.gjstr,s.actionTarget=a.g2),s.buttonType!==c.BUTTON_OK&&s.buttonType!==c.BUTTON_TOGGLE&&s.buttonType!==c.BUTTON_SELECT&&s.buttonType!==c.BUTTON_CONTINUE||(s.option=a.gjstr,0===s.option.length&&(s.buttonType===c.BUTTON_OK?s.option="Ok":s.buttonType===c.BUTTON_TOGGLE||s.buttonType===c.BUTTON_SELECT?s.option="Select":s.buttonType===c.BUTTON_CONTINUE&&(s.option="Continue")))}this.imageCache=null,this.modelCache=null};static getImage=(e,t,i)=>{const s=h.Z.hashCode(t)<<8n|BigInt(i);if(this.imageCache){const e=this.imageCache.get(s);if(e)return e}let a;try{a=n.Z.fromArchive(e,t,i),this.imageCache?.put(s,a)}catch(e){return null}return a};static getModel=e=>{if(this.modelCache){const t=this.modelCache.get(BigInt(e));if(t)return t}const t=a.Z.model(e);return this.modelCache?.put(BigInt(e),t),t};id=-1;layer=-1;type=-1;buttonType=-1;clientCode=0;width=0;height=0;overLayer=-1;scriptComparator=null;scriptOperand=null;scripts=null;scroll=0;hide=!1;draggable=!1;interactable=!1;usable=!1;marginX=0;marginY=0;invSlotOffsetX=null;invSlotOffsetY=null;invSlotSprite=null;iops=null;fill=!1;center=!1;font=null;shadowed=!1;text=null;activeText=null;colour=0;activeColour=0;overColour=0;graphic=null;activeGraphic=null;model=null;activeModel=null;anim=-1;activeAnim=-1;zoom=0;xan=0;yan=0;actionVerb=null;action=null;actionTarget=-1;option=null;childId=null;childX=null;childY=null;x=0;y=0;scrollPosition=0;invSlotObjId=null;invSlotObjCount=null;seqFrame=0;seqCycle=0;getModel=(e,t,i)=>{let s=this.model;if(i&&(s=this.activeModel),!s)return null;if(-1===e&&-1===t&&!s.faceColor)return s;const r=a.Z.modelShareColored(s,!0,!0,!1);return-1===e&&-1===t||r.createLabelReferences(),-1!==e&&r.applyTransform(e),-1!==t&&r.applyTransform(t),r.calculateNormals(64,768,-50,-10,-50,!0),r};getAbsoluteX(){if(this.layer===this.id)return this.x;let e=c.instances[this.layer];if(!e.childId||!e.childX||!e.childY)return this.x;let t=e.childId.indexOf(this.id);if(-1===t)return this.x;let i=e.childX[t];for(;e.layer!==e.id;){const s=c.instances[e.layer];s.childId&&s.childX&&s.childY&&(t=s.childId.indexOf(e.id),-1!==t&&(i+=s.childX[t])),e=s}return i}getAbsoluteY(){if(this.layer===this.id)return this.y;let e=c.instances[this.layer];if(!e.childId||!e.childX||!e.childY)return this.y;let t=e.childId.indexOf(this.id);if(-1===t)return this.y;let i=e.childY[t];for(;e.layer!==e.id;){const s=c.instances[e.layer];s.childId&&s.childX&&s.childY&&(t=s.childId.indexOf(e.id),-1!==t&&(i+=s.childY[t])),e=s}return i}outline(e){const t=this.getAbsoluteX(),i=this.getAbsoluteY();l.Z.drawRect(t,i,this.width,this.height,e)}move(e,t){if(this.layer===this.id)return;this.x=0,this.y=0;const i=c.instances[this.layer];if(i.childId&&i.childX&&i.childY){const s=i.childId.indexOf(this.id);-1!==s&&(i.childX[s]=e,i.childY[s]=t)}}delete(){if(this.layer===this.id)return;const e=c.instances[this.layer];if(e.childId&&e.childX&&e.childY){const t=e.childId.indexOf(this.id);-1!==t&&(e.childId.splice(t,1),e.childX.splice(t,1),e.childY.splice(t,1))}}}},8107:(e,t,i)=>{i.d(t,{r:()=>s});class s{id=-1;debugname=null;decodeType=(e,t)=>{for(this.id=e;;){const i=t.g1;if(0===i)break;this.decode(e,i,t)}}}},8056:(e,t,i)=>{i.d(t,{Z:()=>r});var s=i(2383),a=i(8107);class r extends a.r{static count=0;static instances=[];static unpack=e=>{const t=new s.Z(e.read("flo.dat"));this.count=t.g2;for(let e=0;e(i>179&&(t=t/2|0),i>192&&(t=t/2|0),i>217&&(t=t/2|0),i>243&&(t=t/2|0),((e/4|0)<<10)+((t/32|0)<<7)+(i/2|0));static mulHSL=(e,t)=>-1===e?12345678:((t=t*(127&e)/128|0)<2?t=2:t>126&&(t=126),(65408&e)+t);static adjustLightness=(e,t)=>-2===e?12345678:-1===e?(t<0?t=0:t>127&&(t=127),127-t):((t=t*(127&e)/128|0)<2?t=2:t>126&&(t=126),(65408&e)+t);rgb=0;texture=-1;opcode3=!1;occlude=!0;name=null;hue=0;saturation=0;lightness=0;luminance=0;chroma=0;hsl=0;decode=(e,t,i)=>{1===t?(this.rgb=i.g3,this.setColor(this.rgb)):2===t?this.texture=i.g1:3===t?this.opcode3=!0:5===t?this.occlude=!1:6===t?this.name=i.gjstr:console.log("Error unrecognised config code: ",t)};setColor=e=>{const t=(e>>16&255)/256,i=(e>>8&255)/256,s=(255&e)/256;let a=t;it&&(n=i),s>n&&(n=s);let h=0,o=0;const l=(a+n)/2;a!==n&&(l<.5&&(o=(n-a)/(n+a)),l>=.5&&(o=(n-a)/(2-n-a)),t===n?h=(i-s)/(n-a):i===n?h=(s-t)/(n-a)+2:s===n&&(h=(t-i)/(n-a)+4)),h/=6,this.hue=256*h|0,this.saturation=256*o|0,this.lightness=256*l|0,this.saturation<0?this.saturation=0:this.saturation>255&&(this.saturation=255),this.lightness<0?this.lightness=0:this.lightness>255&&(this.lightness=255),this.luminance=l>.5?(1-l)*o*512|0:l*o*512|0,this.luminance<1&&(this.luminance=1),this.chroma=h*this.luminance|0;let c=this.hue+(16*Math.random()|0)-8;c<0?c=0:c>255&&(c=255);let d=this.saturation+(48*Math.random()|0)-24;d<0?d=0:d>255&&(d=255);let u=this.lightness+(48*Math.random()|0)-24;u<0?u=0:u>255&&(u=255),this.hsl=r.hsl24to16(c,d,u)}}},8809:(e,t,i)=>{i.d(t,{Z:()=>h});var s=i(2383),a=i(8107),r=i(9178),n=i(9345);class h extends a.r{static count=0;static instances=[];static unpack=e=>{const t=new s.Z(e.read("idk.dat"));this.count=t.g2;for(let e=0;e{if(1===t)this.type=i.g1;else if(2===t){const e=i.g1;this.models=new Int32Array(e);for(let t=0;t=40&&t<50)this.recol_s[t-40]=i.g2;else if(t>=50&&t<60)this.recol_d[t-50]=i.g2;else{if(!(t>=60&&t<70))throw new Error(`Unrecognized idk config code: ${t}`);this.heads[t-60]=i.g2}};getModel=()=>{if(!this.models)return null;const e=new n.to(this.models.length,null);for(let t=0;t{let e=0;const t=new n.to(5,null);for(let i=0;i<5;i++)-1!==this.heads[i]&&(t[e++]=r.Z.model(this.heads[i]));const i=r.Z.modelFromModels(t,e);for(let e=0;e<6&&0!==this.recol_s[e];e++)i.recolor(this.recol_s[e],this.recol_d[e]);return i}}},7958:(e,t,i)=>{i.d(t,{Z:()=>c});var s=i(8107),a=i(2383),r=i(5542),n=i(9178),h=i(1908),o=i(5534),l=i(9345);class c extends s.r{static count=0;static cache=null;static dat=null;static offsets=null;static cachePos=0;static modelCacheStatic=new r.Z(500);static modelCacheDynamic=new r.Z(30);static unpack=e=>{this.dat=new a.Z(e.read("loc.dat"));const t=new a.Z(e.read("loc.idx"));this.count=t.g2,this.offsets=new Int32Array(this.count);let i=2;for(let e=0;e{if(!this.cache||!this.offsets||!this.dat)throw new Error("LocType not loaded!!!");for(let t=0;t<10;t++){const i=this.cache[t];if(i&&i.index===e)return i}this.cachePos=(this.cachePos+1)%10;const t=this.cache[this.cachePos];return this.dat.pos=this.offsets[e],t.index=e,t.reset(),t.decodeType(e,this.dat),t.shapes||(t.shapes=new Int32Array(1)),-1===t.active2&&t.shapes&&(t.active=t.shapes.length>0&&t.shapes[0]===h.Z.CENTREPIECE_STRAIGHT,t.ops&&(t.active=!0)),t};static unload=()=>{this.modelCacheStatic=null,this.modelCacheDynamic=null,this.offsets=null,this.cache=null,this.dat=null};index=-1;models=null;shapes=null;name=null;desc=null;recol_s=null;recol_d=null;width=1;length=1;blockwalk=!0;blockrange=!0;active=!1;active2=-1;hillskew=!1;sharelight=!1;occlude=!1;anim=-1;disposeAlpha=!1;walloff=16;ambient=0;contrast=0;ops=null;mapfunction=-1;mapscene=-1;mirror=!1;shadow=!0;resizex=128;resizey=128;resizez=128;forceapproach=0;xoff=0;yoff=0;zoff=0;forcedecor=!1;decode=(e,t,i)=>{if(1===t){const e=i.g1;this.models=new Int32Array(e),this.shapes=new Int32Array(e);for(let t=0;t=30&&t<39)this.ops||(this.ops=new l.to(5,null)),this.ops[t-30]=i.gjstr,"hidden"===this.ops[t-30]?.toLowerCase()&&(this.ops[t-30]=null);else if(40===t){const e=i.g1;this.recol_s=new Uint16Array(e),this.recol_d=new Uint16Array(e);for(let t=0;t{if(!this.shapes)return null;let l=-1;for(let t=0;t=this.models.length)return null;let f=this.models[l];if(-1===f)return null;const p=this.mirror!==t>3;p&&(f+=65536);let m=c.modelCacheStatic?.get(BigInt(f));m||(m=n.Z.model(65535&f),p&&m.rotateY180(),c.modelCacheStatic?.put(BigInt(f),m));const g=128!==this.resizex||128!==this.resizey||128!==this.resizez,y=0!==this.xoff||0!==this.yoff||0!==this.zoff;let C=n.Z.modelShareColored(m,!this.recol_s,!this.disposeAlpha,t===o.Z.WEST&&-1===h&&!g&&!y);for(-1!==h&&(C.createLabelReferences(),C.applyTransform(h),C.labelFaces=null,C.labelVertices=null);t-- >0;)C.rotateY90();if(this.recol_s&&this.recol_d)for(let e=0;e{this.models=null,this.shapes=null,this.name=null,this.desc=null,this.recol_s=null,this.recol_d=null,this.width=1,this.length=1,this.blockwalk=!0,this.blockrange=!0,this.active=!1,this.active2=-1,this.hillskew=!1,this.sharelight=!1,this.occlude=!1,this.anim=-1,this.walloff=16,this.ambient=0,this.contrast=0,this.ops=null,this.disposeAlpha=!1,this.mapfunction=-1,this.mapscene=-1,this.mirror=!1,this.shadow=!0,this.resizex=128,this.resizey=128,this.resizez=128,this.forceapproach=0,this.xoff=0,this.yoff=0,this.zoff=0,this.forcedecor=!1}}},2441:(e,t,i)=>{i.d(t,{Z:()=>o});var s=i(8107),a=i(2383),r=i(5542),n=i(9178),h=i(9345);class o extends s.r{static count=0;static cache=null;static dat=null;static offsets=null;static cachePos=0;static modelCache=new r.Z(30);static unpack=e=>{this.dat=new a.Z(e.read("npc.dat"));const t=new a.Z(e.read("npc.idx"));this.count=t.g2,this.offsets=new Int32Array(this.count);let i=2;for(let e=0;e{if(!this.cache||!this.offsets||!this.dat)throw new Error("LocType not loaded!!!");for(let t=0;t<20;t++){const i=this.cache[t];if(i&&i.index===e)return i}this.cachePos=(this.cachePos+1)%20;const t=this.cache[this.cachePos]=new o;return this.dat.pos=this.offsets[e],t.index=e,t.decodeType(e,this.dat),t};static unload=()=>{this.modelCache=null,this.offsets=null,this.cache=null,this.dat=null};index=-1;name=null;desc=null;size=1;models=null;heads=null;disposeAlpha=!1;readyanim=-1;walkanim=-1;walkanim_b=-1;walkanim_r=-1;walkanim_l=-1;hasalpha=!1;recol_s=null;recol_d=null;ops=null;code90=-1;code91=-1;code92=-1;visonmap=!0;vislevel=-1;resizeh=128;resizev=128;decode=(e,t,i)=>{if(1===t){const e=i.g1;this.models=new Uint16Array(e);for(let t=0;t=30&&t<40)this.ops||(this.ops=new h.to(5,null)),this.ops[t-30]=i.gjstr,"hidden"===this.ops[t-30]?.toLowerCase()&&(this.ops[t-30]=null);else if(40===t){const e=i.g1;this.recol_s=new Uint16Array(e),this.recol_d=new Uint16Array(e);for(let t=0;t{let s=null,a=null;if(o.modelCache&&(a=o.modelCache.get(BigInt(this.index)),!a&&this.models)){const e=new h.to(this.models.length,null);for(let t=0;t{if(!this.heads)return null;const e=new h.to(this.heads.length,null);for(let t=0;t{i.d(t,{Z:()=>u});var s=i(8107),a=i(2383),r=i(6542),n=i(5542),h=i(9178),o=i(8078),l=i(2991),c=i(312),d=i(9345);class u extends s.r{static count=0;static cache=null;static dat=null;static offsets=null;static cachePos=0;static membersWorld=!0;static modelCache=new n.Z(50);static iconCache=new n.Z(200);static unpack=(e,t)=>{this.membersWorld=t,this.dat=new a.Z(e.read("obj.dat"));const i=new a.Z(e.read("obj.idx"));this.count=i.g2,this.offsets=new Int32Array(this.count);let s=2;for(let e=0;e{if(!this.cache||!this.offsets||!this.dat)throw new Error("ObjType not loaded!!!");for(let t=0;t<10;t++){const i=this.cache[t];if(i&&i.index===e)return i}this.cachePos=(this.cachePos+1)%10;const t=this.cache[this.cachePos];return this.dat.pos=this.offsets[e],t.index=e,t.reset(),t.decodeType(e,this.dat),-1!==t.certtemplate&&t.toCertificate(),!this.membersWorld&&t.members&&(t.name="Members Object",t.desc="Login to a members' server to use this object.",t.ops=null,t.iops=null),t};static unload=()=>{this.modelCache=null,this.iconCache=null,this.offsets=null,this.cache=null,this.dat=null};static getIcon=(e,t)=>{if(u.iconCache){let i=u.iconCache.get(BigInt(e));if(i&&i.cropH!==t&&-1!==i.cropH&&(i.unlink(),i=null),i)return i}let i=u.get(e);if(i.countobj||(t=-1),i.countobj&&i.countco&&t>1){let e=-1;for(let s=0;s<10;s++)t>=i.countco[s]&&0!==i.countco[s]&&(e=i.countobj[s]);-1!==e&&(i=u.get(e))}const s=new r.Z(32,32),a=o.Z.centerX,n=o.Z.centerY,h=o.Z.lineOffset,d=l.Z.pixels,f=l.Z.width2d,p=l.Z.height2d,m=l.Z.left,g=l.Z.right,y=l.Z.top,C=l.Z.bottom;o.Z.jagged=!1,l.Z.bind(s.pixels,32,32),l.Z.fillRect(0,0,32,32,c.Z.BLACK),o.Z.init2D();const w=i.getInterfaceModel(1),T=o.Z.sin[i.xan2d]*i.zoom2d>>16,S=o.Z.cos[i.xan2d]*i.zoom2d>>16;w.drawSimple(0,i.yan2d,i.zan2d,i.xan2d,i.xof2d,T+(w.maxY/2|0)+i.yof2d,S+i.yof2d);for(let e=31;e>=0;e--)for(let t=31;t>=0;t--)0===s.pixels[e+32*t]&&(e>0&&s.pixels[e+32*t-1]>1||t>0&&s.pixels[e+32*(t-1)]>1||e<31&&s.pixels[e+32*t+1]>1||t<31&&s.pixels[e+32*(t+1)]>1)&&(s.pixels[e+32*t]=1);for(let e=31;e>=0;e--)for(let t=31;t>=0;t--)0===s.pixels[e+32*t]&&e>0&&t>0&&s.pixels[e+32*(t-1)-1]>0&&(s.pixels[e+32*t]=3153952);if(-1!==i.certtemplate){const e=this.getIcon(i.certlink,10),t=e.cropW,s=e.cropH;e.cropW=32,e.cropH=32,e.crop(5,5,22,22),e.cropW=t,e.cropH=s}return u.iconCache?.put(BigInt(e),s),l.Z.bind(d,f,p),l.Z.setBounds(m,y,g,C),o.Z.centerX=a,o.Z.centerY=n,o.Z.lineOffset=h,o.Z.jagged=!0,i.stackable?s.cropW=33:s.cropW=32,s.cropH=t,s};index=-1;model=0;name=null;desc=null;recol_s=null;recol_d=null;zoom2d=2e3;xan2d=0;yan2d=0;zan2d=0;xof2d=0;yof2d=0;code9=!1;code10=-1;stackable=!1;cost=1;members=!1;ops=null;iops=null;manwear=-1;manwear2=-1;manwearOffsetY=0;womanwear=-1;womanwear2=-1;womanwearOffsetY=0;manwear3=-1;womanwear3=-1;manhead=-1;manhead2=-1;womanhead=-1;womanhead2=-1;countobj=null;countco=null;certlink=-1;certtemplate=-1;decode=(e,t,i)=>{if(1===t)this.model=i.g2;else if(2===t)this.name=i.gjstr;else if(3===t)this.desc=i.gjstr;else if(4===t)this.zoom2d=i.g2;else if(5===t)this.xan2d=i.g2;else if(6===t)this.yan2d=i.g2;else if(7===t)this.xof2d=i.g2b,this.xof2d>32767&&(this.xof2d-=65536);else if(8===t)this.yof2d=i.g2b,this.yof2d>32767&&(this.yof2d-=65536);else if(9===t)this.code9=!0;else if(10===t)this.code10=i.g2;else if(11===t)this.stackable=!0;else if(12===t)this.cost=i.g4;else if(16===t)this.members=!0;else if(23===t)this.manwear=i.g2,this.manwearOffsetY=i.g1b;else if(24===t)this.manwear2=i.g2;else if(25===t)this.womanwear=i.g2,this.womanwearOffsetY=i.g1b;else if(26===t)this.womanwear2=i.g2;else if(t>=30&&t<35)this.ops||(this.ops=new d.to(5,null)),this.ops[t-30]=i.gjstr,"hidden"===this.ops[t-30]?.toLowerCase()&&(this.ops[t-30]=null);else if(t>=35&&t<40)this.iops||(this.iops=new d.to(5,null)),this.iops[t-35]=i.gjstr;else if(40===t){const e=i.g1;this.recol_s=new Uint16Array(e),this.recol_d=new Uint16Array(e);for(let t=0;t=100&&t<110&&(this.countobj&&this.countco||(this.countobj=new Uint16Array(10),this.countco=new Uint16Array(10)),this.countobj[t-100]=i.g2,this.countco[t-100]=i.g2)};getWornModel=e=>{let t=this.manwear;if(1===e&&(t=this.womanwear),-1===t)return null;let i=this.manwear2,s=this.manwear3;1===e&&(i=this.womanwear2,s=this.womanwear3);let a=h.Z.model(t);if(-1!==i){const e=h.Z.model(i);if(-1===s){const t=[a,e];a=h.Z.modelFromModels(t,2)}else{const t=[a,e,h.Z.model(s)];a=h.Z.modelFromModels(t,3)}}if(0===e&&0!==this.manwearOffsetY&&a.translate(this.manwearOffsetY,0,0),1===e&&0!==this.womanwearOffsetY&&a.translate(this.womanwearOffsetY,0,0),this.recol_s&&this.recol_d)for(let e=0;e{let t=this.manhead;if(1===e&&(t=this.womanhead),-1===t)return null;let i=this.manhead2;1===e&&(i=this.womanhead2);let s=h.Z.model(t);if(-1!==i){const e=[s,h.Z.model(i)];s=h.Z.modelFromModels(e,2)}if(this.recol_s&&this.recol_d)for(let e=0;e{if(this.countobj&&this.countco&&e>1){let t=-1;for(let i=0;i<10;i++)e>=this.countco[i]&&0!==this.countco[i]&&(t=this.countobj[i]);if(-1!==t)return u.get(t).getInterfaceModel(1)}if(u.modelCache){const e=u.modelCache.get(BigInt(this.index));if(e)return e}const t=h.Z.model(this.model);if(this.recol_s&&this.recol_d)for(let e=0;e{const e=u.get(this.certtemplate);this.model=e.model,this.zoom2d=e.zoom2d,this.xan2d=e.xan2d,this.yan2d=e.yan2d,this.zan2d=e.zan2d,this.xof2d=e.xof2d,this.yof2d=e.yof2d,this.recol_s=e.recol_s,this.recol_d=e.recol_d;const t=u.get(this.certlink);this.name=t.name,this.members=t.members,this.cost=t.cost;let i="a";const s=(t.name||"").toLowerCase().charAt(0);"a"!==s&&"e"!==s&&"i"!==s&&"o"!==s&&"u"!==s||(i="an"),this.desc=`Swap this note at any bank for ${i} ${t.name}.`,this.stackable=!0};reset=()=>{this.model=0,this.name=null,this.desc=null,this.recol_s=null,this.recol_d=null,this.zoom2d=2e3,this.xan2d=0,this.yan2d=0,this.zan2d=0,this.xof2d=0,this.yof2d=0,this.code9=!1,this.code10=-1,this.stackable=!1,this.cost=1,this.members=!1,this.ops=null,this.iops=null,this.manwear=-1,this.manwear2=-1,this.manwearOffsetY=0,this.womanwear=-1,this.womanwear2=-1,this.womanwearOffsetY=0,this.manwear3=-1,this.womanwear3=-1,this.manhead=-1,this.manhead2=-1,this.womanhead=-1,this.womanhead2=-1,this.countobj=null,this.countco=null,this.certlink=-1,this.certtemplate=-1}}},8067:(e,t,i)=>{i.d(t,{Z:()=>n});var s=i(8107),a=i(2383),r=i(8762);class n extends s.r{static count=0;static instances=[];static unpack=e=>{const t=new a.Z(e.read("seq.dat"));this.count=t.g2;for(let e=0;e{if(1===t){this.frameCount=i.g1,this.frames=new Int16Array(this.frameCount),this.iframes=new Int16Array(this.frameCount),this.delay=new Int16Array(this.frameCount);for(let e=0;e{i.d(t,{Z:()=>o});var s=i(8107),a=i(2383),r=i(8067),n=i(9178),h=i(5542);class o extends s.r{static count=0;static instances=[];static modelCache=new h.Z(30);static unpack=e=>{const t=new a.Z(e.read("spotanim.dat"));this.count=t.g2;for(let e=0;e{if(1===t)this.model=i.g2;else if(2===t)this.anim=i.g2,r.Z.instances&&(this.seq=r.Z.instances[this.anim]);else if(3===t)this.disposeAlpha=!0;else if(4===t)this.resizeh=i.g2;else if(5===t)this.resizev=i.g2;else if(6===t)this.orientation=i.g2;else if(7===t)this.ambient=i.g1;else if(8===t)this.contrast=i.g1;else if(t>=40&&t<50)this.recol_s[t-40]=i.g2;else{if(!(t>=50&&t<60))throw new Error(`Unrecognized spotanim config code: ${t}`);this.recol_d[t-50]=i.g2}};getModel=()=>{let e=o.modelCache?.get(BigInt(this.index));if(e)return e;e=n.Z.model(this.model);for(let t=0;t<6;t++)0!==this.recol_s[0]&&e.recolor(this.recol_s[t],this.recol_d[t]);return o.modelCache?.put(BigInt(this.index),e),e}}},1089:(e,t,i)=>{i.d(t,{Z:()=>r});var s=i(8107),a=i(2383);class r extends s.r{static count=0;static instances=[];static code3=[];static code3Count=0;static unpack=e=>{const t=new a.Z(e.read("varp.dat"));this.count=t.g2;for(let e=0;e{i.d(t,{Z:()=>s});class s{static OPEN=0;static WALL_NORTH_WEST=1;static WALL_NORTH=2;static WALL_NORTH_EAST=4;static WALL_EAST=8;static WALL_SOUTH_EAST=s.WALL_NORTH_WEST<<4;static WALL_SOUTH=s.WALL_NORTH<<4;static WALL_SOUTH_WEST=s.WALL_NORTH_EAST<<4;static WALL_WEST=s.WALL_EAST<<4;static LOC=256;static WALL_NORTH_WEST_PROJ_BLOCKER=512;static WALL_NORTH_PROJ_BLOCKER=1024;static WALL_NORTH_EAST_PROJ_BLOCKER=2048;static WALL_EAST_PROJ_BLOCKER=4096;static WALL_SOUTH_EAST_PROJ_BLOCKER=s.WALL_NORTH_WEST_PROJ_BLOCKER<<4;static WALL_SOUTH_PROJ_BLOCKER=s.WALL_NORTH_PROJ_BLOCKER<<4;static WALL_SOUTH_WEST_PROJ_BLOCKER=s.WALL_NORTH_EAST_PROJ_BLOCKER<<4;static WALL_WEST_PROJ_BLOCKER=s.WALL_EAST_PROJ_BLOCKER<<4;static LOC_PROJ_BLOCKER=s.LOC<<9;static FLOOR_DECORATION=524288;static FLOOR=2097152;static FLOOR_BLOCKED=s.FLOOR|s.FLOOR_DECORATION;static WALK_BLOCKED=s.LOC|s.FLOOR_BLOCKED;static BLOCK_SOUTH=s.WALL_NORTH|s.WALK_BLOCKED;static BLOCK_WEST=s.WALL_EAST|s.WALK_BLOCKED;static BLOCK_SOUTH_WEST=s.WALL_NORTH|s.WALL_NORTH_EAST|s.BLOCK_WEST;static BLOCK_NORTH=s.WALL_SOUTH|s.WALK_BLOCKED;static BLOCK_NORTH_WEST=s.WALL_EAST|s.WALL_SOUTH_EAST|s.BLOCK_NORTH;static BLOCK_EAST=s.WALL_WEST|s.WALK_BLOCKED;static BLOCK_SOUTH_EAST=s.WALL_NORTH_WEST|s.WALL_NORTH|s.BLOCK_EAST;static BLOCK_NORTH_EAST=s.WALL_SOUTH|s.WALL_SOUTH_WEST|s.BLOCK_EAST;static BOUNDS=16777215}},3693:(e,t,i)=>{i.d(t,{Z:()=>h});var s=i(8603),a=i(5534),r=i(1908),n=i(6439);class h{static LEVELS=4;static SIZE=104;static index=(e,t)=>e*h.SIZE+t;offsetX;offsetZ;sizeX;sizeZ;flags;constructor(){this.offsetX=0,this.offsetZ=0,this.sizeX=h.SIZE,this.sizeZ=h.SIZE,this.flags=new Int32Array(this.sizeX*this.sizeZ),this.reset()}reset=()=>{for(let e=0;e{this.flags[h.index(e-this.offsetX,t-this.offsetZ)]|=s.Z.FLOOR};removeFloor=(e,t)=>{this.flags[h.index(e-this.offsetX,t-this.offsetZ)]&=~s.Z.FLOOR};addLoc=(e,t,i,r,n,h)=>{let o=s.Z.LOC;h&&(o|=s.Z.LOC_PROJ_BLOCKER);const l=e-this.offsetX,c=t-this.offsetZ;if(n===a.Z.NORTH||n===a.Z.SOUTH){const e=i;i=r,r=e}for(let e=l;e=0&&e=0&&t{let o=s.Z.LOC;h&&(o|=s.Z.LOC_PROJ_BLOCKER);const l=e-this.offsetX,c=t-this.offsetZ;if(n===a.Z.NORTH||n===a.Z.SOUTH){const e=i;i=r,r=e}for(let e=l;e=0&&e=0&&t{const o=e-this.offsetX,l=t-this.offsetZ,c=h?s.Z.WALL_WEST_PROJ_BLOCKER:s.Z.WALL_WEST,d=h?s.Z.WALL_EAST_PROJ_BLOCKER:s.Z.WALL_EAST,u=h?s.Z.WALL_NORTH_PROJ_BLOCKER:s.Z.WALL_NORTH,f=h?s.Z.WALL_SOUTH_PROJ_BLOCKER:s.Z.WALL_SOUTH,p=h?s.Z.WALL_NORTH_WEST_PROJ_BLOCKER:s.Z.WALL_NORTH_WEST,m=h?s.Z.WALL_SOUTH_EAST_PROJ_BLOCKER:s.Z.WALL_SOUTH_EAST,g=h?s.Z.WALL_NORTH_EAST_PROJ_BLOCKER:s.Z.WALL_NORTH_EAST,y=h?s.Z.WALL_SOUTH_WEST_PROJ_BLOCKER:s.Z.WALL_SOUTH_WEST;i===r.Z.WALL_STRAIGHT?n===a.Z.WEST?(this.add(o,l,c),this.add(o-1,l,d)):n===a.Z.NORTH?(this.add(o,l,u),this.add(o,l+1,f)):n===a.Z.EAST?(this.add(o,l,d),this.add(o+1,l,c)):n===a.Z.SOUTH&&(this.add(o,l,f),this.add(o,l-1,u)):i===r.Z.WALL_DIAGONAL_CORNER||i===r.Z.WALL_SQUARE_CORNER?n===a.Z.WEST?(this.add(o,l,p),this.add(o-1,l+1,m)):n===a.Z.NORTH?(this.add(o,l,g),this.add(o+1,l+1,y)):n===a.Z.EAST?(this.add(o,l,m),this.add(o+1,l-1,p)):n===a.Z.SOUTH&&(this.add(o,l,y),this.add(o-1,l-1,g)):i===r.Z.WALL_L&&(n===a.Z.WEST?(this.add(o,l,u|c),this.add(o-1,l,d),this.add(o,l+1,f)):n===a.Z.NORTH?(this.add(o,l,u|d),this.add(o,l+1,f),this.add(o+1,l,c)):n===a.Z.EAST?(this.add(o,l,f|d),this.add(o+1,l,c),this.add(o,l-1,u)):n===a.Z.SOUTH&&(this.add(o,l,f|c),this.add(o,l-1,u),this.add(o-1,l,d))),h&&this.addWall(e,t,i,n,!1)};removeWall=(e,t,i,n,h)=>{const o=e-this.offsetX,l=t-this.offsetZ,c=h?s.Z.WALL_WEST_PROJ_BLOCKER:s.Z.WALL_WEST,d=h?s.Z.WALL_EAST_PROJ_BLOCKER:s.Z.WALL_EAST,u=h?s.Z.WALL_NORTH_PROJ_BLOCKER:s.Z.WALL_NORTH,f=h?s.Z.WALL_SOUTH_PROJ_BLOCKER:s.Z.WALL_SOUTH,p=h?s.Z.WALL_NORTH_WEST_PROJ_BLOCKER:s.Z.WALL_NORTH_WEST,m=h?s.Z.WALL_SOUTH_EAST_PROJ_BLOCKER:s.Z.WALL_SOUTH_EAST,g=h?s.Z.WALL_NORTH_EAST_PROJ_BLOCKER:s.Z.WALL_NORTH_EAST,y=h?s.Z.WALL_SOUTH_WEST_PROJ_BLOCKER:s.Z.WALL_SOUTH_WEST;i===r.Z.WALL_STRAIGHT?n===a.Z.WEST?(this.remove(o,l,c),this.remove(o-1,l,d)):n===a.Z.NORTH?(this.remove(o,l,u),this.remove(o,l+1,f)):n===a.Z.EAST?(this.remove(o,l,d),this.remove(o+1,l,c)):n===a.Z.SOUTH&&(this.remove(o,l,f),this.remove(o,l-1,u)):i===r.Z.WALL_DIAGONAL_CORNER||i===r.Z.WALL_SQUARE_CORNER?n===a.Z.WEST?(this.remove(o,l,p),this.remove(o-1,l+1,m)):n===a.Z.NORTH?(this.remove(o,l,g),this.remove(o+1,l+1,y)):n===a.Z.EAST?(this.remove(o,l,m),this.remove(o+1,l-1,p)):n===a.Z.SOUTH&&(this.remove(o,l,y),this.remove(o-1,l-1,g)):i===r.Z.WALL_L&&(n===a.Z.WEST?(this.remove(o,l,u|c),this.remove(o-1,l,d),this.remove(o,l+1,f)):n===a.Z.NORTH?(this.remove(o,l,u|d),this.remove(o,l+1,f),this.remove(o+1,l,c)):n===a.Z.EAST?(this.remove(o,l,f|d),this.remove(o+1,l,c),this.remove(o,l-1,u)):n===a.Z.SOUTH&&(this.remove(o,l,f|c),this.remove(o,l-1,u),this.remove(o-1,l,d))),h&&this.removeWall(e,t,i,n,!1)};reachedWall=(e,t,i,n,o,l)=>{if(e===i&&t===n)return!0;const c=e-this.offsetX,d=t-this.offsetZ,u=i-this.offsetX,f=n-this.offsetZ,p=h.index(c,d);if(o===r.Z.WALL_STRAIGHT){if(l===a.Z.WEST){if(c===u-1&&d===f)return!0;if(c===u&&d===f+1&&(this.flags[p]&s.Z.BLOCK_NORTH)===s.Z.OPEN)return!0;if(c===u&&d===f-1&&(this.flags[p]&s.Z.BLOCK_SOUTH)===s.Z.OPEN)return!0}else if(l===a.Z.NORTH){if(c===u&&d===f+1)return!0;if(c===u-1&&d===f&&(this.flags[p]&s.Z.BLOCK_WEST)===s.Z.OPEN)return!0;if(c===u+1&&d===f&&(this.flags[p]&s.Z.BLOCK_EAST)===s.Z.OPEN)return!0}else if(l===a.Z.EAST){if(c===u+1&&d===f)return!0;if(c===u&&d===f+1&&(this.flags[p]&s.Z.BLOCK_NORTH)===s.Z.OPEN)return!0;if(c===u&&d===f-1&&(this.flags[p]&s.Z.BLOCK_SOUTH)===s.Z.OPEN)return!0}else if(l===a.Z.SOUTH){if(c===u&&d===f-1)return!0;if(c===u-1&&d===f&&(this.flags[p]&s.Z.BLOCK_WEST)===s.Z.OPEN)return!0;if(c===u+1&&d===f&&(this.flags[p]&s.Z.BLOCK_EAST)===s.Z.OPEN)return!0}}else if(o===r.Z.WALL_L){if(l===a.Z.WEST){if(c===u-1&&d===f)return!0;if(c===u&&d===f+1)return!0;if(c===u+1&&d===f&&(this.flags[p]&s.Z.BLOCK_EAST)===s.Z.OPEN)return!0;if(c===u&&d===f-1&&(this.flags[p]&s.Z.BLOCK_SOUTH)===s.Z.OPEN)return!0}else if(l===a.Z.NORTH){if(c===u-1&&d===f&&(this.flags[p]&s.Z.BLOCK_WEST)===s.Z.OPEN)return!0;if(c===u&&d===f+1)return!0;if(c===u+1&&d===f)return!0;if(c===u&&d===f-1&&(this.flags[p]&s.Z.BLOCK_SOUTH)===s.Z.OPEN)return!0}else if(l===a.Z.EAST){if(c===u-1&&d===f&&(this.flags[p]&s.Z.BLOCK_WEST)===s.Z.OPEN)return!0;if(c===u&&d===f+1&&(this.flags[p]&s.Z.BLOCK_NORTH)===s.Z.OPEN)return!0;if(c===u+1&&d===f)return!0;if(c===u&&d===f-1)return!0}else if(l===a.Z.SOUTH){if(c===u-1&&d===f)return!0;if(c===u&&d===f+1&&(this.flags[p]&s.Z.BLOCK_NORTH)===s.Z.OPEN)return!0;if(c===u+1&&d===f&&(this.flags[p]&s.Z.BLOCK_EAST)===s.Z.OPEN)return!0;if(c===u&&d===f-1)return!0}}else if(o===r.Z.WALL_DIAGONAL){if(c===u&&d===f+1&&(this.flags[p]&s.Z.WALL_SOUTH)===s.Z.OPEN)return!0;if(c===u&&d===f-1&&(this.flags[p]&s.Z.WALL_NORTH)===s.Z.OPEN)return!0;if(c===u-1&&d===f&&(this.flags[p]&s.Z.WALL_EAST)===s.Z.OPEN)return!0;if(c===u+1&&d===f&&(this.flags[p]&s.Z.WALL_WEST)===s.Z.OPEN)return!0}return!1};reachedWallDecoration=(e,t,i,n,o,l)=>{if(e===i&&t===n)return!0;const c=e-this.offsetX,d=t-this.offsetZ,u=i-this.offsetX,f=n-this.offsetZ,p=h.index(c,d);if(o===r.Z.WALLDECOR_DIAGONAL_OFFSET||o===r.Z.WALLDECOR_DIAGONAL_NOOFFSET){if(o===r.Z.WALLDECOR_DIAGONAL_NOOFFSET&&(l=l+2&3),l===a.Z.WEST){if(c===u+1&&d===f&&(this.flags[p]&s.Z.WALL_WEST)===s.Z.OPEN)return!0;if(c===u&&d===f-1&&(this.flags[p]&s.Z.WALL_NORTH)===s.Z.OPEN)return!0}else if(l===a.Z.NORTH){if(c===u-1&&d===f&&(this.flags[p]&s.Z.WALL_EAST)===s.Z.OPEN)return!0;if(c===u&&d===f-1&&(this.flags[p]&s.Z.WALL_NORTH)===s.Z.OPEN)return!0}else if(l===a.Z.EAST){if(c===u-1&&d===f&&(this.flags[p]&s.Z.WALL_EAST)===s.Z.OPEN)return!0;if(c===u&&d===f+1&&(this.flags[p]&s.Z.WALL_SOUTH)===s.Z.OPEN)return!0}else if(l===a.Z.SOUTH){if(c===u+1&&d===f&&(this.flags[p]&s.Z.WALL_WEST)===s.Z.OPEN)return!0;if(c===u&&d===f+1&&(this.flags[p]&s.Z.WALL_SOUTH)===s.Z.OPEN)return!0}}else if(o===r.Z.WALLDECOR_DIAGONAL_BOTH){if(c===u&&d===f+1&&(this.flags[p]&s.Z.WALL_SOUTH)===s.Z.OPEN)return!0;if(c===u&&d===f-1&&(this.flags[p]&s.Z.WALL_NORTH)===s.Z.OPEN)return!0;if(c===u-1&&d===f&&(this.flags[p]&s.Z.WALL_EAST)===s.Z.OPEN)return!0;if(c===u+1&&d===f&&(this.flags[p]&s.Z.WALL_WEST)===s.Z.OPEN)return!0}return!1};reachedLoc=(e,t,i,a,r,o,l)=>{const c=i+r-1,d=a+o-1,u=h.index(e-this.offsetX,t-this.offsetZ);return e>=i&&e<=c&&t>=a&&t<=d||e===i-1&&t>=a&&t<=d&&(this.flags[u]&s.Z.WALL_EAST)===s.Z.OPEN&&(l&n.Z.WEST)===s.Z.OPEN||e===c+1&&t>=a&&t<=d&&(this.flags[u]&s.Z.WALL_WEST)===s.Z.OPEN&&(l&n.Z.EAST)===s.Z.OPEN||t===a-1&&e>=i&&e<=c&&(this.flags[u]&s.Z.WALL_NORTH)===s.Z.OPEN&&(l&n.Z.SOUTH)===s.Z.OPEN||t===d+1&&e>=i&&e<=c&&(this.flags[u]&s.Z.WALL_SOUTH)===s.Z.OPEN&&(l&n.Z.NORTH)===s.Z.OPEN};add=(e,t,i)=>{this.flags[h.index(e,t)]|=i};remove=(e,t,i)=>{this.flags[h.index(e,t)]&=s.Z.BOUNDS-i}}},6439:(e,t,i)=>{i.d(t,{Z:()=>s});class s{static NORTH=1;static EAST=2;static SOUTH=4;static WEST=8;static SOUTH_WEST=s.WEST|s.SOUTH;static NORTH_WEST=s.WEST|s.NORTH;static SOUTH_EAST=s.EAST|s.SOUTH;static NORTH_EAST=s.EAST|s.NORTH}},5534:(e,t,i)=>{var s;i.d(t,{Z:()=>a}),function(e){e[e.WEST=0]="WEST",e[e.NORTH=1]="NORTH",e[e.EAST=2]="EAST",e[e.SOUTH=3]="SOUTH"}(s||(s={}));const a=s},3714:(e,t,i)=>{var s;i.d(t,{Z:()=>a}),function(e){e[e.WALL=0]="WALL",e[e.WALL_DECOR=1]="WALL_DECOR",e[e.GROUND=2]="GROUND",e[e.GROUND_DECOR=3]="GROUND_DECOR"}(s||(s={}));const a=s},1908:(e,t,i)=>{i.d(t,{Z:()=>r,m:()=>n});var s,a=i(3714);!function(e){e[e.WALL_STRAIGHT=0]="WALL_STRAIGHT",e[e.WALL_DIAGONAL_CORNER=1]="WALL_DIAGONAL_CORNER",e[e.WALL_L=2]="WALL_L",e[e.WALL_SQUARE_CORNER=3]="WALL_SQUARE_CORNER",e[e.WALLDECOR_STRAIGHT_NOOFFSET=4]="WALLDECOR_STRAIGHT_NOOFFSET",e[e.WALLDECOR_STRAIGHT_OFFSET=5]="WALLDECOR_STRAIGHT_OFFSET",e[e.WALLDECOR_DIAGONAL_OFFSET=6]="WALLDECOR_DIAGONAL_OFFSET",e[e.WALLDECOR_DIAGONAL_NOOFFSET=7]="WALLDECOR_DIAGONAL_NOOFFSET",e[e.WALLDECOR_DIAGONAL_BOTH=8]="WALLDECOR_DIAGONAL_BOTH",e[e.WALL_DIAGONAL=9]="WALL_DIAGONAL",e[e.CENTREPIECE_STRAIGHT=10]="CENTREPIECE_STRAIGHT",e[e.CENTREPIECE_DIAGONAL=11]="CENTREPIECE_DIAGONAL",e[e.ROOF_STRAIGHT=12]="ROOF_STRAIGHT",e[e.ROOF_DIAGONAL_WITH_ROOFEDGE=13]="ROOF_DIAGONAL_WITH_ROOFEDGE",e[e.ROOF_DIAGONAL=14]="ROOF_DIAGONAL",e[e.ROOF_L_CONCAVE=15]="ROOF_L_CONCAVE",e[e.ROOF_L_CONVEX=16]="ROOF_L_CONVEX",e[e.ROOF_FLAT=17]="ROOF_FLAT",e[e.ROOFEDGE_STRAIGHT=18]="ROOFEDGE_STRAIGHT",e[e.ROOFEDGE_DIAGONAL_CORNER=19]="ROOFEDGE_DIAGONAL_CORNER",e[e.ROOFEDGE_L=20]="ROOFEDGE_L",e[e.ROOFEDGE_SQUARE_CORNER=21]="ROOFEDGE_SQUARE_CORNER",e[e.GROUND_DECOR=22]="GROUND_DECOR"}(s||(s={}));const r=s;class n{static layer(e){switch(e){case s.WALL_STRAIGHT:case s.WALL_DIAGONAL_CORNER:case s.WALL_L:case s.WALL_SQUARE_CORNER:return a.Z.WALL;case s.WALLDECOR_STRAIGHT_NOOFFSET:case s.WALLDECOR_STRAIGHT_OFFSET:case s.WALLDECOR_DIAGONAL_OFFSET:case s.WALLDECOR_DIAGONAL_NOOFFSET:case s.WALLDECOR_DIAGONAL_BOTH:return a.Z.WALL_DECOR;case s.WALL_DIAGONAL:case s.CENTREPIECE_STRAIGHT:case s.CENTREPIECE_DIAGONAL:case s.ROOF_STRAIGHT:case s.ROOF_DIAGONAL_WITH_ROOFEDGE:case s.ROOF_DIAGONAL:case s.ROOF_L_CONCAVE:case s.ROOF_L_CONVEX:case s.ROOF_FLAT:case s.ROOFEDGE_STRAIGHT:case s.ROOFEDGE_DIAGONAL_CORNER:case s.ROOFEDGE_L:case s.ROOFEDGE_SQUARE_CORNER:return a.Z.GROUND;case s.GROUND_DECOR:return a.Z.GROUND_DECOR;default:throw new Error("Invalid loc shape.")}}}},3909:(e,t,i)=>{i.d(t,{Z:()=>g});var s=i(3693),a=i(8056),r=i(2383),n=i(8078),h=i(7221),o=i(7958),l=i(682),c=i(8067),d=i(1908),u=i(5534),f=i(312),p=i(9190),m=i(9345);class g{static ROTATION_WALL_TYPE=Int32Array.of(1,2,4,8);static ROTATION_WALL_CORNER_TYPE=Int32Array.of(16,32,64,128);static WALL_DECORATION_ROTATION_FORWARD_X=Int32Array.of(1,0,-1,0);static WALL_DECORATION_ROTATION_FORWARD_Z=Int32Array.of(0,-1,0,1);static randomHueOffset=(17*Math.random()|0)-8;static randomLightnessOffset=(33*Math.random()|0)-16;static lowMemory=!0;static levelBuilt=0;static fullbright=!1;static perlin=(e,t)=>{let i=this.perlinScale(e+45365,t+91923,4)+(this.perlinScale(e+10294,t+37821,2)-128>>1)+(this.perlinScale(e,t,1)-128>>2)-128;return i=35+(.3*i|0),i<10?i=10:i>60&&(i=60),i};static perlinScale=(e,t,i)=>{const s=e/i|0,a=e&i-1,r=t/i|0,n=t&i-1,h=this.smoothNoise(s,r),o=this.smoothNoise(s+1,r),l=this.smoothNoise(s,r+1),c=this.smoothNoise(s+1,r+1),d=this.interpolate(h,o,a,i),u=this.interpolate(l,c,a,i);return this.interpolate(d,u,n,i)};static interpolate=(e,t,i,s)=>{const a=65536-n.Z.cos[1024*i/s|0]>>1;return(e*(65536-a)>>16)+(t*a>>16)};static smoothNoise=(e,t)=>((this.noise(e-1,t-1)+this.noise(e+1,t-1)+this.noise(e-1,t+1)+this.noise(e+1,t+1))/16|0)+((this.noise(e-1,t)+this.noise(e+1,t)+this.noise(e,t-1)+this.noise(e,t+1))/8|0)+(this.noise(e,t)/4|0);static noise=(e,t)=>{const i=e+57*t,s=i<<13^i,a=BigInt(s)*(BigInt(s)*BigInt(s)*15731n+789221n)+1376312589n&0x7fffffffn;return 255&Number(a>>19n)};static addLoc=(e,t,i,s,a,r,n,h,f,p,m)=>{const y=a[m][t][i],C=a[m][t+1][i],w=a[m][t+1][i+1],T=a[m][t][i+1],S=y+C+w+T>>2,Z=o.Z.get(h);let A=t+(i<<7)+(h<<14)+1073741824|0;Z.active||(A+=-2147483648),A|=0;const v=((p<<6)+f|0)<<24>>24;if(f===d.Z.GROUND_DECOR)s?.addGroundDecoration(Z.getModel(d.Z.GROUND_DECOR,p,y,C,w,T,-1),e,t,i,S,A,v),Z.blockwalk&&Z.active&&n.addFloor(t,i),-1!==Z.anim&&r.pushBack(new l.Z(h,e,3,t,i,c.Z.instances[Z.anim],!0));else if(f===d.Z.CENTREPIECE_STRAIGHT||f===d.Z.CENTREPIECE_DIAGONAL){const a=Z.getModel(d.Z.CENTREPIECE_STRAIGHT,p,y,C,w,T,-1);if(a){let r,n,h=0;f===d.Z.CENTREPIECE_DIAGONAL&&(h+=256),p===u.Z.NORTH||p===u.Z.SOUTH?(r=Z.length,n=Z.width):(r=Z.width,n=Z.length),s?.addLoc(e,t,i,S,a,null,A,v,r,n,h)}Z.blockwalk&&n.addLoc(t,i,Z.width,Z.length,p,Z.blockrange),-1!==Z.anim&&r.pushBack(new l.Z(h,e,2,t,i,c.Z.instances[Z.anim],!0))}else if(f>=d.Z.ROOF_STRAIGHT)s?.addLoc(e,t,i,S,Z.getModel(f,p,y,C,w,T,-1),null,A,v,1,1,0),Z.blockwalk&&n.addLoc(t,i,Z.width,Z.length,p,Z.blockrange),-1!==Z.anim&&r.pushBack(new l.Z(h,e,2,t,i,c.Z.instances[Z.anim],!0));else if(f===d.Z.WALL_STRAIGHT)s?.addWall(e,t,i,S,g.ROTATION_WALL_TYPE[p],0,Z.getModel(d.Z.WALL_STRAIGHT,p,y,C,w,T,-1),null,A,v),Z.blockwalk&&n.addWall(t,i,f,p,Z.blockrange),-1!==Z.anim&&r.pushBack(new l.Z(h,e,0,t,i,c.Z.instances[Z.anim],!0));else if(f===d.Z.WALL_DIAGONAL_CORNER)s?.addWall(e,t,i,S,g.ROTATION_WALL_CORNER_TYPE[p],0,Z.getModel(d.Z.WALL_DIAGONAL_CORNER,p,y,C,w,T,-1),null,A,v),Z.blockwalk&&n.addWall(t,i,f,p,Z.blockrange),-1!==Z.anim&&r.pushBack(new l.Z(h,e,0,t,i,c.Z.instances[Z.anim],!0));else if(f===d.Z.WALL_L){const a=p+1&3;s?.addWall(e,t,i,S,g.ROTATION_WALL_TYPE[p],g.ROTATION_WALL_TYPE[a],Z.getModel(d.Z.WALL_L,p+4,y,C,w,T,-1),Z.getModel(d.Z.WALL_L,a,y,C,w,T,-1),A,v),Z.blockwalk&&n.addWall(t,i,f,p,Z.blockrange),-1!==Z.anim&&r.pushBack(new l.Z(h,e,0,t,i,c.Z.instances[Z.anim],!0))}else if(f===d.Z.WALL_SQUARE_CORNER)s?.addWall(e,t,i,S,g.ROTATION_WALL_CORNER_TYPE[p],0,Z.getModel(d.Z.WALL_SQUARE_CORNER,p,y,C,w,T,-1),null,A,v),Z.blockwalk&&n.addWall(t,i,f,p,Z.blockrange),-1!==Z.anim&&r.pushBack(new l.Z(h,e,0,t,i,c.Z.instances[Z.anim],!0));else if(f===d.Z.WALL_DIAGONAL)s?.addLoc(e,t,i,S,Z.getModel(f,p,y,C,w,T,-1),null,A,v,1,1,0),Z.blockwalk&&n.addLoc(t,i,Z.width,Z.length,p,Z.blockrange),-1!==Z.anim&&r.pushBack(new l.Z(h,e,2,t,i,c.Z.instances[Z.anim],!0));else if(f===d.Z.WALLDECOR_STRAIGHT_NOOFFSET)s?.setWallDecoration(e,t,i,S,0,0,A,Z.getModel(d.Z.WALLDECOR_STRAIGHT_NOOFFSET,u.Z.WEST,y,C,w,T,-1),v,512*p,g.ROTATION_WALL_TYPE[p]),-1!==Z.anim&&r.pushBack(new l.Z(h,e,1,t,i,c.Z.instances[Z.anim],!0));else if(f===d.Z.WALLDECOR_STRAIGHT_OFFSET){let a=16;if(s){const r=s.getWallBitset(e,t,i);r>0&&(a=o.Z.get(r>>14&32767).walloff)}s?.setWallDecoration(e,t,i,S,g.WALL_DECORATION_ROTATION_FORWARD_X[p]*a,g.WALL_DECORATION_ROTATION_FORWARD_Z[p]*a,A,Z.getModel(d.Z.WALLDECOR_STRAIGHT_NOOFFSET,u.Z.WEST,y,C,w,T,-1),v,512*p,g.ROTATION_WALL_TYPE[p]),-1!==Z.anim&&r.pushBack(new l.Z(h,e,1,t,i,c.Z.instances[Z.anim],!0))}else f===d.Z.WALLDECOR_DIAGONAL_OFFSET?(s?.setWallDecoration(e,t,i,S,0,0,A,Z.getModel(d.Z.WALLDECOR_STRAIGHT_NOOFFSET,u.Z.WEST,y,C,w,T,-1),v,p,256),-1!==Z.anim&&r.pushBack(new l.Z(h,e,1,t,i,c.Z.instances[Z.anim],!0))):f===d.Z.WALLDECOR_DIAGONAL_NOOFFSET?(s?.setWallDecoration(e,t,i,S,0,0,A,Z.getModel(d.Z.WALLDECOR_STRAIGHT_NOOFFSET,u.Z.WEST,y,C,w,T,-1),v,p,512),-1!==Z.anim&&r.pushBack(new l.Z(h,e,1,t,i,c.Z.instances[Z.anim],!0))):f===d.Z.WALLDECOR_DIAGONAL_BOTH&&(s?.setWallDecoration(e,t,i,S,0,0,A,Z.getModel(d.Z.WALLDECOR_STRAIGHT_NOOFFSET,u.Z.WEST,y,C,w,T,-1),v,p,768),-1!==Z.anim&&r.pushBack(new l.Z(h,e,1,t,i,c.Z.instances[Z.anim],!0)))};maxTileX;maxTileZ;levelHeightmap;levelTileFlags;levelTileUnderlayIds;levelTileOverlayIds;levelTileOverlayShape;levelTileOverlayRotation;levelShademap;levelLightmap;blendChroma;blendSaturation;blendLightness;blendLuminance;blendMagnitude;levelOccludemap;constructor(e,t,i,a){this.maxTileX=e,this.maxTileZ=t,this.levelHeightmap=i,this.levelTileFlags=a,this.levelTileUnderlayIds=new m.zi(s.Z.LEVELS,e,t),this.levelTileOverlayIds=new m.zi(s.Z.LEVELS,e,t),this.levelTileOverlayShape=new m.zi(s.Z.LEVELS,e,t),this.levelTileOverlayRotation=new m.zi(s.Z.LEVELS,e,t),this.levelOccludemap=new m.AK(s.Z.LEVELS,e+1,t+1),this.levelShademap=new m.zi(s.Z.LEVELS,e+1,t+1),this.levelLightmap=new m.Nv(e+1,t+1),this.blendChroma=new Int32Array(t),this.blendSaturation=new Int32Array(t),this.blendLightness=new Int32Array(t),this.blendLuminance=new Int32Array(t),this.blendMagnitude=new Int32Array(t)}build=(e,t)=>{for(let e=0;e=0&&t[s]?.addFloor(i,a)}g.randomHueOffset+=(5*Math.random()|0)-2,g.randomHueOffset<-8?g.randomHueOffset=-8:g.randomHueOffset>8&&(g.randomHueOffset=8),g.randomLightnessOffset+=(5*Math.random()|0)-2,g.randomLightnessOffset<-16?g.randomLightnessOffset=-16:g.randomLightnessOffset>16&&(g.randomLightnessOffset=16);for(let t=0;t>8;for(let e=1;e>2)+(i[a+1][e]>>3)+(i[a][e-1]>>2)+(i[a][e+1]>>3)+(i[a][e]>>1);this.levelLightmap[a][e]=u-f}for(let e=0;e=0&&s0){const t=a.Z.instances[i-1];this.blendChroma[e]+=t.chroma,this.blendSaturation[e]+=t.saturation,this.blendLightness[e]+=t.lightness,this.blendLuminance[e]+=t.luminance,r=this.blendMagnitude[e]++}}const n=i-5;if(n>=0&&n0){const t=a.Z.instances[i-1];this.blendChroma[e]-=t.chroma,this.blendSaturation[e]-=t.saturation,this.blendLightness[e]-=t.lightness,this.blendLuminance[e]-=t.luminance,r=this.blendMagnitude[e]--}}}if(i>=1&&i=0&&d=0&&m=1&&c0||m>0){const y=this.levelHeightmap[t][i][c],C=this.levelHeightmap[t][i+1][c],w=this.levelHeightmap[t][i+1][c+1],T=this.levelHeightmap[t][i][c+1],S=this.levelLightmap[i][c],Z=this.levelLightmap[i+1][c],A=this.levelLightmap[i+1][c+1],v=this.levelLightmap[i][c+1];let I=-1,O=-1;if(d>0){const e=256*s/o|0,t=r/l|0;let i=h/l|0;I=a.Z.hsl24to16(e,t,i);const n=e+g.randomHueOffset&255;i+=g.randomLightnessOffset,i<0?i=0:i>255&&(i=255),O=a.Z.hsl24to16(n,t,i)}if(t>0){let e=0!==d||this.levelTileOverlayShape[t][i][c]===p.Z.PLAIN;m>0&&!a.Z.instances[m-1].occlude&&(e=!1),e&&y===C&&y===w&&y===T&&(this.levelOccludemap[t][i][c]|=2340)}let b=0;if(-1!==I&&(b=n.Z.palette[a.Z.mulHSL(O,96)]),0===m)e?.setTile(t,i,c,p.Z.PLAIN,u.Z.WEST,-1,y,C,w,T,a.Z.mulHSL(I,S),a.Z.mulHSL(I,Z),a.Z.mulHSL(I,A),a.Z.mulHSL(I,v),f.Z.BLACK,f.Z.BLACK,f.Z.BLACK,f.Z.BLACK,b,f.Z.BLACK);else{const s=this.levelTileOverlayShape[t][i][c]+1,r=this.levelTileOverlayRotation[t][i][c],h=a.Z.instances[m-1];let o,l,d=h.texture;d>=0?(l=n.Z.getAverageTextureRGB(d),o=-1):h.rgb===f.Z.MAGENTA?(l=0,o=-2,d=-1):(o=a.Z.hsl24to16(h.hue,h.saturation,h.lightness),l=n.Z.palette[a.Z.adjustLightness(h.hsl,96)]),e?.setTile(t,i,c,s,r,d,y,C,w,T,a.Z.mulHSL(I,S),a.Z.mulHSL(I,Z),a.Z.mulHSL(I,A),a.Z.mulHSL(I,v),a.Z.adjustLightness(o,S),a.Z.adjustLightness(o,Z),a.Z.adjustLightness(o,A),a.Z.adjustLightness(o,v),b,l)}}}}}}for(let i=1;i0&&(e<<=3,t<<=3,i<<=3);for(let s=0;s<=a;s++)for(let r=0;r<=this.maxTileZ;r++)for(let n=0;n<=this.maxTileX;n++){if(0!=(this.levelOccludemap[s][n][r]&e)){let t=r,i=r,o=s,l=s;for(;t>0&&0!=(this.levelOccludemap[s][n][t-1]&e);)t--;for(;i0;){for(let s=t;s<=i;s++)if(0==(this.levelOccludemap[o-1][n][s]&e))break e;o--}e:for(;l=8){const s=this.levelHeightmap[l][n][t]-240,r=this.levelHeightmap[o][n][t];h.Z.addOccluder(a,1,128*n,s,128*t,128*n,r,128*i+128);for(let s=o;s<=l;s++)for(let a=t;a<=i;a++)this.levelOccludemap[s][n][a]&=~e}}if(0!=(this.levelOccludemap[s][n][r]&t)){let e=n,i=n,o=s,l=s;for(;e>0&&0!=(this.levelOccludemap[s][e-1][r]&t);)e--;for(;i0;){for(let s=e;s<=i;s++)if(0==(this.levelOccludemap[o-1][s][r]&t))break e;o--}e:for(;l=8){const s=this.levelHeightmap[l][e][r]-240,n=this.levelHeightmap[o][e][r];h.Z.addOccluder(a,2,128*e,s,128*r,128*i+128,n,128*r);for(let s=o;s<=l;s++)for(let a=e;a<=i;a++)this.levelOccludemap[s][a][r]&=~t}}if(0!=(this.levelOccludemap[s][n][r]&i)){let e=n,t=n,o=r,l=r;for(;o>0&&0!=(this.levelOccludemap[s][n][o-1]&i);)o--;for(;l0;){for(let t=o;t<=l;t++)if(0==(this.levelOccludemap[s][e-1][t]&i))break e;e--}e:for(;t=4){const r=this.levelHeightmap[s][e][o];h.Z.addOccluder(a,4,128*e,r,128*o,128*t+128,r,128*l+128);for(let a=e;a<=t;a++)for(let e=o;e<=l;e++)this.levelOccludemap[s][a][e]&=~i}}}}}};clearLandscape=(e,t,i,r)=>{let n=0;for(let e=0;e>24;break}for(let a=e;a=0&&e=0&&a{const h=new r.Z(new Uint8Array(n));for(let r=0;r=0&&l=0&&c>24,this.levelTileOverlayRotation[r][l][c]=(d-2&3)<<24>>24):d<=81?this.levelTileFlags[r][l][c]=d-49<<24>>24:this.levelTileUnderlayIds[r][l][c]=d-81<<24>>24}else for(;d=h.g1,0!==d;){if(1===d){h.g1;break}d<=49&&h.g1}}};readLocs=(e,t,i,a,n,h)=>{const o=new r.Z(new Uint8Array(a));let l=-1;for(;;){const a=o.gsmarts;if(0===a)return;l+=a;let r=0;for(;;){const a=o.gsmarts;if(0===a)break;r+=a-1;const c=63&r,d=r>>6&63,u=r>>12,f=o.g1,p=f>>2,m=3&f,g=d+n,y=c+h;if(g>0&&y>0&&g=0&&(a=i[s]),this.addLoc(u,g,y,e,t,a,l,p,m)}}}};addLoc=(e,t,i,s,a,r,n,h,f)=>{if(g.lowMemory){if(0!=(16&this.levelTileFlags[e][t][i]))return;if(this.getDrawLevel(e,t,i)!==g.levelBuilt)return}const p=this.levelHeightmap[e][t][i],m=this.levelHeightmap[e][t+1][i],y=this.levelHeightmap[e][t+1][i+1],C=this.levelHeightmap[e][t][i+1],w=p+m+y+C>>2,T=o.Z.get(n);let S=t+(i<<7)+(n<<14)+1073741824|0;T.active||(S+=-2147483648),S|=0;const Z=((f<<6)+h|0)<<24>>24;if(h===d.Z.GROUND_DECOR)(!g.lowMemory||T.active||T.forcedecor)&&(s?.addGroundDecoration(T.getModel(d.Z.GROUND_DECOR,f,p,m,y,C,-1),e,t,i,w,S,Z),T.blockwalk&&T.active&&r&&r.addFloor(t,i),-1!==T.anim&&a.pushBack(new l.Z(n,e,3,t,i,c.Z.instances[T.anim],!0)));else if(h===d.Z.CENTREPIECE_STRAIGHT||h===d.Z.CENTREPIECE_DIAGONAL){const o=T.getModel(d.Z.CENTREPIECE_STRAIGHT,f,p,m,y,C,-1);if(o){let a,r,n=0;if(h===d.Z.CENTREPIECE_DIAGONAL&&(n+=256),f===u.Z.NORTH||f===u.Z.SOUTH?(a=T.length,r=T.width):(a=T.width,r=T.length),s?.addLoc(e,t,i,w,o,null,S,Z,a,r,n)&&T.shadow)for(let s=0;s<=a;s++)for(let a=0;a<=r;a++){let r=o.radius/4|0;r>30&&(r=30),r>this.levelShademap[e][t+s][i+a]&&(this.levelShademap[e][t+s][i+a]=r<<24>>24)}}T.blockwalk&&r&&r.addLoc(t,i,T.width,T.length,f,T.blockrange),-1!==T.anim&&a.pushBack(new l.Z(n,e,2,t,i,c.Z.instances[T.anim],!0))}else if(h>=d.Z.ROOF_STRAIGHT)s?.addLoc(e,t,i,w,T.getModel(h,f,p,m,y,C,-1),null,S,Z,1,1,0),h>=d.Z.ROOF_STRAIGHT&&h<=d.Z.ROOF_FLAT&&h!==d.Z.ROOF_DIAGONAL_WITH_ROOFEDGE&&e>0&&(this.levelOccludemap[e][t][i]|=2340),T.blockwalk&&r&&r.addLoc(t,i,T.width,T.length,f,T.blockrange),-1!==T.anim&&a.pushBack(new l.Z(n,e,2,t,i,c.Z.instances[T.anim],!0));else if(h===d.Z.WALL_STRAIGHT)s?.addWall(e,t,i,w,g.ROTATION_WALL_TYPE[f],0,T.getModel(d.Z.WALL_STRAIGHT,f,p,m,y,C,-1),null,S,Z),f===u.Z.WEST?(T.shadow&&(this.levelShademap[e][t][i]=50,this.levelShademap[e][t][i+1]=50),T.occlude&&(this.levelOccludemap[e][t][i]|=585)):f===u.Z.NORTH?(T.shadow&&(this.levelShademap[e][t][i+1]=50,this.levelShademap[e][t+1][i+1]=50),T.occlude&&(this.levelOccludemap[e][t][i+1]|=1170)):f===u.Z.EAST?(T.shadow&&(this.levelShademap[e][t+1][i]=50,this.levelShademap[e][t+1][i+1]=50),T.occlude&&(this.levelOccludemap[e][t+1][i]|=585)):f===u.Z.SOUTH&&(T.shadow&&(this.levelShademap[e][t][i]=50,this.levelShademap[e][t+1][i]=50),T.occlude&&(this.levelOccludemap[e][t][i]|=1170)),T.blockwalk&&r&&r.addWall(t,i,h,f,T.blockrange),-1!==T.anim&&a.pushBack(new l.Z(n,e,0,t,i,c.Z.instances[T.anim],!0)),16!==T.walloff&&s?.setWallDecorationOffset(e,t,i,T.walloff);else if(h===d.Z.WALL_DIAGONAL_CORNER)s?.addWall(e,t,i,w,g.ROTATION_WALL_CORNER_TYPE[f],0,T.getModel(d.Z.WALL_DIAGONAL_CORNER,f,p,m,y,C,-1),null,S,Z),T.shadow&&(f===u.Z.WEST?this.levelShademap[e][t][i+1]=50:f===u.Z.NORTH?this.levelShademap[e][t+1][i+1]=50:f===u.Z.EAST?this.levelShademap[e][t+1][i]=50:f===u.Z.SOUTH&&(this.levelShademap[e][t][i]=50)),T.blockwalk&&r&&r.addWall(t,i,h,f,T.blockrange),-1!==T.anim&&a.pushBack(new l.Z(n,e,0,t,i,c.Z.instances[T.anim],!0));else if(h===d.Z.WALL_L){const o=f+1&3;s?.addWall(e,t,i,w,g.ROTATION_WALL_TYPE[f],g.ROTATION_WALL_TYPE[o],T.getModel(d.Z.WALL_L,f+4,p,m,y,C,-1),T.getModel(d.Z.WALL_L,o,p,m,y,C,-1),S,Z),T.occlude&&(f===u.Z.WEST?(this.levelOccludemap[e][t][i]|=265,this.levelOccludemap[e][t][i+1]|=1170):f===u.Z.NORTH?(this.levelOccludemap[e][t][i+1]|=1170,this.levelOccludemap[e][t+1][i]|=585):f===u.Z.EAST?(this.levelOccludemap[e][t+1][i]|=585,this.levelOccludemap[e][t][i]|=1170):f===u.Z.SOUTH&&(this.levelOccludemap[e][t][i]|=1170,this.levelOccludemap[e][t][i]|=585)),T.blockwalk&&r&&r.addWall(t,i,h,f,T.blockrange),-1!==T.anim&&a.pushBack(new l.Z(n,e,0,t,i,c.Z.instances[T.anim],!0)),16!==T.walloff&&s?.setWallDecorationOffset(e,t,i,T.walloff)}else if(h===d.Z.WALL_SQUARE_CORNER)s?.addWall(e,t,i,w,g.ROTATION_WALL_CORNER_TYPE[f],0,T.getModel(d.Z.WALL_SQUARE_CORNER,f,p,m,y,C,-1),null,S,Z),T.shadow&&(f===u.Z.WEST?this.levelShademap[e][t][i+1]=50:f===u.Z.NORTH?this.levelShademap[e][t+1][i+1]=50:f===u.Z.EAST?this.levelShademap[e][t+1][i]=50:f===u.Z.SOUTH&&(this.levelShademap[e][t][i]=50)),T.blockwalk&&r&&r.addWall(t,i,h,f,T.blockrange),-1!==T.anim&&a.pushBack(new l.Z(n,e,0,t,i,c.Z.instances[T.anim],!0));else if(h===d.Z.WALL_DIAGONAL)s?.addLoc(e,t,i,w,T.getModel(h,f,p,m,y,C,-1),null,S,Z,1,1,0),T.blockwalk&&r&&r.addLoc(t,i,T.width,T.length,f,T.blockrange),-1!==T.anim&&a.pushBack(new l.Z(n,e,2,t,i,c.Z.instances[T.anim],!0));else if(h===d.Z.WALLDECOR_STRAIGHT_NOOFFSET)s?.setWallDecoration(e,t,i,w,0,0,S,T.getModel(d.Z.WALLDECOR_STRAIGHT_NOOFFSET,u.Z.WEST,p,m,y,C,-1),Z,512*f,g.ROTATION_WALL_TYPE[f]),-1!==T.anim&&a.pushBack(new l.Z(n,e,1,t,i,c.Z.instances[T.anim],!0));else if(h===d.Z.WALLDECOR_STRAIGHT_OFFSET){let r=16;if(s){const a=s.getWallBitset(e,t,i);a>0&&(r=o.Z.get(a>>14&32767).walloff)}s?.setWallDecoration(e,t,i,w,g.WALL_DECORATION_ROTATION_FORWARD_X[f]*r,g.WALL_DECORATION_ROTATION_FORWARD_Z[f]*r,S,T.getModel(d.Z.WALLDECOR_STRAIGHT_NOOFFSET,u.Z.WEST,p,m,y,C,-1),Z,512*f,g.ROTATION_WALL_TYPE[f]),-1!==T.anim&&a.pushBack(new l.Z(n,e,1,t,i,c.Z.instances[T.anim],!0))}else h===d.Z.WALLDECOR_DIAGONAL_OFFSET?(s?.setWallDecoration(e,t,i,w,0,0,S,T.getModel(d.Z.WALLDECOR_STRAIGHT_NOOFFSET,u.Z.WEST,p,m,y,C,-1),Z,f,256),-1!==T.anim&&a.pushBack(new l.Z(n,e,1,t,i,c.Z.instances[T.anim],!0))):h===d.Z.WALLDECOR_DIAGONAL_NOOFFSET?(s?.setWallDecoration(e,t,i,w,0,0,S,T.getModel(d.Z.WALLDECOR_STRAIGHT_NOOFFSET,u.Z.WEST,p,m,y,C,-1),Z,f,512),-1!==T.anim&&a.pushBack(new l.Z(n,e,1,t,i,c.Z.instances[T.anim],!0))):h===d.Z.WALLDECOR_DIAGONAL_BOTH&&(s?.setWallDecoration(e,t,i,w,0,0,S,T.getModel(d.Z.WALLDECOR_STRAIGHT_NOOFFSET,u.Z.WEST,p,m,y,C,-1),Z,f,768),-1!==T.anim&&a.pushBack(new l.Z(n,e,1,t,i,c.Z.instances[T.anim],!0)))};getDrawLevel=(e,t,i)=>0==(8&this.levelTileFlags[e][t][i])?e<=0||0==(2&this.levelTileFlags[1][t][i])?e:e-1:0}},7221:(e,t,i)=>{i.d(t,{Z:()=>w});var s=i(8078),a=i(6539),r=i(220),n=i(4138),h=i(3693),o=i(4155),l=i(3806),c=i(9118),d=i(9080),u=i(6711),f=i(9865),p=i(2991),m=i(8570),g=i(9190),y=i(5534),C=i(9345);class w{static visibilityMatrix=new C.nz(8,32,51,51,!1);static locBuffer=new C.to(100,null);static levelOccluderCount=new Int32Array(h.Z.LEVELS);static levelOccluders=new C.IY(h.Z.LEVELS,500,null);static activeOccluders=new C.to(500,null);static drawTileQueue=new d.Z;static cycle=0;static viewportLeft=0;static viewportTop=0;static viewportRight=0;static viewportBottom=0;static viewportCenterX=0;static viewportCenterY=0;static sinEyePitch=0;static cosEyePitch=0;static sinEyeYaw=0;static cosEyeYaw=0;static eyeX=0;static eyeY=0;static eyeZ=0;static eyeTileX=0;static eyeTileZ=0;static minDrawTileX=0;static maxDrawTileX=0;static minDrawTileZ=0;static maxDrawTileZ=0;static topLevel=0;static tilesRemaining=0;static takingInput=!1;static visibilityMap=null;static FRONT_WALL_TYPES=Int32Array.of(19,55,38,155,255,110,137,205,76);static DIRECTION_ALLOW_WALL_CORNER_TYPE=Int32Array.of(160,192,80,96,0,144,80,48,160);static BACK_WALL_TYPES=Int32Array.of(76,8,137,4,0,1,38,2,19);static WALL_CORNER_TYPE_16_BLOCK_LOC_SPANS=Int32Array.of(0,0,2,0,0,2,1,1,0);static WALL_CORNER_TYPE_32_BLOCK_LOC_SPANS=Int32Array.of(2,0,0,2,0,0,0,4,4);static WALL_CORNER_TYPE_64_BLOCK_LOC_SPANS=Int32Array.of(0,4,4,8,0,0,8,0,0);static WALL_CORNER_TYPE_128_BLOCK_LOC_SPANS=Int32Array.of(1,1,0,0,0,8,0,0,8);static WALL_DECORATION_INSET_X=Int32Array.of(53,-53,-53,53);static WALL_DECORATION_INSET_Z=Int32Array.of(-53,-53,53,53);static WALL_DECORATION_OUTSET_X=Int32Array.of(-45,45,45,-45);static WALL_DECORATION_OUTSET_Z=Int32Array.of(45,45,-45,-45);static MINIMAP_TILE_MASK=[new Int32Array(16),Int32Array.of(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),Int32Array.of(1,0,0,0,1,1,0,0,1,1,1,0,1,1,1,1),Int32Array.of(1,1,0,0,1,1,0,0,1,0,0,0,1,0,0,0),Int32Array.of(0,0,1,1,0,0,1,1,0,0,0,1,0,0,0,1),Int32Array.of(0,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1),Int32Array.of(1,1,1,0,1,1,1,0,1,1,1,1,1,1,1,1),Int32Array.of(1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0),Int32Array.of(0,0,0,0,0,0,0,0,1,0,0,0,1,1,0,0),Int32Array.of(1,1,1,1,1,1,1,1,0,1,1,1,0,0,1,1),Int32Array.of(1,1,1,1,1,1,0,0,1,0,0,0,1,0,0,0),Int32Array.of(0,0,0,0,0,0,1,1,0,1,1,1,0,1,1,1),Int32Array.of(0,0,0,0,0,0,0,0,0,1,1,0,1,1,1,1)];static MINIMAP_TILE_ROTATION_MAP=[Int32Array.of(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15),Int32Array.of(12,8,4,0,13,9,5,1,14,10,6,2,15,11,7,3),Int32Array.of(15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0),Int32Array.of(3,7,11,15,2,6,10,14,1,5,9,13,0,4,8,12)];static TEXTURE_HSL=Int32Array.of(41,39248,41,4643,41,41,41,41,41,41,41,41,41,41,41,43086,41,41,41,41,41,41,41,8602,41,28992,41,41,41,41,41,5056,41,41,41,41,41,41,41,41,41,41,41,41,41,41,3131,41,41,41);static activeOccluderCount=0;static mouseX=0;static mouseY=0;static clickTileX=-1;static clickTileZ=-1;static lowMemory=!0;static init=(e,t,i,a,r)=>{this.viewportLeft=0,this.viewportTop=0,this.viewportRight=e,this.viewportBottom=t,this.viewportCenterX=e/2|0,this.viewportCenterY=t/2|0;const n=new C.nz(9,32,53,53,!1);for(let e=128;e<=384;e+=32)for(let t=0;t<2048;t+=64){this.sinEyePitch=s.Z.sin[e],this.cosEyePitch=s.Z.cos[e],this.sinEyeYaw=s.Z.sin[t],this.cosEyeYaw=s.Z.cos[t];const h=(e-128)/32|0,o=t/64|0;for(let e=-26;e<=26;e++)for(let t=-26;t<=26;t++){const s=128*e,l=128*t;let c=!1;for(let e=-i;e<=a;e+=128)if(this.testPoint(s,l,r[h]+e)){c=!0;break}n[h][o][e+25+1][t+25+1]=c}}for(let e=0;e<8;e++)for(let t=0;t<32;t++)for(let i=-25;i<25;i++)for(let s=-25;s<25;s++){let a=!1;e:for(let r=-1;r<=1;r++)for(let h=-1;h<=1;h++){if(n[e][t][i+r+25+1][s+h+25+1]){a=!0;break e}if(n[e][(t+1)%31][i+r+25+1][s+h+25+1]){a=!0;break e}if(n[e+1][t][i+r+25+1][s+h+25+1]){a=!0;break e}if(n[e+1][(t+1)%31][i+r+25+1][s+h+25+1]){a=!0;break e}}this.visibilityMatrix[e][t][i+25][s+25]=a}};static unload=()=>{this.locBuffer=null,this.levelOccluderCount=null,this.levelOccluders=null,this.drawTileQueue=null,this.visibilityMatrix=null,this.activeOccluders=null,this.visibilityMap=null,console.log("World3D unloaded!")};static addOccluder=(e,t,i,s,a,r,h,o)=>{w.levelOccluders[e][w.levelOccluderCount[e]++]=new n.Z(i/128|0,r/128|0,a/128|0,o/128|0,t,i,r,a,o,s,h)};static testPoint=(e,t,i)=>{const s=t*this.sinEyeYaw+e*this.cosEyeYaw>>16,a=t*this.cosEyeYaw-e*this.sinEyeYaw>>16,r=i*this.sinEyePitch+a*this.cosEyePitch>>16,n=i*this.cosEyePitch-a*this.sinEyePitch>>16;if(r<50||r>3500)return!1;const h=this.viewportCenterX+((s<<9)/r|0),o=this.viewportCenterY+((n<<9)/r|0);return h>=this.viewportLeft&&h<=this.viewportRight&&o>=this.viewportTop&&o<=this.viewportBottom};maxLevel;maxTileX;maxTileZ;levelHeightmaps;levelTiles;temporaryLocs;levelTileOcclusionCycles;mergeIndexA;mergeIndexB;temporaryLocCount=0;minLevel=0;tmpMergeIndex=0;constructor(e,t,i,s){this.maxLevel=i,this.maxTileX=s,this.maxTileZ=t,this.levelTiles=new C.N$(i,s,t,null),this.levelTileOcclusionCycles=new C.AK(i,s+1,t+1),this.levelHeightmaps=e,this.temporaryLocs=new C.to(5e3,null),this.mergeIndexA=new Int32Array(1e4),this.mergeIndexB=new Int32Array(1e4),this.reset()}reset=()=>{for(let e=0;e{this.minLevel=e;for(let t=0;t{const i=this.levelTiles[0][e][t];for(let i=0;i<3;i++){this.levelTiles[i][e][t]=this.levelTiles[i+1][e][t];const s=this.levelTiles[i][e][t];s&&s.level--}this.levelTiles[0][e][t]||(this.levelTiles[0][e][t]=new r.Z(0,e,t));const s=this.levelTiles[0][e][t];s&&(s.bridge=i),this.levelTiles[3][e][t]=null};setDrawLevel=(e,t,i,s)=>{const a=this.levelTiles[e][t][i];a&&(a.drawLevel=s)};setTile=(e,t,i,s,a,n,h,o,l,c,d,u,p,y,C,w,T,S,Z,A)=>{if(s===g.Z.PLAIN){for(let s=e;s>=0;s--)this.levelTiles[s][t][i]||(this.levelTiles[s][t][i]=new r.Z(s,t,i));const s=this.levelTiles[e][t][i];s&&(s.underlay=new f.Z(d,u,p,y,-1,Z,!1))}else if(s===g.Z.DIAGONAL){for(let s=e;s>=0;s--)this.levelTiles[s][t][i]||(this.levelTiles[s][t][i]=new r.Z(s,t,i));const s=this.levelTiles[e][t][i];s&&(s.underlay=new f.Z(C,w,T,S,n,A,h===o&&h===l&&h===c))}else{for(let s=e;s>=0;s--)this.levelTiles[s][t][i]||(this.levelTiles[s][t][i]=new r.Z(s,t,i));const f=this.levelTiles[e][t][i];f&&(f.overlay=new m.Z(t,s,w,o,p,a,d,c,A,C,n,S,Z,l,T,y,h,i,u))}};addGroundDecoration=(e,t,i,s,a,n,h)=>{this.levelTiles[t][i][s]||(this.levelTiles[t][i][s]=new r.Z(t,i,s));const l=this.levelTiles[t][i][s];l&&(l.groundDecoration=new o.Z(a,128*i+64,128*s+64,e,n,h))};removeGroundDecoration=(e,t,i)=>{const s=this.levelTiles[e][t][i];s&&(s.groundDecoration=null)};addObjStack=(e,t,i,s,a,n,h,o)=>{let l=0;const c=this.levelTiles[s][e][t];if(c)for(let e=0;el&&(l=i)}else this.levelTiles[s][e][t]=new r.Z(s,e,t);const d=this.levelTiles[s][e][t];d&&(d.objStack=new u.Z(i,128*e+64,128*t+64,n,h,o,a,l))};removeObjStack=(e,t,i)=>{const s=this.levelTiles[e][t][i];s&&(s.objStack=null)};addWall=(e,t,i,s,a,n,h,o,c,d)=>{if(!h&&!o)return;for(let s=e;s>=0;s--)this.levelTiles[s][t][i]||(this.levelTiles[s][t][i]=new r.Z(s,t,i));const u=this.levelTiles[e][t][i];u&&(u.wall=new l.Z(s,128*t+64,128*i+64,a,n,h,o,c,d))};removeWall=(e,t,i,s)=>{const a=this.levelTiles[e][t][i];1===s&&a&&(a.wall=null)};setWallDecoration=(e,t,i,s,a,n,h,o,l,d,u)=>{if(!o)return;for(let s=e;s>=0;s--)this.levelTiles[s][t][i]||(this.levelTiles[s][t][i]=new r.Z(s,t,i));const f=this.levelTiles[e][t][i];f&&(f.wallDecoration=new c.Z(s,128*t+a+64,128*i+n+64,u,d,o,h,l))};removeWallDecoration=(e,t,i)=>{const s=this.levelTiles[e][t][i];s&&(s.wallDecoration=null)};setWallDecorationOffset=(e,t,i,s)=>{const a=this.levelTiles[e][t][i];if(!a)return;const r=a.wallDecoration;if(!r)return;const n=128*t+64,h=128*i+64;r.x=n+((r.x-n)*s/16|0),r.z=h+((r.z-h)*s/16|0)};setWallDecorationModel=(e,t,i,s)=>{if(!s)return;const a=this.levelTiles[e][t][i];if(!a)return;const r=a.wallDecoration;r&&(r.model=s)};setGroundDecorationModel=(e,t,i,s)=>{if(!s)return;const a=this.levelTiles[e][t][i];if(!a)return;const r=a.groundDecoration;r&&(r.model=s)};setWallModel=(e,t,i,s)=>{if(!s)return;const a=this.levelTiles[e][t][i];if(!a)return;const r=a.wall;r&&(r.modelA=s)};setWallModels=(e,t,i,s,a)=>{if(!s)return;const r=this.levelTiles[i][e][t];if(!r)return;const n=r.wall;n&&(n.modelA=s,n.modelB=a)};addLoc=(e,t,i,s,a,r,n,h,o,l,c)=>{if(!a&&!r)return!0;const d=128*t+64*o,u=128*i+64*l;return this.addLoc2(d,u,s,e,t,i,o,l,a,r,n,h,c,!1)};addTemporary=(e,t,i,s,a,r,n,h,o,l)=>{if(!a&&!r)return!0;let c=t-o,d=s-o,u=t+o,f=s+o;return l&&(h>640&&h<1408&&(f+=128),h>1152&&h<1920&&(u+=128),(h>1664||h<384)&&(d-=128),h>128&&h<896&&(c-=128)),c=c/128|0,d=d/128|0,u=u/128|0,f=f/128|0,this.addLoc2(t,s,i,e,c,d,u+1-c,f-d+1,a,r,n,0,h,!0)};addTemporary2=(e,t,i,s,a,r,n,h,o,l,c,d)=>!o&&!l||this.addLoc2(t,s,i,e,a,r,n+1-a,h-r+1,o,l,c,0,d,!0);removeLoc=(e,t,i)=>{const s=this.levelTiles[e][t][i];if(s)for(let e=0;e>29&3)&&a.minSceneTileX===t&&a.minSceneTileZ===i)return void this.removeLoc2(a)}};setLocModel=(e,t,i,s)=>{if(!s)return;const a=this.levelTiles[e][t][i];if(a)for(let e=0;e>29&3))return void(t.model=s)}};clearTemporaryLocs=()=>{for(let e=0;e{const s=this.levelTiles[e][t][i];return s&&s.wall?s.wall.bitset:0};getWallDecorationBitset=(e,t,i)=>{const s=this.levelTiles[e][i][t];return s&&s.wallDecoration?s.wallDecoration.bitset:0};getLocBitset=(e,t,i)=>{const s=this.levelTiles[e][t][i];if(!s)return 0;for(let e=0;e>29&3)&&a.minSceneTileX===t&&a.minSceneTileZ===i)return a.bitset}return 0};getGroundDecorationBitset=(e,t,i)=>{const s=this.levelTiles[e][t][i];return s&&s.groundDecoration?s.groundDecoration.bitset:0};getInfo=(e,t,i,s)=>{const a=this.levelTiles[e][t][i];if(a){if(a.wall&&a.wall.bitset===s)return 255&a.wall.info;if(a.wallDecoration&&a.wallDecoration.bitset===s)return 255&a.wallDecoration.info;if(a.groundDecoration&&a.groundDecoration.bitset===s)return 255&a.groundDecoration.info;for(let e=0;e{const r=t*(0|Math.sqrt(i*i+s*s+a*a))>>8;for(let t=0;t{if(t0){const a=this.levelTiles[e][t+1][i-1];a&&a.groundDecoration&&a.groundDecoration.model&&a.groundDecoration.model.vertexNormal&&this.mergeNormals(s,a.groundDecoration.model,128,0,-128,!0)}};mergeLocNormals=(e,t,i,s,a,r)=>{let n=!0,h=t;const o=t+s,l=i-1,c=i+a;for(let d=e;d<=e+1;d++)if(d!==this.maxLevel){for(let u=h;u<=o;u++)if(!(u<0||u>=this.maxTileX))for(let h=l;h<=c;h++){if(h<0||h>=this.maxTileZ||n&&u=i||u===t))continue;const l=this.levelTiles[d][u][h];if(!l)continue;const f=128*(u-t)+64*(1-s),p=128*(h-i)+64*(1-a),m=((this.levelHeightmaps[d][u][h]+this.levelHeightmaps[d][u+1][h]+this.levelHeightmaps[d][u][h+1]+this.levelHeightmaps[d][u+1][h+1])/4|0)-((this.levelHeightmaps[e][t][i]+this.levelHeightmaps[e][t+1][i]+this.levelHeightmaps[e][t][i+1]+this.levelHeightmaps[e][t+1][i+1])/4|0),g=l.wall;g&&g.modelA&&g.modelA.vertexNormal&&this.mergeNormals(r,g.modelA,f,m,p,n),g&&g.modelB&&g.modelB.vertexNormal&&this.mergeNormals(r,g.modelB,f,m,p,n);for(let e=0;e{this.tmpMergeIndex++;let n=0;const h=t.vertexX,o=t.vertexCount;if(e.vertexNormal&&e.vertexNormalOriginal)for(let r=0;rt.minY)continue;const u=e.vertexX[r]-i;if(ut.maxX)continue;const f=e.vertexZ[r]-a;if(ft.maxZ)continue;if(t.vertexNormal&&t.vertexNormalOriginal)for(let e=0;e{const n=this.levelTiles[e][t][i];if(!n)return;const h=n.underlay;if(h){const e=h.color;if(0!==e)for(let t=0;t<4;t++)s[a]=e,s[a+1]=e,s[a+2]=e,s[a+3]=e,a+=r;return}const o=n.overlay;if(!o)return;const l=o.shape,c=o.rotation,d=o.backgroundRgb,u=o.foregroundRgb,f=w.MINIMAP_TILE_MASK[l],p=w.MINIMAP_TILE_ROTATION_MAP[c];let m=0;if(0===d)for(let e=0;e<4;e++)0!==f[p[m++]]&&(s[a]=u),0!==f[p[m++]]&&(s[a+1]=u),0!==f[p[m++]]&&(s[a+2]=u),0!==f[p[m++]]&&(s[a+3]=u),a+=r;else for(let e=0;e<4;e++)s[a]=0===f[p[m++]]?d:u,s[a+1]=0===f[p[m++]]?d:u,s[a+2]=0===f[p[m++]]?d:u,s[a+3]=0===f[p[m++]]?d:u,a+=r};click=(e,t)=>{w.takingInput=!0,w.mouseX=e,w.mouseY=t,w.clickTileX=-1,w.clickTileZ=-1};draw=(e,t,i,a,r,n,h)=>{e<0?e=0:e>=128*this.maxTileX&&(e=128*this.maxTileX-1),i<0?i=0:i>=128*this.maxTileZ&&(i=128*this.maxTileZ-1),w.cycle++,w.sinEyePitch=s.Z.sin[n],w.cosEyePitch=s.Z.cos[n],w.sinEyeYaw=s.Z.sin[r],w.cosEyeYaw=s.Z.cos[r],w.visibilityMap=w.visibilityMatrix[(n-128)/32|0][r/64|0],w.eyeX=e,w.eyeY=t,w.eyeZ=i,w.eyeTileX=e/128|0,w.eyeTileZ=i/128|0,w.topLevel=a,w.minDrawTileX=w.eyeTileX-25,w.minDrawTileX<0&&(w.minDrawTileX=0),w.minDrawTileZ=w.eyeTileZ-25,w.minDrawTileZ<0&&(w.minDrawTileZ=0),w.maxDrawTileX=w.eyeTileX+25,w.maxDrawTileX>this.maxTileX&&(w.maxDrawTileX=this.maxTileX),w.maxDrawTileZ=w.eyeTileZ+25,w.maxDrawTileZ>this.maxTileZ&&(w.maxDrawTileZ=this.maxTileZ),this.updateActiveOccluders(),w.tilesRemaining=0;for(let e=this.minLevel;e=2e3)?(n.visible=!0,n.update=!0,n.containsLocs=n.locCount>0,w.tilesRemaining++):(n.visible=!1,n.update=!1,n.checkLocSpans=0))}}for(let e=this.minLevel;e=w.maxDrawTileX))for(let e=-25;e<=0;e++){const a=w.eyeTileZ+e,r=w.eyeTileZ-e;let n;if(i>=w.minDrawTileX&&(a>=w.minDrawTileZ&&(n=t[i][a],n&&n.visible&&this.drawTile(n,!0,h)),r=w.minDrawTileZ&&(n=t[s][a],n&&n.visible&&this.drawTile(n,!0,h)),r=w.maxDrawTileX))for(let e=-25;e<=0;e++){const a=w.eyeTileZ+e,r=w.eyeTileZ-e;let n;if(i>=w.minDrawTileX&&(a>=w.minDrawTileZ&&(n=t[i][a],n&&n.visible&&this.drawTile(n,!1,h)),r=w.minDrawTileZ&&(n=t[s][a],n&&n.visible&&this.drawTile(n,!1,h)),r{if(!c&&!d)return!1;for(let e=n;e=this.maxTileX||t>=this.maxTileZ)return!1;const i=this.levelTiles[s][e][t];if(i&&i.locCount>=5)return!1}const g=new a.Z(s,i,e,t,c,d,p,n,n+o-1,h,h+l-1,u,f);for(let e=n;en&&(i|=1),eh&&(i+=8),t=0;i--)this.levelTiles[i][e][t]||(this.levelTiles[i][e][t]=new r.Z(i,e,t));const a=this.levelTiles[s][e][t];a&&(a.locs[a.locCount]=g,a.locSpan[a.locCount]=i,a.locSpans|=i,a.locCount++)}return m&&(this.temporaryLocs[this.temporaryLocCount++]=g),!0};removeLoc2=e=>{for(let t=e.minSceneTileX;t<=e.maxSceneTileX;t++)for(let i=e.minSceneTileZ;i<=e.maxSceneTileZ;i++){const s=this.levelTiles[e.level][t][i];if(s){for(let t=0;t{const e=w.levelOccluderCount[w.topLevel],t=w.levelOccluders[w.topLevel];w.activeOccluderCount=0;for(let i=0;i=0&&s<=50){a=e.minTileZ+25-w.eyeTileZ,a<0&&(a=0),r=e.maxTileZ+25-w.eyeTileZ,r>50&&(r=50);let t=!1;for(;a<=r;)if(w.visibilityMap&&w.visibilityMap[s][a++]){t=!0;break}if(t){if(n=w.eyeX-e.minX,n>32)e.mode=1;else{if(n>=-32)continue;e.mode=2,n=-n}e.minDeltaZ=(e.minZ-w.eyeZ<<8)/n|0,e.maxDeltaZ=(e.maxZ-w.eyeZ<<8)/n|0,e.minDeltaY=(e.minY-w.eyeY<<8)/n|0,e.maxDeltaY=(e.maxY-w.eyeY<<8)/n|0,w.activeOccluders[w.activeOccluderCount++]=e}}}else if(2===e.type){if(s=e.minTileZ+25-w.eyeTileZ,s>=0&&s<=50){a=e.minTileX+25-w.eyeTileX,a<0&&(a=0),r=e.maxTileX+25-w.eyeTileX,r>50&&(r=50);let t=!1;for(;a<=r;)if(w.visibilityMap&&w.visibilityMap[a++][s]){t=!0;break}if(t){if(n=w.eyeZ-e.minZ,n>32)e.mode=3;else{if(n>=-32)continue;e.mode=4,n=-n}e.minDeltaX=(e.minX-w.eyeX<<8)/n|0,e.maxDeltaX=(e.maxX-w.eyeX<<8)/n|0,e.minDeltaY=(e.minY-w.eyeY<<8)/n|0,e.maxDeltaY=(e.maxY-w.eyeY<<8)/n|0,w.activeOccluders[w.activeOccluderCount++]=e}}}else if(4===e.type&&(s=e.minY-w.eyeY,s>128&&(a=e.minTileZ+25-w.eyeTileZ,a<0&&(a=0),r=e.maxTileZ+25-w.eyeTileZ,r>50&&(r=50),a<=r))){let t=e.minTileX+25-w.eyeTileX;t<0&&(t=0),n=e.maxTileX+25-w.eyeTileX,n>50&&(n=50);let i=!1;e:for(let e=t;e<=n;e++)for(let t=a;t<=r;t++)if(w.visibilityMap&&w.visibilityMap[e][t]){i=!0;break e}i&&(e.mode=5,e.minDeltaX=(e.minX-w.eyeX<<8)/s|0,e.maxDeltaX=(e.maxX-w.eyeX<<8)/s|0,e.minDeltaZ=(e.minZ-w.eyeZ<<8)/s|0,e.maxDeltaZ=(e.maxZ-w.eyeZ<<8)/s|0,w.activeOccluders[w.activeOccluderCount++]=e)}}};drawTile=(e,t,i)=>{for(w.drawTileQueue.pushBack(e);;){let e;do{if(e=w.drawTileQueue.pollFront(),!e)return}while(!e.update);const s=e.x,a=e.z,r=e.level,n=e.occludeLevel,h=this.levelTiles[r];if(e.visible){if(t){if(r>0){const e=this.levelTiles[r-1][s][a];if(e&&e.update)continue}if(s<=w.eyeTileX&&s>w.minDrawTileX){const t=h[s-1][a];if(t&&t.update&&(t.visible||0==(1&e.locSpans)))continue}if(s>=w.eyeTileX&&sw.minDrawTileZ){const t=h[s][a-1];if(t&&t.update&&(t.visible||0==(8&e.locSpans)))continue}if(a>=w.eyeTileZ&&aa&&(l+=6),c=w.FRONT_WALL_TYPES[l],e.backWallTypes=w.BACK_WALL_TYPES[l]),d&&(0==(d.typeA&w.DIRECTION_ALLOW_WALL_CORNER_TYPE[l])?e.checkLocSpans=0:16===d.typeA?(e.checkLocSpans=3,e.blockLocSpans=w.WALL_CORNER_TYPE_16_BLOCK_LOC_SPANS[l],e.inverseBlockLocSpans=3-e.blockLocSpans):32===d.typeA?(e.checkLocSpans=6,e.blockLocSpans=w.WALL_CORNER_TYPE_32_BLOCK_LOC_SPANS[l],e.inverseBlockLocSpans=6-e.blockLocSpans):64===d.typeA?(e.checkLocSpans=12,e.blockLocSpans=w.WALL_CORNER_TYPE_64_BLOCK_LOC_SPANS[l],e.inverseBlockLocSpans=12-e.blockLocSpans):(e.checkLocSpans=9,e.blockLocSpans=w.WALL_CORNER_TYPE_128_BLOCK_LOC_SPANS[l],e.inverseBlockLocSpans=9-e.blockLocSpans),0==(d.typeA&c)||this.wallVisible(n,s,a,d.typeA)||d.modelA?.draw(0,w.sinEyePitch,w.cosEyePitch,w.sinEyeYaw,w.cosEyeYaw,d.x-w.eyeX,d.y-w.eyeY,d.z-w.eyeZ,d.bitset),0==(d.typeB&c)||this.wallVisible(n,s,a,d.typeB)||d.modelB?.draw(0,w.sinEyePitch,w.cosEyePitch,w.sinEyeYaw,w.cosEyeYaw,d.x-w.eyeX,d.y-w.eyeY,d.z-w.eyeZ,d.bitset)),u&&!this.visible(n,s,a,u.model.maxY))if(0!=(u.type&c))u.model.draw(u.angle,w.sinEyePitch,w.cosEyePitch,w.sinEyeYaw,w.cosEyeYaw,u.x-w.eyeX,u.y-w.eyeY,u.z-w.eyeZ,u.bitset);else if(0!=(768&u.type)){const e=u.x-w.eyeX,t=u.y-w.eyeY,i=u.z-w.eyeZ,s=u.angle;let a,r;if(a=s===y.Z.NORTH||s===y.Z.EAST?-e:e,r=s===y.Z.EAST||s===y.Z.SOUTH?-i:i,0!=(256&u.type)&&ra){const a=e+w.WALL_DECORATION_OUTSET_X[s],r=i+w.WALL_DECORATION_OUTSET_Z[s];u.model.draw(512*s+1280&2047,w.sinEyePitch,w.cosEyePitch,w.sinEyeYaw,w.cosEyeYaw,a,t,r,u.bitset)}}if(o){const t=e.groundDecoration;t&&t.model?.draw(0,w.sinEyePitch,w.cosEyePitch,w.sinEyeYaw,w.cosEyeYaw,t.x-w.eyeX,t.y-w.eyeY,t.z-w.eyeZ,t.bitset);const i=e.objStack;i&&0===i.offset&&(i.bottomObj&&i.bottomObj.draw(0,w.sinEyePitch,w.cosEyePitch,w.sinEyeYaw,w.cosEyeYaw,i.x-w.eyeX,i.y-w.eyeY,i.z-w.eyeZ,i.bitset),i.middleObj&&i.middleObj.draw(0,w.sinEyePitch,w.cosEyePitch,w.sinEyeYaw,w.cosEyeYaw,i.x-w.eyeX,i.y-w.eyeY,i.z-w.eyeZ,i.bitset),i.topObj&&i.topObj.draw(0,w.sinEyePitch,w.cosEyePitch,w.sinEyeYaw,w.cosEyeYaw,i.x-w.eyeX,i.y-w.eyeY,i.z-w.eyeZ,i.bitset))}const f=e.locSpans;if(0!==f){if(sw.eyeTileX&&0!=(1&f)){const e=h[s-1][a];e&&e.update&&w.drawTileQueue.pushBack(e)}if(a>w.eyeTileZ&&0!=(8&f)){const e=h[s][a-1];e&&e.update&&w.drawTileQueue.pushBack(e)}}}if(0!==e.checkLocSpans){let t=!0;for(let i=0;it.minSceneTileX&&(r+=1),it.minSceneTileZ&&(r+=8),ss&&(s=a);const n=w.eyeTileZ-t.minSceneTileZ,o=t.maxSceneTileZ-w.eyeTileZ;t.distance=o>n?s+o:s+n}for(;;){let e=-50,t=-1;for(let i=0;ie&&(e=s.distance,t=i)}if(-1===t)break;const o=w.locBuffer[t];if(o){o.cycle=w.cycle;let e=o.model;e||(e=o.entity?.draw(i)??null),e&&!this.locVisible(n,o.minSceneTileX,o.maxSceneTileX,o.minSceneTileZ,o.maxSceneTileZ,e.maxY)&&e.draw(o.yaw,w.sinEyePitch,w.cosEyePitch,w.sinEyeYaw,w.cosEyeYaw,o.x-w.eyeX,o.y-w.eyeY,o.z-w.eyeZ,o.bitset);for(let e=o.minSceneTileX;e<=o.maxSceneTileX;e++)for(let t=o.minSceneTileZ;t<=o.maxSceneTileZ;t++){const i=h[e][t];i&&(0!==i.checkLocSpans?w.drawTileQueue.pushBack(i):e===s&&t===a||!i.update||w.drawTileQueue.pushBack(i))}}}if(e.containsLocs)continue}if(!e.update||0!==e.checkLocSpans)continue;if(s<=w.eyeTileX&&s>w.minDrawTileX){const e=h[s-1][a];if(e&&e.update)continue}if(s>=w.eyeTileX&&sw.minDrawTileZ){const e=h[s][a-1];if(e&&e.update)continue}if(a>=w.eyeTileZ&&a=r){const r=e+w.WALL_DECORATION_INSET_X[a],n=s+w.WALL_DECORATION_INSET_Z[a];t.model.draw(512*a+256,w.sinEyePitch,w.cosEyePitch,w.sinEyeYaw,w.cosEyeYaw,r,i,n,t.bitset)}if(0!=(512&t.type)&&n<=r){const r=e+w.WALL_DECORATION_OUTSET_X[a],n=s+w.WALL_DECORATION_OUTSET_Z[a];t.model.draw(512*a+1280&2047,w.sinEyePitch,w.cosEyePitch,w.sinEyeYaw,w.cosEyeYaw,r,i,n,t.bitset)}}const i=e.wall;i&&(0==(i.typeB&e.backWallTypes)||this.wallVisible(n,s,a,i.typeB)||i.modelB?.draw(0,w.sinEyePitch,w.cosEyePitch,w.sinEyeYaw,w.cosEyeYaw,i.x-w.eyeX,i.y-w.eyeY,i.z-w.eyeZ,i.bitset),0==(i.typeA&e.backWallTypes)||this.wallVisible(n,s,a,i.typeA)||i.modelA?.draw(0,w.sinEyePitch,w.cosEyePitch,w.sinEyeYaw,w.cosEyeYaw,i.x-w.eyeX,i.y-w.eyeY,i.z-w.eyeZ,i.bitset))}if(rw.eyeTileX){const e=h[s-1][a];e&&e.update&&w.drawTileQueue.pushBack(e)}if(a>w.eyeTileZ){const e=h[s][a-1];e&&e.update&&w.drawTileQueue.pushBack(e)}}};drawTileUnderlay=(e,t,i,a,r,n,h,o)=>{let l,c,d,u,f=l=(i<<7)-w.eyeX,m=c=(a<<7)-w.eyeZ,g=d=f+128,y=u=m+128,C=this.levelHeightmaps[t][i][a]-w.eyeY,T=this.levelHeightmaps[t][i+1][a]-w.eyeY,S=this.levelHeightmaps[t][i+1][a+1]-w.eyeY,Z=this.levelHeightmaps[t][i][a+1]-w.eyeY,A=m*h+f*o>>16;if(m=m*o-f*h>>16,f=A,A=C*n-m*r>>16,m=C*r+m*n>>16,C=A,m<50)return;if(A=c*h+g*o>>16,c=c*o-g*h>>16,g=A,A=T*n-c*r>>16,c=T*r+c*n>>16,T=A,c<50)return;if(A=y*h+d*o>>16,y=y*o-d*h>>16,d=A,A=S*n-y*r>>16,y=S*r+y*n>>16,S=A,y<50)return;if(A=u*h+l*o>>16,u=u*o-l*h>>16,l=A,A=Z*n-u*r>>16,u=Z*r+u*n>>16,Z=A,u<50)return;const v=s.Z.centerX+((f<<9)/m|0),I=s.Z.centerY+((C<<9)/m|0),O=s.Z.centerX+((g<<9)/c|0),b=s.Z.centerY+((T<<9)/c|0),L=s.Z.centerX+((d<<9)/y|0),E=s.Z.centerY+((S<<9)/y|0),x=s.Z.centerX+((l<<9)/u|0),_=s.Z.centerY+((Z<<9)/u|0);if(s.Z.alpha=0,(L-x)*(b-_)-(E-_)*(O-x)>0)if(s.Z.clipX=L<0||x<0||O<0||L>p.Z.boundX||x>p.Z.boundX||O>p.Z.boundX,w.takingInput&&this.pointInsideTriangle(w.mouseX,w.mouseY,E,_,b,L,x,O)&&(w.clickTileX=i,w.clickTileZ=a),-1===e.textureId)12345678!==e.northeastColor&&s.Z.fillGouraudTriangle(L,x,O,E,_,b,e.northeastColor,e.northwestColor,e.southeastColor);else if(w.lowMemory){const t=w.TEXTURE_HSL[e.textureId];s.Z.fillGouraudTriangle(L,x,O,E,_,b,this.mulLightness(t,e.northeastColor),this.mulLightness(t,e.northwestColor),this.mulLightness(t,e.southeastColor))}else e.flat?s.Z.fillTexturedTriangle(L,x,O,E,_,b,e.northeastColor,e.northwestColor,e.southeastColor,f,C,m,g,l,T,Z,c,u,e.textureId):s.Z.fillTexturedTriangle(L,x,O,E,_,b,e.northeastColor,e.northwestColor,e.southeastColor,d,S,y,l,g,Z,T,u,c,e.textureId);if(!((v-O)*(_-b)-(I-b)*(x-O)<=0))if(s.Z.clipX=v<0||O<0||x<0||v>p.Z.boundX||O>p.Z.boundX||x>p.Z.boundX,w.takingInput&&this.pointInsideTriangle(w.mouseX,w.mouseY,I,b,_,v,O,x)&&(w.clickTileX=i,w.clickTileZ=a),-1!==e.textureId){if(!w.lowMemory)return void s.Z.fillTexturedTriangle(v,O,x,I,b,_,e.southwestColor,e.southeastColor,e.northwestColor,f,C,m,g,l,T,Z,c,u,e.textureId);const t=w.TEXTURE_HSL[e.textureId];s.Z.fillGouraudTriangle(v,O,x,I,b,_,this.mulLightness(t,e.southwestColor),this.mulLightness(t,e.southeastColor),this.mulLightness(t,e.northwestColor))}else 12345678!==e.southwestColor&&s.Z.fillGouraudTriangle(v,O,x,I,b,_,e.southwestColor,e.southeastColor,e.northwestColor)};drawTileOverlay=(e,t,i,a,r,n,h)=>{let o=i.vertexX.length;for(let e=0;e>16;if(l=l*h-t*n>>16,t=c,c=o*r-l*a>>16,l=o*a+l*r>>16,o=c,l<50)return;i.triangleTextureIds&&(m.Z.tmpViewspaceX[e]=t,m.Z.tmpViewspaceY[e]=o,m.Z.tmpViewspaceZ[e]=l),m.Z.tmpScreenX[e]=s.Z.centerX+((t<<9)/l|0),m.Z.tmpScreenY[e]=s.Z.centerY+((o<<9)/l|0)}s.Z.alpha=0,o=i.triangleVertexA.length;for(let a=0;a0)if(s.Z.clipX=o<0||l<0||c<0||o>p.Z.boundX||l>p.Z.boundX||c>p.Z.boundX,w.takingInput&&this.pointInsideTriangle(w.mouseX,w.mouseY,d,u,f,o,l,c)&&(w.clickTileX=e,w.clickTileZ=t),i.triangleTextureIds&&-1!==i.triangleTextureIds[a])if(w.lowMemory){const e=w.TEXTURE_HSL[i.triangleTextureIds[a]];s.Z.fillGouraudTriangle(o,l,c,d,u,f,this.mulLightness(e,i.triangleColorA[a]),this.mulLightness(e,i.triangleColorB[a]),this.mulLightness(e,i.triangleColorC[a]))}else i.flat?s.Z.fillTexturedTriangle(o,l,c,d,u,f,i.triangleColorA[a],i.triangleColorB[a],i.triangleColorC[a],m.Z.tmpViewspaceX[0],m.Z.tmpViewspaceY[0],m.Z.tmpViewspaceZ[0],m.Z.tmpViewspaceX[1],m.Z.tmpViewspaceX[3],m.Z.tmpViewspaceY[1],m.Z.tmpViewspaceY[3],m.Z.tmpViewspaceZ[1],m.Z.tmpViewspaceZ[3],i.triangleTextureIds[a]):s.Z.fillTexturedTriangle(o,l,c,d,u,f,i.triangleColorA[a],i.triangleColorB[a],i.triangleColorC[a],m.Z.tmpViewspaceX[r],m.Z.tmpViewspaceY[r],m.Z.tmpViewspaceZ[r],m.Z.tmpViewspaceX[n],m.Z.tmpViewspaceX[h],m.Z.tmpViewspaceY[n],m.Z.tmpViewspaceY[h],m.Z.tmpViewspaceZ[n],m.Z.tmpViewspaceZ[h],i.triangleTextureIds[a]);else 12345678!==i.triangleColorA[a]&&s.Z.fillGouraudTriangle(o,l,c,d,u,f,i.triangleColorA[a],i.triangleColorB[a],i.triangleColorC[a])}};tileVisible=(e,t,i)=>{const s=this.levelTileOcclusionCycles[e][t][i];if(s===-w.cycle)return!1;if(s===w.cycle)return!0;{const s=t<<7,a=i<<7;return this.occluded(s+1,this.levelHeightmaps[e][t][i],a+1)&&this.occluded(s+128-1,this.levelHeightmaps[e][t+1][i],a+1)&&this.occluded(s+128-1,this.levelHeightmaps[e][t+1][i+1],a+128-1)&&this.occluded(s+1,this.levelHeightmaps[e][t][i+1],a+128-1)?(this.levelTileOcclusionCycles[e][t][i]=w.cycle,!0):(this.levelTileOcclusionCycles[e][t][i]=-w.cycle,!1)}};wallVisible=(e,t,i,s)=>{if(!this.tileVisible(e,t,i))return!1;const a=t<<7,r=i<<7,n=this.levelHeightmaps[e][t][i]-1,h=n-120,o=n-230,l=n-238;if(s<16){if(1===s){if(a>w.eyeX){if(!this.occluded(a,n,r))return!1;if(!this.occluded(a,n,r+128))return!1}if(e>0){if(!this.occluded(a,h,r))return!1;if(!this.occluded(a,h,r+128))return!1}return!!this.occluded(a,o,r)&&this.occluded(a,o,r+128)}if(2===s){if(r0){if(!this.occluded(a,h,r+128))return!1;if(!this.occluded(a+128,h,r+128))return!1}return!!this.occluded(a,o,r+128)&&this.occluded(a+128,o,r+128)}if(4===s){if(a0){if(!this.occluded(a+128,h,r))return!1;if(!this.occluded(a+128,h,r+128))return!1}return!!this.occluded(a+128,o,r)&&this.occluded(a+128,o,r+128)}if(8===s){if(r>w.eyeZ){if(!this.occluded(a,n,r))return!1;if(!this.occluded(a+128,n,r))return!1}if(e>0){if(!this.occluded(a,h,r))return!1;if(!this.occluded(a+128,h,r))return!1}return!!this.occluded(a,o,r)&&this.occluded(a+128,o,r)}}return!!this.occluded(a+64,l,r+64)&&(16===s?this.occluded(a,o,r+128):32===s?this.occluded(a+128,o,r+128):64===s?this.occluded(a+128,o,r):128===s?this.occluded(a,o,r):(console.warn("Warning unsupported wall type!"),!0))};visible=(e,t,i,s)=>{if(this.tileVisible(e,t,i)){const a=t<<7,r=i<<7;return this.occluded(a+1,this.levelHeightmaps[e][t][i]-s,r+1)&&this.occluded(a+128-1,this.levelHeightmaps[e][t+1][i]-s,r+1)&&this.occluded(a+128-1,this.levelHeightmaps[e][t+1][i+1]-s,r+128-1)&&this.occluded(a+1,this.levelHeightmaps[e][t][i+1]-s,r+128-1)}return!1};locVisible=(e,t,i,s,a,r)=>{let n,h;if(t!==i||s!==a){for(n=t;n<=i;n++)for(h=s;h<=a;h++)if(this.levelTileOcclusionCycles[e][n][h]===-w.cycle)return!1;h=1+(t<<7);const o=2+(s<<7),l=this.levelHeightmaps[e][t][s]-r;if(!this.occluded(h,l,o))return!1;const c=(i<<7)-1;if(!this.occluded(c,l,o))return!1;const d=(a<<7)-1;return!!this.occluded(h,l,d)&&this.occluded(c,l,d)}return!!this.tileVisible(e,t,s)&&(n=t<<7,h=s<<7,this.occluded(n+1,this.levelHeightmaps[e][t][s]-r,h+1)&&this.occluded(n+128-1,this.levelHeightmaps[e][t+1][s]-r,h+1)&&this.occluded(n+128-1,this.levelHeightmaps[e][t+1][s+1]-r,h+128-1)&&this.occluded(n+1,this.levelHeightmaps[e][t][s+1]-r,h+128-1))};occluded=(e,t,i)=>{for(let s=0;s0){const e=a.minZ+(a.minDeltaZ*s>>8),r=a.maxZ+(a.maxDeltaZ*s>>8),n=a.minY+(a.minDeltaY*s>>8),h=a.maxY+(a.maxDeltaY*s>>8);if(i>=e&&i<=r&&t>=n&&t<=h)return!0}}else if(2===a.mode){const s=e-a.minX;if(s>0){const e=a.minZ+(a.minDeltaZ*s>>8),r=a.maxZ+(a.maxDeltaZ*s>>8),n=a.minY+(a.minDeltaY*s>>8),h=a.maxY+(a.maxDeltaY*s>>8);if(i>=e&&i<=r&&t>=n&&t<=h)return!0}}else if(3===a.mode){const s=a.minZ-i;if(s>0){const i=a.minX+(a.minDeltaX*s>>8),r=a.maxX+(a.maxDeltaX*s>>8),n=a.minY+(a.minDeltaY*s>>8),h=a.maxY+(a.maxDeltaY*s>>8);if(e>=i&&e<=r&&t>=n&&t<=h)return!0}}else if(4===a.mode){const s=i-a.minZ;if(s>0){const i=a.minX+(a.minDeltaX*s>>8),r=a.maxX+(a.maxDeltaX*s>>8),n=a.minY+(a.minDeltaY*s>>8),h=a.maxY+(a.maxDeltaY*s>>8);if(e>=i&&e<=r&&t>=n&&t<=h)return!0}}else if(5===a.mode){const s=t-a.minY;if(s>0){const t=a.minX+(a.minDeltaX*s>>8),r=a.maxX+(a.maxDeltaX*s>>8),n=a.minZ+(a.minDeltaZ*s>>8),h=a.maxZ+(a.maxDeltaZ*s>>8);if(e>=t&&e<=r&&i>=n&&i<=h)return!0}}}return!1};pointInsideTriangle=(e,t,i,s,a,r,n,h)=>{if(ti&&t>s&&t>a)return!1;if(er&&e>n&&e>h)return!1;const o=(t-s)*(h-n)-(e-n)*(a-s);return((t-i)*(n-r)-(e-r)*(s-i))*o>0&&o*((t-a)*(r-h)-(e-h)*(i-a))>0};mulLightness=(e,t)=>((t=(127-t)*(127&e)/160|0)<2?t=2:t>126&&(t=126),(65408&e)+t)}},9129:(e,t,i)=>{i.d(t,{Z:()=>a});var s=i(3064);class a extends s.Z{}},682:(e,t,i)=>{i.d(t,{Z:()=>a});var s=i(3064);class a extends s.Z{heightmapSW;heightmapSE;heightmapNE;heightmapNW;index;seq;seqFrame;seqCycle;constructor(e,t,i,s,a,r,n){super(),this.heightmapSW=t,this.heightmapSE=i,this.heightmapNE=s,this.heightmapNW=a,this.index=e,this.seq=r,n&&-1!==r.replayoff&&this.seq.delay?(this.seqFrame=Math.random()*this.seq.frameCount|0,this.seqCycle=Math.random()*this.seq.delay[this.seqFrame]|0):(this.seqFrame=-1,this.seqCycle=0)}}},1353:(e,t,i)=>{i.d(t,{Z:()=>h});var s=i(8839),a=i(9178),r=i(551),n=i(8067);class h extends s.Z{type=null;draw=()=>{if(!this.type)return null;if(-1===this.spotanimId||-1===this.spotanimFrame)return this.getSequencedModel();const e=this.getSequencedModel();if(!e)return null;const t=r.Z.instances[this.spotanimId],i=a.Z.modelShareColored(t.getModel(),!0,!t.disposeAlpha,!1);i.translate(-this.spotanimOffset,0,0),i.createLabelReferences(),t.seq&&t.seq.frames&&i.applyTransform(t.seq.frames[this.spotanimFrame]),i.labelFaces=null,i.labelVertices=null,128===t.resizeh&&128===t.resizev||i.scale(t.resizeh,t.resizev,t.resizeh),i.calculateNormals(64+t.ambient,850+t.contrast,-30,-50,-30,!0);const s=[e,i],n=a.Z.modelFromModelsBounds(s,2);return 1===this.type.size&&(n.pickable=!0),n};isVisible=()=>null!==this.type;getSequencedModel=()=>{if(!this.type)return null;if(this.primarySeqId>=0&&0===this.primarySeqDelay){const e=n.Z.instances[this.primarySeqId].frames;if(e){const t=e[this.primarySeqFrame];let i=-1;if(this.secondarySeqId>=0&&this.secondarySeqId!==this.seqStandId){const e=n.Z.instances[this.secondarySeqId].frames;e&&(i=e[this.secondarySeqFrame])}return this.type.getSequencedModel(t,i,n.Z.instances[this.primarySeqId].labelGroups)}}let e=-1;if(this.secondarySeqId>=0){const t=n.Z.instances[this.secondarySeqId].frames;t&&(e=t[this.secondarySeqFrame])}const t=this.type.getSequencedModel(e,-1,null);return t?(this.height=t.maxY,t):null}}},7973:(e,t,i)=>{i.d(t,{Z:()=>a});var s=i(3064);class a extends s.Z{index;count;constructor(e,t){super(),this.index=e,this.count=t}}},8839:(e,t,i)=>{i.d(t,{Z:()=>n});var s=i(9129),a=i(8067),r=i(9345);class n extends s.Z{x=0;z=0;yaw=0;seqStretches=!1;size=1;seqStandId=-1;seqTurnId=-1;seqWalkId=-1;seqTurnAroundId=-1;seqTurnLeftId=-1;seqTurnRightId=-1;seqRunId=-1;chat=null;chatTimer=100;chatColor=0;chatStyle=0;damage=0;damageType=0;combatCycle=-1e3;health=0;totalHealth=0;targetId=-1;targetTileX=0;targetTileZ=0;secondarySeqId=-1;secondarySeqFrame=0;secondarySeqCycle=0;primarySeqId=-1;primarySeqFrame=0;primarySeqCycle=0;primarySeqDelay=0;primarySeqLoop=0;spotanimId=-1;spotanimFrame=0;spotanimCycle=0;spotanimLastCycle=0;spotanimOffset=0;forceMoveStartSceneTileX=0;forceMoveEndSceneTileX=0;forceMoveStartSceneTileZ=0;forceMoveEndSceneTileZ=0;forceMoveEndCycle=0;forceMoveStartCycle=0;forceMoveFaceDirection=0;cycle=0;height=0;dstYaw=0;pathLength=0;pathTileX=new Int32Array(10);pathTileZ=new Int32Array(10);pathRunning=new r.to(10,!1);seqTrigger=0;lastMask=-1;lastMaskCycle=-1;lastFaceX=-1;lastFaceZ=-1;move=(e,t,i)=>{if(-1!==this.primarySeqId&&a.Z.instances[this.primarySeqId].priority<=1&&(this.primarySeqId=-1),!e){const e=t-this.pathTileX[0],s=i-this.pathTileZ[0];if(e>=-8&&e<=8&&s>=-8&&s<=8){this.pathLength<9&&this.pathLength++;for(let e=this.pathLength;e>0;e--)this.pathTileX[e]=this.pathTileX[e-1],this.pathTileZ[e]=this.pathTileZ[e-1],this.pathRunning[e]=this.pathRunning[e-1];return this.pathTileX[0]=t,this.pathTileZ[0]=i,void(this.pathRunning[0]=!1)}}this.pathLength=0,this.seqTrigger=0,this.pathTileX[0]=t,this.pathTileZ[0]=i,this.x=128*this.pathTileX[0]+64*this.size,this.z=128*this.pathTileZ[0]+64*this.size};step=(e,t)=>{let i=this.pathTileX[0],s=this.pathTileZ[0];0===t?(i--,s++):1===t?s++:2===t?(i++,s++):3===t?i--:4===t?i++:5===t?(i--,s--):6===t?s--:7===t&&(i++,s--),-1!==this.primarySeqId&&a.Z.instances[this.primarySeqId].priority<=1&&(this.primarySeqId=-1),this.pathLength<9&&this.pathLength++;for(let e=this.pathLength;e>0;e--)this.pathTileX[e]=this.pathTileX[e-1],this.pathTileZ[e]=this.pathTileZ[e-1],this.pathRunning[e]=this.pathRunning[e-1];this.pathTileX[0]=i,this.pathTileZ[0]=s,this.pathRunning[0]=e}}},4191:(e,t,i)=>{i.d(t,{Z:()=>u});var s=i(8839),a=i(9178),r=i(5542),n=i(551),h=i(8067),o=i(8809),l=i(1840),c=i(8934),d=i(9345);class u extends s.Z{static DESIGN_HAIR_COLOR=[9104,10275,7595,3610,7975,8526,918,38802,24466,10145,58654,5027,1457,16565,34991,25486];static DESIGN_BODY_COLOR=[[6798,107,10283,16,4797,7744,5799,4634,33697,22433,2983,54193],[8741,12,64030,43162,7735,8404,1701,38430,24094,10153,56621,4783,1341,16578,35003,25239],[25238,8742,12,64030,43162,7735,8404,1701,38430,24094,10153,56621,4783,1341,16578,35003],[4626,11146,6439,12,4758,10270],[4550,4537,5681,5673,5790,6806,8076,4574]];static modelCache=new r.Z(200);name=null;visible=!1;gender=0;headicons=0;appearances=new Uint16Array(12);colors=new Uint16Array(5);combatLevel=0;appearanceHashcode=0n;y=0;locStartCycle=0;locStopCycle=0;locOffsetX=0;locOffsetY=0;locOffsetZ=0;locModel=null;minTileX=0;minTileZ=0;maxTileX=0;maxTileZ=0;lowMemory=!1;draw(e){if(!this.visible)return null;let t=this.getSequencedModel();if(this.height=t.maxY,t.pickable=!0,this.lowMemory)return t;if(-1!==this.spotanimId&&-1!==this.spotanimFrame){const e=n.Z.instances[this.spotanimId],i=a.Z.modelShareColored(e.getModel(),!0,!e.disposeAlpha,!1);i.translate(-this.spotanimOffset,0,0),i.createLabelReferences(),e.seq&&e.seq.frames&&i.applyTransform(e.seq.frames[this.spotanimFrame]),i.labelFaces=null,i.labelVertices=null,128===e.resizeh&&128===e.resizev||i.scale(e.resizeh,e.resizev,e.resizeh),i.calculateNormals(e.ambient+64,e.contrast+850,-30,-50,-30,!0);const s=[t,i];t=a.Z.modelFromModelsBounds(s,2)}if(this.locModel&&(e>=this.locStopCycle&&(this.locModel=null),e>=this.locStartCycle&&ethis.visible;read=e=>{e.pos=0,this.gender=e.g1,this.headicons=e.g1;for(let t=0;t<12;t++){const i=e.g1;this.appearances[t]=0===i?0:(i<<8)+e.g1}for(let t=0;t<5;t++){let i=e.g1;(i<0||i>=u.DESIGN_BODY_COLOR[t].length)&&(i=0),this.colors[t]=i}this.seqStandId=e.g2,65535===this.seqStandId&&(this.seqStandId=-1),this.seqTurnId=e.g2,65535===this.seqTurnId&&(this.seqTurnId=-1),this.seqWalkId=e.g2,65535===this.seqWalkId&&(this.seqWalkId=-1),this.seqTurnAroundId=e.g2,65535===this.seqTurnAroundId&&(this.seqTurnAroundId=-1),this.seqTurnLeftId=e.g2,65535===this.seqTurnLeftId&&(this.seqTurnLeftId=-1),this.seqTurnRightId=e.g2,65535===this.seqTurnRightId&&(this.seqTurnRightId=-1),this.seqRunId=e.g2,65535===this.seqRunId&&(this.seqRunId=-1),this.name=c.Z.formatName(c.Z.fromBase37(e.g8)),this.combatLevel=e.g1,this.visible=!0,this.appearanceHashcode=0n;for(let e=0;e<12;e++)this.appearanceHashcode<<=0x4n,this.appearances[e]>=256&&(this.appearanceHashcode+=BigInt(this.appearances[e])-256n);this.appearances[0]>=256&&(this.appearanceHashcode+=BigInt(this.appearances[0])-256n>>4n),this.appearances[1]>=256&&(this.appearanceHashcode+=BigInt(this.appearances[1])-256n>>8n);for(let e=0;e<5;e++)this.appearanceHashcode<<=0x3n,this.appearanceHashcode+=BigInt(this.colors[e]);this.appearanceHashcode<<=0x1n,this.appearanceHashcode+=BigInt(this.gender)};getHeadModel=()=>{if(!this.visible)return null;const e=new d.to(12,null);let t=0;for(let i=0;i<12;i++){const s=this.appearances[i];if(s>=256&&s<512&&(e[t++]=o.Z.instances[s-256].getHeadModel()),s>=512){const i=l.Z.get(s-512).getHeadModel(this.gender);i&&(e[t++]=i)}}const i=a.Z.modelFromModels(e,t);for(let e=0;e<5;e++)0!==this.colors[e]&&(i.recolor(u.DESIGN_BODY_COLOR[e][0],u.DESIGN_BODY_COLOR[e][this.colors[e]]),1===e&&i.recolor(u.DESIGN_HAIR_COLOR[0],u.DESIGN_HAIR_COLOR[this.colors[e]]));return i};getSequencedModel=()=>{let e=this.appearanceHashcode,t=-1,i=-1,s=-1,r=-1;if(this.primarySeqId>=0&&0===this.primarySeqDelay){const a=h.Z.instances[this.primarySeqId];if(a.frames&&(t=a.frames[this.primarySeqFrame]),this.secondarySeqId>=0&&this.secondarySeqId!==this.seqStandId){const e=h.Z.instances[this.secondarySeqId].frames;e&&(i=e[this.secondarySeqFrame])}a.mainhand>=0&&(s=a.mainhand,e+=BigInt(s-this.appearances[5])<<8n),a.offhand>=0&&(r=a.offhand,e+=BigInt(r-this.appearances[3])<<16n)}else if(this.secondarySeqId>=0){const e=h.Z.instances[this.secondarySeqId].frames;e&&(t=e[this.secondarySeqFrame])}let n=u.modelCache?.get(e);if(!n){const t=new d.to(12,null);let i=0;for(let e=0;e<12;e++){let a=this.appearances[e];if(r>=0&&3===e&&(a=r),s>=0&&5===e&&(a=s),a>=256&&a<512){const e=o.Z.instances[a-256].getModel();e&&(t[i++]=e)}if(a>=512){const e=l.Z.get(a-512).getWornModel(this.gender);e&&(t[i++]=e)}}n=a.Z.modelFromModels(t,i);for(let e=0;e<5;e++)0!==this.colors[e]&&(n.recolor(u.DESIGN_BODY_COLOR[e][0],u.DESIGN_BODY_COLOR[e][this.colors[e]]),1===e&&n.recolor(u.DESIGN_HAIR_COLOR[0],u.DESIGN_HAIR_COLOR[this.colors[e]]));n.createLabelReferences(),n.calculateNormals(64,850,-30,-50,-30,!0),u.modelCache?.put(e,n)}if(this.lowMemory)return n;const c=a.Z.modelShareAlpha(n,!0);return-1!==t&&-1!==i?c.applyTransforms(t,i,h.Z.instances[this.primarySeqId].labelGroups):-1!==t&&c.applyTransform(t),c.calculateBoundsCylinder(),c.labelFaces=null,c.labelVertices=null,c}}},1810:(e,t,i)=>{i.d(t,{Z:()=>n});var s=i(551),a=i(9129),r=i(9178);class n extends a.Z{spotanim;level;srcX;srcZ;srcY;offsetY;startCycle;lastCycle;peakPitch;arc;target;mobile=!1;x=0;z=0;y=0;velocityX=0;velocityZ=0;velocity=0;velocityY=0;accelerationY=0;yaw=0;pitch=0;seqFrame=0;seqCycle=0;constructor(e,t,i,a,r,n,h,o,l,c,d){super(),this.spotanim=s.Z.instances[e],this.level=t,this.srcX=i,this.srcZ=r,this.srcY=a,this.startCycle=n,this.lastCycle=h,this.peakPitch=o,this.arc=l,this.target=c,this.offsetY=d}updateVelocity=(e,t,i,s)=>{if(!this.mobile){const t=e-this.srcX,s=i-this.srcZ,a=Math.sqrt(t*t+s*s);this.x=this.srcX+t*this.arc/a,this.z=this.srcZ+s*this.arc/a,this.y=this.srcY}const a=this.lastCycle+1-s;this.velocityX=(e-this.x)/a,this.velocityZ=(i-this.z)/a,this.velocity=Math.sqrt(this.velocityX*this.velocityX+this.velocityZ*this.velocityZ),this.mobile||(this.velocityY=-this.velocity*Math.tan(.02454369*this.peakPitch)),this.accelerationY=2*(t-this.y-this.velocityY*a)/(a*a)};update=e=>{if(this.mobile=!0,this.x+=this.velocityX*e,this.z+=this.velocityZ*e,this.y+=this.velocityY*e+.5*this.accelerationY*e*e,this.velocityY+=this.accelerationY*e,this.yaw=2047&(325.949*Math.atan2(this.velocityX,this.velocityZ)+1024|0),this.pitch=2047&(325.949*Math.atan2(this.velocityY,this.velocity)|0),this.spotanim.seq&&this.spotanim.seq.delay)for(this.seqCycle+=e;this.seqCycle>this.spotanim.seq.delay[this.seqFrame];)this.seqCycle-=this.spotanim.seq.delay[this.seqFrame]+1,this.seqFrame++,this.seqFrame>=this.spotanim.seq.frameCount&&(this.seqFrame=0)};draw=()=>{const e=this.spotanim.getModel(),t=r.Z.modelShareColored(e,!0,!this.spotanim.disposeAlpha,!1);return this.spotanim.seq&&this.spotanim.seq.frames&&(t.createLabelReferences(),t.applyTransform(this.spotanim.seq.frames[this.seqFrame]),t.labelFaces=null,t.labelVertices=null),128===this.spotanim.resizeh&&128===this.spotanim.resizev||t.scale(this.spotanim.resizeh,this.spotanim.resizev,this.spotanim.resizeh),t.rotateX(this.pitch),t.calculateNormals(64+this.spotanim.ambient,850+this.spotanim.contrast,-30,-50,-30,!0),t}}},5659:(e,t,i)=>{i.d(t,{Z:()=>n});var s=i(9129),a=i(551),r=i(9178);class n extends s.Z{type;level;x;z;y;startCycle;seqComplete=!1;seqFrame=0;seqCycle=0;constructor(e,t,i,s,r,n,h){super(),this.type=a.Z.instances[e],this.level=t,this.x=i,this.z=s,this.y=r,this.startCycle=n+h}update=e=>{if(this.type.seq&&this.type.seq.delay)for(this.seqCycle+=e;this.seqCycle>this.type.seq.delay[this.seqFrame];)this.seqCycle-=this.type.seq.delay[this.seqFrame]+1,this.seqFrame++,this.seqFrame>=this.type.seq.frameCount&&(this.seqFrame=0,this.seqComplete=!0)};draw=()=>{const e=this.type.getModel(),t=r.Z.modelShareColored(e,!0,!this.type.disposeAlpha,!1);return!this.seqComplete&&this.type.seq&&this.type.seq.frames&&(t.createLabelReferences(),t.applyTransform(this.type.seq.frames[this.seqFrame]),t.labelFaces=null,t.labelVertices=null),128===this.type.resizeh&&128===this.type.resizev||t.scale(this.type.resizeh,this.type.resizev,this.type.resizeh),0!==this.type.orientation&&(90===this.type.orientation?t.rotateY90():180===this.type.orientation?(t.rotateY90(),t.rotateY90()):270===this.type.orientation&&(t.rotateY90(),t.rotateY90(),t.rotateY90())),t.calculateNormals(64+this.type.ambient,850+this.type.contrast,-30,-50,-30,!0),t}}},4155:(e,t,i)=>{i.d(t,{Z:()=>s});class s{y;x;z;model;bitset;info;constructor(e,t,i,s,a,r){this.y=e,this.x=t,this.z=i,this.model=s,this.bitset=a,this.info=r}}},6539:(e,t,i)=>{i.d(t,{Z:()=>s});class s{level;y;x;z;model;entity;yaw;minSceneTileX;maxSceneTileX;minSceneTileZ;maxSceneTileZ;bitset;info;distance=0;cycle=0;constructor(e,t,i,s,a,r,n,h,o,l,c,d,u){this.level=e,this.y=t,this.x=i,this.z=s,this.model=a,this.entity=r,this.yaw=n,this.minSceneTileX=h,this.maxSceneTileX=o,this.minSceneTileZ=l,this.maxSceneTileZ=c,this.bitset=d,this.info=u}}},7396:(e,t,i)=>{i.d(t,{Z:()=>a});var s=i(3064);class a extends s.Z{plane;layer;x;z;locIndex;angle;shape;lastCycle;constructor(e,t,i,s,a,r,n,h){super(),this.plane=e,this.layer=t,this.x=i,this.z=s,this.locIndex=a,this.angle=r,this.shape=n,this.lastCycle=h}}},6150:(e,t,i)=>{i.d(t,{Z:()=>a});var s=i(3064);class a extends s.Z{plane;layer;x;z;locIndex;angle;shape;lastLocIndex;lastAngle;lastShape;constructor(e,t,i,s,a,r,n,h,o,l){super(),this.plane=e,this.layer=t,this.x=i,this.z=s,this.locIndex=a,this.angle=r,this.shape=n,this.lastLocIndex=h,this.lastAngle=o,this.lastShape=l}}},6711:(e,t,i)=>{i.d(t,{Z:()=>s});class s{y;x;z;topObj;middleObj;bottomObj;bitset;offset;constructor(e,t,i,s,a,r,n,h){this.y=e,this.x=t,this.z=i,this.topObj=s,this.middleObj=a,this.bottomObj=r,this.bitset=n,this.offset=h}}},4138:(e,t,i)=>{i.d(t,{Z:()=>s});class s{minTileX;maxTileX;minTileZ;maxTileZ;type;minX;maxX;minZ;maxZ;minY;maxY;mode=0;minDeltaX=0;maxDeltaX=0;minDeltaZ=0;maxDeltaZ=0;minDeltaY=0;maxDeltaY=0;constructor(e,t,i,s,a,r,n,h,o,l,c){this.minTileX=e,this.maxTileX=t,this.minTileZ=i,this.maxTileZ=s,this.type=a,this.minX=r,this.maxX=n,this.minZ=h,this.maxZ=o,this.minY=l,this.maxY=c}}},220:(e,t,i)=>{i.d(t,{Z:()=>r});var s=i(3064),a=i(9345);class r extends s.Z{level;x;z;occludeLevel;locs;locSpan;underlay=null;overlay=null;wall=null;wallDecoration=null;groundDecoration=null;objStack=null;bridge=null;locCount=0;locSpans=0;drawLevel=0;visible=!1;update=!1;containsLocs=!1;checkLocSpans=0;blockLocSpans=0;inverseBlockLocSpans=0;backWallTypes=0;constructor(e,t,i){super(),this.occludeLevel=this.level=e,this.x=t,this.z=i,this.locs=new a.to(5,null),this.locSpan=new Int32Array(5)}}},8570:(e,t,i)=>{i.d(t,{Z:()=>s});class s{static tmpScreenX=new Int32Array(6);static tmpScreenY=new Int32Array(6);static tmpViewspaceX=new Int32Array(6);static tmpViewspaceY=new Int32Array(6);static tmpViewspaceZ=new Int32Array(6);static SHAPE_POINTS=[Int32Array.of(1,3,5,7),Int32Array.of(1,3,5,7),Int32Array.of(1,3,5,7),Int32Array.of(1,3,5,7,6),Int32Array.of(1,3,5,7,6),Int32Array.of(1,3,5,7,6),Int32Array.of(1,3,5,7,6),Int32Array.of(1,3,5,7,2,6),Int32Array.of(1,3,5,7,2,8),Int32Array.of(1,3,5,7,2,8),Int32Array.of(1,3,5,7,11,12),Int32Array.of(1,3,5,7,11,12),Int32Array.of(1,3,5,7,13,14)];static SHAPE_PATHS=[Int32Array.of(0,1,2,3,0,0,1,3),Int32Array.of(1,1,2,3,1,0,1,3),Int32Array.of(0,1,2,3,1,0,1,3),Int32Array.of(0,0,1,2,0,0,2,4,1,0,4,3),Int32Array.of(0,0,1,4,0,0,4,3,1,1,2,4),Int32Array.of(0,0,4,3,1,0,1,2,1,0,2,4),Int32Array.of(0,1,2,4,1,0,1,4,1,0,4,3),Int32Array.of(0,4,1,2,0,4,2,5,1,0,4,5,1,0,5,3),Int32Array.of(0,4,1,2,0,4,2,3,0,4,3,5,1,0,4,5),Int32Array.of(0,0,4,5,1,4,1,2,1,4,2,3,1,4,3,5),Int32Array.of(0,0,1,5,0,1,4,5,0,1,2,4,1,0,5,3,1,5,4,3,1,4,2,3),Int32Array.of(1,0,1,5,1,1,4,5,1,1,2,4,0,0,5,3,0,5,4,3,0,4,2,3),Int32Array.of(1,0,5,4,1,0,1,5,0,0,4,3,0,4,5,3,0,5,2,3,0,1,2,5)];static FULL_SQUARE=128;static HALF_SQUARE=this.FULL_SQUARE/2|0;static CORNER_SMALL=this.FULL_SQUARE/4|0;static CORNER_BIG=3*this.FULL_SQUARE/4|0;vertexX;vertexY;vertexZ;triangleColorA;triangleColorB;triangleColorC;triangleVertexA;triangleVertexB;triangleVertexC;triangleTextureIds;flat;shape;rotation;backgroundRgb;foregroundRgb;constructor(e,t,i,a,r,n,h,o,l,c,d,u,f,p,m,g,y,C,w){this.flat=!(y!==a||y!==p||y!==o),this.shape=t,this.rotation=n,this.backgroundRgb=f,this.foregroundRgb=l;const T=s.SHAPE_POINTS[t],S=T.length;this.vertexX=new Int32Array(S),this.vertexY=new Int32Array(S),this.vertexZ=new Int32Array(S);const Z=new Int32Array(S),A=new Int32Array(S),v=e*s.FULL_SQUARE,I=C*s.FULL_SQUARE;for(let e=0;e8&&S<=12&&(S=9+(S-n-9&3)),S>12&&S<=16&&(S=13+(S-n-13&3)),1===S?(t=v,l=I,d=y,f=h,C=c):2===S?(t=v+s.HALF_SQUARE,l=I,d=y+a>>1,f=h+w>>1,C=c+i>>1):3===S?(t=v+s.FULL_SQUARE,l=I,d=a,f=w,C=i):4===S?(t=v+s.FULL_SQUARE,l=I+s.HALF_SQUARE,d=a+p>>1,f=w+r>>1,C=i+m>>1):5===S?(t=v+s.FULL_SQUARE,l=I+s.FULL_SQUARE,d=p,f=r,C=m):6===S?(t=v+s.HALF_SQUARE,l=I+s.FULL_SQUARE,d=p+o>>1,f=r+g>>1,C=m+u>>1):7===S?(t=v,l=I+s.FULL_SQUARE,d=o,f=g,C=u):8===S?(t=v,l=I+s.HALF_SQUARE,d=o+y>>1,f=g+h>>1,C=u+c>>1):9===S?(t=v+s.HALF_SQUARE,l=I+s.CORNER_SMALL,d=y+a>>1,f=h+w>>1,C=c+i>>1):10===S?(t=v+s.CORNER_BIG,l=I+s.HALF_SQUARE,d=a+p>>1,f=w+r>>1,C=i+m>>1):11===S?(t=v+s.HALF_SQUARE,l=I+s.CORNER_BIG,d=p+o>>1,f=r+g>>1,C=m+u>>1):12===S?(t=v+s.CORNER_SMALL,l=I+s.HALF_SQUARE,d=o+y>>1,f=g+h>>1,C=u+c>>1):13===S?(t=v+s.CORNER_SMALL,l=I+s.CORNER_SMALL,d=y,f=h,C=c):14===S?(t=v+s.CORNER_BIG,l=I+s.CORNER_SMALL,d=a,f=w,C=i):15===S?(t=v+s.CORNER_BIG,l=I+s.CORNER_BIG,d=p,f=r,C=m):(t=v+s.CORNER_SMALL,l=I+s.CORNER_BIG,d=o,f=g,C=u),this.vertexX[e]=t,this.vertexY[e]=d,this.vertexZ[e]=l,Z[e]=f,A[e]=C}const O=s.SHAPE_PATHS[t],b=O.length/4|0;this.triangleVertexA=new Int32Array(b),this.triangleVertexB=new Int32Array(b),this.triangleVertexC=new Int32Array(b),this.triangleColorA=new Int32Array(b),this.triangleColorB=new Int32Array(b),this.triangleColorC=new Int32Array(b),this.triangleTextureIds=-1!==d?new Int32Array(b):null;let L=0;for(let e=0;e{var s;i.d(t,{Z:()=>a}),function(e){e[e.PLAIN=0]="PLAIN",e[e.DIAGONAL=1]="DIAGONAL",e[e.LEFT_SEMI_DIAGONAL_SMALL=2]="LEFT_SEMI_DIAGONAL_SMALL",e[e.RIGHT_SEMI_DIAGONAL_SMALL=3]="RIGHT_SEMI_DIAGONAL_SMALL",e[e.LEFT_SEMI_DIAGONAL_BIG=4]="LEFT_SEMI_DIAGONAL_BIG",e[e.RIGHT_SEMI_DIAGONAL_BIG=5]="RIGHT_SEMI_DIAGONAL_BIG",e[e.HALF_SQUARE=6]="HALF_SQUARE",e[e.CORNER_SMALL=7]="CORNER_SMALL",e[e.CORNER_BIG=8]="CORNER_BIG",e[e.FAN_SMALL=9]="FAN_SMALL",e[e.FAN_BIG=10]="FAN_BIG",e[e.TRAPEZIUM=11]="TRAPEZIUM"}(s||(s={}));const a=s},9865:(e,t,i)=>{i.d(t,{Z:()=>s});class s{southwestColor;southeastColor;northeastColor;northwestColor;textureId;color;flat;constructor(e,t,i,s,a,r,n){this.southwestColor=e,this.southeastColor=t,this.northeastColor=i,this.northwestColor=s,this.textureId=a,this.color=r,this.flat=n}}},3806:(e,t,i)=>{i.d(t,{Z:()=>s});class s{y;x;z;typeA;typeB;modelA;modelB;bitset;info;constructor(e,t,i,s,a,r,n,h,o){this.y=e,this.x=t,this.z=i,this.typeA=s,this.typeB=a,this.modelA=r,this.modelB=n,this.bitset=h,this.info=o}}},9118:(e,t,i)=>{i.d(t,{Z:()=>s});class s{y;x;z;type;angle;model;bitset;info;constructor(e,t,i,s,a,r,n,h){this.y=e,this.x=t,this.z=i,this.type=s,this.angle=a,this.model=r,this.bitset=n,this.info=h}}},3832:(e,t,i)=>{i.d(t,{Z:()=>a});var s=i(3064);class a{size;nodes;constructor(e){this.size=e,this.nodes=[];for(let t=0;t{const t=this.nodes[Number(e&BigInt(this.size-1))];if(!t.prev)return null;for(let i=t.prev;i!==t;i=i.prev)if(i&&i.id===e)return i;return null};put=(e,t)=>{t.next&&t.unlink();const i=this.nodes[Number(e&BigInt(this.size-1))];t.next=i.next,t.prev=i,t.next&&(t.next.prev=t),t.prev.next=t,t.id=e}}},6327:(e,t,i)=>{i.d(t,{Z:()=>a});var s=i(3064);class a extends s.Z{nextHashable;prevHashable;constructor(){super(),this.nextHashable=this,this.prevHashable=this}uncache=()=>{this.prevHashable&&this.nextHashable&&(this.prevHashable.nextHashable=this.nextHashable,this.nextHashable.prevHashable=this.prevHashable,this.nextHashable=null,this.prevHashable=null)}}},8934:(e,t,i)=>{i.d(t,{Z:()=>s});class s{static BASE37_LOOKUP=["_","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"];static toBase37=e=>{e=e.trim();let t=0n;for(let i=0;i=65&&s<=90?t+=BigInt(s+1-65):s>=97&&s<=122?t+=BigInt(s+1-97):s>=48&&s<=57&&(t+=BigInt(s+27-48))}return t};static fromBase37=e=>{if(e<0n||e>=6582952005840035281n)return"invalid_name";if(e%37n===0n)return"invalid_name";let t=0;const i=Array(12);for(;0n!==e;){const s=e;e/=37n,i[11-t++]=this.BASE37_LOOKUP[Number(s-37n*e)]}return i.slice(12-t).join("")};static toSentenceCase=e=>{const t=[...e.toLowerCase()];let i=!0;for(let e=0;e="a"&&s<="z"&&(t[e]=s.toUpperCase(),i=!1),"."!==s&&"!"!==s||(i=!0)}return t.join("")};static toAsterisks=e=>{let t="";for(let i=0;i(e>>24&255)+"."+(e>>16&255)+"."+(e>>8&255)+"."+(255&e);static formatName=e=>{if(0===e.length)return e;const t=[...e];for(let e=0;e="a"&&t[e+1]<="z"&&(t[e+1]=String.fromCharCode(t[e+1].charCodeAt(0)+"A".charCodeAt(0)-97)));return t[0]>="a"&&t[0]<="z"&&(t[0]=String.fromCharCode(t[0].charCodeAt(0)+"A".charCodeAt(0)-97)),t.join("")};static hashCode=e=>{const t=e.toUpperCase();let i=0n;for(let e=0;e>56n)&0xffffffffffffffn;return i}}},9080:(e,t,i)=>{i.d(t,{Z:()=>a});var s=i(3064);class a{head;peeked=null;constructor(){const e=new s.Z;e.prev=e,e.next=e,this.head=e}pushBack=e=>{e.next&&e.unlink(),e.next=this.head.next,e.prev=this.head,e.next&&(e.next.prev=e),e.prev.next=e};pushFront=e=>{e.next&&e.unlink(),e.next=this.head,e.prev=this.head.prev,e.next.prev=e,e.prev&&(e.prev.next=e)};pollFront=()=>{const e=this.head.prev;return e===this.head?null:(e?.unlink(),e)};peekFront=()=>{const e=this.head.prev;return e===this.head?(this.peeked=null,null):(this.peeked=e?.prev||null,e)};peekBack=()=>{const e=this.head.next;return e===this.head?(this.peeked=null,null):(this.peeked=e?.next||null,e)};prev=()=>{const e=this.peeked;return e===this.head?(this.peeked=null,null):(this.peeked=e?.prev||null,e)};next=()=>{const e=this.peeked;return e===this.head?(this.peeked=null,null):(this.peeked=e?.next||null,e)};clear=()=>{for(;;){const e=this.head.prev;if(e===this.head)return;e?.unlink()}}}},3064:(e,t,i)=>{i.d(t,{Z:()=>s});class s{id;prev;next;constructor(){this.id=0n,this.prev=this,this.next=this}unlink=()=>{this.next&&this.prev&&(this.next.prev=this.prev,this.prev.next=this.next,this.prev=null,this.next=null)}}},5542:(e,t,i)=>{i.d(t,{Z:()=>r});var s=i(8329),a=i(3832);class r{capacity;hashtable;history;available;constructor(e){this.capacity=e,this.available=e,this.hashtable=new a.Z(1024),this.history=new s.Z}get=e=>{const t=this.hashtable.get(e);return t&&this.history.push(t),t};put=(e,t)=>{if(0===this.available){const e=this.history.pop();e?.unlink(),e?.uncache()}else this.available--;this.hashtable.put(e,t),this.history.push(t)};clear=()=>{const e=this.history.pop();e?(e.unlink(),e.uncache()):this.available=this.capacity}}},8329:(e,t,i)=>{i.d(t,{Z:()=>a});var s=i(6327);class a{head;constructor(){this.head=new s.Z}push=e=>{e.prevHashable&&e.uncache(),e.prevHashable=this.head.prevHashable,e.nextHashable=this.head,e.prevHashable&&(e.prevHashable.nextHashable=e),e.nextHashable.prevHashable=e};pop=()=>{const e=this.head.nextHashable;return e===this.head?null:(e?.uncache(),e)}}},6121:(e,t,i)=>{i.d(t,{E1:()=>a,Ew:()=>n,JQ:()=>s,nS:()=>r,tw:()=>h});const s=document.getElementById("canvas"),a=s.getContext("2d",{willReadFrequently:!0}),r=document.createElement("canvas"),n=document.createElement("img"),h=r.getContext("2d",{willReadFrequently:!0})},312:(e,t,i)=>{i.d(t,{Z:()=>s});class s{static RED=16711680;static GREEN=65280;static BLUE=255;static YELLOW=16776960;static CYAN=65535;static MAGENTA=16711935;static WHITE=16777215;static BLACK=0;static LIGHTRED=16748608;static DARKRED=8388608;static DARKBLUE=128;static ORANGE1=16756736;static ORANGE2=16740352;static ORANGE3=16723968;static GREEN1=12648192;static GREEN2=8453888;static GREEN3=4259584;static PROGRESS_RED=9179409;static OPTIONS_MENU=6116423;static SCROLLBAR_TRACK=2301979;static SCROLLBAR_GRIP_FOREGROUND=5063219;static SCROLLBAR_GRIP_HIGHLIGHT=7759444;static SCROLLBAR_GRIP_LOWLIGHT=3353893;static TRADE_MESSAGE=8388736;static DUEL_MESSAGE=13350793;static CHAT_COLORS=Int32Array.of(s.YELLOW,s.RED,s.GREEN,s.CYAN,s.MAGENTA,s.WHITE)}},2991:(e,t,i)=>{i.d(t,{Z:()=>a});var s=i(6327);class a extends s.Z{static pixels=new Int32Array;static width2d=0;static height2d=0;static top=0;static bottom=0;static left=0;static right=0;static boundX=0;static centerX2d=0;static centerY2d=0;static bind=(e,t,i)=>{this.pixels=e,this.width2d=t,this.height2d=i,this.setBounds(0,0,t,i)};static resetBounds=()=>{this.left=0,this.top=0,this.right=this.width2d,this.bottom=this.height2d,this.boundX=this.right-1,this.centerX2d=this.right/2|0};static setBounds=(e,t,i,s)=>{e<0&&(e=0),t<0&&(t=0),i>this.width2d&&(i=this.width2d),s>this.height2d&&(s=this.height2d),this.top=t,this.bottom=s,this.left=e,this.right=i,this.boundX=this.right-1,this.centerX2d=this.right/2|0,this.centerY2d=this.bottom/2|0};static clear=()=>{const e=this.width2d*this.height2d;for(let t=0;t{this.drawHorizontalLine(e,t,a,i),this.drawHorizontalLine(e,t+s-1,a,i),this.drawVerticalLine(e,t,a,s),this.drawVerticalLine(e+i-1,t,a,s)};static drawHorizontalLine=(e,t,i,s)=>{if(t=this.bottom)return;ethis.right&&(s=this.right-e);const a=e+t*this.width2d;for(let e=0;e{if(e=this.right)return;tthis.bottom&&(s=this.bottom-t);const a=e+t*this.width2d;for(let e=0;e{const r=Math.abs(i-e),n=Math.abs(s-t),h=e=this.left&&e=this.top&&t-n&&(l-=n,e+=h),i{ethis.right&&(i=this.right-e),t+s>this.bottom&&(s=this.bottom-t);const r=this.width2d-i;let n=e+t*this.width2d;for(let e=-s;e<0;e++){for(let e=-i;e<0;e++)this.pixels[n++]=a;n+=r}};static setPixel=(e,t,i)=>{e=this.right||t=this.bottom||(this.pixels[e+t*this.width2d]=i)}}},8078:(e,t,i)=>{i.d(t,{Z:()=>n});var s=i(2991),a=i(664),r=i(9345);class n extends s.Z{static lowMemory=!1;static reciprocal15=new Int32Array(512);static reciprocal16=new Int32Array(2048);static sin=new Int32Array(2048);static cos=new Int32Array(2048);static palette=new Int32Array(65536);static textures=new r.to(50,null);static textureCount=0;static lineOffset=new Int32Array;static centerX=0;static centerY=0;static jagged=!0;static clipX=!1;static alpha=0;static texelPool=null;static activeTexels=new r.to(50,null);static poolSize=0;static cycle=0;static textureCycle=new Int32Array(50);static texturePalette=new r.to(50,null);static opaque=!1;static textureTranslucent=new r.to(50,!1);static averageTextureRGB=new Int32Array(50);static{for(let e=1;e<512;e++)this.reciprocal15[e]=32768/e|0;for(let e=1;e<2048;e++)this.reciprocal16[e]=65536/e|0;for(let e=0;e<2048;e++)this.sin[e]=65536*Math.sin(.0030679615757712823*e)|0,this.cos[e]=65536*Math.cos(.0030679615757712823*e)|0}static unload=()=>{this.reciprocal15=null,this.reciprocal15=null,this.sin=null,this.cos=null,this.lineOffset=null,this.textures=null,this.textureTranslucent=null,this.averageTextureRGB=null,this.texelPool=null,this.activeTexels=null,this.textureCycle=null,this.palette=null,this.texturePalette=null,console.log("Draw3D unloaded!")};static init2D=()=>{this.lineOffset=new Int32Array(this.height2d);for(let e=0;e{this.lineOffset=new Int32Array(t);for(let i=0;i{this.texelPool=null,this.activeTexels.fill(null)};static unpackTextures=e=>{this.textureCount=0;for(let t=0;t<50;t++)try{this.textures[t]=a.Z.fromArchive(e,t.toString()),this.lowMemory&&128===this.textures[t]?.cropW?this.textures[t]?.shrink():this.textures[t]?.crop(),this.textureCount++}catch(e){}};static getAverageTextureRGB=e=>{if(0!==this.averageTextureRGB[e])return this.averageTextureRGB[e];const t=this.texturePalette[e];if(!t)return 0;let i=0,s=0,a=0;const r=t.length;for(let e=0;e>16&255,s+=t[e]>>8&255,a+=255&t[e];let n=((i/r|0)<<16)+((s/r|0)<<8)+(a/r|0);return n=this.setGamma(n,1.4),0===n&&(n=1),this.averageTextureRGB[e]=n,n};static setBrightness=e=>{const t=e+.03*Math.random()-.015;let i=0;for(let e=0;e<512;e++){const s=(e/8|0)/64+.0078125,a=(7&e)/8+.0625;for(let e=0;e<128;e++){const r=e/128;let n=r,h=r,o=r;if(0!==a){let e;e=r<.5?r*(a+1):r+a-r*a;const t=2*r-e;let i=s+.3333333333333333;i>1&&i--;let l=s-.3333333333333333;l<0&&l++,n=6*i<1?t+6*(e-t)*i:2*i<1?e:3*i<2?t+(e-t)*(.6666666666666666-i)*6:t,h=6*s<1?t+6*(e-t)*s:2*s<1?e:3*s<2?t+(e-t)*(.6666666666666666-s)*6:t,o=6*l<1?t+6*(e-t)*l:2*l<1?e:3*l<2?t+(e-t)*(.6666666666666666-l)*6:t}const l=((256*n|0)<<16)+((256*h|0)<<8)+(256*o|0);this.palette[i++]=this.setGamma(l,t)}}for(let e=0;e<50;e++){const i=this.textures[e];if(!i)continue;const s=i.palette;this.texturePalette[e]=new Int32Array(s.length);for(let i=0;i{const i=(e>>16)/256,s=(e>>8&255)/256,a=(255&e)/256;return((256*Math.pow(i,t)|0)<<16)+((256*Math.pow(s,t)|0)<<8)+(256*Math.pow(a,t)|0)};static initPool=e=>{this.texelPool||(this.poolSize=e,this.lowMemory?this.texelPool=new r.Nv(e,16384):this.texelPool=new r.Nv(e,65536),this.activeTexels.fill(null))};static fillGouraudTriangle=(e,t,i,s,a,r,n,h,o)=>{let l=0,c=0;a!==s&&(l=(t-e<<16)/(a-s)|0,c=(h-n<<15)/(a-s)|0);let d=0,u=0;r!==a&&(d=(i-t<<16)/(r-a)|0,u=(o-h<<15)/(r-a)|0);let f=0,p=0;if(r!==s&&(f=(e-i<<16)/(s-r)|0,p=(n-o<<15)/(s-r)|0),s<=a&&s<=r){if(sthis.bottom&&(a=this.bottom),r>this.bottom&&(r=this.bottom),ad)for(r-=a,a-=s,s=this.lineOffset[s];;){if(--a<0)for(;;){if(--r<0)return;this.drawGouraudScanline(i>>16,t>>16,o>>7,h>>7,this.pixels,s,0),i+=f,t+=d,o+=p,h+=u,s+=this.width2d}this.drawGouraudScanline(i>>16,e>>16,o>>7,n>>7,this.pixels,s,0),i+=f,e+=l,o+=p,n+=c,s+=this.width2d}else for(r-=a,a-=s,s=this.lineOffset[s];;){if(--a<0)for(;;){if(--r<0)return;this.drawGouraudScanline(t>>16,i>>16,h>>7,o>>7,this.pixels,s,0),i+=f,t+=d,o+=p,h+=u,s+=this.width2d}this.drawGouraudScanline(e>>16,i>>16,n>>7,o>>7,this.pixels,s,0),i+=f,e+=l,o+=p,n+=c,s+=this.width2d}else if(t=e<<=16,h=n<<=15,s<0&&(t-=f*s,e-=l*s,h-=p*s,n-=c*s,s=0),i<<=16,o<<=15,r<0&&(i-=d*r,o-=u*r,r=0),s!==r&&fl)for(a-=r,r-=s,s=this.lineOffset[s];;){if(--r<0)for(;;){if(--a<0)return;this.drawGouraudScanline(i>>16,e>>16,o>>7,n>>7,this.pixels,s,0),i+=d,e+=l,o+=u,n+=c,s+=this.width2d}this.drawGouraudScanline(t>>16,e>>16,h>>7,n>>7,this.pixels,s,0),t+=f,e+=l,h+=p,n+=c,s+=this.width2d}else for(a-=r,r-=s,s=this.lineOffset[s];;){if(--r<0)for(;;){if(--a<0)return;this.drawGouraudScanline(e>>16,i>>16,n>>7,o>>7,this.pixels,s,0),i+=d,e+=l,o+=u,n+=c,s+=this.width2d}this.drawGouraudScanline(e>>16,t>>16,n>>7,h>>7,this.pixels,s,0),t+=f,e+=l,h+=p,n+=c,s+=this.width2d}}else if(a<=r){if(athis.bottom&&(r=this.bottom),s>this.bottom&&(s=this.bottom),rf)for(s-=r,r-=a,a=this.lineOffset[a];;){if(--r<0)for(;;){if(--s<0)return;this.drawGouraudScanline(e>>16,i>>16,n>>7,o>>7,this.pixels,a,0),e+=l,i+=f,n+=c,o+=p,a+=this.width2d}this.drawGouraudScanline(e>>16,t>>16,n>>7,h>>7,this.pixels,a,0),e+=l,t+=d,n+=c,h+=u,a+=this.width2d}else for(s-=r,r-=a,a=this.lineOffset[a];;){if(--r<0)for(;;){if(--s<0)return;this.drawGouraudScanline(i>>16,e>>16,o>>7,n>>7,this.pixels,a,0),e+=l,i+=f,n+=c,o+=p,a+=this.width2d}this.drawGouraudScanline(t>>16,e>>16,h>>7,n>>7,this.pixels,a,0),e+=l,t+=d,n+=c,h+=u,a+=this.width2d}else if(i=t<<=16,o=h<<=15,a<0&&(i-=l*a,t-=d*a,o-=c*a,h-=u*a,a=0),e<<=16,n<<=15,s<0&&(e-=f*s,n-=p*s,s=0),r-=s,s-=a,a=this.lineOffset[a],l>16,t>>16,n>>7,h>>7,this.pixels,a,0),e+=f,t+=d,n+=p,h+=u,a+=this.width2d}this.drawGouraudScanline(i>>16,t>>16,o>>7,h>>7,this.pixels,a,0),i+=l,t+=d,o+=c,h+=u,a+=this.width2d}else for(;;){if(--s<0)for(;;){if(--r<0)return;this.drawGouraudScanline(t>>16,e>>16,h>>7,n>>7,this.pixels,a,0),e+=f,t+=d,n+=p,h+=u,a+=this.width2d}this.drawGouraudScanline(t>>16,i>>16,h>>7,o>>7,this.pixels,a,0),i+=l,t+=d,o+=c,h+=u,a+=this.width2d}}else if(rthis.bottom&&(s=this.bottom),a>this.bottom&&(a=this.bottom),s>16,e>>16,h>>7,n>>7,this.pixels,r,0),t+=d,e+=l,h+=u,n+=c,r+=this.width2d}this.drawGouraudScanline(t>>16,i>>16,h>>7,o>>7,this.pixels,r,0),t+=d,i+=f,h+=u,o+=p,r+=this.width2d}else for(;;){if(--s<0)for(;;){if(--a<0)return;this.drawGouraudScanline(e>>16,t>>16,n>>7,h>>7,this.pixels,r,0),t+=d,e+=l,h+=u,n+=c,r+=this.width2d}this.drawGouraudScanline(i>>16,t>>16,o>>7,h>>7,this.pixels,r,0),t+=d,i+=f,h+=u,o+=p,r+=this.width2d}else if(e=i<<=16,n=o<<=15,r<0&&(e-=d*r,i-=f*r,n-=u*r,o-=p*r,r=0),t<<=16,h<<=15,a<0&&(t-=l*a,h-=c*a,a=0),s-=a,a-=r,r=this.lineOffset[r],d>16,i>>16,h>>7,o>>7,this.pixels,r,0),t+=l,i+=f,h+=c,o+=p,r+=this.width2d}this.drawGouraudScanline(e>>16,i>>16,n>>7,o>>7,this.pixels,r,0),e+=d,i+=f,n+=u,o+=p,r+=this.width2d}else for(;;){if(--a<0)for(;;){if(--s<0)return;this.drawGouraudScanline(i>>16,t>>16,o>>7,h>>7,this.pixels,r,0),t+=l,i+=f,h+=c,o+=p,r+=this.width2d}this.drawGouraudScanline(i>>16,e>>16,o>>7,n>>7,this.pixels,r,0),e+=d,i+=f,n+=u,o+=p,r+=this.width2d}};static drawGouraudScanline=(e,t,i,s,a,r,n)=>{let h;if(this.jagged){let o;if(this.clipX){if(o=t-e>3?(s-i)/(t-e)|0:0,t>this.boundX&&(t=this.boundX),e<0&&(i-=e*o,e=0),e>=t)return;r+=e,n=t-e>>2,o<<=2}else{if(!(e>2)>0?(s-i)*this.reciprocal15[n]>>15:0}if(0===this.alpha)for(;;){if(--n<0){if((n=t-e&3)>0){h=this.palette[i>>8];do{a[r++]=h,n--}while(n>0);return}break}h=this.palette[i>>8],i+=o,a[r++]=h,a[r++]=h,a[r++]=h,a[r++]=h}else{const s=this.alpha,l=256-this.alpha;for(;;){if(--n<0){if((n=t-e&3)>0){h=this.palette[i>>8],h=((16711935&h)*l>>8&16711935)+((65280&h)*l>>8&65280);do{a[r++]=h+((16711935&a[r])*s>>8&16711935)+((65280&a[r])*s>>8&65280),n--}while(n>0)}break}h=this.palette[i>>8],i+=o,h=((16711935&h)*l>>8&16711935)+((65280&h)*l>>8&65280),a[r++]=h+((16711935&a[r])*s>>8&16711935)+((65280&a[r])*s>>8&65280),a[r++]=h+((16711935&a[r])*s>>8&16711935)+((65280&a[r])*s>>8&65280),a[r++]=h+((16711935&a[r])*s>>8&16711935)+((65280&a[r])*s>>8&65280),a[r++]=h+((16711935&a[r])*s>>8&16711935)+((65280&a[r])*s>>8&65280)}}}else if(ethis.boundX&&(t=this.boundX),e<0&&(i-=e*o,e=0),e>=t))return;if(r+=e,n=t-e,0===this.alpha)do{a[r++]=this.palette[i>>8],i+=o,n--}while(n>0);else{const e=this.alpha,t=256-this.alpha;do{h=this.palette[i>>8],i+=o,h=((16711935&h)*t>>8&16711935)+((65280&h)*t>>8&65280),a[r++]=h+((16711935&a[r])*e>>8&16711935)+((65280&a[r])*e>>8&65280),n--}while(n>0)}}};static fillTriangle=(e,t,i,s,a,r,n)=>{let h=0;a!==s&&(h=(t-e<<16)/(a-s)|0);let o=0;r!==a&&(o=(i-t<<16)/(r-a)|0);let l=0;if(r!==s&&(l=(e-i<<16)/(s-r)|0),s<=a&&s<=r){if(sthis.bottom&&(a=this.bottom),r>this.bottom&&(r=this.bottom),ao)for(r-=a,a-=s,s=this.lineOffset[s];;){if(--a<0)for(;;){if(--r<0)return;this.drawScanline(i>>16,t>>16,this.pixels,s,n),i+=l,t+=o,s+=this.width2d}this.drawScanline(i>>16,e>>16,this.pixels,s,n),i+=l,e+=h,s+=this.width2d}else for(r-=a,a-=s,s=this.lineOffset[s];;){if(--a<0)for(;;){if(--r<0)return;this.drawScanline(t>>16,i>>16,this.pixels,s,n),i+=l,t+=o,s+=this.width2d}this.drawScanline(e>>16,i>>16,this.pixels,s,n),i+=l,e+=h,s+=this.width2d}else if(t=e<<=16,s<0&&(t-=l*s,e-=h*s,s=0),i<<=16,r<0&&(i-=o*r,r=0),s!==r&&lh)for(a-=r,r-=s,s=this.lineOffset[s];;){if(--r<0)for(;;){if(--a<0)return;this.drawScanline(i>>16,e>>16,this.pixels,s,n),i+=o,e+=h,s+=this.width2d}this.drawScanline(t>>16,e>>16,this.pixels,s,n),t+=l,e+=h,s+=this.width2d}else for(a-=r,r-=s,s=this.lineOffset[s];;){if(--r<0)for(;;){if(--a<0)return;this.drawScanline(e>>16,i>>16,this.pixels,s,n),i+=o,e+=h,s+=this.width2d}this.drawScanline(e>>16,t>>16,this.pixels,s,n),t+=l,e+=h,s+=this.width2d}}else if(a<=r){if(athis.bottom&&(r=this.bottom),s>this.bottom&&(s=this.bottom),rl)for(s-=r,r-=a,a=this.lineOffset[a];;){if(--r<0)for(;;){if(--s<0)return;this.drawScanline(e>>16,i>>16,this.pixels,a,n),e+=h,i+=l,a+=this.width2d}this.drawScanline(e>>16,t>>16,this.pixels,a,n),e+=h,t+=o,a+=this.width2d}else for(s-=r,r-=a,a=this.lineOffset[a];;){if(--r<0)for(;;){if(--s<0)return;this.drawScanline(i>>16,e>>16,this.pixels,a,n),e+=h,i+=l,a+=this.width2d}this.drawScanline(t>>16,e>>16,this.pixels,a,n),e+=h,t+=o,a+=this.width2d}else if(i=t<<=16,a<0&&(i-=h*a,t-=o*a,a=0),e<<=16,s<0&&(e-=l*s,s=0),h>16,t>>16,this.pixels,a,n),e+=l,t+=o,a+=this.width2d}this.drawScanline(i>>16,t>>16,this.pixels,a,n),i+=h,t+=o,a+=this.width2d}else for(r-=s,s-=a,a=this.lineOffset[a];;){if(--s<0)for(;;){if(--r<0)return;this.drawScanline(t>>16,e>>16,this.pixels,a,n),e+=l,t+=o,a+=this.width2d}this.drawScanline(t>>16,i>>16,this.pixels,a,n),i+=h,t+=o,a+=this.width2d}}else if(rthis.bottom&&(s=this.bottom),a>this.bottom&&(a=this.bottom),s>16,e>>16,this.pixels,r,n),t+=o,e+=h,r+=this.width2d}this.drawScanline(t>>16,i>>16,this.pixels,r,n),t+=o,i+=l,r+=this.width2d}else for(a-=s,s-=r,r=this.lineOffset[r];;){if(--s<0)for(;;){if(--a<0)return;this.drawScanline(e>>16,t>>16,this.pixels,r,n),t+=o,e+=h,r+=this.width2d}this.drawScanline(i>>16,t>>16,this.pixels,r,n),t+=o,i+=l,r+=this.width2d}else if(e=i<<=16,r<0&&(e-=o*r,i-=l*r,r=0),t<<=16,a<0&&(t-=h*a,a=0),o>16,i>>16,this.pixels,r,n),t+=h,i+=l,r+=this.width2d}this.drawScanline(e>>16,i>>16,this.pixels,r,n),e+=o,i+=l,r+=this.width2d}else for(s-=a,a-=r,r=this.lineOffset[r];;){if(--a<0)for(;;){if(--s<0)return;this.drawScanline(i>>16,t>>16,this.pixels,r,n),t+=h,i+=l,r+=this.width2d}this.drawScanline(i>>16,e>>16,this.pixels,r,n),e+=o,i+=l,r+=this.width2d}};static fillTexturedTriangle=(e,t,i,s,a,r,n,h,o,l,c,d,u,f,p,m,g,y,C)=>{const w=this.getTexels(C);this.opaque=!this.textureTranslucent[C];const T=l-u,S=c-p,Z=d-g,A=f-l,v=m-c,I=y-d;let O=A*c-v*l<<14;const b=v*d-I*c<<8,L=I*l-A*d<<5;let E=T*c-S*l<<14;const x=S*d-Z*c<<8,_=Z*l-T*d<<5;let k=S*A-T*v<<14;const R=Z*v-S*I<<8,P=T*I-Z*A<<5;let M=0,N=0;a!==s&&(M=(t-e<<16)/(a-s)|0,N=(h-n<<16)/(a-s)|0);let B=0,D=0;r!==a&&(B=(i-t<<16)/(r-a)|0,D=(o-h<<16)/(r-a)|0);let Y=0,X=0;if(r!==s&&(Y=(e-i<<16)/(s-r)|0,X=(n-o<<16)/(s-r)|0),s<=a&&s<=r){if(sthis.bottom&&(a=this.bottom),r>this.bottom&&(r=this.bottom),aB)for(r-=a,a-=s,s=this.lineOffset[s];;){if(--a<0)for(;;){if(--r<0)return;this.drawTexturedScanline(i>>16,t>>16,this.pixels,s,w,0,0,O,E,k,b,x,R,o>>8,h>>8),i+=Y,t+=B,o+=X,h+=D,s+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}this.drawTexturedScanline(i>>16,e>>16,this.pixels,s,w,0,0,O,E,k,b,x,R,o>>8,n>>8),i+=Y,e+=M,o+=X,n+=N,s+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}else for(r-=a,a-=s,s=this.lineOffset[s];;){if(--a<0)for(;;){if(--r<0)return;this.drawTexturedScanline(t>>16,i>>16,this.pixels,s,w,0,0,O,E,k,b,x,R,h>>8,o>>8),i+=Y,t+=B,o+=X,h+=D,s+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}this.drawTexturedScanline(e>>16,i>>16,this.pixels,s,w,0,0,O,E,k,b,x,R,n>>8,o>>8),i+=Y,e+=M,o+=X,n+=N,s+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}}else{t=e<<=16,h=n<<=16,s<0&&(t-=Y*s,e-=M*s,h-=X*s,n-=N*s,s=0),i<<=16,o<<=16,r<0&&(i-=B*r,o-=D*r,r=0);const l=s-this.centerY;if(O+=L*l,E+=_*l,k+=P*l,O|=0,E|=0,k|=0,(s===r||Y>=M)&&(s!==r||B<=M))for(a-=r,r-=s,s=this.lineOffset[s];;){if(--r<0)for(;;){if(--a<0)return;this.drawTexturedScanline(e>>16,i>>16,this.pixels,s,w,0,0,O,E,k,b,x,R,n>>8,o>>8),i+=B,e+=M,o+=D,n+=N,s+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}this.drawTexturedScanline(e>>16,t>>16,this.pixels,s,w,0,0,O,E,k,b,x,R,n>>8,h>>8),t+=Y,e+=M,h+=X,n+=N,s+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}else for(a-=r,r-=s,s=this.lineOffset[s];;){if(--r<0)for(;;){if(--a<0)return;this.drawTexturedScanline(i>>16,e>>16,this.pixels,s,w,0,0,O,E,k,b,x,R,o>>8,n>>8),i+=B,e+=M,o+=D,n+=N,s+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}this.drawTexturedScanline(t>>16,e>>16,this.pixels,s,w,0,0,O,E,k,b,x,R,h>>8,n>>8),t+=Y,e+=M,h+=X,n+=N,s+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}}}else if(a<=r){if(athis.bottom&&(r=this.bottom),s>this.bottom&&(s=this.bottom),rY)for(s-=r,r-=a,a=this.lineOffset[a];;){if(--r<0)for(;;){if(--s<0)return;this.drawTexturedScanline(e>>16,i>>16,this.pixels,a,w,0,0,O,E,k,b,x,R,n>>8,o>>8),e+=M,i+=Y,n+=N,o+=X,a+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}this.drawTexturedScanline(e>>16,t>>16,this.pixels,a,w,0,0,O,E,k,b,x,R,n>>8,h>>8),e+=M,t+=B,n+=N,h+=D,a+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}else for(s-=r,r-=a,a=this.lineOffset[a];;){if(--r<0)for(;;){if(--s<0)return;this.drawTexturedScanline(i>>16,e>>16,this.pixels,a,w,0,0,O,E,k,b,x,R,o>>8,n>>8),e+=M,i+=Y,n+=N,o+=X,a+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}this.drawTexturedScanline(t>>16,e>>16,this.pixels,a,w,0,0,O,E,k,b,x,R,h>>8,n>>8),e+=M,t+=B,n+=N,h+=D,a+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}}else{i=t<<=16,o=h<<=16,a<0&&(i-=M*a,t-=B*a,o-=N*a,h-=D*a,a=0),e<<=16,n<<=16,s<0&&(e-=Y*s,n-=X*s,s=0);const l=a-this.centerY;if(O+=L*l,E+=_*l,k+=P*l,O|=0,E|=0,k|=0,r-=s,s-=a,a=this.lineOffset[a],M>16,t>>16,this.pixels,a,w,0,0,O,E,k,b,x,R,n>>8,h>>8),e+=Y,t+=B,n+=X,h+=D,a+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}this.drawTexturedScanline(i>>16,t>>16,this.pixels,a,w,0,0,O,E,k,b,x,R,o>>8,h>>8),i+=M,t+=B,o+=N,h+=D,a+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}else for(;;){if(--s<0)for(;;){if(--r<0)return;this.drawTexturedScanline(t>>16,e>>16,this.pixels,a,w,0,0,O,E,k,b,x,R,h>>8,n>>8),e+=Y,t+=B,n+=X,h+=D,a+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}this.drawTexturedScanline(t>>16,i>>16,this.pixels,a,w,0,0,O,E,k,b,x,R,h>>8,o>>8),i+=M,t+=B,o+=N,h+=D,a+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}}}else if(rthis.bottom&&(s=this.bottom),a>this.bottom&&(a=this.bottom),s>16,e>>16,this.pixels,r,w,0,0,O,E,k,b,x,R,h>>8,n>>8),t+=B,e+=M,h+=D,n+=N,r+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}this.drawTexturedScanline(t>>16,i>>16,this.pixels,r,w,0,0,O,E,k,b,x,R,h>>8,o>>8),t+=B,i+=Y,h+=D,o+=X,r+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}else for(;;){if(--s<0)for(;;){if(--a<0)return;this.drawTexturedScanline(e>>16,t>>16,this.pixels,r,w,0,0,O,E,k,b,x,R,n>>8,h>>8),t+=B,e+=M,h+=D,n+=N,r+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}this.drawTexturedScanline(i>>16,t>>16,this.pixels,r,w,0,0,O,E,k,b,x,R,o>>8,h>>8),t+=B,i+=Y,h+=D,o+=X,r+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}}else{e=i<<=16,n=o<<=16,r<0&&(e-=B*r,i-=Y*r,n-=D*r,o-=X*r,r=0),t<<=16,h<<=16,a<0&&(t-=M*a,h-=N*a,a=0);const l=r-this.centerY;if(O+=L*l,E+=_*l,k+=P*l,O|=0,E|=0,k|=0,s-=a,a-=r,r=this.lineOffset[r],B>16,i>>16,this.pixels,r,w,0,0,O,E,k,b,x,R,h>>8,o>>8),t+=M,i+=Y,h+=N,o+=X,r+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}this.drawTexturedScanline(e>>16,i>>16,this.pixels,r,w,0,0,O,E,k,b,x,R,n>>8,o>>8),e+=B,i+=Y,n+=D,o+=X,r+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}else for(;;){if(--a<0)for(;;){if(--s<0)return;this.drawTexturedScanline(i>>16,t>>16,this.pixels,r,w,0,0,O,E,k,b,x,R,o>>8,h>>8),t+=M,i+=Y,h+=N,o+=X,r+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}this.drawTexturedScanline(i>>16,e>>16,this.pixels,r,w,0,0,O,E,k,b,x,R,o>>8,n>>8),e+=B,i+=Y,n+=D,o+=X,r+=this.width2d,O+=L,E+=_,k+=P,O|=0,E|=0,k|=0}}};static drawTexturedScanline=(e,t,i,s,a,r,n,h,o,l,c,d,u,f,p)=>{if(e>=t)return;let m,g,y,C,w,T,S,Z,A;if(this.clipX){if(m=(p-f)/(t-e)|0,t>this.boundX&&(t=this.boundX),e<0&&(f-=e*m,e=0),e>=t)return;g=t-e>>3,m<<=12}else t-e>7?(g=t-e>>3,m=(p-f)*this.reciprocal15[g]>>6):(g=0,m=0);if(f<<=9,s+=e,this.lowMemory&&a)if(y=0,C=0,T=e-this.centerX,h+=(c>>3)*T,o+=(d>>3)*T,l+=(u>>3)*T,h|=0,o|=0,w=(l|=0)>>12,0!==w&&(n=o/w|0,(r=h/w|0)<0?r=0:r>4032&&(r=4032)),h+=c,o+=d,l+=u,h|=0,o|=0,w=(l|=0)>>12,0!==w&&(y=h/w|0,C=o/w|0,y<7?y=7:y>4032&&(y=4032)),S=y-r>>3,Z=C-n>>3,r+=f>>3&786432,A=f>>23,this.opaque){for(;g-- >0;)i[s++]=a[(4032&n)+(r>>6)]>>>A,r+=S,n+=Z,i[s++]=a[(4032&n)+(r>>6)]>>>A,r+=S,n+=Z,i[s++]=a[(4032&n)+(r>>6)]>>>A,r+=S,n+=Z,i[s++]=a[(4032&n)+(r>>6)]>>>A,r+=S,n+=Z,i[s++]=a[(4032&n)+(r>>6)]>>>A,r+=S,n+=Z,i[s++]=a[(4032&n)+(r>>6)]>>>A,r+=S,n+=Z,i[s++]=a[(4032&n)+(r>>6)]>>>A,r+=S,n+=Z,i[s++]=a[(4032&n)+(r>>6)]>>>A,r=y,n=C,h+=c,o+=d,w=(l+=u)>>12,0!==w&&(y=h/w|0,C=o/w|0,y<7?y=7:y>4032&&(y=4032)),S=y-r>>3,Z=C-n>>3,r+=(f+=m)>>3&786432,A=f>>23;for(g=t-e&7;g-- >0;)i[s++]=a[(4032&n)+(r>>6)]>>>A,r+=S,n+=Z}else{for(;g-- >0;){let e;0!=(e=a[(4032&n)+(r>>6)]>>>A)&&(i[s]=e),s+=1,0!=(e=a[(4032&(n+=Z))+((r+=S)>>6)]>>>A)&&(i[s]=e),s++,0!=(e=a[(4032&(n+=Z))+((r+=S)>>6)]>>>A)&&(i[s]=e),s++,0!=(e=a[(4032&(n+=Z))+((r+=S)>>6)]>>>A)&&(i[s]=e),s++,0!=(e=a[(4032&(n+=Z))+((r+=S)>>6)]>>>A)&&(i[s]=e),s++,0!=(e=a[(4032&(n+=Z))+((r+=S)>>6)]>>>A)&&(i[s]=e),s++,0!=(e=a[(4032&(n+=Z))+((r+=S)>>6)]>>>A)&&(i[s]=e),s++,0!=(e=a[(4032&(n+=Z))+((r+=S)>>6)]>>>A)&&(i[s]=e),s+=1,r=y,n=C,h+=c,o+=d,l+=u,h|=0,o|=0,w=(l|=0)>>12,0!==w&&(y=h/w|0,C=o/w|0,y<7?y=7:y>4032&&(y=4032)),S=y-r>>3,Z=C-n>>3,r+=(f+=m)>>3&786432,A=f>>23}for(g=t-e&7;g-- >0;){let e;0!=(e=a[(4032&n)+(r>>6)]>>>A)&&(i[s]=e),s++,r+=S,n+=Z}}else if(y=0,C=0,T=e-this.centerX,h+=(c>>3)*T,o+=(d>>3)*T,l+=(u>>3)*T,h|=0,o|=0,w=(l|=0)>>14,0!==w&&(n=o/w|0,(r=h/w|0)<0?r=0:r>16256&&(r=16256)),h+=c,o+=d,l+=u,h|=0,o|=0,w=(l|=0)>>14,0!==w&&(y=h/w|0,C=o/w|0,y<7?y=7:y>16256&&(y=16256)),S=y-r>>3,Z=C-n>>3,r+=6291456&f,A=f>>23,this.opaque&&a){for(;g-- >0;)i[s++]=a[(16256&n)+(r>>7)]>>>A,r+=S,n+=Z,i[s++]=a[(16256&n)+(r>>7)]>>>A,r+=S,n+=Z,i[s++]=a[(16256&n)+(r>>7)]>>>A,r+=S,n+=Z,i[s++]=a[(16256&n)+(r>>7)]>>>A,r+=S,n+=Z,i[s++]=a[(16256&n)+(r>>7)]>>>A,r+=S,n+=Z,i[s++]=a[(16256&n)+(r>>7)]>>>A,r+=S,n+=Z,i[s++]=a[(16256&n)+(r>>7)]>>>A,r+=S,n+=Z,i[s++]=a[(16256&n)+(r>>7)]>>>A,r=y,n=C,h+=c,o+=d,l+=u,h|=0,o|=0,w=(l|=0)>>14,0!==w&&(y=h/w|0,C=o/w|0,y<7?y=7:y>16256&&(y=16256)),S=y-r>>3,Z=C-n>>3,r+=6291456&(f+=m),A=f>>23;for(g=t-e&7;g-- >0;)i[s++]=a[(16256&n)+(r>>7)]>>>A,r+=S,n+=Z}else{for(;g-- >0&&a;){let e;0!=(e=a[(16256&n)+(r>>7)]>>>A)&&(i[s]=e),s+=1,0!=(e=a[(16256&(n+=Z))+((r+=S)>>7)]>>>A)&&(i[s]=e),s++,0!=(e=a[(16256&(n+=Z))+((r+=S)>>7)]>>>A)&&(i[s]=e),s++,0!=(e=a[(16256&(n+=Z))+((r+=S)>>7)]>>>A)&&(i[s]=e),s++,0!=(e=a[(16256&(n+=Z))+((r+=S)>>7)]>>>A)&&(i[s]=e),s++,0!=(e=a[(16256&(n+=Z))+((r+=S)>>7)]>>>A)&&(i[s]=e),s++,0!=(e=a[(16256&(n+=Z))+((r+=S)>>7)]>>>A)&&(i[s]=e),s++,0!=(e=a[(16256&(n+=Z))+((r+=S)>>7)]>>>A)&&(i[s]=e),s++,r=y,n=C,h+=c,o+=d,l+=u,h|=0,o|=0,w=(l|=0)>>14,0!==w&&(y=h/w|0,C=o/w|0,y<7?y=7:y>16256&&(y=16256)),S=y-r>>3,Z=C-n>>3,r+=6291456&(f+=m),A=f>>23}for(g=t-e&7;g-- >0&&a;){let e;0!=(e=a[(16256&n)+(r>>7)]>>>A)&&(i[s]=e),s++,r+=S,n+=Z}}};static drawScanline=(e,t,i,s,a)=>{if(this.clipX&&(t>this.boundX&&(t=this.boundX),e<0&&(e=0)),e>=t)return;s+=e;let r=t-e>>2;if(0===this.alpha)for(;;){if(r--,r<0)for(r=t-e&3;;){if(r--,r<0)return;i[s++]=a}i[s++]=a,i[s++]=a,i[s++]=a,i[s++]=a}const n=this.alpha,h=256-this.alpha;for(a=((16711935&a)*h>>8&16711935)+((65280&a)*h>>8&65280);;){if(r--,r<0)for(r=t-e&3;;){if(r--,r<0)return;i[s++]=a+((16711935&i[s])*n>>8&16711935)+((65280&i[s])*n>>8&65280)}i[s++]=a+((16711935&i[s])*n>>8&16711935)+((65280&i[s])*n>>8&65280),i[s++]=a+((16711935&i[s])*n>>8&16711935)+((65280&i[s])*n>>8&65280),i[s++]=a+((16711935&i[s])*n>>8&16711935)+((65280&i[s])*n>>8&65280),i[s++]=a+((16711935&i[s])*n>>8&16711935)+((65280&i[s])*n>>8&65280)}};static pushTexture=e=>{this.activeTexels[e]&&this.texelPool&&(this.texelPool[this.poolSize++]=this.activeTexels[e],this.activeTexels[e]=null)};static getTexels=e=>{if(this.textureCycle[e]=this.cycle++,this.activeTexels[e])return this.activeTexels[e];let t;if(this.poolSize>0&&this.texelPool)t=this.texelPool[--this.poolSize],this.texelPool[this.poolSize]=null;else{let e=0,i=-1;for(let t=0;t>>3)&16316671,t[a+8192]=r-(r>>>2)&16316671,t[a+12288]=r-(r>>>2)-(r>>>3)&16316671}}else{if(64===i.width)for(let e=0;e<128;e++)for(let a=0;a<128;a++)t[a+(e<<7|0)]=s[i.pixels[(a>>1)+(e>>1<<6|0)]];else for(let e=0;e<16384;e++)t[e]=s[i.pixels[e]];this.textureTranslucent[e]=!1;for(let i=0;i<16384;i++){t[i]&=16316671;const s=t[i];0===s&&(this.textureTranslucent[e]=!0),t[i+16384]=s-(s>>>3)&16316671,t[i+32768]=s-(s>>>2)&16316671,t[i+49152]=s-(s>>>2)-(s>>>3)&16316671}}return t}}},5147:(e,t,i)=>{i.d(t,{Y:()=>a});var s=i(6121);const a=async e=>{255!==e[0]&&(e[0]=255),URL.revokeObjectURL(s.Ew.src),s.Ew.src=URL.createObjectURL(new Blob([e],{type:"image/jpeg"})),await new Promise((e=>s.Ew.onload=()=>e())),s.tw.clearRect(0,0,s.nS.width,s.nS.height);const t=s.Ew.naturalWidth,i=s.Ew.naturalHeight;return s.nS.width=t,s.nS.height=i,s.tw.drawImage(s.Ew,0,0),s.tw.getImageData(0,0,t,i)}},9178:(e,t,i)=>{i.d(t,{Z:()=>d});var s=i(2383),a=i(2991),r=i(8078),n=i(8762),h=i(6327),o=i(9345);class l{vertexCount=0;faceCount=0;texturedFaceCount=0;vertexFlagsOffset=-1;vertexXOffset=-1;vertexYOffset=-1;vertexZOffset=-1;vertexLabelsOffset=-1;faceVerticesOffset=-1;faceOrientationsOffset=-1;faceColorsOffset=-1;faceInfosOffset=-1;facePrioritiesOffset=0;faceAlphasOffset=-1;faceLabelsOffset=-1;faceTextureAxisOffset=-1;data=null}class c{x=0;y=0;z=0;w=0}class d extends h.Z{static metadata=null;static head=null;static face1=null;static face2=null;static face3=null;static face4=null;static face5=null;static point1=null;static point2=null;static point3=null;static point4=null;static point5=null;static vertex1=null;static vertex2=null;static axis=null;static faceClippedX=new o.to(4096,!1);static faceNearClipped=new o.to(4096,!1);static vertexScreenX=new Int32Array(4096);static vertexScreenY=new Int32Array(4096);static vertexScreenZ=new Int32Array(4096);static vertexViewSpaceX=new Int32Array(4096);static vertexViewSpaceY=new Int32Array(4096);static vertexViewSpaceZ=new Int32Array(4096);static tmpDepthFaceCount=new Int32Array(1500);static tmpDepthFaces=new o.Nv(1500,512);static tmpPriorityFaceCount=new Int32Array(12);static tmpPriorityFaces=new o.Nv(12,2e3);static tmpPriority10FaceDepth=new Int32Array(2e3);static tmpPriority11FaceDepth=new Int32Array(2e3);static tmpPriorityDepthSum=new Int32Array(12);static clippedX=new Int32Array(10);static clippedY=new Int32Array(10);static clippedColor=new Int32Array(10);static baseX=0;static baseY=0;static baseZ=0;static checkHover=!1;static mouseX=0;static mouseY=0;static pickedCount=0;static pickedBitsets=new Int32Array(1e3);static checkHoverFace=!1;static unpack(e){try{d.head=new s.Z(e.read("ob_head.dat")),d.face1=new s.Z(e.read("ob_face1.dat")),d.face2=new s.Z(e.read("ob_face2.dat")),d.face3=new s.Z(e.read("ob_face3.dat")),d.face4=new s.Z(e.read("ob_face4.dat")),d.face5=new s.Z(e.read("ob_face5.dat")),d.point1=new s.Z(e.read("ob_point1.dat")),d.point2=new s.Z(e.read("ob_point2.dat")),d.point3=new s.Z(e.read("ob_point3.dat")),d.point4=new s.Z(e.read("ob_point4.dat")),d.point5=new s.Z(e.read("ob_point5.dat")),d.vertex1=new s.Z(e.read("ob_vertex1.dat")),d.vertex2=new s.Z(e.read("ob_vertex2.dat")),d.axis=new s.Z(e.read("ob_axis.dat")),d.head.pos=0,d.point1.pos=0,d.point2.pos=0,d.point3.pos=0,d.point4.pos=0,d.vertex1.pos=0,d.vertex2.pos=0;const t=d.head.g2;d.metadata=new o.to(t+100,null);let i=0,a=0,r=0,n=0,h=0,c=0,u=0;for(let e=0;e127&&(t=127),127-t):((t=t*(127&e)>>7)<2?t=2:t>126&&(t=126),(65408&e)+t)}static modelCopyFaces=(e,t,i)=>{const s=e.vertexCount,a=e.faceCount,r=e.texturedFaceCount;let n,h,l,u,f;if(t){n=new Int32Array(s);for(let t=0;t{const a=e.vertexCount,r=e.faceCount,n=e.texturedFaceCount;let h,o,l,c,u;if(s)h=e.vertexX,o=e.vertexY,l=e.vertexZ;else{h=new Int32Array(a),o=new Int32Array(a),l=new Int32Array(a);for(let t=0;t{const i=e.vertexCount,s=e.faceCount,a=e.texturedFaceCount,r=new Int32Array(i),n=new Int32Array(i),h=new Int32Array(i);for(let t=0;t{let i=!1,s=!1,a=!1,r=!1,n=0,h=0,o=0,l=-1;for(let c=0;c{let i=!1,s=!1,a=!1,r=!1,n=0,h=0,o=0,l=-1;for(let c=0;c{let h=-1;const o=e.vertexX[t],l=e.vertexY[t],c=e.vertexZ[t];for(let e=0;e{if(!d.metadata)throw new Error("cant loading model metadata!!!!!");const t=d.metadata[e];if(!t)throw console.log(`Error model:${e} not found!`),new Error("cant loading model metadata!!!!!");if(!(d.head&&d.face1&&d.face2&&d.face3&&d.face4&&d.face5&&d.point1&&d.point2&&d.point3&&d.point4&&d.point5&&d.vertex1&&d.vertex2&&d.axis))throw new Error("cant loading model!!!!!");const i=t.vertexCount,s=t.faceCount,a=t.texturedFaceCount,r=new Int32Array(i),n=new Int32Array(i),h=new Int32Array(i),o=new Int32Array(s),l=new Int32Array(s),c=new Int32Array(s),u=new Int32Array(a),f=new Int32Array(a),p=new Int32Array(a);let m=null;t.vertexLabelsOffset>=0&&(m=new Int32Array(i));let g=null;t.faceInfosOffset>=0&&(g=new Int32Array(s));let y=null,C=0;t.facePrioritiesOffset>=0?y=new Int32Array(s):C=-t.facePrioritiesOffset-1;let w=null;t.faceAlphasOffset>=0&&(w=new Int32Array(s));let T=null;t.faceLabelsOffset>=0&&(T=new Int32Array(s));const S=new Int32Array(s);d.point1.pos=t.vertexFlagsOffset,d.point2.pos=t.vertexXOffset,d.point3.pos=t.vertexYOffset,d.point4.pos=t.vertexZOffset,d.point5.pos=t.vertexLabelsOffset;let Z,A,v,I=0,O=0,b=0;for(let e=0;e{if(!d.metadata||!d.metadata[t])throw new Error("No model metadata");const i=d.metadata[t];if(i.data=e,!i.data.length)throw new Error("No model data");const a=i.vertexCount,r=i.faceCount,n=i.texturedFaceCount,h=new Int32Array(a),o=new Int32Array(a),l=new Int32Array(a),c=new Int32Array(r),u=new Int32Array(r),f=new Int32Array(r),p=new Int32Array(n),m=new Int32Array(n),g=new Int32Array(n);let y=null;i.vertexLabelsOffset>=0&&(y=new Int32Array(a));let C=null;i.faceInfosOffset>=0&&(C=new Int32Array(r));let w=null,T=0;i.facePrioritiesOffset>=0?w=new Int32Array(r):T=-i.facePrioritiesOffset-1;let S=null;i.faceAlphasOffset>=0&&(S=new Int32Array(r));let Z=null;i.faceLabelsOffset>=0&&(Z=new Int32Array(r));const A=new Int32Array(r),v=new s.Z(i.data);v.pos=i.vertexFlagsOffset;const I=new s.Z(i.data);I.pos=i.vertexXOffset;const O=new s.Z(i.data);O.pos=i.vertexYOffset;const b=new s.Z(i.data);b.pos=i.vertexZOffset;const L=new s.Z(i.data);L.pos=i.vertexLabelsOffset;let E,x,_,k=0,R=0,P=0;for(let e=0;e{this.maxY=0,this.radius=0,this.minY=0;for(let e=0;ethis.maxY&&(this.maxY=-i),i>this.minY&&(this.minY=i);const a=t*t+s*s;a>this.radius&&(this.radius=a)}this.radius=Math.sqrt(this.radius)+.99|0,this.minDepth=Math.sqrt(this.radius*this.radius+this.maxY*this.maxY)+.99|0,this.maxDepth=this.minDepth+(Math.sqrt(this.radius*this.radius+this.minY*this.minY)+.99|0)};calculateBoundsY=()=>{this.maxY=0,this.minY=0;for(let e=0;ethis.maxY&&(this.maxY=-t),t>this.minY&&(this.minY=t)}this.minDepth=Math.sqrt(this.radius*this.radius+this.maxY*this.maxY)+.99|0,this.maxDepth=this.minDepth+(Math.sqrt(this.radius*this.radius+this.minY*this.minY)+.99|0)};createLabelReferences=()=>{if(this.vertexLabel){const e=new Int32Array(256);let t=0;for(let i=0;it&&(t=s)}this.labelVertices=new o.to(t+1,null);for(let i=0;i<=t;i++)this.labelVertices[i]=new Int32Array(e[i]),e[i]=0;let i=0;for(;it&&(t=s)}this.labelFaces=new o.to(t+1,null);for(let i=0;i<=t;i++)this.labelFaces[i]=new Int32Array(e[i]),e[i]=0;let i=0;for(;i{if(-1!==e)if(i&&-1!==t){const s=n.Z.instances[e],a=n.Z.instances[t],r=s.base;d.baseX=0,d.baseY=0,d.baseZ=0;let h=0,o=i[h++];for(let e=0;eo;)o=i[h++];r&&r.types&&s.x&&s.y&&s.z&&r.labels&&(t!==o||0===r.types[t])&&this.applyTransform2(s.x[e],s.y[e],s.z[e],r.labels[t],r.types[t])}d.baseX=0,d.baseY=0,d.baseZ=0,h=0,o=i[h++];for(let e=0;eo;)o=i[h++];r&&r.types&&a.x&&a.y&&a.z&&r.labels&&(t===o||0===r.types[t])&&this.applyTransform2(a.x[e],a.y[e],a.z[e],r.labels[t],r.types[t])}}else this.applyTransform(e)};applyTransform=e=>{if(!this.labelVertices||-1===e||!n.Z.instances[e])return;const t=n.Z.instances[e],i=t.base;d.baseX=0,d.baseY=0,d.baseZ=0;for(let e=0;e{for(let e=0;e{const t=r.Z.sin[e],i=r.Z.cos[e];for(let e=0;e>16;this.vertexZ[e]=this.vertexY[e]*t+this.vertexZ[e]*i>>16,this.vertexY[e]=s}};translate=(e,t,i)=>{for(let s=0;s{if(this.faceColor)for(let i=0;i{for(let e=0;e{for(let s=0;s{const n=t*(0|Math.sqrt(i*i+s*s+a*a))>>8;if(this.faceColorA&&this.faceColorB&&this.faceColorC||(this.faceColorA=new Int32Array(this.faceCount),this.faceColorB=new Int32Array(this.faceCount),this.faceColorC=new Int32Array(this.faceCount)),!this.vertexNormal){this.vertexNormal=new o.to(this.vertexCount,null);for(let e=0;e8192||y>8192||C>8192||g<-8192||y<-8192||C<-8192;)g>>=1,y>>=1,C>>=1;let w=0|Math.sqrt(g*g+y*y+C*C);if(w<=0&&(w=1),g=256*g/w|0,y=256*y/w|0,C=256*C/w|0,this.faceInfo&&0!=(1&this.faceInfo[t])){const r=e+((i*g+s*y+a*C)/(n+(n/2|0))|0);this.faceColor&&(this.faceColorA[t]=d.mulColorLightness(this.faceColor[t],r,this.faceInfo[t]))}else{let e=this.vertexNormal[r];e&&(e.x+=g,e.y+=y,e.z+=C,e.w++),e=this.vertexNormal[h],e&&(e.x+=g,e.y+=y,e.z+=C,e.w++),e=this.vertexNormal[o],e&&(e.x+=g,e.y+=y,e.z+=C,e.w++)}}if(r)this.applyLighting(e,n,i,s,a);else{this.vertexNormalOriginal=new o.to(this.vertexCount,null);for(let e=0;e{for(let r=0;r{const o=r.Z.sin[e],l=r.Z.cos[e],c=r.Z.sin[t],u=r.Z.cos[t],f=r.Z.sin[i],p=r.Z.cos[i],m=r.Z.sin[s],g=r.Z.cos[s],y=n*m+h*g>>16;for(let s=0;s>16,T=T*p-w*f>>16,w=C),0!==e&&(C=T*l-S*o>>16,S=T*o+S*l>>16,T=C),0!==t&&(C=S*c+w*u>>16,S=S*u-w*c>>16,w=C),w+=a,T+=n,S+=h,C=T*g-S*m>>16,S=T*m+S*g>>16,T=C,d.vertexScreenX&&d.vertexScreenY&&d.vertexScreenZ&&(d.vertexScreenZ[s]=S-y,d.vertexScreenX[s]=r.Z.centerX+((w<<9)/S|0),d.vertexScreenY[s]=r.Z.centerY+((T<<9)/S|0)),this.texturedFaceCount>0&&d.vertexViewSpaceX&&d.vertexViewSpaceY&&d.vertexViewSpaceZ&&(d.vertexViewSpaceX[s]=w,d.vertexViewSpaceY[s]=T,d.vertexViewSpaceZ[s]=S)}try{this.draw2(!1,!1,0)}catch(e){}};draw=(e,t,i,s,n,h,o,l,c)=>{const u=l*n-h*s>>16,f=o*t+u*i>>16,p=this.radius*i>>16,m=f+p;if(m<=50||f>=3500)return;const g=l*s+h*n>>16;let y=g-this.radius<<9;if((y/m|0)>=a.Z.centerX2d)return;let C=g+this.radius<<9;if((C/m|0)<=-a.Z.centerX2d)return;const w=o*i-u*t>>16,T=this.radius*t>>16;let S=w+T<<9;if((S/m|0)<=-a.Z.centerY2d)return;let Z=w-(T+(this.maxY*i>>16))<<9;if((Z/m|0)>=a.Z.centerY2d)return;let A=f-(p+(this.maxY*t>>16))<=50,v=!1;if(c>0&&d.checkHover){let e=f-p;e<=50&&(e=50),g>0?(y=y/m|0,C=C/e|0):(C=C/m|0,y=y/e|0),w>0?(Z=Z/m|0,S=S/e|0):(S=S/m|0,Z=Z/e|0);const t=d.mouseX-r.Z.centerX,i=d.mouseY-r.Z.centerY;t>y&&tZ&&i>16,p=p*L-c*b>>16,c=r),c+=h,u+=o,p+=l,r=p*s+c*n>>16,p=p*n-c*s>>16,c=r,r=u*i-p*t>>16,p=u*t+p*i>>16,u=r,d.vertexScreenZ&&(d.vertexScreenZ[a]=p-f),p>=50&&d.vertexScreenX&&d.vertexScreenY?(d.vertexScreenX[a]=I+((c<<9)/p|0),d.vertexScreenY[a]=O+((u<<9)/p|0)):d.vertexScreenX&&(d.vertexScreenX[a]=-5e3,A=!0),(A||this.texturedFaceCount>0)&&d.vertexViewSpaceX&&d.vertexViewSpaceY&&d.vertexViewSpaceZ&&(d.vertexViewSpaceX[a]=c,d.vertexViewSpaceY[a]=u,d.vertexViewSpaceZ[a]=p)}try{this.draw2(A,v,c)}catch(e){}};draw2=(e,t,i,s=!1)=>{d.checkHoverFace&&(this.pickedFace=-1,this.pickedFaceDepth=-1);for(let e=0;ea.Z.boundX||l>a.Z.boundX||c>a.Z.boundX),d.tmpDepthFaces&&d.tmpDepthFaceCount){const e=((m+g+y)/3|0)+this.minDepth;d.tmpDepthFaces[e][d.tmpDepthFaceCount[e]++]=s,d.checkHoverFace&&this.pointWithinTriangle(d.mouseX,d.mouseY,u,f,p,o,l,c)&&this.pickedFaceDepth=0;e--){const t=d.tmpDepthFaceCount[e];if(!(t<=0)&&d.tmpDepthFaces){const i=d.tmpDepthFaces[e];for(let e=0;e=0;e--){const t=d.tmpDepthFaceCount[e];if(t>0&&d.tmpDepthFaces){const i=d.tmpDepthFaces[e];for(let s=0;s0||d.tmpPriorityFaceCount[2]>0)&&(r=(d.tmpPriorityDepthSum[1]+d.tmpPriorityDepthSum[2])/(d.tmpPriorityFaceCount[1]+d.tmpPriorityFaceCount[2])|0);let n=0;d.tmpPriorityFaceCount&&d.tmpPriorityDepthSum&&(d.tmpPriorityFaceCount[3]>0||d.tmpPriorityFaceCount[4]>0)&&(n=(d.tmpPriorityDepthSum[3]+d.tmpPriorityDepthSum[4])/(d.tmpPriorityFaceCount[3]+d.tmpPriorityFaceCount[4])|0);let h=0;if(d.tmpPriorityFaceCount&&d.tmpPriorityDepthSum&&(d.tmpPriorityFaceCount[6]>0||d.tmpPriorityFaceCount[8]>0)&&(h=(d.tmpPriorityDepthSum[6]+d.tmpPriorityDepthSum[8])/(d.tmpPriorityFaceCount[6]+d.tmpPriorityFaceCount[8])|0),d.tmpPriorityFaceCount&&d.tmpPriorityFaces){let e,t=0,i=d.tmpPriorityFaceCount[10],a=d.tmpPriorityFaces[10],o=d.tmpPriority10FaceDepth;t===i&&(t=0,i=d.tmpPriorityFaceCount[11],a=d.tmpPriorityFaces[11],o=d.tmpPriority11FaceDepth),e=tr;)this.drawFace(a[t++],s),t===i&&a!==d.tmpPriorityFaces[11]&&(t=0,i=d.tmpPriorityFaceCount[11],a=d.tmpPriorityFaces[11],o=d.tmpPriority11FaceDepth),e=tn;)this.drawFace(a[t++],s),t===i&&a!==d.tmpPriorityFaces[11]&&(t=0,i=d.tmpPriorityFaceCount[11],a=d.tmpPriorityFaces[11],o=d.tmpPriority11FaceDepth),e=th;)this.drawFace(a[t++],s),t===i&&a!==d.tmpPriorityFaces[11]&&(t=0,i=d.tmpPriorityFaceCount[11],a=d.tmpPriorityFaces[11],o=d.tmpPriority11FaceDepth),e=t{if(d.faceNearClipped&&d.faceNearClipped[e])return void this.drawNearClippedFace(e,t);const i=this.faceVertexA[e],s=this.faceVertexB[e],a=this.faceVertexC[e];let n;if(d.faceClippedX&&(r.Z.clipX=d.faceClippedX[e]),this.faceAlpha?r.Z.alpha=this.faceAlpha[e]:r.Z.alpha=0,n=this.faceInfo?3&this.faceInfo[e]:0,t&&d.vertexScreenX&&d.vertexScreenY&&this.faceColorA&&this.faceColorB&&this.faceColorC)r.Z.drawLine(d.vertexScreenX[i],d.vertexScreenY[i],d.vertexScreenX[s],d.vertexScreenY[s],r.Z.palette[this.faceColorA[e]]),r.Z.drawLine(d.vertexScreenX[s],d.vertexScreenY[s],d.vertexScreenX[a],d.vertexScreenY[a],r.Z.palette[this.faceColorB[e]]),r.Z.drawLine(d.vertexScreenX[a],d.vertexScreenY[a],d.vertexScreenX[i],d.vertexScreenY[i],r.Z.palette[this.faceColorC[e]]);else if(0===n&&this.faceColorA&&this.faceColorB&&this.faceColorC&&d.vertexScreenX&&d.vertexScreenY)r.Z.fillGouraudTriangle(d.vertexScreenX[i],d.vertexScreenX[s],d.vertexScreenX[a],d.vertexScreenY[i],d.vertexScreenY[s],d.vertexScreenY[a],this.faceColorA[e],this.faceColorB[e],this.faceColorC[e]);else if(1===n&&this.faceColorA&&d.vertexScreenX&&d.vertexScreenY)r.Z.fillTriangle(d.vertexScreenX[i],d.vertexScreenX[s],d.vertexScreenX[a],d.vertexScreenY[i],d.vertexScreenY[s],d.vertexScreenY[a],r.Z.palette[this.faceColorA[e]]);else if(2===n&&this.faceInfo&&this.faceColor&&this.faceColorA&&this.faceColorB&&this.faceColorC&&d.vertexScreenX&&d.vertexScreenY&&d.vertexViewSpaceX&&d.vertexViewSpaceY&&d.vertexViewSpaceZ){const t=this.faceInfo[e]>>2,n=this.texturedVertexA[t],h=this.texturedVertexB[t],o=this.texturedVertexC[t];r.Z.fillTexturedTriangle(d.vertexScreenX[i],d.vertexScreenX[s],d.vertexScreenX[a],d.vertexScreenY[i],d.vertexScreenY[s],d.vertexScreenY[a],this.faceColorA[e],this.faceColorB[e],this.faceColorC[e],d.vertexViewSpaceX[n],d.vertexViewSpaceY[n],d.vertexViewSpaceZ[n],d.vertexViewSpaceX[h],d.vertexViewSpaceX[o],d.vertexViewSpaceY[h],d.vertexViewSpaceY[o],d.vertexViewSpaceZ[h],d.vertexViewSpaceZ[o],this.faceColor[e])}else if(3===n&&this.faceInfo&&this.faceColor&&this.faceColorA&&d.vertexScreenX&&d.vertexScreenY&&d.vertexViewSpaceX&&d.vertexViewSpaceY&&d.vertexViewSpaceZ){const t=this.faceInfo[e]>>2,n=this.texturedVertexA[t],h=this.texturedVertexB[t],o=this.texturedVertexC[t];r.Z.fillTexturedTriangle(d.vertexScreenX[i],d.vertexScreenX[s],d.vertexScreenX[a],d.vertexScreenY[i],d.vertexScreenY[s],d.vertexScreenY[a],this.faceColorA[e],this.faceColorA[e],this.faceColorA[e],d.vertexViewSpaceX[n],d.vertexViewSpaceY[n],d.vertexViewSpaceZ[n],d.vertexViewSpaceX[h],d.vertexViewSpaceX[o],d.vertexViewSpaceY[h],d.vertexViewSpaceY[o],d.vertexViewSpaceZ[h],d.vertexViewSpaceZ[o],this.faceColor[e])}};drawNearClippedFace=(e,t=!1)=>{let i=0;if(d.vertexViewSpaceZ){const t=r.Z.centerX,s=r.Z.centerY,a=this.faceVertexA[e],n=this.faceVertexB[e],h=this.faceVertexC[e],o=d.vertexViewSpaceZ[a],l=d.vertexViewSpaceZ[n],c=d.vertexViewSpaceZ[h];if(o>=50&&d.vertexScreenX&&d.vertexScreenY&&this.faceColorA)d.clippedX[i]=d.vertexScreenX[a],d.clippedY[i]=d.vertexScreenY[a],d.clippedColor[i++]=this.faceColorA[e];else if(d.vertexViewSpaceX&&d.vertexViewSpaceY&&this.faceColorA){const u=d.vertexViewSpaceX[a],f=d.vertexViewSpaceY[a],p=this.faceColorA[e];if(c>=50&&this.faceColorC){const a=(50-o)*r.Z.reciprocal16[c-o];d.clippedX[i]=t+((u+((d.vertexViewSpaceX[h]-u)*a>>16)<<9)/50|0),d.clippedY[i]=s+((f+((d.vertexViewSpaceY[h]-f)*a>>16)<<9)/50|0),d.clippedColor[i++]=p+((this.faceColorC[e]-p)*a>>16)}if(l>=50&&this.faceColorB){const a=(50-o)*r.Z.reciprocal16[l-o];d.clippedX[i]=t+((u+((d.vertexViewSpaceX[n]-u)*a>>16)<<9)/50|0),d.clippedY[i]=s+((f+((d.vertexViewSpaceY[n]-f)*a>>16)<<9)/50|0),d.clippedColor[i++]=p+((this.faceColorB[e]-p)*a>>16)}}if(l>=50&&d.vertexScreenX&&d.vertexScreenY&&this.faceColorB)d.clippedX[i]=d.vertexScreenX[n],d.clippedY[i]=d.vertexScreenY[n],d.clippedColor[i++]=this.faceColorB[e];else if(d.vertexViewSpaceX&&d.vertexViewSpaceY&&this.faceColorB){const u=d.vertexViewSpaceX[n],f=d.vertexViewSpaceY[n],p=this.faceColorB[e];if(o>=50&&this.faceColorA){const n=(50-l)*r.Z.reciprocal16[o-l];d.clippedX[i]=t+((u+((d.vertexViewSpaceX[a]-u)*n>>16)<<9)/50|0),d.clippedY[i]=s+((f+((d.vertexViewSpaceY[a]-f)*n>>16)<<9)/50|0),d.clippedColor[i++]=p+((this.faceColorA[e]-p)*n>>16)}if(c>=50&&this.faceColorC){const a=(50-l)*r.Z.reciprocal16[c-l];d.clippedX[i]=t+((u+((d.vertexViewSpaceX[h]-u)*a>>16)<<9)/50|0),d.clippedY[i]=s+((f+((d.vertexViewSpaceY[h]-f)*a>>16)<<9)/50|0),d.clippedColor[i++]=p+((this.faceColorC[e]-p)*a>>16)}}if(c>=50&&d.vertexScreenX&&d.vertexScreenY&&this.faceColorC)d.clippedX[i]=d.vertexScreenX[h],d.clippedY[i]=d.vertexScreenY[h],d.clippedColor[i++]=this.faceColorC[e];else if(d.vertexViewSpaceX&&d.vertexViewSpaceY&&this.faceColorC){const u=d.vertexViewSpaceX[h],f=d.vertexViewSpaceY[h],p=this.faceColorC[e];if(l>=50&&this.faceColorB){const a=(50-c)*r.Z.reciprocal16[l-c];d.clippedX[i]=t+((u+((d.vertexViewSpaceX[n]-u)*a>>16)<<9)/50|0),d.clippedY[i]=s+((f+((d.vertexViewSpaceY[n]-f)*a>>16)<<9)/50|0),d.clippedColor[i++]=p+((this.faceColorB[e]-p)*a>>16)}if(o>=50&&this.faceColorA){const n=(50-c)*r.Z.reciprocal16[o-c];d.clippedX[i]=t+((u+((d.vertexViewSpaceX[a]-u)*n>>16)<<9)/50|0),d.clippedY[i]=s+((f+((d.vertexViewSpaceY[a]-f)*n>>16)<<9)/50|0),d.clippedColor[i++]=p+((this.faceColorA[e]-p)*n>>16)}}}const s=d.clippedX[0],n=d.clippedX[1],h=d.clippedX[2],o=d.clippedY[0],l=d.clippedY[1],c=d.clippedY[2];if(!((s-n)*(c-l)-(o-l)*(h-n)<=0))if(r.Z.clipX=!1,3===i){let i;if((s<0||n<0||h<0||s>a.Z.boundX||n>a.Z.boundX||h>a.Z.boundX)&&(r.Z.clipX=!0),i=this.faceInfo?3&this.faceInfo[e]:0,t)r.Z.drawLine(s,n,o,l,d.clippedColor[0]),r.Z.drawLine(n,h,l,c,d.clippedColor[1]),r.Z.drawLine(h,s,c,o,d.clippedColor[2]);else if(0===i)r.Z.fillGouraudTriangle(s,n,h,o,l,c,d.clippedColor[0],d.clippedColor[1],d.clippedColor[2]);else if(1===i&&this.faceColorA)r.Z.fillTriangle(s,n,h,o,l,c,r.Z.palette[this.faceColorA[e]]);else if(2===i&&this.faceInfo&&this.faceColor&&d.vertexViewSpaceX&&d.vertexViewSpaceY&&d.vertexViewSpaceZ){const t=this.faceInfo[e]>>2,i=this.texturedVertexA[t],a=this.texturedVertexB[t],u=this.texturedVertexC[t];r.Z.fillTexturedTriangle(s,n,h,o,l,c,d.clippedColor[0],d.clippedColor[1],d.clippedColor[2],d.vertexViewSpaceX[i],d.vertexViewSpaceY[i],d.vertexViewSpaceZ[i],d.vertexViewSpaceX[a],d.vertexViewSpaceX[u],d.vertexViewSpaceY[a],d.vertexViewSpaceY[u],d.vertexViewSpaceZ[a],d.vertexViewSpaceZ[u],this.faceColor[e])}else if(3===i&&this.faceInfo&&this.faceColor&&this.faceColorA&&d.vertexViewSpaceX&&d.vertexViewSpaceY&&d.vertexViewSpaceZ){const t=this.faceInfo[e]>>2,i=this.texturedVertexA[t],a=this.texturedVertexB[t],u=this.texturedVertexC[t];r.Z.fillTexturedTriangle(s,n,h,o,l,c,this.faceColorA[e],this.faceColorA[e],this.faceColorA[e],d.vertexViewSpaceX[i],d.vertexViewSpaceY[i],d.vertexViewSpaceZ[i],d.vertexViewSpaceX[a],d.vertexViewSpaceX[u],d.vertexViewSpaceY[a],d.vertexViewSpaceY[u],d.vertexViewSpaceZ[a],d.vertexViewSpaceZ[u],this.faceColor[e])}}else if(4===i){let i;if((s<0||n<0||h<0||s>a.Z.boundX||n>a.Z.boundX||h>a.Z.boundX||d.clippedX[3]<0||d.clippedX[3]>a.Z.boundX)&&(r.Z.clipX=!0),i=this.faceInfo?3&this.faceInfo[e]:0,t)r.Z.drawLine(s,n,o,l,d.clippedColor[0]),r.Z.drawLine(n,h,l,c,d.clippedColor[1]),r.Z.drawLine(h,d.clippedX[3],c,d.clippedY[3],d.clippedColor[2]),r.Z.drawLine(d.clippedX[3],s,d.clippedY[3],o,d.clippedColor[3]);else if(0===i)r.Z.fillGouraudTriangle(s,n,h,o,l,c,d.clippedColor[0],d.clippedColor[1],d.clippedColor[2]),r.Z.fillGouraudTriangle(s,h,d.clippedX[3],o,c,d.clippedY[3],d.clippedColor[0],d.clippedColor[2],d.clippedColor[3]);else if(1===i){if(this.faceColorA){const t=r.Z.palette[this.faceColorA[e]];r.Z.fillTriangle(s,n,h,o,l,c,t),r.Z.fillTriangle(s,h,d.clippedX[3],o,c,d.clippedY[3],t)}}else if(2===i&&this.faceInfo&&this.faceColor&&d.vertexViewSpaceX&&d.vertexViewSpaceY&&d.vertexViewSpaceZ){const t=this.faceInfo[e]>>2,i=this.texturedVertexA[t],a=this.texturedVertexB[t],u=this.texturedVertexC[t];r.Z.fillTexturedTriangle(s,n,h,o,l,c,d.clippedColor[0],d.clippedColor[1],d.clippedColor[2],d.vertexViewSpaceX[i],d.vertexViewSpaceY[i],d.vertexViewSpaceZ[i],d.vertexViewSpaceX[a],d.vertexViewSpaceX[u],d.vertexViewSpaceY[a],d.vertexViewSpaceY[u],d.vertexViewSpaceZ[a],d.vertexViewSpaceZ[u],this.faceColor[e]),r.Z.fillTexturedTriangle(s,h,d.clippedX[3],o,c,d.clippedY[3],d.clippedColor[0],d.clippedColor[2],d.clippedColor[3],d.vertexViewSpaceX[i],d.vertexViewSpaceY[i],d.vertexViewSpaceZ[i],d.vertexViewSpaceX[a],d.vertexViewSpaceX[u],d.vertexViewSpaceY[a],d.vertexViewSpaceY[u],d.vertexViewSpaceZ[a],d.vertexViewSpaceZ[u],this.faceColor[e])}else if(3===i&&this.faceInfo&&this.faceColor&&this.faceColorA&&d.vertexViewSpaceX&&d.vertexViewSpaceY&&d.vertexViewSpaceZ){const t=this.faceInfo[e]>>2,i=this.texturedVertexA[t],a=this.texturedVertexB[t],u=this.texturedVertexC[t];r.Z.fillTexturedTriangle(s,n,h,o,l,c,this.faceColorA[e],this.faceColorA[e],this.faceColorA[e],d.vertexViewSpaceX[i],d.vertexViewSpaceY[i],d.vertexViewSpaceZ[i],d.vertexViewSpaceX[a],d.vertexViewSpaceX[u],d.vertexViewSpaceY[a],d.vertexViewSpaceY[u],d.vertexViewSpaceZ[a],d.vertexViewSpaceZ[u],this.faceColor[e]),r.Z.fillTexturedTriangle(s,h,d.clippedX[3],o,c,d.clippedY[3],this.faceColorA[e],this.faceColorA[e],this.faceColorA[e],d.vertexViewSpaceX[i],d.vertexViewSpaceY[i],d.vertexViewSpaceZ[i],d.vertexViewSpaceX[a],d.vertexViewSpaceX[u],d.vertexViewSpaceY[a],d.vertexViewSpaceY[u],d.vertexViewSpaceZ[a],d.vertexViewSpaceZ[u],this.faceColor[e])}}};applyTransform2=(e,t,i,s,a)=>{if(!s)return;const n=s.length;if(0===a){let a=0;d.baseX=0,d.baseY=0,d.baseZ=0;for(let e=0;e0?(d.baseX=(d.baseX/a|0)+e,d.baseY=(d.baseY/a|0)+t,d.baseZ=(d.baseZ/a|0)+i):(d.baseX=e,d.baseY=t,d.baseZ=i)}else if(1===a)for(let a=0;a=this.labelVertices.length)continue;const n=this.labelVertices[r];if(n)for(let s=0;s=this.labelVertices.length)continue;const h=this.labelVertices[n];if(h)for(let s=0;s>16;this.vertexY[a]=this.vertexY[a]*u-this.vertexX[a]*c>>16,this.vertexX[a]=e}if(0!==n){c=r.Z.sin[n],u=r.Z.cos[n];const e=this.vertexY[a]*u-this.vertexZ[a]*c>>16;this.vertexZ[a]=this.vertexY[a]*c+this.vertexZ[a]*u>>16,this.vertexY[a]=e}if(0!==o){c=r.Z.sin[o],u=r.Z.cos[o];const e=this.vertexZ[a]*c+this.vertexX[a]*u>>16;this.vertexZ[a]=this.vertexZ[a]*u-this.vertexX[a]*c>>16,this.vertexX[a]=e}this.vertexX[a]+=d.baseX,this.vertexY[a]+=d.baseY,this.vertexZ[a]+=d.baseZ}}else if(3===a)for(let a=0;a=this.labelVertices.length)continue;const n=this.labelVertices[r];if(n)for(let s=0;s=this.labelFaces.length)continue;const a=this.labelFaces[i];if(a)for(let t=0;t255&&(this.faceAlpha[i]=255)}}};calculateBoundsAABB=()=>{this.maxY=0,this.radius=0,this.minY=0,this.minX=999999,this.maxX=-999999,this.maxZ=-99999,this.minZ=99999;for(let e=0;ethis.maxX&&(this.maxX=t),sthis.maxZ&&(this.maxZ=s),-i>this.maxY&&(this.maxY=-i),i>this.minY&&(this.minY=i);const a=t*t+s*s;a>this.radius&&(this.radius=a)}this.radius=0|Math.sqrt(this.radius),this.minDepth=0|Math.sqrt(this.radius*this.radius+this.maxY*this.maxY),this.maxDepth=this.minDepth+(0|Math.sqrt(this.radius*this.radius+this.minY*this.minY))};pointWithinTriangle=(e,t,i,s,a,r,n,h)=>!(ti&&t>s&&t>a||e{if(!(d.vertexScreenX&&d.vertexScreenY&&this.faceColorA&&this.faceColorB&&this.faceColorC))return;const t=this.faceVertexA[e],i=this.faceVertexB[e],s=this.faceVertexC[e];r.Z.drawLine(d.vertexScreenX[t],d.vertexScreenY[t],d.vertexScreenX[i],d.vertexScreenY[i],r.Z.palette[1e3]),r.Z.drawLine(d.vertexScreenX[i],d.vertexScreenY[i],d.vertexScreenX[s],d.vertexScreenY[s],r.Z.palette[1e3]),r.Z.drawLine(d.vertexScreenX[s],d.vertexScreenY[s],d.vertexScreenX[t],d.vertexScreenY[t],r.Z.palette[1e3])}}},6542:(e,t,i)=>{i.d(t,{Z:()=>h});var s=i(2991),a=i(2383),r=i(6327),n=i(5147);class h extends r.Z{pixels;width;height;cropX;cropY;cropW;cropH;constructor(e,t){super(),this.pixels=new Int32Array(e*t),this.width=this.cropW=e,this.height=this.cropH=t,this.cropX=this.cropY=0}static fromJpeg=async(e,t)=>{const i=e.read(t+".dat");if(!i)throw new Error(`${t} jpeg not found!`);const s=await(0,n.Y)(i),a=new h(s.width,s.height),r=a.pixels,o=s.data;for(let e=0;e{const s=new a.Z(e.read(t+".dat")),r=new a.Z(e.read("index.dat"));r.pos=s.g2;const n=r.g2,o=r.g2,l=[],c=r.g1-1;for(let e=0;es.data.length||r.pos>r.data.length)throw new Error;const d=r.g1,u=r.g1,f=r.g2,p=r.g2,m=new h(f,p);m.cropX=d,m.cropY=u,m.cropW=n,m.cropH=o;const g=r.g1;if(0===g){const e=m.width*m.height;for(let t=0;t{s.Z.bind(this.pixels,this.width,this.height)};draw=(e,t)=>{e|=0,t|=0;let i=(e+=this.cropX)+(t+=this.cropY)*s.Z.width2d,a=0,r=this.height,n=this.width,h=s.Z.width2d-n,o=0;if(ts.Z.bottom&&(r-=t+r-s.Z.bottom),es.Z.right){const t=e+n-s.Z.right;n-=t,o+=t,h+=t}n>0&&r>0&&this.copyImageDraw(n,r,this.pixels,a,o,s.Z.pixels,i,h)};drawAlpha=(e,t,i)=>{t|=0,i|=0;let a=(t+=this.cropX)+(i+=this.cropY)*s.Z.width2d,r=0,n=this.height,h=this.width,o=s.Z.width2d-h,l=0;if(is.Z.bottom&&(n-=i+n-s.Z.bottom),ts.Z.right){const e=t+h-s.Z.right;h-=e,l+=e,o+=e}h>0&&n>0&&this.copyPixelsAlpha(h,n,this.pixels,r,l,s.Z.pixels,a,o,e)};blitOpaque=(e,t)=>{e|=0,t|=0;let i=(e+=this.cropX)+(t+=this.cropY)*s.Z.width2d,a=0,r=this.height,n=this.width,h=s.Z.width2d-n,o=0;if(ts.Z.bottom&&(r-=t+r-s.Z.bottom),es.Z.right){const t=e+n-s.Z.right;n-=t,o+=t,h+=t}n>0&&r>0&&this.copyImageBlitOpaque(n,r,this.pixels,a,o,s.Z.pixels,i,h)};flipHorizontally=()=>{const e=this.pixels,t=this.width,i=this.height;for(let s=0;s{const e=this.pixels,t=this.width,i=this.height;for(let s=0;s<(i/2|0);s++)for(let a=0;a{for(let s=0;s>16&255;r+=e,r<1?r=1:r>255&&(r=255);let n=a>>8&255;n+=t,n<1?n=1:n>255&&(n=255);let h=255&a;h+=i,h<1?h=1:h>255&&(h=255),this.pixels[s]=(r<<16)+(n<<8)+h}}};crop=(e,t,i,a)=>{e|=0,t|=0,i|=0,a|=0;try{const r=this.width;let n=0,h=0;const o=this.cropW,l=this.cropH,c=(o<<16)/i|0,d=(l<<16)/a|0;e+=(this.cropX*i+o-1)/o|0,t+=(this.cropY*a+l-1)/l|0,this.cropX*i%o!=0&&(n=(o-this.cropX*i%o<<16)/i|0),this.cropY*a%l!=0&&(h=(l-this.cropY*a%l<<16)/a|0),i=i*(this.width-(n>>16))/o|0,a=a*(this.height-(h>>16))/l|0;let u=e+t*s.Z.width2d,f=s.Z.width2d-i;if(ts.Z.bottom&&(a-=t+a-s.Z.bottom),es.Z.right){const t=e+i-s.Z.right;i-=t,f+=t}this.scale(i,a,this.pixels,n,h,s.Z.pixels,f,u,r,c,d)}catch(e){console.error("error in sprite clipping routine")}};drawRotatedMasked=(e,t,i,a,r,n,h,o,l,c)=>{e|=0,t|=0,i|=0,a|=0;try{const d=-i/2|0,u=-a/2|0,f=65536*Math.sin(l/326.11)|0,p=65536*Math.cos(l/326.11)|0,m=f*c>>8,g=p*c>>8;let y=(h<<16)+u*m+d*g,C=u*g-d*m+(o<<16),w=e+t*s.Z.width2d;for(let e=0;e>16)+(h>>16)*this.width],a+=g,h-=m;y+=m,C+=g,w+=s.Z.width2d}}catch(e){}};drawMasked=(e,t,i)=>{e|=0,t|=0;let a=(e+=this.cropX)+(t+=this.cropY)*s.Z.width2d,r=0,n=this.height,h=this.width,o=s.Z.width2d-h,l=0;if(ts.Z.bottom&&(n-=t+n-s.Z.bottom),es.Z.right){const t=e+h-s.Z.right;h-=t,l+=t,o+=t}h>0&&n>0&&this.copyPixelsMasked(h,n,this.pixels,l,r,s.Z.pixels,a,o,i.pixels)};scale=(e,t,i,s,a,r,n,h,o,l,c)=>{try{const d=s;for(let u=-t;u<0;u++){const t=(a>>16)*o;for(let a=-e;a<0;a++){const e=i[(s>>16)+t];0===e?h++:r[h++]=e,s+=l}a+=c,s=d,h+=n}}catch(e){console.error("error in plot_scale")}};copyImageBlitOpaque=(e,t,i,s,a,r,n,h)=>{const o=-(e>>2);e=-(3&e);for(let l=-t;l<0;l++){for(let e=o;e<0;e++)r[n++]=i[s++],r[n++]=i[s++],r[n++]=i[s++],r[n++]=i[s++];for(let t=e;t<0;t++)r[n++]=i[s++];n+=h,s+=a}};copyPixelsAlpha=(e,t,i,s,a,r,n,h,o)=>{const l=256-o;for(let c=-t;c<0;c++){for(let t=-e;t<0;t++){const e=i[s++];if(0===e)n++;else{const t=r[n];r[n++]=((16711935&e)*o+(16711935&t)*l&4278255360)+((65280&e)*o+(65280&t)*l&16711680)>>8}}n+=h,s+=a}};copyImageDraw=(e,t,i,s,a,r,n,h)=>{const o=-(e>>2);e=-(3&e);for(let l=-t;l<0;l++){for(let e=o;e<0;e++){let e=i[s++];0===e?n++:r[n++]=e,e=i[s++],0===e?n++:r[n++]=e,e=i[s++],0===e?n++:r[n++]=e,e=i[s++],0===e?n++:r[n++]=e}for(let t=e;t<0;t++){const e=i[s++];0===e?n++:r[n++]=e}n+=h,s+=a}};copyPixelsMasked=(e,t,i,s,a,r,n,h,o)=>{const l=-(e>>2);e=-(3&e);for(let c=-t;c<0;c++){for(let e=l;e<0;e++){let e=i[a++];0!==e&&0===o[n]?r[n++]=e:n++,e=i[a++],0!==e&&0===o[n]?r[n++]=e:n++,e=i[a++],0!==e&&0===o[n]?r[n++]=e:n++,e=i[a++],0!==e&&0===o[n]?r[n++]=e:n++}for(let t=e;t<0;t++){const e=i[a++];0!==e&&0===o[n]?r[n++]=e:n++}n+=h,a+=s}}}},664:(e,t,i)=>{i.d(t,{Z:()=>n});var s=i(2991),a=i(2383),r=i(6327);class n extends r.Z{pixels;width;height;cropX;cropY;cropW;cropH;palette;constructor(e,t,i){super(),this.pixels=new Int8Array(e*t),this.width=this.cropW=e,this.height=this.cropH=t,this.cropX=this.cropY=0,this.palette=i}static fromArchive=(e,t,i=0)=>{const s=new a.Z(e.read(t+".dat")),r=new a.Z(e.read("index.dat"));r.pos=s.g2;const h=r.g2,o=r.g2,l=r.g1,c=new Int32Array(l);for(let e=1;es.data.length||r.pos>r.data.length)throw new Error;const d=r.g1,u=r.g1,f=r.g2,p=r.g2,m=new n(f,p,c);m.cropX=d,m.cropY=u,m.cropW=h,m.cropH=o;const g=m.pixels,y=r.g1;if(0===y){const e=m.width*m.height;for(let t=0;t{e|=0,t|=0;let i=(e+=this.cropX)+(t+=this.cropY)*s.Z.width2d,a=0,r=this.height,n=this.width,h=s.Z.width2d-n,o=0;if(ts.Z.bottom&&(r-=t+r-s.Z.bottom),es.Z.right){const t=e+n-s.Z.right;n-=t,o+=t,h+=t}n>0&&r>0&&this.copyImage(n,r,this.pixels,a,o,s.Z.pixels,i,h)};flipHorizontally=()=>{const e=this.pixels,t=this.width,i=this.height;for(let s=0;s{const e=this.pixels,t=this.width,i=this.height;for(let s=0;s<(i/2|0);s++)for(let a=0;a{for(let s=0;s>16&255;a+=e,a<0?a=0:a>255&&(a=255);let r=this.palette[s]>>8&255;r+=t,r<0?r=0:r>255&&(r=255);let n=255&this.palette[s];n+=i,n<0?n=0:n>255&&(n=255),this.palette[s]=(a<<16)+(r<<8)+n}};shrink=()=>{this.cropW|=0,this.cropH|=0,this.cropW/=2,this.cropH/=2,this.cropW|=0,this.cropH|=0;const e=new Int8Array(this.cropW*this.cropH);let t=0;for(let i=0;i>1)+(i+this.cropY>>1)*this.cropW]=this.pixels[t++];this.pixels=e,this.width=this.cropW,this.height=this.cropH,this.cropX=0,this.cropY=0};crop=()=>{if(this.width===this.cropW&&this.height===this.cropH)return;const e=new Int8Array(this.cropW*this.cropH);let t=0;for(let i=0;i{const o=-(e>>2);e=-(3&e);for(let l=-t;l<0;l++){for(let e=o;e<0;e++){let e=i[s++];0===e?n++:r[n++]=this.palette[255&e],e=i[s++],0===e?n++:r[n++]=this.palette[255&e],e=i[s++],0===e?n++:r[n++]=this.palette[255&e],e=i[s++],0===e?n++:r[n++]=this.palette[255&e]}for(let t=e;t<0;t++){const e=i[s++];0===e?n++:r[n++]=this.palette[255&e]}n+=h,s+=a}}}},4628:(e,t,i)=>{i.d(t,{Z:()=>o});var s=i(2991),a=i(2383),r=i(6327);class n{seed;constructor(e){this.seed=(0x5deece66dn^e)&(1n<<48n)-1n}setSeed=e=>{this.seed=(0x5deece66dn^e)&(1n<<48n)-1n};nextInt=()=>this.next(32);next=e=>(this.seed=0x5deece66dn*this.seed+0xbn&(1n<<48n)-1n,Number(this.seed)>>>48-e)}var h=i(312);class o extends r.Z{static CHARSET="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"£$%^&*()-_=+[{]};:'@#~,<.>/?\\| ";static CHARCODESET=[];static{for(let e=0;e<256;e++){let t=o.CHARSET.indexOf(String.fromCharCode(e));-1===t&&(t=74),o.CHARCODESET[e]=t}}charMask=[];charMaskWidth=new Int32Array(94);charMaskHeight=new Int32Array(94);charOffsetX=new Int32Array(94);charOffsetY=new Int32Array(94);charAdvance=new Int32Array(95);drawWidth=new Int32Array(256);random=new n(BigInt(Date.now()));height=0;static fromArchive=(e,t)=>{const i=new a.Z(e.read(t+".dat")),s=new a.Z(e.read("index.dat"));s.pos=i.g2+4;const r=s.g1;r>0&&(s.pos+=3*(r-1));const n=new o;for(let e=0;e<94;e++){n.charOffsetX[e]=s.g1,n.charOffsetY[e]=s.g1;const t=n.charMaskWidth[e]=s.g2,a=n.charMaskHeight[e]=s.g2,r=s.g1,h=t*a;if(n.charMask[e]=new Int8Array(h),0===r)for(let s=0;sn.height&&(n.height=a),n.charOffsetX[e]=1,n.charAdvance[e]=t+2;{let i=0;for(let s=a/7|0;s{if(!i)return;e|=0,t|=0;const a=i.length;t-=this.height;for(let r=0;r{e|=0,t|=0;const r=i.length;t-=this.height;for(let n=0;n{if(!e)return 0;const t=e.length;let i=0;for(let s=0;s{e|=0,t|=0,this.drawStringTaggable(e-this.stringWidth(i)/2,t,i,s,a)};drawStringCenter=(e,t,i,s)=>{i&&(e|=0,t|=0,this.drawString(e-this.stringWidth(i)/2,t,i,s))};drawStringTooltip=(e,t,i,s,a,r)=>{e|=0,t|=0,this.random.setSeed(BigInt(r));const n=192+(31&this.random.nextInt()),l=t-this.height;for(let t=0;t{e|=0,t|=0,a&&this.drawString(e-this.stringWidth(i)+1,t+1,i,h.Z.BLACK),this.drawString(e-this.stringWidth(i),t,i,s)};drawCenteredWave=(e,t,i,s,a)=>{if(!i)return;e|=0,t|=0,e-=this.stringWidth(i)/2|0;const r=t-this.height;for(let t=0;t{a|=0,r|=0;let h=(t|=0)+(i|=0)*s.Z.width2d,o=s.Z.width2d-a,l=0,c=0;if(i=s.Z.bottom&&(r-=i+r+1-s.Z.bottom),t=s.Z.right){const e=t+a+1-s.Z.right;a-=e,l+=e,o+=e}a>0&&r>0&&this.drawMask(a,r,e,c,l,s.Z.pixels,h,o,n)};drawCharAlpha=(e,t,i,a,r,n,h)=>{i|=0,a|=0;let o=(e|=0)+(t|=0)*s.Z.width2d,l=s.Z.width2d-i,c=0,d=0;if(t=s.Z.bottom&&(a-=t+a+1-s.Z.bottom),e=s.Z.right){const t=e+i+1-s.Z.right;i-=t,c+=t,l+=t}i>0&&a>0&&this.drawMaskAlpha(i,a,s.Z.pixels,o,l,h,d,c,r,n)};drawMask=(e,t,i,s,a,r,n,h,o)=>{const l=-((e|=0)>>2);e=-(3&e);for(let c=-(t|=0);c<0;c++){for(let e=l;e<0;e++)0===i[s++]?n++:r[n++]=o,0===i[s++]?n++:r[n++]=o,0===i[s++]?n++:r[n++]=o,0===i[s++]?n++:r[n++]=o;for(let t=e;t<0;t++)0===i[s++]?n++:r[n++]=o;n+=h,s+=a}};drawMaskAlpha=(e,t,i,s,a,r,n,h,o,l)=>{e|=0;const c=((16711935&o)*l&4278255360)+((65280&o)*l&16711680)>>8,d=256-l;for(let o=-(t|=0);o<0;o++){for(let t=-e;t<0;t++)if(0===r[n++])s++;else{const e=i[s];i[s++]=(((16711935&e)*d&4278255360)+((65280&e)*d&16711680)>>8)+c}s+=a,n+=h}};evaluateTag=e=>"red"===e?h.Z.RED:"gre"===e?h.Z.GREEN:"blu"===e?h.Z.BLUE:"yel"===e?h.Z.YELLOW:"cya"===e?h.Z.CYAN:"mag"===e?h.Z.MAGENTA:"whi"===e?h.Z.WHITE:"bla"===e?h.Z.BLACK:"lre"===e?h.Z.LIGHTRED:"dre"===e?h.Z.DARKRED:"dbl"===e?h.Z.DARKBLUE:"or1"===e?h.Z.ORANGE1:"or2"===e?h.Z.ORANGE2:"or3"===e?h.Z.ORANGE3:"gr1"===e?h.Z.GREEN1:"gr2"===e?h.Z.GREEN2:"gr3"===e?h.Z.GREEN3:h.Z.BLACK;split(e,t){if(0===e.length)return[e];const i=[];for(;e.length>0;){if(this.stringWidth(e)<=t&&-1===e.indexOf("|")){i.push(e);break}let s=e.length;for(let i=0;it)break;s=i}else if("|"===e[i]){s=i;break}i.push(e.substring(0,s)),e=e.substring(s+1)}return i}}},651:(e,t,i)=>{i.d(t,{Z:()=>r});var s=i(2991),a=i(6121);class r{image;width;height;ctx;pixels;constructor(e,t,i=a.E1){this.ctx=i,this.image=this.ctx.getImageData(0,0,e,t),this.pixels=new Int32Array(e*t),this.width=e,this.height=t,this.bind()}clear=()=>{this.pixels.fill(0)};bind=()=>{s.Z.bind(this.pixels,this.width,this.height)};draw=(e,t)=>{this.#e(),this.ctx.putImageData(this.image,e,t)};#e=()=>{const e=this.image.data;for(let t=0;t>16&255,e[s+1]=i>>8&255,e[s+2]=i>>0&255,e[s+3]=255}}}},2157:(e,t,i)=>{i.d(t,{Z:()=>r});var s=i(2383),a=i(9345);class r{static instances=[];static unpack=e=>{const t=new s.Z(e.read("base_head.dat")),i=new s.Z(e.read("base_type.dat")),n=new s.Z(e.read("base_label.dat")),h=t.g2;t.pos+=2;for(let e=0;e{i.d(t,{Z:()=>r});var s=i(2157),a=i(2383);class r{static instances=[];static unpack=e=>{const t=new a.Z(e.read("frame_head.dat")),i=new a.Z(e.read("frame_tran1.dat")),n=new a.Z(e.read("frame_tran2.dat")),h=new a.Z(e.read("frame_del.dat")),o=t.g2;t.pos+=2;const l=new Int32Array(500),c=new Int32Array(500),d=new Int32Array(500),u=new Int32Array(500);for(let e=0;e0){if(0!==f.types[e])for(let t=e-1;t>m;t--)if(0===f.types[t]){l[g]=t,c[g]=0,d[g]=0,u[g]=0,g++;break}l[g]=e;let i=0;3===f.types[l[g]]&&(i=128),c[g]=0==(1&t)?i:n.gsmart,d[g]=0==(2&t)?i:n.gsmart,u[g]=0==(4&t)?i:n.gsmart,m=e,g++}}a.length=g,a.bases=new Int32Array(g),a.x=new Int32Array(g),a.y=new Int32Array(g),a.z=new Int32Array(g);for(let e=0;e{var s;i.d(t,{Z:()=>a}),function(e){e[e.REBUILD_GETMAPS=150]="REBUILD_GETMAPS",e[e.IDLE_TIMER=70]="IDLE_TIMER",e[e.NO_TIMEOUT=108]="NO_TIMEOUT",e[e.EVENT_TRACKING=81]="EVENT_TRACKING",e[e.EVENT_CAMERA_POSITION=189]="EVENT_CAMERA_POSITION",e[e.ANTICHEAT_OPLOGIC1=7]="ANTICHEAT_OPLOGIC1",e[e.ANTICHEAT_OPLOGIC2=88]="ANTICHEAT_OPLOGIC2",e[e.ANTICHEAT_OPLOGIC3=30]="ANTICHEAT_OPLOGIC3",e[e.ANTICHEAT_OPLOGIC4=176]="ANTICHEAT_OPLOGIC4",e[e.ANTICHEAT_OPLOGIC5=220]="ANTICHEAT_OPLOGIC5",e[e.ANTICHEAT_OPLOGIC6=66]="ANTICHEAT_OPLOGIC6",e[e.ANTICHEAT_OPLOGIC7=17]="ANTICHEAT_OPLOGIC7",e[e.ANTICHEAT_OPLOGIC8=2]="ANTICHEAT_OPLOGIC8",e[e.ANTICHEAT_OPLOGIC9=238]="ANTICHEAT_OPLOGIC9",e[e.ANTICHEAT_CYCLELOGIC1=233]="ANTICHEAT_CYCLELOGIC1",e[e.ANTICHEAT_CYCLELOGIC2=146]="ANTICHEAT_CYCLELOGIC2",e[e.ANTICHEAT_CYCLELOGIC3=215]="ANTICHEAT_CYCLELOGIC3",e[e.ANTICHEAT_CYCLELOGIC4=236]="ANTICHEAT_CYCLELOGIC4",e[e.ANTICHEAT_CYCLELOGIC5=85]="ANTICHEAT_CYCLELOGIC5",e[e.ANTICHEAT_CYCLELOGIC6=219]="ANTICHEAT_CYCLELOGIC6",e[e.OPOBJ1=140]="OPOBJ1",e[e.OPOBJ2=40]="OPOBJ2",e[e.OPOBJ3=200]="OPOBJ3",e[e.OPOBJ4=178]="OPOBJ4",e[e.OPOBJ5=247]="OPOBJ5",e[e.OPOBJT=138]="OPOBJT",e[e.OPOBJU=239]="OPOBJU",e[e.OPNPC1=194]="OPNPC1",e[e.OPNPC2=8]="OPNPC2",e[e.OPNPC3=27]="OPNPC3",e[e.OPNPC4=113]="OPNPC4",e[e.OPNPC5=100]="OPNPC5",e[e.OPNPCT=134]="OPNPCT",e[e.OPNPCU=202]="OPNPCU",e[e.OPLOC1=245]="OPLOC1",e[e.OPLOC2=172]="OPLOC2",e[e.OPLOC3=96]="OPLOC3",e[e.OPLOC4=97]="OPLOC4",e[e.OPLOC5=116]="OPLOC5",e[e.OPLOCT=9]="OPLOCT",e[e.OPLOCU=75]="OPLOCU",e[e.OPPLAYER1=164]="OPPLAYER1",e[e.OPPLAYER2=53]="OPPLAYER2",e[e.OPPLAYER3=185]="OPPLAYER3",e[e.OPPLAYER4=206]="OPPLAYER4",e[e.OPPLAYERT=177]="OPPLAYERT",e[e.OPPLAYERU=248]="OPPLAYERU",e[e.OPHELD1=195]="OPHELD1",e[e.OPHELD2=71]="OPHELD2",e[e.OPHELD3=133]="OPHELD3",e[e.OPHELD4=157]="OPHELD4",e[e.OPHELD5=211]="OPHELD5",e[e.OPHELDT=48]="OPHELDT",e[e.OPHELDU=130]="OPHELDU",e[e.INV_BUTTON1=31]="INV_BUTTON1",e[e.INV_BUTTON2=59]="INV_BUTTON2",e[e.INV_BUTTON3=212]="INV_BUTTON3",e[e.INV_BUTTON4=38]="INV_BUTTON4",e[e.INV_BUTTON5=6]="INV_BUTTON5",e[e.IF_BUTTON=155]="IF_BUTTON",e[e.RESUME_PAUSEBUTTON=235]="RESUME_PAUSEBUTTON",e[e.CLOSE_MODAL=231]="CLOSE_MODAL",e[e.RESUME_P_COUNTDIALOG=237]="RESUME_P_COUNTDIALOG",e[e.TUTORIAL_CLICKSIDE=175]="TUTORIAL_CLICKSIDE",e[e.MOVE_OPCLICK=93]="MOVE_OPCLICK",e[e.BUG_REPORT=190]="BUG_REPORT",e[e.MOVE_MINIMAPCLICK=165]="MOVE_MINIMAPCLICK",e[e.INV_BUTTOND=159]="INV_BUTTOND",e[e.IGNORELIST_DEL=171]="IGNORELIST_DEL",e[e.IGNORELIST_ADD=79]="IGNORELIST_ADD",e[e.IF_PLAYERDESIGN=52]="IF_PLAYERDESIGN",e[e.CHAT_SETMODE=244]="CHAT_SETMODE",e[e.MESSAGE_PRIVATE=148]="MESSAGE_PRIVATE",e[e.FRIENDLIST_DEL=11]="FRIENDLIST_DEL",e[e.FRIENDLIST_ADD=118]="FRIENDLIST_ADD",e[e.CLIENT_CHEAT=4]="CLIENT_CHEAT",e[e.MESSAGE_PUBLIC=158]="MESSAGE_PUBLIC",e[e.MOVE_GAMECLICK=181]="MOVE_GAMECLICK"}(s||(s={}));const a=s},1812:(e,t,i)=>{i.d(t,{Z:()=>s});class s{socket;wsin;wsout;closed=!1;ioerror=!1;static openSocket=async e=>await new Promise(((t,i)=>{const s=e.host.startsWith("https"),a=s?"wss":"ws",r=e.host.substring(e.host.indexOf("//")+2),n=s?e.port+2:e.port+1,h=new WebSocket(`${a}://${r}:${n}`,"binary");h.addEventListener("open",(()=>{console.log("connection open!"),t(h)})),h.addEventListener("error",(()=>{console.log("connection error!"),i(h)}))}));constructor(e){e.onclose=this.onclose,e.onerror=this.onerror,this.wsin=new r(e),this.wsout=new a(e),this.socket=e}get host(){return this.socket.url.split("/")[2]}get port(){return parseInt(this.socket.url.split(":")[2],10)}get available(){return this.closed?0:this.wsin.available}write=(e,t)=>{this.wsout.write(e,t)};read=async()=>this.closed?0:await this.wsin.read();readBytes=async(e,t,i)=>{if(!this.closed)for(;i>0;){const s=await this.wsin.readBytes(i);if(s.length<=0)throw new Error("EOF");for(let a=0;a{this.closed=!0,this.socket.close(),this.wsin.close(),this.wsout.close(),console.log("connection close!"),this.ioerror&&console.log("connection error!")};onclose=e=>{this.closed||this.close()};onerror=e=>{this.closed||(this.ioerror=!0,this.close())}}class a{socket;closed=!1;ioerror=!1;constructor(e){this.socket=e}write=(e,t)=>{if(!this.closed){if(this.ioerror)throw this.ioerror=!1,new Error("Error in writer thread");if(t>5e3)throw new Error("buffer overflow");try{this.socket.send(e.slice(0,t))}catch(e){this.ioerror=!0}}};close=()=>{this.closed=!0}}class r{buf=null;pos=0;remaining=0;callback=null;closed=!1;constructor(e){e.binaryType="arraybuffer",e.addEventListener("message",this.on.bind(this))}on=e=>{if(this.closed)throw new Error("WebSocketReader is closed!");const t=new Uint8Array(e.data);if(null===this.buf)this.buf=t,this.pos=0,this.remaining=t.length;else{const e=new Uint8Array(this.remaining+t.length);e.set(this.buf.subarray(this.pos),0),e.set(t,this.remaining),this.buf=e,this.pos=0,this.remaining+=t.length}this.callback&&this.callback(this.buf.subarray(this.pos))};readBytes=async e=>{if(this.closed)throw new Error("WebSocketReader is closed!");return new Promise((t=>{if(this.remaining>=e){if(!this.buf)throw new Error("WebSocketReader buf was null!");const i=this.buf.subarray(this.pos,this.pos+e);return this.pos+=e,this.remaining-=e,void t(i)}this.callback=i=>{if(i.length>=e){const s=i.subarray(0,e);this.pos+=e,this.remaining-=e,t(s),this.callback=null}}}))};read=async()=>{if(this.closed)throw new Error("WebSocketReader is closed!");return new Promise((e=>{if(this.remaining>=1){if(!this.buf)throw new Error("WebSocketReader buf was null!");const t=this.buf[this.pos];return this.pos++,this.remaining--,void e(t)}this.callback=t=>{if(t.length>=1){const i=t[0];this.pos++,this.remaining--,e(i),this.callback=null}}}))};get available(){return this.remaining}close=()=>{this.callback=null,this.remaining=0,this.buf=null,this.pos=0,this.closed=!0}}},8432:(e,t,i)=>{i.d(t,{Z:()=>s});class s{db;constructor(e){e.onerror=this.onerror,e.onclose=this.onclose,this.db=e}static openDatabase=async()=>await new Promise(((e,t)=>{const i=indexedDB.open("lostcity",1);i.onsuccess=t=>{const i=t.target;console.log("database success!"),e(i.result)},i.onupgradeneeded=e=>{e.target.result.createObjectStore("cache")},i.onerror=e=>{const i=e.target;console.error("database error!: ",i.error),t(i.result)}}));cacheload=async e=>await new Promise((t=>{const i=this.db.transaction("cache","readonly").objectStore("cache").get(e);i.onsuccess=()=>{t(i.result)},i.onerror=e=>{t(void 0)}}));cachesave=async(e,t)=>await new Promise(((i,s)=>{const a=this.db.transaction("cache","readwrite").objectStore("cache").put(t,e);a.onsuccess=()=>{i()},a.onerror=e=>{s()}}));onclose=e=>{console.log("database close!")};onerror=e=>{console.log("database error!")};genHash=e=>{const t=e.trim();let i=0;for(let e=0;e="A"&&s<="Z"?i+=s.charCodeAt(0)+1-65:s>="a"&&s<="z"?i+=s.charCodeAt(0)+1-97:s>="0"&&s<="9"&&(i+=s.charCodeAt(0)+27-48)}return i}}},7576:(e,t,i)=>{i.d(t,{Z:()=>s});class s{count=0;rsl=new Int32Array(256);mem=new Int32Array(256);a=0;b=0;c=0;constructor(e){for(let t=0;t{let e=2654435769,t=2654435769,i=2654435769,s=2654435769,a=2654435769,r=2654435769,n=2654435769,h=2654435769;for(let o=0;o<4;o++)e^=t<<11,s+=e,t+=i,t^=i>>>2,a+=t,i+=s,i^=s<<8,r+=i,s+=a,s^=a>>>16,n+=s,a+=r,a^=r<<10,h+=a,r+=n,r^=n>>>4,e+=r,n+=h,n^=h<<8,t+=n,h+=e,h^=e>>>9,i+=h,e+=t;for(let o=0;o<256;o+=8)e+=this.rsl[o],t+=this.rsl[o+1],i+=this.rsl[o+2],s+=this.rsl[o+3],a+=this.rsl[o+4],r+=this.rsl[o+5],n+=this.rsl[o+6],h+=this.rsl[o+7],e^=t<<11,s+=e,t+=i,t^=i>>>2,a+=t,i+=s,i^=s<<8,r+=i,s+=a,s^=a>>>16,n+=s,a+=r,a^=r<<10,h+=a,r+=n,r^=n>>>4,e+=r,n+=h,n^=h<<8,t+=n,h+=e,h^=e>>>9,i+=h,e+=t,this.mem[o]=e,this.mem[o+1]=t,this.mem[o+2]=i,this.mem[o+3]=s,this.mem[o+4]=a,this.mem[o+5]=r,this.mem[o+6]=n,this.mem[o+7]=h;for(let o=0;o<256;o+=8)e+=this.mem[o],t+=this.mem[o+1],i+=this.mem[o+2],s+=this.mem[o+3],a+=this.mem[o+4],r+=this.mem[o+5],n+=this.mem[o+6],h+=this.mem[o+7],e^=t<<11,s+=e,t+=i,t^=i>>>2,a+=t,i+=s,i^=s<<8,r+=i,s+=a,s^=a>>>16,n+=s,a+=r,a^=r<<10,h+=a,r+=n,r^=n>>>4,e+=r,n+=h,n^=h<<8,t+=n,h+=e,h^=e>>>9,i+=h,e+=t,this.mem[o]=e,this.mem[o+1]=t,this.mem[o+2]=i,this.mem[o+3]=s,this.mem[o+4]=a,this.mem[o+5]=r,this.mem[o+6]=n,this.mem[o+7]=h;this.isaac(),this.count=256};isaac=()=>{this.c++,this.b+=this.c;for(let e=0;e<256;e++){const t=this.mem[e],i=3&e;let s;0===i?this.a^=this.a<<13:1===i?this.a^=this.a>>>6:2===i?this.a^=this.a<<2:3===i&&(this.a^=this.a>>>16),this.a+=this.mem[e+128&255],this.mem[e]=s=this.mem[t>>>2&255]+this.a+this.b,this.rsl[e]=this.b=this.mem[s>>>8>>>2&255]+t}}}},2028:(e,t,i)=>{i.d(t,{Z:()=>r});var s=i(2383),a=i(5810);class r{static genHash=e=>{let t=0;e=e.toUpperCase();for(let i=0;i{const t=r.genHash(e),i=this.fileHash.indexOf(t);return-1===i?null:this.readIndex(i)};readIndex=e=>{if(e<0||e>=this.fileCount)return null;if(this.fileUnpacked[e])return this.fileUnpacked[e];const t=this.fileOffset[e],i=t+this.filePackedSize[e];if(this.compressedWhole){const s=Uint8Array.from(this.buffer.subarray(t,t+i));return this.fileUnpacked[e]=s,s}{const t=Uint8Array.from(a.Z.read(this.fileUnpackedSize[e],this.buffer,this.filePackedSize[e],this.fileOffset[e]));return this.fileUnpacked[e]=t,t}}}},2383:(e,t,i)=>{i.d(t,{Z:()=>n});var s=i(1519),a=i(9080),r=i(6327);class n extends r.Z{static CRC32_POLYNOMIAL=3988292384;static crctable=new Int32Array(256);static bitmask=new Uint32Array(33);static cacheMin=new a.Z;static cacheMid=new a.Z;static cacheMax=new a.Z;static cacheMinCount=0;static cacheMidCount=0;static cacheMaxCount=0;static{for(let e=0;e<32;e++)n.bitmask[e]=(1<>>1^n.CRC32_POLYNOMIAL:t>>>=1;n.crctable[e]=t}}static crc32=e=>{let t=4294967295;for(let i=0;i>>8^n.crctable[255&(t^e[i])];return~t};data;pos;bitPos=0;random=null;constructor(e){if(!e)throw new Error("Input src packet array was null!");super(),e instanceof Int8Array?this.data=new Uint8Array(e):this.data=e,this.pos=0}get length(){return this.data.length}get available(){return this.data.length-this.pos}static alloc=e=>{let t=null;return 0===e&&n.cacheMinCount>0?(n.cacheMinCount--,t=n.cacheMin.pollFront()):1===e&&n.cacheMidCount>0?(n.cacheMidCount--,t=n.cacheMid.pollFront()):2===e&&n.cacheMaxCount>0&&(n.cacheMaxCount--,t=n.cacheMax.pollFront()),t?(t.pos=0,t):new n(0===e?new Uint8Array(100):1===e?new Uint8Array(5e3):new Uint8Array(3e4))};release=()=>{this.pos=0,100===this.data.length&&n.cacheMinCount<1e3?(n.cacheMin.pushBack(this),n.cacheMinCount++):5e3===this.data.length&&n.cacheMidCount<250?(n.cacheMid.pushBack(this),n.cacheMidCount++):3e4===this.data.length&&n.cacheMaxCount<50&&(n.cacheMax.pushBack(this),n.cacheMaxCount++)};get g1(){return this.data[this.pos++]}get g1b(){return this.data[this.pos++]<<24>>24}get g2(){return this.data[this.pos++]<<8|this.data[this.pos++]}get g2b(){let e=this.data[this.pos++]<<8|this.data[this.pos++];return e>32767&&(e-=65536),e}get g3(){return this.data[this.pos++]<<16|this.data[this.pos++]<<8|this.data[this.pos++]}get g4(){return this.data[this.pos++]<<24|this.data[this.pos++]<<16|this.data[this.pos++]<<8|this.data[this.pos++]}get g8(){return(0xffffffffn&BigInt(this.g4))<<32n|0xffffffffn&BigInt(this.g4)}get gsmart(){return this.data[this.pos]<128?this.g1-64:this.g2-49152}get gsmarts(){return this.data[this.pos]<128?this.g1:this.g2-32768}get gjstr(){let e="";for(;10!==this.data[this.pos]&&this.pos{for(let s=t;s{this.data[this.pos++]=e+(this.random?.nextInt??0)&255};p1=e=>{this.data[this.pos++]=e};p2=e=>{this.data[this.pos++]=e>>>8,this.data[this.pos++]=e};ip2=e=>{this.data[this.pos++]=e,this.data[this.pos++]=e>>>8};p3=e=>{this.data[this.pos++]=e>>>16,this.data[this.pos++]=e>>>8,this.data[this.pos++]=e};p4=e=>{this.data[this.pos++]=e>>>24,this.data[this.pos++]=e>>>16,this.data[this.pos++]=e>>>8,this.data[this.pos++]=e};ip4=e=>{this.data[this.pos++]=e,this.data[this.pos++]=e>>>8,this.data[this.pos++]=e>>>16,this.data[this.pos++]=e>>>24};p8=e=>{this.p4(Number(e>>32n)),this.p4(Number(0xffffffffn&e))};pjstr=e=>{for(let t=0;t{for(let s=i;s{this.data[this.pos-e-1]=e};bits=()=>{this.bitPos=8*this.pos};bytes=()=>{this.pos=(this.bitPos+7)/8|0};gBit=e=>{let t=this.bitPos>>>3,i=8-(7&this.bitPos),s=0;for(this.bitPos+=e;e>i;i=8)s+=(this.data[t++]&n.bitmask[i])<>>i-e&n.bitmask[e],s};rsaenc=(e,t)=>{const i=new Uint8Array(this.pos);(0,s.fH)(this.data,0,i,0,this.pos);const a=(0,s.v3)(i),r=(0,s.yz)(a,t,e),n=(0,s.jk)(r);this.pos=0,this.p1(n.length),this.pdata(n,n.length,0)}}},741:(e,t,i)=>{i.d(t,{Z:()=>s});class s{static CLIENTPROT_SCRAMBLED=[95,218,67,50,253,222,194,60,101,128,8,251,92,111,24,33,223,66,232,59,227,113,153,105,126,98,167,102,177,238,62,190,147,23,150,151,156,144,193,155,81,0,198,22,137,210,179,16,168,170,32,181,248,141,58,87,208,106,180,191,221,241,40,176,196,154,65,145,230,78,30,161,188,41,14,129,18,199,47,247,225,34,51,10,159,75,12,56,61,31,39,91,46,242,134,5,122,123,209,228,104,195,21,3,11,44,107,172,6,186,110,215,205,103,27,185,124,77,252,117,86,115,127,207,52,79,43,97,219,116,169,7,118,162,108,36,20,233,88,135,80,19,42,237,57,152,71,9,250,17,4,119,234,130,26,200,189,163,254,245,197,171,220,235,140,244,184,94,211,231,99,246,121,212,112,204,63,148,83,178,1,255,131,13,183,142,236,45,55,35,243,136,37,85,100,160,38,224,146,174,82,48,109,132,125,90,143,138,240,173,165,164,192,175,29,74,28,114,213,73,64,206,76,139,96,2,229,15,93,25,239,202,49,70,214,201,72,203,68,89,69,157,216,217,249,120,226,84,149,187,54,53,158,166,182,133,0];static SERVERPROT_SIZES=[0,-2,4,6,-1,0,0,2,0,0,0,0,5,4,2,2,0,0,0,0,2,-2,2,14,0,6,3,0,4,0,0,0,3,0,0,0,0,0,0,0,0,-1,4,2,6,0,6,0,0,3,7,0,0,0,-1,0,0,0,0,4,0,0,0,0,0,0,0,0,1,15,0,0,0,0,6,0,2,0,0,0,2,0,0,0,1,0,0,4,0,0,0,0,0,0,0,0,0,0,-2,0,0,0,0,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,-2,0,0,2,0,0,0,2,9,0,0,0,0,0,4,0,0,0,3,7,9,0,0,0,0,0,0,0,0,0,-2,0,0,0,0,3,2,0,0,0,0,0,0,6,0,0,0,0,0,0,0,0,-2,2,0,0,0,0,0,6,0,0,0,2,0,2,0,0,0,-2,0,0,4,0,0,0,0,6,0,0,-2,-2,0,0,0,0,0,0,-2,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,-2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0]}},9782:(e,t,i)=>{var s;i.d(t,{Z:()=>a}),function(e){e[e.IF_OPENCHATMODAL=14]="IF_OPENCHATMODAL",e[e.IF_OPENMAINSIDEMODAL=28]="IF_OPENMAINSIDEMODAL",e[e.IF_CLOSE=129]="IF_CLOSE",e[e.IF_OPENSIDEOVERLAY=167]="IF_OPENSIDEOVERLAY",e[e.IF_OPENMAINMODAL=168]="IF_OPENMAINMODAL",e[e.IF_OPENSIDEMODAL=195]="IF_OPENSIDEMODAL",e[e.IF_SETCOLOUR=2]="IF_SETCOLOUR",e[e.IF_SETHIDE=26]="IF_SETHIDE",e[e.IF_SETOBJECT=46]="IF_SETOBJECT",e[e.IF_SHOWSIDE=84]="IF_SHOWSIDE",e[e.IF_SETMODEL=87]="IF_SETMODEL",e[e.IF_SETRECOL=103]="IF_SETRECOL",e[e.IF_SETANIM=146]="IF_SETANIM",e[e.IF_SETPLAYERHEAD=197]="IF_SETPLAYERHEAD",e[e.IF_SETTEXT=201]="IF_SETTEXT",e[e.IF_SETNPCHEAD=204]="IF_SETNPCHEAD",e[e.IF_SETPOSITION=209]="IF_SETPOSITION",e[e.TUTORIAL_FLASHSIDE=126]="TUTORIAL_FLASHSIDE",e[e.TUTORIAL_OPENCHAT=185]="TUTORIAL_OPENCHAT",e[e.UPDATE_INV_STOP_TRANSMIT=15]="UPDATE_INV_STOP_TRANSMIT",e[e.UPDATE_INV_FULL=98]="UPDATE_INV_FULL",e[e.UPDATE_INV_PARTIAL=213]="UPDATE_INV_PARTIAL",e[e.CAM_LOOKAT=3]="CAM_LOOKAT",e[e.CAM_SHAKE=13]="CAM_SHAKE",e[e.CAM_MOVETO=74]="CAM_MOVETO",e[e.CAM_RESET=239]="CAM_RESET",e[e.NPC_INFO=1]="NPC_INFO",e[e.PLAYER_INFO=184]="PLAYER_INFO",e[e.FINISH_TRACKING=133]="FINISH_TRACKING",e[e.ENABLE_TRACKING=226]="ENABLE_TRACKING",e[e.MESSAGE_GAME=4]="MESSAGE_GAME",e[e.UPDATE_IGNORELIST=21]="UPDATE_IGNORELIST",e[e.CHAT_FILTER_SETTINGS=32]="CHAT_FILTER_SETTINGS",e[e.MESSAGE_PRIVATE=41]="MESSAGE_PRIVATE",e[e.UPDATE_FRIENDLIST=152]="UPDATE_FRIENDLIST",e[e.UNSET_MAP_FLAG=19]="UNSET_MAP_FLAG",e[e.UPDATE_RUNWEIGHT=22]="UPDATE_RUNWEIGHT",e[e.HINT_ARROW=25]="HINT_ARROW",e[e.UPDATE_REBOOT_TIMER=43]="UPDATE_REBOOT_TIMER",e[e.UPDATE_STAT=44]="UPDATE_STAT",e[e.UPDATE_RUNENERGY=68]="UPDATE_RUNENERGY",e[e.RESET_ANIMS=136]="RESET_ANIMS",e[e.UPDATE_UID192=139]="UPDATE_UID192",e[e.LAST_LOGIN_INFO=140]="LAST_LOGIN_INFO",e[e.LOGOUT=142]="LOGOUT",e[e.P_COUNTDIALOG=243]="P_COUNTDIALOG",e[e.SET_MULTIWAY=254]="SET_MULTIWAY",e[e.DATA_LOC_DONE=20]="DATA_LOC_DONE",e[e.DATA_LAND_DONE=80]="DATA_LAND_DONE",e[e.DATA_LAND=132]="DATA_LAND",e[e.DATA_LOC=220]="DATA_LOC",e[e.REBUILD_NORMAL=237]="REBUILD_NORMAL",e[e.VARP_SMALL=150]="VARP_SMALL",e[e.VARP_LARGE=175]="VARP_LARGE",e[e.RESET_CLIENT_VARCACHE=193]="RESET_CLIENT_VARCACHE",e[e.SYNTH_SOUND=12]="SYNTH_SOUND",e[e.MIDI_SONG=54]="MIDI_SONG",e[e.MIDI_JINGLE=212]="MIDI_JINGLE",e[e.UPDATE_ZONE_PARTIAL_FOLLOWS=7]="UPDATE_ZONE_PARTIAL_FOLLOWS",e[e.UPDATE_ZONE_FULL_FOLLOWS=135]="UPDATE_ZONE_FULL_FOLLOWS",e[e.UPDATE_ZONE_PARTIAL_ENCLOSED=162]="UPDATE_ZONE_PARTIAL_ENCLOSED",e[e.LOC_MERGE=23]="LOC_MERGE",e[e.LOC_ANIM=42]="LOC_ANIM",e[e.OBJ_DEL=49]="OBJ_DEL",e[e.OBJ_REVEAL=50]="OBJ_REVEAL",e[e.LOC_ADD_CHANGE=59]="LOC_ADD_CHANGE",e[e.MAP_PROJANIM=69]="MAP_PROJANIM",e[e.LOC_DEL=76]="LOC_DEL",e[e.OBJ_COUNT=151]="OBJ_COUNT",e[e.MAP_ANIM=191]="MAP_ANIM",e[e.OBJ_ADD=223]="OBJ_ADD"}(s||(s={}));const a=s},6970:(e,t,i)=>{i.d(t,{Z:()=>h});class s{start=0;end=0;form=0;length=0;shapeDelta=null;shapePeak=null;threshold=0;position=0;delta=0;amplitude=0;ticks=0;read=e=>{this.form=e.g1,this.start=e.g4,this.end=e.g4,this.length=e.g1,this.shapeDelta=new Int32Array(this.length),this.shapePeak=new Int32Array(this.length);for(let t=0;t{this.threshold=0,this.position=0,this.delta=0,this.amplitude=0,this.ticks=0};evaluate=e=>(this.ticks>=this.threshold&&this.shapePeak&&this.shapeDelta&&(this.amplitude=this.shapePeak[this.position++]<<15,this.position>=this.length&&(this.position=this.length-1),this.threshold=this.shapeDelta[this.position]/65536*e|0,this.threshold>this.ticks&&(this.delta=((this.shapePeak[this.position]<<15)-this.amplitude)/(this.threshold-this.ticks)|0)),this.amplitude+=this.delta,this.ticks++,this.amplitude-this.delta>>15)}class a{static buffer=null;static noise=null;static sin=null;static tmpPhases=new Int32Array(5);static tmpDelays=new Int32Array(5);static tmpVolumes=new Int32Array(5);static tmpSemitones=new Int32Array(5);static tmpStarts=new Int32Array(5);frequencyBase=null;amplitudeBase=null;frequencyModRate=null;frequencyModRange=null;amplitudeModRate=null;amplitudeModRange=null;release=null;attack=null;harmonicVolume=new Int32Array(5);harmonicSemitone=new Int32Array(5);harmonicDelay=new Int32Array(5);start=0;length=500;reverbVolume=100;reverbDelay=0;static init=()=>{this.noise=new Int32Array(32768);for(let e=0;e<32768;e++)Math.random()>.5?this.noise[e]=1:this.noise[e]=-1;this.sin=new Int32Array(32768);for(let e=0;e<32768;e++)this.sin[e]=16384*Math.sin(e/5215.1903)|0;this.buffer=new Int32Array(220500)};generate=(e,t)=>{for(let t=0;t>1,n+=(t*s>>16)+r}if(this.amplitudeModRate&&this.amplitudeModRange){const t=this.amplitudeModRate.evaluate(e),i=this.amplitudeModRange.evaluate(e);c=c*(32768+(this.generate2(i,l,this.amplitudeModRate.form)>>1))>>15,l+=(t*h>>16)+o}for(let s=0;s<5;s++)if(0!==this.harmonicVolume[s]){const r=t+a.tmpDelays[s];r>15,a.tmpPhases[s],this.frequencyBase.form),a.tmpPhases[s]+=(i*a.tmpSemitones[s]>>16)+a.tmpStarts[s])}}if(this.release&&this.attack){this.release.reset(),this.attack.reset();let t=0,i=!0;for(let s=0;s>8):this.release.start+((this.release.end-this.release.start)*n>>8),t+=256,t>=h&&(t=0,i=!i),i&&(a.buffer[s]=0)}}if(this.reverbDelay>0&&this.reverbVolume>0){const t=this.reverbDelay*i;for(let i=t;i32767&&(a.buffer[t]=32767);return a.buffer};generate2=(e,t,i)=>1===i?(32767&t)<16384?e:-e:2===i?a.sin[32767&t]*e>>14:3===i?((32767&t)*e>>14)-e:4===i?a.noise[32767&(t/2607|0)]*e:0;read=e=>{this.frequencyBase=new s,this.frequencyBase.read(e),this.amplitudeBase=new s,this.amplitudeBase.read(e),0!==e.g1&&(e.pos--,this.frequencyModRate=new s,this.frequencyModRate.read(e),this.frequencyModRange=new s,this.frequencyModRange.read(e)),0!==e.g1&&(e.pos--,this.amplitudeModRate=new s,this.amplitudeModRate.read(e),this.amplitudeModRange=new s,this.amplitudeModRange.read(e)),0!==e.g1&&(e.pos--,this.release=new s,this.release.read(e),this.attack=new s,this.attack.read(e));for(let t=0;t<10;t++){const i=e.gsmarts;if(0===i)break;this.harmonicVolume[t]=i,this.harmonicSemitone[t]=e.gsmart,this.harmonicDelay[t]=e.gsmarts}this.reverbDelay=e.gsmarts,this.reverbVolume=e.gsmarts,this.length=e.g2,this.start=e.g2}}var r=i(2383),n=i(9345);class h{static delays=new Int32Array(1e3);static waveBytes=null;static waveBuffer=null;static tracks=new n.to(1e3,null);tones=new n.to(10,null);loopBegin=0;loopEnd=0;static unpack=e=>{const t=new r.Z(e.read("sounds.dat"));for(this.waveBytes=new Uint8Array(441e3),this.waveBuffer=new r.Z(this.waveBytes),a.init();;){const e=t.g2;if(65535===e)break;const i=new h;i.read(t),this.tracks[e]=i,this.delays[e]=i.trim()}};static generate=(e,t)=>{if(!this.tracks[e])return null;const i=this.tracks[e];return i?.getWave(t)??null};read=e=>{for(let t=0;t<10;t++)0!==e.g1&&(e.pos--,this.tones[t]=new a,this.tones[t]?.read(e));this.loopBegin=e.g2,this.loopEnd=e.g2};trim=()=>{let e=9999999;for(let t=0;t<10;t++)this.tones[t]&&(this.tones[t].start/20|0){const t=this.generate(e);return h.waveBuffer.pos=0,h.waveBuffer?.p4(1380533830),h.waveBuffer?.ip4(t+36),h.waveBuffer?.p4(1463899717),h.waveBuffer?.p4(1718449184),h.waveBuffer?.ip4(16),h.waveBuffer?.ip2(1),h.waveBuffer?.ip2(1),h.waveBuffer?.ip4(22050),h.waveBuffer?.ip4(22050),h.waveBuffer?.ip2(1),h.waveBuffer?.ip2(8),h.waveBuffer?.p4(1684108385),h.waveBuffer?.ip4(t),h.waveBuffer.pos+=t,h.waveBuffer};generate=e=>{let t=0;for(let e=0;e<10;e++)this.tones[e]&&this.tones[e].length+this.tones[e].start>t&&(t=this.tones[e].length+this.tones[e].start);if(0===t)return 0;let i=22050*t/1e3|0,s=22050*this.loopBegin/1e3|0,a=22050*this.loopEnd/1e3|0;(s<0||a<0||a>i||s>=a)&&(e=0);let r=i+(a-s)*(e-1);for(let e=44;e>8<<24>>24)}if(e>1){s+=44,a+=44,i+=44,r+=44;const t=r-i;for(let e=i-1;e>=a;e--)h.waveBytes&&(h.waveBytes[e+t]=h.waveBytes[e]);for(let t=1;t{i.d(t,{AK:()=>l,IY:()=>a,N$:()=>r,Nv:()=>o,nz:()=>n,to:()=>s,zi:()=>h});class s extends Array{constructor(e,t){super(e);for(let i=0;i{i.d(t,{Di:()=>r,GR:()=>a,_v:()=>s,fH:()=>n,jk:()=>o,v3:()=>h,yz:()=>l});const s=async e=>new Promise((t=>setTimeout(t,e))),a=async e=>new Int8Array(await(await fetch(e)).arrayBuffer()),r=async e=>(await fetch(e)).text(),n=(e,t,i,s,a)=>{for(;a--;)i[s++]=e[t++]},h=e=>{let t=0n;for(let i=0;i{const t=[];for(;e>0n;)t.unshift(Number(255n&e)),e>>=8n;return new Uint8Array(t)},l=(e,t,i)=>{let s=1n;for(;t>0n;)t%2n===1n&&(s=s*e%i),e=e*e%i,t>>=1n;return s}},9897:(e,t,i)=>{i.d(t,{Z:()=>a});var s=i(2383);class a{static PERIOD=new Uint16Array(["d","o","t"].join("").split("").map((e=>e.charCodeAt(0))));static AMPERSAT=new Uint16Array(["(","a",")"].join("").split("").map((e=>e.charCodeAt(0))));static SLASH=new Uint16Array(["s","l","a","s","h"].join("").split("").map((e=>e.charCodeAt(0))));static whitelist=["cook","cook's","cooks","seeks","sheet"];static tlds=[];static tldTypes=[];static bads=[];static badCombinations=[];static domains=[];static fragments=[];static unpack=e=>{const t=new s.Z(e.read("fragmentsenc.txt")),i=new s.Z(e.read("badenc.txt")),a=new s.Z(e.read("domainenc.txt")),r=new s.Z(e.read("tldlist.txt"));this.read(i,a,t,r)};static filter=e=>{const t=[...e];this.format(t);const i=t.join("").trim(),s=i.toLowerCase(),a=[...s];this.filterTlds(a),this.filterBadWords(a),this.filterDomains(a),this.filterFragments(a);for(let e=0;e{this.readBadWords(e),this.readDomains(t),this.readFragments(i),this.readTld(s)};static readTld=e=>{const t=e.g4;for(let i=0;ie.g1))};static readBadWords=e=>{const t=e.g4;for(let i=0;ie.g1));const t=new Array(e.g1).fill([]).map((()=>[e.g1b,e.g1b]));t.length>0&&(this.badCombinations[i]=t)}};static readDomains=e=>{const t=e.g4;for(let i=0;ie.g1))};static readFragments=e=>{const t=e.g4;for(let i=0;i{const t=[...e],i=[...e];this.filterBadCombinations(null,t,this.PERIOD),this.filterBadCombinations(null,i,this.SLASH);for(let s=0;s{for(let t=0;t<2;t++)for(let t=this.bads.length-1;t>=0;t--)this.filterBadCombinations(this.badCombinations[t],e,this.bads[t])};static filterDomains=e=>{const t=[...e],i=[...e];this.filterBadCombinations(null,t,this.AMPERSAT),this.filterBadCombinations(null,i,this.PERIOD);for(let s=this.domains.length-1;s>=0;s--)this.filterDomain(i,t,this.domains[s],e)};static filterFragments=e=>{for(let t=0;t=0&&a{if(this.isNumericalChars(e))return!0;const t=this.getInteger(e),i=this.fragments,s=i.length;if(t===i[0]||t===i[s-1])return!0;let a=0,r=s-1;for(;a<=r;){const e=(a+r)/2|0;if(t===i[e])return!0;t{if(e.length>6)return 0;let t=0;for(let i=0;i{for(let i=t;i=0;i++)if(this.isNumerical(e[i]))return i;return-1};static indexOfNonNumber=(e,t)=>{for(let i=e;i=0;i++)if(!this.isNumerical(t[i]))return i;return t.length};static getEmulatedDomainCharLen=(e,t,i)=>t===i||"o"===t&&"0"===i?1:"o"===t&&"("===i&&")"===e?2:"c"!==t||"("!==i&&"<"!==i&&"["!==i?"e"===t&&"€"===i||"s"===t&&"$"===i||"l"===t&&"i"===i?1:0:1;static filterDomain=(e,t,i,s)=>{const a=i.length,r=s.length;for(let n=0;n<=r-a;n++){const{matched:a,currentIndex:r}=this.findMatchingDomain(n,i,s);if(!a)continue;const h=this.prefixSymbolStatus(n,s,3,t,["@"]),o=this.suffixSymbolStatus(r-1,s,3,e,[".",","]);(h>2||o>2)&&this.maskChars(n,r,s)}};static findMatchingDomain=(e,t,i)=>{const s=t.length;let a=e,r=0;for(;a0)a+=o,r++;else{if(0===r)break;const i=this.getEmulatedDomainCharLen(h,String.fromCharCode(t[r-1]),n);if(i>0)a+=i,1===r&&e++;else{if(r>=s||!this.isSymbol(n))break;a++}}}return{matched:r>=s,currentIndex:a}};static filterBadCombinations=(e,t,i)=>{if(!(i.length>t.length))for(let s=0;s<=t.length-i.length;s++){let a=s;const{currentIndex:r,badIndex:n,hasSymbol:h,hasNumber:o,hasDigit:l}=this.processBadCharacters(t,i,a);a=r;let c=t[a],d=a+1=i.length)||o&&l)continue;let u,f=!0;if(h){let e=!1,i=!1;if((s-1<0||this.isSymbol(t[s-1])&&"'"!==t[s-1])&&(e=!0),(a>=t.length||this.isSymbol(t[a])&&"'"!==t[a])&&(i=!0),!e||!i){let i=!1;for(u=s-2,e&&(u=s);!i&&u=0&&(!this.isSymbol(t[u])||"'"===t[u])){const e=[];let s;for(s=0;s<3&&u+s=0&&(!this.isSymbol(t[u-1])||"'"===t[u-1])&&(a=!1),a&&!this.isBadFragment(e)&&(i=!0)}u++}i||(f=!1)}}else{c=" ",s-1>=0&&(c=t[s-1]),d=" ",a{let s=i,a=0,r=0,n=!1,h=!1,o=!1;for(;s=e.length||h&&o);){const l=e[s],c=s+10)1===d&&this.isNumerical(l)&&(h=!0),2===d&&(this.isNumerical(l)||this.isNumerical(c))&&(h=!0),s+=d,a++;else{if(0===a)break;let e;if((e=this.getEmulatedBadCharLen(c,String.fromCharCode(t[a-1]),l))>0)s+=e;else{if(a>=t.length||!this.isNotLowercaseAlpha(l))break;if(this.isSymbol(l)&&"'"!==l&&(n=!0),this.isNumerical(l)&&(o=!0),s++,r++,(100*r/(s-i)|0)>90)break}}}return{currentIndex:s,badIndex:a,hasSymbol:n,hasNumber:h,hasDigit:o}};static getEmulatedBadCharLen=(e,t,i)=>{if(t===i)return 1;if(t>="a"&&t<="m"){if("a"===t)return"4"!==i&&"@"!==i&&"^"!==i?"/"===i&&"\\"===e?2:0:1;if("b"===t)return"6"!==i&&"8"!==i?"1"===i&&"3"===e?2:0:1;if("c"===t)return"("!==i&&"<"!==i&&"{"!==i&&"["!==i?0:1;if("d"===t)return"["===i&&")"===e?2:0;if("e"===t)return"3"!==i&&"€"!==i?0:1;if("f"===t)return"p"===i&&"h"===e?2:"£"===i?1:0;if("g"===t)return"9"!==i&&"6"!==i?0:1;if("h"===t)return"#"===i?1:0;if("i"===t)return"y"!==i&&"l"!==i&&"j"!==i&&"1"!==i&&"!"!==i&&":"!==i&&";"!==i&&"|"!==i?0:1;if("j"===t)return 0;if("k"===t)return 0;if("l"===t)return"1"!==i&&"|"!==i&&"i"!==i?0:1;if("m"===t)return 0}if(t>="n"&&t<="z"){if("n"===t)return 0;if("o"===t)return"0"!==i&&"*"!==i?"("===i&&")"===e||"["===i&&"]"===e||"{"===i&&"}"===e||"<"===i&&">"===e?2:0:1;if("p"===t)return 0;if("q"===t)return 0;if("r"===t)return 0;if("s"===t)return"5"!==i&&"z"!==i&&"$"!==i&&"2"!==i?0:1;if("t"===t)return"7"!==i&&"+"!==i?0:1;if("u"===t)return"v"===i?1:"\\"===i&&"/"===e||"\\"===i&&"|"===e||"|"===i&&"/"===e?2:0;if("v"===t)return"\\"===i&&"/"===e||"\\"===i&&"|"===e||"|"===i&&"/"===e?2:0;if("w"===t)return"v"===i&&"v"===e?2:0;if("x"===t)return")"===i&&"("===e||"}"===i&&"{"===e||"]"===i&&"["===e||">"===i&&"<"===e?2:0;if("y"===t)return 0;if("z"===t)return 0}return t>="0"&&t<="9"?"0"===t?"o"===i||"O"===i?1:"("===i&&")"===e||"{"===i&&"}"===e||"["===i&&"]"===e?2:0:"1"===t&&"l"===i?1:0:","===t?"."===i?1:0:"."===t?","===i?1:0:"!"===t&&"i"===i?1:0};static comboMatches=(e,t,i)=>{let s=0,a=t.length-1;for(;s<=a;){const r=(s+a)/2|0;if(t[r][0]===e&&t[r][1]===i)return!0;ethis.isLowercaseAlpha(e)?e.charCodeAt(0)+1-"a".charCodeAt(0):"'"===e?28:this.isNumerical(e)?e.charCodeAt(0)+29-"0".charCodeAt(0):27;static filterTld=(e,t,i,s,a)=>{if(!(s.length>i.length))for(let r=0;r<=i.length-s.length;r++){const{currentIndex:n,tldIndex:h}=this.processTlds(i,s,r);if(h0&&c>0&&(o=!0),2===t&&(l>2&&c>0||l>0&&c>2)&&(o=!0),3===t&&l>0&&c>2&&(o=!0),!o)continue;let d,u=r,f=n-1,p=!1;if(l>2){if(4===l)for(p=!1,d=r-1;d>=0;d--)if(p){if("*"!==a[d])break;u=d}else"*"===a[d]&&(u=d,p=!0);for(p=!1,d=u-1;d>=0;d--)if(p){if(this.isSymbol(i[d]))break;u=d}else this.isSymbol(i[d])||(p=!0,u=d)}if(c>2){if(4===c)for(p=!1,d=f+1;d{let s=0;for(;i0)i+=n,s++;else{if(0===s)break;let e;if((e=this.getEmulatedDomainCharLen(r,String.fromCharCode(t[s-1]),a))>0)i+=e;else{if(!this.isSymbol(a))break;i++}}}return{currentIndex:i,tldIndex:s}};static isSymbol=e=>!this.isAlpha(e)&&!this.isNumerical(e);static isNotLowercaseAlpha=e=>!this.isLowercaseAlpha(e)||"v"===e||"x"===e||"j"===e||"q"===e||"z"===e;static isAlpha=e=>this.isLowercaseAlpha(e)||this.isUppercaseAlpha(e);static isNumerical=e=>e>="0"&&e<="9";static isLowercaseAlpha=e=>e>="a"&&e<="z";static isUppercaseAlpha=e=>e>="A"&&e<="Z";static isNumericalChars=e=>{for(let t=0;t{for(let s=e;s{let i=0;for(let s=t-1;s>=0&&this.isSymbol(e[s]);s--)"*"===e[s]&&i++;return i};static maskedCountForwards=(e,t)=>{let i=0;for(let s=t+1;s(a?this.maskedCountBackwards(t,i):this.maskedCountForwards(t,i))>=s?4:this.isSymbol(a?e[i-1]:e[i+1])?1:0;static prefixSymbolStatus=(e,t,i,s,a)=>{if(0===e)return 2;for(let i=e-1;i>=0&&this.isSymbol(t[i]);i--)if(a.includes(t[i]))return 3;return this.maskedCharsStatus(t,s,e,i,!0)};static suffixSymbolStatus=(e,t,i,s,a)=>{if(e+1===t.length)return 2;for(let i=e+1;i{let t=0;for(let i=0;ie>=" "&&e<=""||" "===e||"\n"===e||"\t"===e||"£"===e||"€"===e;static replaceUppercases=(e,t)=>{for(let i=0;i{let t=!0;for(let i=0;i{i.d(t,{Z:()=>s});class s{static TABLE=[" ","e","t","a","o","i","h","n","s","r","d","l","u","m","w","c","y","f","g","p","b","v","k","x","j","q","z","0","1","2","3","4","5","6","7","8","9"," ","!","?",".",",",":",";","(",")","-","&","*","\\","'","@","#","+","=","£","$","%",'"',"[","]"];static charBuffer=[];static unpack=(e,t)=>{let i,s=0,a=-1;for(let r=0;r>4&15,-1!==a?(this.charBuffer[s++]=this.TABLE[(a<<4)+i-195],a=-1):i<13?this.charBuffer[s++]=this.TABLE[i]:a=i,i=15&t,-1!==a?(this.charBuffer[s++]=this.TABLE[(a<<4)+i-195],a=-1):i<13?this.charBuffer[s++]=this.TABLE[i]:a=i}let r=!0;for(let e=0;e="a"&&t<="z"&&(this.charBuffer[e]=t.toUpperCase(),r=!1),"."!==t&&"!"!==t||(r=!0)}return this.charBuffer.slice(0,s).join("")};static pack=(e,t)=>{t.length>80&&(t=t.substring(0,80)),t=t.toLowerCase();let i=-1;for(let s=0;s12&&(r+=195),-1===i?r<13?i=r:e.p1(r):r<13?(e.p1((i<<4)+r),i=-1):(e.p1((i<<4)+(r>>4)),i=15&r)}-1!==i&&e.p1(i<<4)}}},5810:(e,t,i)=>{i.d(t,{Z:()=>a});var s=i(937);class a{static bz2=null;static state=null;static load=async e=>{const t=new WebAssembly.Module(e),i=await(0,s._)(t,{env:void 0});this.bz2=i,this.state=i.newBzip2State()};static read=(e,t,i,s)=>{if(!this.bz2||!this.state)throw new Error("bz2 not found!!");return this.bz2.read(e,t,i,s,this.state)}}},3584:(e,t,i)=>{let s;async function a(e,t){r(t);try{const t=await window.audioContext.decodeAudioData(Uint8Array.from(e).buffer);let i=window.audioContext.createBufferSource();i.buffer=t,i.connect(s),i.start()}catch(e){console.log(e)}}function r(e){s||(s=window.audioContext.createGain(),s.connect(window.audioContext.destination)),s.gain.value=e/256}function n(e,t){window._tinyMidiPlay&&window._tinyMidiPlay(e,t/256)}function h(e){window._tinyMidiVolume&&window._tinyMidiVolume(e/256)}function o(){window._tinyMidiStop&&window._tinyMidiStop()}i.d(t,{Q6:()=>n,mQ:()=>r,nu:()=>h,tb:()=>o,w3:()=>a})},937:(e,t,i)=>{async function s(e,t={}){const i={env:Object.assign(Object.create(globalThis),t.env||{},{abort(e,t,i,s){e=n(e>>>0),t=n(t>>>0),i>>>=0,s>>>=0,(()=>{throw Error(`${e} in ${t}:${i}:${s}`)})()}})},{exports:s}=await WebAssembly.instantiate(e,i),a=s.memory||t.env.memory,r=Object.setPrototypeOf({newBzip2State(){return(e=s.newBzip2State()>>>0)?{stream:l(Int8Array,T(e+0)),decompressed:l(Int8Array,T(e+4)),next_in:w(e+8),avail_in:w(e+12),total_in_lo32:w(e+16),total_in_hi32:w(e+20),next_out:w(e+24),avail_out:w(e+28),total_out_lo32:w(e+32),total_out_hi32:w(e+36),state_out_ch:C(e+40),state_out_len:w(e+44),blockRandomized:0!=C(e+48),bsBuff:w(e+52),bsLive:w(e+56),currBlockNo:w(e+60),origPtr:w(e+64),tPos:w(e+68),k0:w(e+72),c_nblock_used:w(e+76),nInUse:w(e+80),save_nblock:w(e+84),unzftab:d(w,2,T(e+88)),cftab:d(w,2,T(e+92)),cftabCopy:d(w,2,T(e+96)),inUse:d((e=>0!=C(e)),0,T(e+100)),inUse16:d((e=>0!=C(e)),0,T(e+104)),seqToUnseq:d(C,0,T(e+108)),mtfa:d(C,0,T(e+112)),mtfbase:d(w,2,T(e+116)),selector:d(C,0,T(e+120)),selectorMtf:d(C,0,T(e+124)),len:h((e=>d(C,0,T(e))),2,T(e+128)),limit:h((e=>d(w,2,T(e))),2,T(e+132)),base:h((e=>d(w,2,T(e))),2,T(e+136)),perm:h((e=>d(w,2,T(e))),2,T(e+140)),minLens:d(w,2,T(e+144))}:null;var e},read(e,t,i,a,r){t=function(e){if(e){const t=f.get(e);t?f.set(e,t+1):f.set(s.__pin(e),1)}return e}(c(Int8Array,6,0,t)||p()),r=function(e){if(null==e)return 0;const t=s.__pin(s.__new(148,5));return y(t+0,c(Int8Array,6,0,e.stream)||p()),y(t+4,c(Int8Array,6,0,e.decompressed)||p()),y(t+8,e.next_in),y(t+12,e.avail_in),y(t+16,e.total_in_lo32),y(t+20,e.total_in_hi32),y(t+24,e.next_out),y(t+28,e.avail_out),y(t+32,e.total_out_lo32),y(t+36,e.total_out_hi32),g(t+40,e.state_out_ch),y(t+44,e.state_out_len),g(t+48,e.blockRandomized?1:0),y(t+52,e.bsBuff),y(t+56,e.bsLive),y(t+60,e.currBlockNo),y(t+64,e.origPtr),y(t+68,e.tPos),y(t+72,e.k0),y(t+76,e.c_nblock_used),y(t+80,e.nInUse),y(t+84,e.save_nblock),y(t+88,u(y,4,2,e.unzftab,Int32Array)||p()),y(t+92,u(y,4,2,e.cftab,Int32Array)||p()),y(t+96,u(y,4,2,e.cftabCopy,Int32Array)||p()),y(t+100,u(g,7,0,e.inUse,Uint8Array)||p()),y(t+104,u(g,7,0,e.inUse16,Uint8Array)||p()),y(t+108,u(g,8,0,e.seqToUnseq,Uint8Array)||p()),y(t+112,u(g,8,0,e.mtfa,Uint8Array)||p()),y(t+116,u(y,4,2,e.mtfbase,Int32Array)||p()),y(t+120,u(g,8,0,e.selector,Uint8Array)||p()),y(t+124,u(g,8,0,e.selectorMtf,Uint8Array)||p()),y(t+128,o(((e,t)=>{y(e,u(g,8,0,t,Uint8Array)||p())}),9,2,e.len)||p()),y(t+132,o(((e,t)=>{y(e,u(y,4,2,t,Int32Array)||p())}),10,2,e.limit)||p()),y(t+136,o(((e,t)=>{y(e,u(y,4,2,t,Int32Array)||p())}),10,2,e.base)||p()),y(t+140,o(((e,t)=>{y(e,u(y,4,2,t,Int32Array)||p())}),10,2,e.perm)||p()),y(t+144,u(y,4,2,e.minLens,Int32Array)||p()),s.__unpin(t),t}(r)||p();try{return l(Int8Array,s.read(e,t,i,a,r)>>>0)}finally{!function(e){if(e){const t=f.get(e);if(1===t)s.__unpin(e),f.delete(e);else{if(!t)throw Error(`invalid refcount '${t}' for reference '${e}'`);f.set(e,t-1)}}}(t)}}},s);function n(e){if(!e)return null;const t=e+new Uint32Array(a.buffer)[e-4>>>2]>>>1,i=new Uint16Array(a.buffer);let s=e>>>1,r="";for(;t-s>1024;)r+=String.fromCharCode(...i.subarray(s,s+=1024));return r+String.fromCharCode(...i.subarray(s,t))}function h(e,t,i){if(!i)return null;const s=T(i+4),a=m.getUint32(i+12,!0),r=new Array(a);for(let i=0;i>>0));return r}function o(e,t,i,a){if(null==a)return 0;const r=a.length,n=s.__pin(s.__new(r<>>0,h=s.__pin(s.__new(16,t))>>>0;y(h+0,n),m.setUint32(h+4,n,!0),m.setUint32(h+8,r<>>0),a[t]);return s.__unpin(n),s.__unpin(h),h}function l(e,t){return t?new e(a.buffer,T(t+4),m.getUint32(t+8,!0)/e.BYTES_PER_ELEMENT).slice():null}function c(e,t,i,r){if(null==r)return 0;const n=r.length,h=s.__pin(s.__new(n<>>0,o=s.__new(12,t)>>>0;return y(o+0,h),m.setUint32(o+4,h,!0),m.setUint32(o+8,n<>>t,a=new Array(s);for(let r=0;r>>0));return a}function u(e,t,i,r,n){if(null==r)return 0;const h=r.length,o=s.__pin(s.__new(h<>>0;if(n)new n(a.buffer,o,h).set(r);else for(let t=0;t>>0),r[t]);return s.__unpin(o),o}const f=new Map;function p(){throw TypeError("value must not be null")}let m=new DataView(a.buffer);function g(e,t){try{m.setUint8(e,t,!0)}catch{m=new DataView(a.buffer),m.setUint8(e,t,!0)}}function y(e,t){try{m.setUint32(e,t,!0)}catch{m=new DataView(a.buffer),m.setUint32(e,t,!0)}}function C(e){try{return m.getUint8(e,!0)}catch{return m=new DataView(a.buffer),m.getUint8(e,!0)}}function w(e){try{return m.getInt32(e,!0)}catch{return m=new DataView(a.buffer),m.getInt32(e,!0)}}function T(e){try{return m.getUint32(e,!0)}catch{return m=new DataView(a.buffer),m.getUint32(e,!0)}}return r}i.d(t,{_:()=>s})},1527:(e,t,i)=>{var s=i(1928);!function(){window.AudioContext=window.AudioContext||window.webkitAudioContext,window.AudioContext&&(window.audioContext=new window.AudioContext);var e=function(t){if(window.audioContext){var i=window.audioContext.createBuffer(1,1,22050),s=window.audioContext.createBufferSource();s.buffer=i,s.connect(window.audioContext.destination),s.start?s.start(0):s.play?s.play(0):s.noteOn&&s.noteOn(0)}document.removeEventListener("touchstart",e),document.removeEventListener("touchend",e),document.removeEventListener("click",e)};document.addEventListener("touchstart",e),document.addEventListener("touchend",e),document.addEventListener("click",e)}(),(async()=>{let e=new Float32Array,t=window.audioContext.createGain();t.gain.value=.1,t.connect(window.audioContext.destination);let i=window.audioContext.currentTime,a=[];const r=new s.Z({renderInterval:30,onPCMData:t=>{let i=new Float32Array(t.buffer),s=new Float32Array(e.length+i.length);s.set(e,0),s.set(i,e.length),e=s},onRenderEnd:e=>{},bufferSize:102400});await r.init();const n=await fetch("./SCC1_Florestan.sf2"),h=new Uint8Array(await n.arrayBuffer());function o(){if(!window.audioContext||!e.length)return;let s=window.audioContext.createBufferSource();const r=e.length/2,n=window.audioContext.createBuffer(2,r,44100);for(let t=0;t<2;t++){const i=n.getChannelData(t);let s=t;for(let t=0;t{if(l&&clearInterval(l),e=new Float32Array,a.length){let e=t.gain.value;t.gain.value=0,a.forEach((e=>{e.stop(window.audioContext.currentTime)})),a=[],t.gain.value=e}},window._tinyMidiVolume=(e=1)=>{t.gain.value=e},window._tinyMidiPlay=async(e,t=1)=>{e&&(await window._tinyMidiStop(),-1!=t&&window._tinyMidiVolume(t),i=window.audioContext.currentTime,l=setInterval(o,250),r.render(e))}})()},1928:(e,t,i)=>{i.d(t,{Z:()=>a});var s=i(1885);const a=class{constructor(e={}){this.wasmModule=void 0,this.soundfontBufferPtr=0,this.soundfontPtr=0,this.midiBufferPtr=0,this.renderInterval=e.renderInterval||100,this.sampleRate=e.sampleRate||44100,this.channels=e.channels||2,this.gain=e.gain||0,e.bufferSize?this.bufferSize=e.bufferSize:this.setBufferDuration(1),this.onPCMData=e.onPCMData||(()=>{}),this.onRenderEnd=e.onRenderEnd||(()=>{}),this.renderTimer=void 0,this.test=0}async init(){if(!this.wasmModule){if("undefined"!=typeof process){const{dirname:e}=await import("path"),{createRequire:t}=await import("module");globalThis.__dirname=e("file:///home/runner/work/Client2/Client2/src/js/vendor/tinymidipcm/index.js"),globalThis.require=t("file:///home/runner/work/Client2/Client2/src/js/vendor/tinymidipcm/index.js")}this.wasmModule=await(0,s.Z)(),this.pcmBufferPtr=this.wasmModule._malloc(this.bufferSize),this.msecsPtr=this.wasmModule._malloc(8)}}setBufferDuration(e){this.bufferSize=4*this.sampleRate*this.channels*e}ensureInitialized(){if(!this.wasmModule)throw new Error(`${this.constructor.name} not initalized. call .init()`)}setSoundfont(e){this.ensureInitialized();const{_malloc:t,_free:i,_tsf_load_memory:s,_tsf_set_output:a,_tsf_channel_set_bank_preset:r,_tsf_set_max_voices:n,_tsf_channel_set_presetnumber:h}=this.wasmModule;i(this.soundfontBufferPtr),this.soundfontBufferPtr=t(e.length),this.wasmModule.HEAPU8.set(e,this.soundfontBufferPtr),this.soundfontPtr=s(this.soundfontBufferPtr,e.length),a(this.soundfontPtr,2===this.channels?0:2,this.sampleRate,this.gain)}getPCMBuffer(){this.ensureInitialized();const e=new Uint8Array(this.bufferSize);return e.set(this.wasmModule.HEAPU8.subarray(this.pcmBufferPtr,this.pcmBufferPtr+this.bufferSize)),e}getMIDIMessagePtr(e){const{_malloc:t,_free:i,_tml_load_memory:s}=this.wasmModule;return i(this.midiBufferPtr),this.midiBufferPtr=t(e.length),this.wasmModule.HEAPU8.set(e,this.midiBufferPtr),s(this.midiBufferPtr,e.length)}renderMIDIMessage(e){const{_midi_render:t}=this.wasmModule;return t(this.soundfontPtr,e,this.channels,this.sampleRate,this.pcmBufferPtr,this.bufferSize,this.msecsPtr)}render(e){if(this.ensureInitialized(),!this.soundfontPtr)throw new Error("no soundfont buffer set. call .setSoundfont");window.clearTimeout(this.renderTimer);const{setValue:t,getValue:i}=this.wasmModule;t(this.msecsPtr,0,"double"),this.wasmModule._tsf_reset(this.soundfontPtr),this.wasmModule._tsf_channel_set_bank_preset(this.soundfontPtr,9,128,0),e[0]==="R".charCodeAt(0)&&(e=e.slice(20));let s=this.getMIDIMessagePtr(e);const a=()=>{s=this.renderMIDIMessage(s);const e=this.getPCMBuffer();this.onPCMData(e),s?this.renderTimer=setTimeout(a,this.renderInterval):this.onRenderEnd(i(this.msecsPtr,"double"))};this.renderTimer=setTimeout(a,16)}}},5621:(e,t,i)=>{e.exports=i.p+"9f86b5397894e28b5ae2.wasm"},1885:(e,t,i)=>{var s;i.d(t,{Z:()=>a});const a=(s="file:///home/runner/work/Client2/Client2/src/js/vendor/tinymidipcm/tinymidipcm.mjs",function(e){var t,a,r=void 0!==(e=e||{})?e:{};r.ready=new Promise((function(e,i){t=e,a=i})),["_tsf_load_memory","_tsf_set_output","_tsf_channel_set_bank_preset","_tsf_set_max_voices","_tsf_channel_set_presetnumber","_tsf_reset","_tsf_close","_tml_load_memory","_midi_render","_malloc","_realloc","_free","_fflush","onRuntimeInitialized"].forEach((e=>{Object.getOwnPropertyDescriptor(r.ready,e)||Object.defineProperty(r.ready,e,{get:()=>V("You are getting "+e+" on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js"),set:()=>V("You are setting "+e+" on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")})}));var n=Object.assign({},r),h=[],o="object"==typeof window,l="function"==typeof importScripts,c="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,d=!o&&!c&&!l;if(r.ENVIRONMENT)throw new Error("Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)");var u,f,p,m="";if(c){if("undefined"==typeof process||!process.release||"node"!==process.release.name)throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");var g,y;m=l?require("path").dirname(m)+"/":__dirname+"/";var C=()=>{y||(g=require("fs"),y=require("path"))};u=(e,t)=>(C(),e=y.normalize(e),g.readFileSync(e,t?void 0:"utf8")),p=e=>{var t=u(e,!0);return t.buffer||(t=new Uint8Array(t)),P(t.buffer),t},f=(e,t,i)=>{C(),e=y.normalize(e),g.readFile(e,(function(e,s){e?i(e):t(s.buffer)}))},process.argv.length>1&&process.argv[1].replace(/\\/g,"/"),h=process.argv.slice(2),process.on("uncaughtException",(function(e){if(!(e instanceof se))throw e})),process.on("unhandledRejection",(function(e){throw e})),r.inspect=function(){return"[Emscripten Module object]"}}else if(d){if("object"==typeof process&&"function"==typeof require||"object"==typeof window||"function"==typeof importScripts)throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");"undefined"!=typeof read&&(u=function(e){return read(e)}),p=function(e){let t;return"function"==typeof readbuffer?new Uint8Array(readbuffer(e)):(t=read(e,"binary"),P("object"==typeof t),t)},f=function(e,t,i){setTimeout((()=>t(p(e))),0)},"undefined"!=typeof scriptArgs?h=scriptArgs:void 0!==arguments&&(h=arguments),"undefined"!=typeof print&&("undefined"==typeof console&&(console={}),console.log=print,console.warn=console.error="undefined"!=typeof printErr?printErr:print)}else{if(!o&&!l)throw new Error("environment detection error");if(l?m=self.location.href:"undefined"!=typeof document&&document.currentScript&&(m=document.currentScript.src),s&&(m=s),m=0!==m.indexOf("blob:")?m.substr(0,m.replace(/[?#].*/,"").lastIndexOf("/")+1):"","object"!=typeof window&&"function"!=typeof importScripts)throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");u=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},l&&(p=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),f=(e,t,i)=>{var s=new XMLHttpRequest;s.open("GET",e,!0),s.responseType="arraybuffer",s.onload=()=>{200==s.status||0==s.status&&s.response?t(s.response):i()},s.onerror=i,s.send(null)}}r.print||console.log.bind(console);var w,T,S,Z=r.printErr||console.warn.bind(console);function A(e,t){Object.getOwnPropertyDescriptor(r,e)||Object.defineProperty(r,e,{configurable:!0,get:function(){V("Module."+e+" has been replaced with plain "+t+" (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)")}})}function v(e){return"FS_createPath"===e||"FS_createDataFile"===e||"FS_createPreloadedFile"===e||"FS_unlink"===e||"addRunDependency"===e||"FS_createLazyFile"===e||"FS_createDevice"===e||"removeRunDependency"===e}Object.assign(r,n),n=null,w="fetchSettings",Object.getOwnPropertyDescriptor(r,w)&&V("`Module."+w+"` was supplied but `"+w+"` not included in INCOMING_MODULE_JS_API"),r.arguments&&(h=r.arguments),A("arguments","arguments_"),r.thisProgram&&r.thisProgram,A("thisProgram","thisProgram"),r.quit&&r.quit,A("quit","quit_"),P(void 0===r.memoryInitializerPrefixURL,"Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead"),P(void 0===r.pthreadMainPrefixURL,"Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead"),P(void 0===r.cdInitializerPrefixURL,"Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead"),P(void 0===r.filePackagePrefixURL,"Module.filePackagePrefixURL option was removed, use Module.locateFile instead"),P(void 0===r.read,"Module.read option was removed (modify read_ in JS)"),P(void 0===r.readAsync,"Module.readAsync option was removed (modify readAsync in JS)"),P(void 0===r.readBinary,"Module.readBinary option was removed (modify readBinary in JS)"),P(void 0===r.setWindowTitle,"Module.setWindowTitle option was removed (modify setWindowTitle in JS)"),P(void 0===r.TOTAL_MEMORY,"Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY"),A("read","read_"),A("readAsync","readAsync"),A("readBinary","readBinary"),A("setWindowTitle","setWindowTitle"),P(!d,"shell environment detected but not enabled at build time. Add 'shell' to `-sENVIRONMENT` to enable."),r.wasmBinary&&(T=r.wasmBinary),A("wasmBinary","wasmBinary"),r.noExitRuntime,A("noExitRuntime","noExitRuntime"),"object"!=typeof WebAssembly&&V("no native wasm support detected");var I,O,b,L,E,x,_,k,R=!1;function P(e,t){e||V("Assertion failed"+(t?": "+t:""))}function M(e){I=e,r.HEAP8=O=new Int8Array(e),r.HEAP16=L=new Int16Array(e),r.HEAP32=E=new Int32Array(e),r.HEAPU8=b=new Uint8Array(e),r.HEAPU16=new Uint16Array(e),r.HEAPU32=x=new Uint32Array(e),r.HEAPF32=_=new Float32Array(e),r.HEAPF64=k=new Float64Array(e)}"undefined"!=typeof TextDecoder&&new TextDecoder("utf8");var N=5242880;r.TOTAL_STACK&&P(N===r.TOTAL_STACK,"the stack size can no longer be determined at runtime");var B=r.INITIAL_MEMORY||16777216;function D(){if(!R){var e=ce(),t=x[e>>2],i=x[e+4>>2];34821223==t&&2310721022==i||V("Stack overflow! Stack cookie has been overwritten at 0x"+e.toString(16)+", expected hex dwords 0x89BACDFE and 0x2135467, but received 0x"+i.toString(16)+" 0x"+t.toString(16)),1668509029!==x[0]&&V("Runtime error: The application has corrupted its heap memory area (address zero)!")}}A("INITIAL_MEMORY","INITIAL_MEMORY"),P(B>=N,"INITIAL_MEMORY should be larger than TOTAL_STACK, was "+B+"! (TOTAL_STACK="+N+")"),P("undefined"!=typeof Int32Array&&"undefined"!=typeof Float64Array&&null!=Int32Array.prototype.subarray&&null!=Int32Array.prototype.set,"JS engine does not provide full typed array support"),P(!r.wasmMemory,"Use of `wasmMemory` detected. Use -sIMPORTED_MEMORY to define wasmMemory externally"),P(16777216==B,"Detected runtime INITIAL_MEMORY setting. Use -sIMPORTED_MEMORY to define wasmMemory dynamically"),function(){var e=new Int16Array(1),t=new Int8Array(e.buffer);if(e[0]=25459,115!==t[0]||99!==t[1])throw"Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)"}();var Y=[],X=[],F=[],H=!1;P(Math.imul,"This browser does not support Math.imul(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),P(Math.fround,"This browser does not support Math.fround(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),P(Math.clz32,"This browser does not support Math.clz32(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),P(Math.trunc,"This browser does not support Math.trunc(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill");var W=0,z=null,U=null,G={};function V(e){r.onAbort&&r.onAbort(e),Z(e="Aborted("+e+")"),R=!0;var t=new WebAssembly.RuntimeError(e);throw a(t),t}var j={error:function(){V("Filesystem support (FS) was not included. The problem is that you are using files from JS, but files were not used from C/C++, so filesystem support was not auto-included. You can force-include filesystem support with -sFORCE_FILESYSTEM")},init:function(){j.error()},createDataFile:function(){j.error()},createPreloadedFile:function(){j.error()},createLazyFile:function(){j.error()},open:function(){j.error()},mkdev:function(){j.error()},registerDevice:function(){j.error()},analyzePath:function(){j.error()},loadFilesFromDB:function(){j.error()},ErrnoError:function(){j.error()}};r.FS_createDataFile=j.createDataFile,r.FS_createPreloadedFile=j.createPreloadedFile;var q,K,J,Q;function $(e){return e.startsWith("data:application/octet-stream;base64,")}function ee(e){return e.startsWith("file://")}function te(e,t){return function(){var i=e,s=t;return t||(s=r.asm),P(H,"native function `"+i+"` called before runtime initialization"),s[e]||P(s[e],"exported native function `"+i+"` not found"),s[e].apply(null,arguments)}}function ie(e){try{if(e==q&&T)return new Uint8Array(T);if(p)return p(e);throw"both async and sync fetching of the wasm failed"}catch(e){V(e)}}function se(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}function ae(e){for(;e.length>0;)e.shift()(r)}function re(e){re.shown||(re.shown={}),re.shown[e]||(re.shown[e]=1,c&&(e="warning: "+e),Z(e))}function ne(e){try{return S.grow(e-I.byteLength+65535>>>16),M(S.buffer),1}catch(t){Z("emscripten_realloc_buffer: Attempted to grow heap from "+I.byteLength+" bytes to "+e+" bytes, but got error: "+t)}}r.locateFile?$(q="tinymidipcm.wasm")||(K=q,q=r.locateFile?r.locateFile(K,m):m+K):q=new URL(i(5621),i.b).toString();var he,oe={emscripten_memcpy_big:function(e,t,i){b.copyWithin(e,t,t+i)},emscripten_resize_heap:function(e){var t=b.length;P((e>>>=0)>t);var i,s=2147483648;if(e>s)return Z("Cannot enlarge memory, asked to go up to "+e+" bytes, but the limit is "+s+" bytes!"),!1;for(var a=1;a<=4;a*=2){var r=t*(1+.2/a);r=Math.min(r,e+100663296);var n=Math.min(s,(i=Math.max(e,r))+(65536-i%65536)%65536);if(ne(n))return!0}return Z("Failed to grow the heap from "+t+" bytes to "+n+" bytes, not enough memory!"),!1}},le=(function(){var e,t={env:oe,wasi_snapshot_preview1:oe};function i(e,t){var i,s=e.exports;r.asm=s,P(S=r.asm.memory,"memory not found in wasm exports"),M(S.buffer),P(r.asm.__indirect_function_table,"table not found in wasm exports"),i=r.asm.__wasm_call_ctors,X.unshift(i),function(e){if(W--,r.monitorRunDependencies&&r.monitorRunDependencies(W),e?(P(G[e]),delete G[e]):Z("warning: run dependency removed without ID"),0==W&&(null!==z&&(clearInterval(z),z=null),U)){var t=U;U=null,t()}}("wasm-instantiate")}e="wasm-instantiate",W++,r.monitorRunDependencies&&r.monitorRunDependencies(W),e?(P(!G[e]),G[e]=1,null===z&&"undefined"!=typeof setInterval&&(z=setInterval((function(){if(R)return clearInterval(z),void(z=null);var e=!1;for(var t in G)e||(e=!0,Z("still waiting on run dependencies:")),Z("dependency: "+t);e&&Z("(end of list)")}),1e4))):Z("warning: run dependency added without ID");var s=r;function n(e){P(r===s,"the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?"),s=null,i(e.instance)}function h(e){return function(){if(!T&&(o||l)){if("function"==typeof fetch&&!ee(q))return fetch(q,{credentials:"same-origin"}).then((function(e){if(!e.ok)throw"failed to load wasm binary file at '"+q+"'";return e.arrayBuffer()})).catch((function(){return ie(q)}));if(f)return new Promise((function(e,t){f(q,(function(t){e(new Uint8Array(t))}),t)}))}return Promise.resolve().then((function(){return ie(q)}))}().then((function(e){return WebAssembly.instantiate(e,t)})).then((function(e){return e})).then(e,(function(e){Z("failed to asynchronously prepare wasm: "+e),ee(q)&&Z("warning: Loading from a file URI ("+q+") is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing"),V(e)}))}if(r.instantiateWasm)try{return r.instantiateWasm(t,i)}catch(e){Z("Module.instantiateWasm callback failed with error: "+e),a(e)}(T||"function"!=typeof WebAssembly.instantiateStreaming||$(q)||ee(q)||c||"function"!=typeof fetch?h(n):fetch(q,{credentials:"same-origin"}).then((function(e){return WebAssembly.instantiateStreaming(e,t).then(n,(function(e){return Z("wasm streaming compile failed: "+e),Z("falling back to ArrayBuffer instantiation"),h(n)}))}))).catch(a)}(),r.___wasm_call_ctors=te("__wasm_call_ctors"),r._malloc=te("malloc"),r._free=te("free"),r._tsf_load_memory=te("tsf_load_memory"),r._tsf_close=te("tsf_close"),r._tsf_reset=te("tsf_reset"),r._tsf_set_output=te("tsf_set_output"),r._tsf_set_max_voices=te("tsf_set_max_voices"),r._realloc=te("realloc"),r._tsf_channel_set_presetnumber=te("tsf_channel_set_presetnumber"),r._tsf_channel_set_bank_preset=te("tsf_channel_set_bank_preset"),r._tml_load_memory=te("tml_load_memory"),r._midi_render=te("midi_render"),r.___errno_location=te("__errno_location"),r._fflush=te("fflush"),r._emscripten_stack_init=function(){return(le=r._emscripten_stack_init=r.asm.emscripten_stack_init).apply(null,arguments)}),ce=(r._emscripten_stack_get_free=function(){return(r._emscripten_stack_get_free=r.asm.emscripten_stack_get_free).apply(null,arguments)},r._emscripten_stack_get_base=function(){return(r._emscripten_stack_get_base=r.asm.emscripten_stack_get_base).apply(null,arguments)},r._emscripten_stack_get_end=function(){return(ce=r._emscripten_stack_get_end=r.asm.emscripten_stack_get_end).apply(null,arguments)});function de(e){function i(){he||(he=!0,r.calledRun=!0,R||(P(!H),H=!0,D(),ae(X),t(r),r.onRuntimeInitialized&&r.onRuntimeInitialized(),P(!r._main,'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]'),function(){if(D(),r.postRun)for("function"==typeof r.postRun&&(r.postRun=[r.postRun]);r.postRun.length;)e=r.postRun.shift(),F.unshift(e);var e;ae(F)}()))}var s;e=e||h,W>0||(le(),P(0==(3&(s=ce()))),x[s>>2]=34821223,x[s+4>>2]=2310721022,x[0]=1668509029,function(){if(r.preRun)for("function"==typeof r.preRun&&(r.preRun=[r.preRun]);r.preRun.length;)e=r.preRun.shift(),Y.unshift(e);var e;ae(Y)}(),W>0||(r.setStatus?(r.setStatus("Running..."),setTimeout((function(){setTimeout((function(){r.setStatus("")}),1),i()}),1)):i(),D()))}if(r.stackSave=te("stackSave"),r.stackRestore=te("stackRestore"),r.stackAlloc=te("stackAlloc"),r.setValue=function(e,t,i="i8"){switch(i.endsWith("*")&&(i="*"),i){case"i1":case"i8":O[e>>0]=t;break;case"i16":L[e>>1]=t;break;case"i32":E[e>>2]=t;break;case"i64":Q=[t>>>0,(J=t,+Math.abs(J)>=1?J>0?(0|Math.min(+Math.floor(J/4294967296),4294967295))>>>0:~~+Math.ceil((J-+(~~J>>>0))/4294967296)>>>0:0)],E[e>>2]=Q[0],E[e+4>>2]=Q[1];break;case"float":_[e>>2]=t;break;case"double":k[e>>3]=t;break;case"*":x[e>>2]=t;break;default:V("invalid type for setValue: "+i)}},r.getValue=function(e,t="i8"){switch(t.endsWith("*")&&(t="*"),t){case"i1":case"i8":return O[e>>0];case"i16":return L[e>>1];case"i32":case"i64":return E[e>>2];case"float":return _[e>>2];case"double":return k[e>>3];case"*":return x[e>>2];default:V("invalid type for getValue: "+t)}return null},["run","UTF8ArrayToString","UTF8ToString","stringToUTF8Array","stringToUTF8","lengthBytesUTF8","addOnPreRun","addOnInit","addOnPreMain","addOnExit","addOnPostRun","addRunDependency","removeRunDependency","FS_createFolder","FS_createPath","FS_createDataFile","FS_createPreloadedFile","FS_createLazyFile","FS_createLink","FS_createDevice","FS_unlink","getLEB","getFunctionTables","alignFunctionTables","registerFunctions","prettyPrint","getCompilerSetting","print","printErr","callMain","abort","keepRuntimeAlive","wasmMemory","stackAlloc","stackSave","stackRestore","getTempRet0","setTempRet0","writeStackCookie","checkStackCookie","ptrToString","zeroMemory","stringToNewUTF8","exitJS","getHeapMax","emscripten_realloc_buffer","ENV","ERRNO_CODES","ERRNO_MESSAGES","setErrNo","inetPton4","inetNtop4","inetPton6","inetNtop6","readSockaddr","writeSockaddr","DNS","getHostByName","Protocols","Sockets","getRandomDevice","warnOnce","traverseStack","UNWIND_CACHE","convertPCtoSourceLocation","readAsmConstArgsArray","readAsmConstArgs","mainThreadEM_ASM","jstoi_q","jstoi_s","getExecutableName","listenOnce","autoResumeAudioContext","dynCallLegacy","getDynCaller","dynCall","handleException","runtimeKeepalivePush","runtimeKeepalivePop","callUserCallback","maybeExit","safeSetTimeout","asmjsMangle","asyncLoad","alignMemory","mmapAlloc","writeI53ToI64","writeI53ToI64Clamped","writeI53ToI64Signaling","writeI53ToU64Clamped","writeI53ToU64Signaling","readI53FromI64","readI53FromU64","convertI32PairToI53","convertI32PairToI53Checked","convertU32PairToI53","getCFunc","ccall","cwrap","uleb128Encode","sigToWasmTypes","generateFuncType","convertJsFunctionToWasm","freeTableIndexes","functionsInTableMap","getEmptyTableSlot","updateTableMap","addFunction","removeFunction","reallyNegative","unSign","strLen","reSign","formatString","PATH","PATH_FS","intArrayFromString","intArrayToString","AsciiToString","stringToAscii","UTF16Decoder","UTF16ToString","stringToUTF16","lengthBytesUTF16","UTF32ToString","stringToUTF32","lengthBytesUTF32","allocateUTF8","allocateUTF8OnStack","writeStringToMemory","writeArrayToMemory","writeAsciiToMemory","SYSCALLS","getSocketFromFD","getSocketAddress","JSEvents","registerKeyEventCallback","specialHTMLTargets","maybeCStringToJsString","findEventTarget","findCanvasEventTarget","getBoundingClientRect","fillMouseEventData","registerMouseEventCallback","registerWheelEventCallback","registerUiEventCallback","registerFocusEventCallback","fillDeviceOrientationEventData","registerDeviceOrientationEventCallback","fillDeviceMotionEventData","registerDeviceMotionEventCallback","screenOrientation","fillOrientationChangeEventData","registerOrientationChangeEventCallback","fillFullscreenChangeEventData","registerFullscreenChangeEventCallback","JSEvents_requestFullscreen","JSEvents_resizeCanvasForFullscreen","registerRestoreOldStyle","hideEverythingExceptGivenElement","restoreHiddenElements","setLetterbox","currentFullscreenStrategy","restoreOldWindowedStyle","softFullscreenResizeWebGLRenderTarget","doRequestFullscreen","fillPointerlockChangeEventData","registerPointerlockChangeEventCallback","registerPointerlockErrorEventCallback","requestPointerLock","fillVisibilityChangeEventData","registerVisibilityChangeEventCallback","registerTouchEventCallback","fillGamepadEventData","registerGamepadEventCallback","registerBeforeUnloadEventCallback","fillBatteryEventData","battery","registerBatteryEventCallback","setCanvasElementSize","getCanvasElementSize","demangle","demangleAll","jsStackTrace","stackTrace","ExitStatus","getEnvStrings","checkWasiClock","flush_NO_FILESYSTEM","dlopenMissingError","createDyncallWrapper","setImmediateWrapped","clearImmediateWrapped","polyfillSetImmediate","uncaughtExceptionCount","exceptionLast","exceptionCaught","ExceptionInfo","exception_addRef","exception_decRef","Browser","setMainLoop","wget","FS","MEMFS","TTY","PIPEFS","SOCKFS","_setNetworkCallback","tempFixedLengthArray","miniTempWebGLFloatBuffers","heapObjectForWebGLType","heapAccessShiftForWebGLHeap","GL","emscriptenWebGLGet","computeUnpackAlignedImageSize","emscriptenWebGLGetTexPixelData","emscriptenWebGLGetUniform","webglGetUniformLocation","webglPrepareUniformLocationsBeforeFirstUse","webglGetLeftBracePos","emscriptenWebGLGetVertexAttrib","writeGLArray","AL","SDL_unicode","SDL_ttfContext","SDL_audio","SDL","SDL_gfx","GLUT","EGL","GLFW_Window","GLFW","GLEW","IDBStore","runAndAbortIfError","ALLOC_NORMAL","ALLOC_STACK","allocate"].forEach((function(e){Object.getOwnPropertyDescriptor(r,e)||Object.defineProperty(r,e,{configurable:!0,get:function(){var t="'"+e+"' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)";v(e)&&(t+=". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you"),V(t)}})})),["ptrToString","zeroMemory","stringToNewUTF8","exitJS","setErrNo","inetPton4","inetNtop4","inetPton6","inetNtop6","readSockaddr","writeSockaddr","getHostByName","getRandomDevice","traverseStack","convertPCtoSourceLocation","readAsmConstArgs","mainThreadEM_ASM","jstoi_q","jstoi_s","getExecutableName","listenOnce","autoResumeAudioContext","dynCallLegacy","getDynCaller","dynCall","runtimeKeepalivePush","runtimeKeepalivePop","callUserCallback","maybeExit","safeSetTimeout","asmjsMangle","asyncLoad","alignMemory","mmapAlloc","writeI53ToI64","writeI53ToI64Clamped","writeI53ToI64Signaling","writeI53ToU64Clamped","writeI53ToU64Signaling","readI53FromI64","readI53FromU64","convertI32PairToI53","convertI32PairToI53Checked","convertU32PairToI53","getCFunc","ccall","cwrap","uleb128Encode","sigToWasmTypes","generateFuncType","convertJsFunctionToWasm","getEmptyTableSlot","updateTableMap","addFunction","removeFunction","reallyNegative","unSign","strLen","reSign","formatString","intArrayFromString","intArrayToString","AsciiToString","stringToAscii","UTF16ToString","stringToUTF16","lengthBytesUTF16","UTF32ToString","stringToUTF32","lengthBytesUTF32","allocateUTF8","allocateUTF8OnStack","writeStringToMemory","writeAsciiToMemory","getSocketFromFD","getSocketAddress","registerKeyEventCallback","maybeCStringToJsString","findEventTarget","findCanvasEventTarget","getBoundingClientRect","fillMouseEventData","registerMouseEventCallback","registerWheelEventCallback","registerUiEventCallback","registerFocusEventCallback","fillDeviceOrientationEventData","registerDeviceOrientationEventCallback","fillDeviceMotionEventData","registerDeviceMotionEventCallback","screenOrientation","fillOrientationChangeEventData","registerOrientationChangeEventCallback","fillFullscreenChangeEventData","registerFullscreenChangeEventCallback","JSEvents_requestFullscreen","JSEvents_resizeCanvasForFullscreen","registerRestoreOldStyle","hideEverythingExceptGivenElement","restoreHiddenElements","setLetterbox","softFullscreenResizeWebGLRenderTarget","doRequestFullscreen","fillPointerlockChangeEventData","registerPointerlockChangeEventCallback","registerPointerlockErrorEventCallback","requestPointerLock","fillVisibilityChangeEventData","registerVisibilityChangeEventCallback","registerTouchEventCallback","fillGamepadEventData","registerGamepadEventCallback","registerBeforeUnloadEventCallback","fillBatteryEventData","battery","registerBatteryEventCallback","setCanvasElementSize","getCanvasElementSize","getEnvStrings","checkWasiClock","flush_NO_FILESYSTEM","createDyncallWrapper","setImmediateWrapped","clearImmediateWrapped","polyfillSetImmediate","ExceptionInfo","exception_addRef","exception_decRef","setMainLoop","_setNetworkCallback","heapObjectForWebGLType","heapAccessShiftForWebGLHeap","emscriptenWebGLGet","computeUnpackAlignedImageSize","emscriptenWebGLGetTexPixelData","emscriptenWebGLGetUniform","webglGetUniformLocation","webglPrepareUniformLocationsBeforeFirstUse","webglGetLeftBracePos","emscriptenWebGLGetVertexAttrib","writeGLArray","SDL_unicode","SDL_ttfContext","SDL_audio","GLFW_Window","runAndAbortIfError","ALLOC_NORMAL","ALLOC_STACK","allocate"].forEach((function(e){"undefined"==typeof globalThis||Object.getOwnPropertyDescriptor(globalThis,e)||Object.defineProperty(globalThis,e,{configurable:!0,get:function(){var t="`"+e+"` is a library symbol and not included by default; add it to your library.js __deps or to DEFAULT_LIBRARY_FUNCS_TO_INCLUDE on the command line";v(e)&&(t+=". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you"),re(t)}})})),U=function e(){he||de(),he||(U=e)},r.preInit)for("function"==typeof r.preInit&&(r.preInit=[r.preInit]);r.preInit.length>0;)r.preInit.pop()();return de(),e.ready})}},r={};function n(e){var t=r[e];if(void 0!==t)return t.exports;var i=r[e]={exports:{}};return a[e](i,i.exports,n),i.exports}n.m=a,e="function"==typeof Symbol?Symbol("webpack queues"):"__webpack_queues__",t="function"==typeof Symbol?Symbol("webpack exports"):"__webpack_exports__",i="function"==typeof Symbol?Symbol("webpack error"):"__webpack_error__",s=e=>{e&&e.d<1&&(e.d=1,e.forEach((e=>e.r--)),e.forEach((e=>e.r--?e.r++:e())))},n.a=(a,r,n)=>{var h;n&&((h=[]).d=-1);var o,l,c,d=new Set,u=a.exports,f=new Promise(((e,t)=>{c=t,l=e}));f[t]=u,f[e]=e=>(h&&e(h),d.forEach(e),f.catch((e=>{}))),a.exports=f,r((a=>{var r;o=(a=>a.map((a=>{if(null!==a&&"object"==typeof a){if(a[e])return a;if(a.then){var r=[];r.d=0,a.then((e=>{n[t]=e,s(r)}),(e=>{n[i]=e,s(r)}));var n={};return n[e]=e=>e(r),n}}var h={};return h[e]=e=>{},h[t]=a,h})))(a);var n=()=>o.map((e=>{if(e[i])throw e[i];return e[t]})),l=new Promise((t=>{(r=()=>t(n)).r=0;var i=e=>e!==h&&!d.has(e)&&(d.add(e),e&&!e.d&&(r.r++,e.push(r)));o.map((t=>t[e](i)))}));return r.r?l:n()}),(e=>(e?c(f[i]=e):l(u),s(h)))),h&&h.d<0&&(h.d=0)},n.d=(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.p="/Client2/",n.b=document.baseURI||self.location.href,n(1979)})(); \ No newline at end of file