quake2ts 0.0.291 → 0.0.292
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/packages/client/dist/browser/index.global.js +3 -3
- package/packages/client/dist/browser/index.global.js.map +1 -1
- package/packages/client/dist/cjs/index.cjs +2 -0
- package/packages/client/dist/cjs/index.cjs.map +1 -1
- package/packages/client/dist/esm/index.js +2 -0
- package/packages/client/dist/esm/index.js.map +1 -1
- package/packages/client/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/engine/dist/browser/index.global.js +1 -1
- package/packages/engine/dist/browser/index.global.js.map +1 -1
- package/packages/engine/dist/cjs/index.cjs +1 -0
- package/packages/engine/dist/cjs/index.cjs.map +1 -1
- package/packages/engine/dist/esm/index.js +1 -0
- package/packages/engine/dist/esm/index.js.map +1 -1
- package/packages/engine/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/game/dist/browser/index.global.js +4 -3
- package/packages/game/dist/browser/index.global.js.map +1 -1
- package/packages/game/dist/cjs/index.cjs +116 -4
- package/packages/game/dist/cjs/index.cjs.map +1 -1
- package/packages/game/dist/esm/index.js +116 -4
- package/packages/game/dist/esm/index.js.map +1 -1
- package/packages/game/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/game/dist/types/entities/entity.d.ts +1 -0
- package/packages/game/dist/types/entities/entity.d.ts.map +1 -1
- package/packages/game/dist/types/entities/system.d.ts +7 -0
- package/packages/game/dist/types/entities/system.d.ts.map +1 -1
- package/packages/game/dist/types/entities/targets.d.ts.map +1 -1
- package/packages/game/dist/types/imports.d.ts +1 -0
- package/packages/game/dist/types/imports.d.ts.map +1 -1
- package/packages/game/dist/types/index.d.ts +2 -0
- package/packages/game/dist/types/index.d.ts.map +1 -1
- package/packages/game/dist/types/save/rerelease.d.ts.map +1 -1
- package/packages/game/dist/types/save/save.d.ts.map +1 -1
- package/packages/server/dist/index.cjs +4 -1
- package/packages/server/dist/index.js +4 -1
- package/packages/shared/dist/browser/index.global.js +1 -1
- package/packages/shared/dist/browser/index.global.js.map +1 -1
- package/packages/shared/dist/cjs/index.cjs +1 -0
- package/packages/shared/dist/cjs/index.cjs.map +1 -1
- package/packages/shared/dist/esm/index.js +1 -0
- package/packages/shared/dist/esm/index.js.map +1 -1
- package/packages/shared/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/shared/dist/types/protocol/configstrings.d.ts +1 -0
- package/packages/shared/dist/types/protocol/configstrings.d.ts.map +1 -1
- package/packages/tools/dist/tsconfig.tsbuildinfo +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Quake2Engine=(()=>{var Gu=Object.create;var bo=Object.defineProperty;var Wu=Object.getOwnPropertyDescriptor;var Xu=Object.getOwnPropertyNames;var Ku=Object.getPrototypeOf,$u=Object.prototype.hasOwnProperty;var Zu=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),pa=(e,t)=>{for(var r in t)bo(e,r,{get:t[r],enumerable:!0})},Mc=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Xu(t))!$u.call(e,i)&&i!==r&&bo(e,i,{get:()=>t[i],enumerable:!(n=Wu(t,i))||n.enumerable});return e};var Yu=(e,t,r)=>(r=e!=null?Gu(Ku(e)):{},Mc(t||!e||!e.__esModule?bo(r,"default",{value:e,enumerable:!0}):r,e)),qu=e=>Mc(bo({},"__esModule",{value:!0}),e);var ad=Zu((G_,sd)=>{"use strict";sd.exports=Worker});var gx={};pa(gx,{ATTN_IDLE:()=>Ra,ATTN_LOOP_NONE:()=>Ta,ATTN_NONE:()=>Bn,ATTN_NORM:()=>Ia,ATTN_STATIC:()=>Lo,AssetDependencyError:()=>Er,AssetDependencyTracker:()=>Ui,AssetManager:()=>gs,AudioApi:()=>Wr,AudioContextController:()=>ys,AudioRegistry:()=>pn,AudioRegistryError:()=>Fi,AudioSystem:()=>As,BSP_SURFACE_FRAGMENT_SOURCE:()=>ml,BSP_SURFACE_VERTEX_SOURCE:()=>hl,BSP_VERTEX_LAYOUT:()=>dl,BspLoader:()=>Kr,BspParseError:()=>j,BspSurfacePipeline:()=>Ts,Camera:()=>ks,Command:()=>zn,CommandRegistry:()=>Nr,ConfigStringRegistry:()=>Gr,Cvar:()=>Un,CvarRegistry:()=>Hr,DemoPlaybackController:()=>po,DemoReader:()=>Lr,EngineHost:()=>Vr,EngineRuntime:()=>Hn,FixedTimestepLoop:()=>cr,Framebuffer:()=>Es,IndexBuffer:()=>ye,LruCache:()=>Ft,MAX_SOUND_CHANNELS:()=>Fn,MD2_FRAGMENT_SHADER:()=>vl,MD2_VERTEX_SHADER:()=>bl,MD3_FRAGMENT_SHADER:()=>Rl,MD3_VERTEX_SHADER:()=>Il,Md2Loader:()=>$r,Md2MeshBuffers:()=>Rs,Md2ParseError:()=>me,Md2Pipeline:()=>Cs,Md3Loader:()=>Zr,Md3ModelMesh:()=>Ds,Md3ParseError:()=>Ge,Md3Pipeline:()=>Os,Md3SurfaceMesh:()=>Gi,MusicSystem:()=>Ms,NetworkMessageParser:()=>Fr,PARTICLE_FRAGMENT_SHADER:()=>zl,PARTICLE_VERTEX_SHADER:()=>Cl,PROTOCOL_VERSION_RERELEASE:()=>qs,PakArchive:()=>Xr,PakIndexStore:()=>ps,PakIngestionError:()=>Pt,PakParseError:()=>Ve,PakValidationError:()=>dr,PakValidator:()=>Io,ParticleRenderer:()=>Fs,ParticleSystem:()=>Ps,PlaybackState:()=>ma,RERELEASE_KNOWN_PAKS:()=>za,SKYBOX_FRAGMENT_SHADER:()=>xl,SKYBOX_VERTEX_SHADER:()=>yl,SOUND_FULLVOLUME:()=>Dt,SOUND_LOOP_ATTENUATE:()=>Ca,ShaderProgram:()=>Ee,SkyboxPipeline:()=>Is,SoundChannel:()=>ot,SoundPrecache:()=>bs,SoundRegistry:()=>_s,SpriteLoader:()=>Yr,SpriteParseError:()=>Bt,Texture2D:()=>gn,TextureCache:()=>qr,TextureCubeMap:()=>yn,TgaParseError:()=>yt,U_ALPHA:()=>uc,U_ANGLE1:()=>oa,U_ANGLE2:()=>ea,U_ANGLE3:()=>ta,U_EFFECTS16:()=>ho,U_EFFECTS8:()=>co,U_EVENT:()=>na,U_FRAME16:()=>aa,U_FRAME8:()=>ra,U_INSTANCE_BITS:()=>hc,U_LOOP_ATTENUATION_HIGH:()=>pc,U_LOOP_VOLUME:()=>mc,U_MODEL:()=>sa,U_MODEL2:()=>la,U_MODEL3:()=>ca,U_MODEL4:()=>da,U_OLDORIGIN:()=>ua,U_OLD_FRAME_HIGH:()=>yc,U_ORIGIN1:()=>Qs,U_ORIGIN2:()=>Js,U_ORIGIN3:()=>ia,U_OWNER_HIGH:()=>gc,U_REMOVE:()=>dc,U_RENDERFX16:()=>fo,U_RENDERFX8:()=>lo,U_SCALE:()=>fc,U_SKIN16:()=>mo,U_SKIN8:()=>uo,U_SOLID:()=>ha,U_SOUND:()=>fa,VertexArray:()=>ze,VertexBuffer:()=>Le,VirtualFileSystem:()=>To,advanceAnimation:()=>td,applySurfaceState:()=>Zd,attenuationToDistanceMultiplier:()=>Ot,boxIntersectsFrustum:()=>Vi,buildBspGeometry:()=>Hd,buildMd2Geometry:()=>Sl,buildMd2VertexData:()=>wl,buildMd3SurfaceGeometry:()=>Ll,buildMd3VertexData:()=>Tl,calculateMaxAudibleDistance:()=>Nn,calculatePakChecksum:()=>Gc,computeFrameBlend:()=>rd,computeSkyScroll:()=>jd,createAnimationState:()=>nd,createAudioGraph:()=>xs,createBspSurfaces:()=>Ud,createEmptyEntityState:()=>Pr,createEmptyProtocolPlayerState:()=>js,createEngine:()=>px,createEngineRuntime:()=>Hc,createFaceLightmap:()=>Co,createInitialChannels:()=>vs,createProgramFromSources:()=>Nd,createWebGLContext:()=>Fd,decodeOgg:()=>ms,deriveSurfaceRenderState:()=>gl,extractFrustumPlanes:()=>Vd,filesToPakSources:()=>ka,findLeafForPoint:()=>fl,gatherVisibleFaces:()=>Kd,groupMd2Animations:()=>jc,ingestPakFiles:()=>Wc,ingestPaks:()=>Ro,interpolateMd3Tag:()=>p0,interpolateVec3:()=>id,parseBsp:()=>Da,parseMd2:()=>Oa,parseMd3:()=>Pa,parsePcx:()=>Xn,parseSprite:()=>Fa,parseTga:()=>Ba,parseWal:()=>ko,parseWalTexture:()=>Po,parseWav:()=>Fo,pcxToRgba:()=>Do,pickChannel:()=>Ss,preparePcxTexture:()=>Oo,removeViewTranslation:()=>qd,resolveLightStyles:()=>pl,spatializeOrigin:()=>ws,spawnBlood:()=>x0,spawnBulletImpact:()=>g0,spawnExplosion:()=>y0,spawnMuzzleFlash:()=>b0,spawnTeleportFlash:()=>_0,spawnTrail:()=>v0,walToRgba:()=>Na,wireDropTarget:()=>Xc,wireFileInput:()=>Kc});var ju=()=>typeof performance<"u"?performance.now():Date.now(),Qu=e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(()=>e()):setTimeout(e,25)},cr=class{constructor(t,r={}){this.callbacks=t;this.accumulatorMs=0;this.frame=0;this.running=!1;this.tick=()=>{if(!this.running)return;let t=this.options.now(),r=this.lastTimeMs===void 0?0:t-this.lastTimeMs;this.lastTimeMs=t,this.advance(r,t),this.running&&this.options.schedule(this.tick)};let n=r.fixedDeltaMs??25,i=r.maxSubSteps??5;this.options={fixedDeltaMs:n,maxSubSteps:i,maxDeltaMs:r.maxDeltaMs??n*i,startTimeMs:r.startTimeMs,now:r.now??ju,schedule:r.schedule??Qu}}start(){this.running||(this.running=!0,this.lastTimeMs=this.options.startTimeMs??this.options.now(),this.options.schedule(this.tick))}stop(){this.running=!1}pump(t){let r=(this.lastTimeMs??0)+t;this.lastTimeMs=r,this.advance(t,r)}isRunning(){return this.running}get frameNumber(){return this.frame}advance(t,r){let n=Math.min(Math.max(t,0),this.options.maxDeltaMs);this.accumulatorMs=Math.min(this.accumulatorMs+n,this.options.fixedDeltaMs*this.options.maxSubSteps);let i=0;for(;this.accumulatorMs>=this.options.fixedDeltaMs&&i<this.options.maxSubSteps;)this.frame+=1,this.callbacks.simulate({frame:this.frame,deltaMs:this.options.fixedDeltaMs,nowMs:r}),this.accumulatorMs-=this.options.fixedDeltaMs,i+=1;let o=this.options.fixedDeltaMs===0?0:this.accumulatorMs/this.options.fixedDeltaMs;this.callbacks.render?.({alpha:o,nowMs:r,accumulatorMs:this.accumulatorMs,frame:this.frame})}};var zn=class{constructor(t,r,n){this.name=t,this.callback=r,this.description=n}execute(t){this.callback(t)}},Nr=class{constructor(){this.commands=new Map}register(t,r,n){let i=new zn(t,r,n);return this.commands.set(t,i),i}get(t){return this.commands.get(t)}execute(t){let r=this.tokenize(t);if(r.length===0)return!1;let n=r[0],i=r.slice(1),o=this.get(n);return o?(o.execute(i),!0):!1}tokenize(t){return t.trim().split(/\s+/)}list(){return[...this.commands.values()].sort((t,r)=>t.name.localeCompare(r.name))}};var Ju=Object.defineProperty,Ec=(e,t)=>{for(var r in t)Ju(e,r,{get:t[r],enumerable:!0})},Lc={x:0,y:0,z:0};var bx=Math.PI/180;function Tc(e,t){return{x:e.x-t.x,y:e.y-t.y,z:e.z-t.z}}function ef(e,t){return{x:e.x*t,y:e.y*t,z:e.z*t}}function xa(e,t){return e.x*t.x+e.y*t.y+e.z*t.z}function tf(e){return xa(e,e)}function _a(e){return Math.sqrt(tf(e))}function Je(e){let t=_a(e);return t===0?e:ef(e,1/t)}var rf=Math.PI/180,vx=180/Math.PI,Ur=rf;var ya=[[-.525731,0,.850651],[-.442863,.238856,.864188],[-.295242,0,.955423],[-.309017,.5,.809017],[-.16246,.262866,.951056],[0,0,1],[0,.850651,.525731],[-.147621,.716567,.681718],[.147621,.716567,.681718],[0,.525731,.850651],[.309017,.5,.809017],[.525731,0,.850651],[.295242,0,.955423],[.442863,.238856,.864188],[.16246,.262866,.951056],[-.681718,.147621,.716567],[-.809017,.309017,.5],[-.587785,.425325,.688191],[-.850651,.525731,0],[-.864188,.442863,.238856],[-.716567,.681718,.147621],[-.688191,.587785,.425325],[-.5,.809017,.309017],[-.238856,.864188,.442863],[-.425325,.688191,.587785],[-.716567,.681718,-.147621],[-.5,.809017,-.309017],[-.525731,.850651,0],[0,.850651,-.525731],[-.238856,.864188,-.442863],[0,.955423,-.295242],[-.262866,.951056,-.16246],[0,1,0],[0,.955423,.295242],[-.262866,.951056,.16246],[.238856,.864188,.442863],[.262866,.951056,.16246],[.5,.809017,.309017],[.238856,.864188,-.442863],[.262866,.951056,-.16246],[.5,.809017,-.309017],[.850651,.525731,0],[.716567,.681718,.147621],[.716567,.681718,-.147621],[.525731,.850651,0],[.425325,.688191,.587785],[.864188,.442863,.238856],[.688191,.587785,.425325],[.809017,.309017,.5],[.681718,.147621,.716567],[.587785,.425325,.688191],[.955423,.295242,0],[1,0,0],[.951056,.16246,.262866],[.850651,-.525731,0],[.955423,-.295242,0],[.864188,-.442863,.238856],[.951056,-.16246,.262866],[.809017,-.309017,.5],[.681718,-.147621,.716567],[.850651,0,.525731],[.864188,.442863,-.238856],[.809017,.309017,-.5],[.951056,.16246,-.262866],[.525731,0,-.850651],[.681718,.147621,-.716567],[.681718,-.147621,-.716567],[.850651,0,-.525731],[.809017,-.309017,-.5],[.864188,-.442863,-.238856],[.951056,-.16246,-.262866],[.147621,.716567,-.681718],[.309017,.5,-.809017],[.425325,.688191,-.587785],[.442863,.238856,-.864188],[.587785,.425325,-.688191],[.688191,.587785,-.425325],[-.147621,.716567,-.681718],[-.309017,.5,-.809017],[0,.525731,-.850651],[-.525731,0,-.850651],[-.442863,.238856,-.864188],[-.295242,0,-.955423],[-.16246,.262866,-.951056],[0,0,-1],[.295242,0,-.955423],[.16246,.262866,-.951056],[-.442863,-.238856,-.864188],[-.309017,-.5,-.809017],[-.16246,-.262866,-.951056],[0,-.850651,-.525731],[-.147621,-.716567,-.681718],[.147621,-.716567,-.681718],[0,-.525731,-.850651],[.309017,-.5,-.809017],[.442863,-.238856,-.864188],[.16246,-.262866,-.951056],[.238856,-.864188,-.442863],[.5,-.809017,-.309017],[.425325,-.688191,-.587785],[.716567,-.681718,-.147621],[.688191,-.587785,-.425325],[.587785,-.425325,-.688191],[0,-.955423,-.295242],[0,-1,0],[.262866,-.951056,-.16246],[0,-.850651,.525731],[0,-.955423,.295242],[.238856,-.864188,.442863],[.262866,-.951056,.16246],[.5,-.809017,.309017],[.716567,-.681718,.147621],[.525731,-.850651,0],[-.238856,-.864188,-.442863],[-.5,-.809017,-.309017],[-.262866,-.951056,-.16246],[-.850651,-.525731,0],[-.716567,-.681718,-.147621],[-.716567,-.681718,.147621],[-.525731,-.850651,0],[-.5,-.809017,.309017],[-.238856,-.864188,.442863],[-.262866,-.951056,.16246],[-.864188,-.442863,.238856],[-.809017,-.309017,.5],[-.688191,-.587785,.425325],[-.681718,-.147621,.716567],[-.442863,-.238856,.864188],[-.587785,-.425325,.688191],[-.309017,-.5,.809017],[-.147621,-.716567,.681718],[-.425325,-.688191,.587785],[-.16246,-.262866,.951056],[.442863,-.238856,.864188],[.16246,-.262866,.951056],[.309017,-.5,.809017],[.147621,-.716567,.681718],[0,-.525731,.850651],[.425325,-.688191,.587785],[.587785,-.425325,.688191],[.688191,-.587785,.425325],[-.955423,.295242,0],[-.951056,.16246,.262866],[-1,0,0],[-.850651,0,.525731],[-.955423,-.295242,0],[-.951056,-.16246,.262866],[-.864188,.442863,-.238856],[-.951056,.16246,-.262866],[-.809017,.309017,-.5],[-.864188,-.442863,-.238856],[-.951056,-.16246,-.262866],[-.809017,-.309017,-.5],[-.681718,.147621,-.716567],[-.681718,-.147621,-.716567],[-.850651,0,-.525731],[-.688191,.587785,-.425325],[-.587785,.425325,-.688191],[-.425325,.688191,-.587785],[-.425325,-.688191,-.587785],[-.587785,-.425325,-.688191],[-.688191,-.587785,-.425325]];function nf(){return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function Ic(e,t){let r=t.x,n=t.y,i=t.z;return{x:e[0]*r+e[4]*n+e[8]*i+e[12],y:e[1]*r+e[5]*n+e[9]*i+e[13],z:e[2]*r+e[6]*n+e[10]*i+e[14]}}function Rc(e,t){let r=nf();return r[0]=t[0].x,r[1]=t[0].y,r[2]=t[0].z,r[4]=t[1].x,r[5]=t[1].y,r[6]=t[1].z,r[8]=t[2].x,r[9]=t[2].y,r[10]=t[2].z,r[12]=e.x,r[13]=e.y,r[14]=e.z,r}var it=1,kt=2;var ba=8,va=16,of=32;var sf=16384;var vo=65536,Cc=1<<17,af=1<<18,lf=1<<19,cf=1<<20,df=1<<21,uf=1<<22,ff=1<<23,Sx=1<<24,So=1<<25,hf=1<<26,wx=1<<27,Ax=1<<28,Mx=1<<29,wo=1<<30,Ex=1<<31;var On=0;var zc=4,kc=8,Dc=16,Oc=32,Pc=64;var Lx=1<<25,Tx=1<<28,Ix=1<<29,Rx=1<<30,Cx=1<<31;var zx=it|kt,kx=it|vo|kt|So|wo,Dx=it|vo|kt,Ox=it|Cc|kt|So|wo,Px=of|ba|va,Fx=it|va|ba,mf=it|So|wo|kt|hf,Bx=af|lf|cf|df|uf|ff,Nx=it|ba|va|So|wo,Ux=it|vo|kt,Hx=it|kt,Vx=it|vo|kt|Cc,Gx=mf|sf;var Wx=Number.MAX_SAFE_INTEGER-1;var Ao=(e=>(e[e.None=0]="None",e[e.Archive=1]="Archive",e[e.UserInfo=2]="UserInfo",e[e.ServerInfo=4]="ServerInfo",e[e.Latch=8]="Latch",e[e.Cheat=16]="Cheat",e))(Ao||{});var Mo=256;var Sa=256,wa=8192,Eo=2048,Aa=512,Ma=256,Ea=Mo*2,La=256,ga=32,kn=96;var q=(e=>(e[e.Name=0]="Name",e[e.CdTrack=1]="CdTrack",e[e.Sky=2]="Sky",e[e.SkyAxis=3]="SkyAxis",e[e.SkyRotate=4]="SkyRotate",e[e.StatusBar=5]="StatusBar",e[e.CONFIG_N64_PHYSICS=56]="CONFIG_N64_PHYSICS",e[e.CONFIG_CTF_TEAMS=57]="CONFIG_CTF_TEAMS",e[e.CONFIG_COOP_RESPAWN_STRING=58]="CONFIG_COOP_RESPAWN_STRING",e[e.AirAccel=59]="AirAccel",e[e.MaxClients=60]="MaxClients",e[e.MapChecksum=61]="MapChecksum",e[e.Models=62]="Models",e[e.Sounds=62+wa]="Sounds",e[e.Images=e.Sounds+Eo]="Images",e[e.Lights=e.Images+Aa]="Lights",e[e.ShadowLights=e.Lights+Sa]="ShadowLights",e[e.Items=e.ShadowLights+La]="Items",e[e.PlayerSkins=e.Items+Ma]="PlayerSkins",e[e.General=e.PlayerSkins+Mo]="General",e[e.WheelWeapons=e.General+Ea]="WheelWeapons",e[e.WheelAmmo=e.WheelWeapons+ga]="WheelAmmo",e[e.WheelPowerups=e.WheelAmmo+ga]="WheelPowerups",e[e.CdLoopCount=e.WheelPowerups+ga]="CdLoopCount",e[e.GameStyle=e.CdLoopCount+1]="GameStyle",e[e.MaxConfigStrings=e.GameStyle+1]="MaxConfigStrings",e))(q||{}),Fc=q.MaxConfigStrings;function Bc(e){return e>=5&&e<59?kn*(59-e):e>=q.General&&e<q.WheelWeapons?kn*(q.MaxConfigStrings-e):kn}var pf={};Ec(pf,{addReplayFrame:()=>_f,createReplaySession:()=>xf,deserializeReplay:()=>yf,serializeReplay:()=>gf});function gf(e){return JSON.stringify(e,null,2)}function yf(e){let t=JSON.parse(e);if(!t.metadata||!Array.isArray(t.frames))throw new Error("Invalid replay format: missing metadata or frames");return t}function xf(e,t){return{metadata:{map:e,date:new Date().toISOString(),version:"1.0",seed:t},frames:[]}}function _f(e,t,r,n){e.frames.push({serverFrame:r,cmd:t,timestamp:Date.now()-n})}var O=(e=>(e[e.bad=0]="bad",e[e.muzzleflash=1]="muzzleflash",e[e.muzzleflash2=2]="muzzleflash2",e[e.temp_entity=3]="temp_entity",e[e.layout=4]="layout",e[e.inventory=5]="inventory",e[e.nop=6]="nop",e[e.disconnect=7]="disconnect",e[e.reconnect=8]="reconnect",e[e.sound=9]="sound",e[e.print=10]="print",e[e.stufftext=11]="stufftext",e[e.serverdata=12]="serverdata",e[e.configstring=13]="configstring",e[e.spawnbaseline=14]="spawnbaseline",e[e.centerprint=15]="centerprint",e[e.download=16]="download",e[e.playerinfo=17]="playerinfo",e[e.packetentities=18]="packetentities",e[e.deltapacketentities=19]="deltapacketentities",e[e.frame=20]="frame",e[e.splitclient=21]="splitclient",e[e.configblast=22]="configblast",e[e.spawnbaselineblast=23]="spawnbaselineblast",e[e.level_restart=24]="level_restart",e[e.damage=25]="damage",e[e.locprint=26]="locprint",e[e.fog=27]="fog",e[e.waitingforplayers=28]="waitingforplayers",e[e.bot_chat=29]="bot_chat",e[e.poi=30]="poi",e[e.help_path=31]="help_path",e[e.muzzleflash3=32]="muzzleflash3",e[e.achievement=33]="achievement",e))(O||{});var I=(e=>(e[e.GUNSHOT=0]="GUNSHOT",e[e.BLOOD=1]="BLOOD",e[e.BLASTER=2]="BLASTER",e[e.RAILTRAIL=3]="RAILTRAIL",e[e.SHOTGUN=4]="SHOTGUN",e[e.EXPLOSION1=5]="EXPLOSION1",e[e.EXPLOSION2=6]="EXPLOSION2",e[e.ROCKET_EXPLOSION=7]="ROCKET_EXPLOSION",e[e.GRENADE_EXPLOSION=8]="GRENADE_EXPLOSION",e[e.SPARKS=9]="SPARKS",e[e.SPLASH=10]="SPLASH",e[e.BUBBLETRAIL=11]="BUBBLETRAIL",e[e.SCREEN_SPARKS=12]="SCREEN_SPARKS",e[e.SHIELD_SPARKS=13]="SHIELD_SPARKS",e[e.BULLET_SPARKS=14]="BULLET_SPARKS",e[e.LASER_SPARKS=15]="LASER_SPARKS",e[e.PARASITE_ATTACK=16]="PARASITE_ATTACK",e[e.ROCKET_EXPLOSION_WATER=17]="ROCKET_EXPLOSION_WATER",e[e.GRENADE_EXPLOSION_WATER=18]="GRENADE_EXPLOSION_WATER",e[e.MEDIC_CABLE_ATTACK=19]="MEDIC_CABLE_ATTACK",e[e.BFG_EXPLOSION=20]="BFG_EXPLOSION",e[e.BFG_BIGEXPLOSION=21]="BFG_BIGEXPLOSION",e[e.BOSSTPORT=22]="BOSSTPORT",e[e.BFG_LASER=23]="BFG_LASER",e[e.GRAPPLE_CABLE=24]="GRAPPLE_CABLE",e[e.WELDING_SPARKS=25]="WELDING_SPARKS",e[e.GREENBLOOD=26]="GREENBLOOD",e[e.BLUEHYPERBLASTER=27]="BLUEHYPERBLASTER",e[e.PLASMA_EXPLOSION=28]="PLASMA_EXPLOSION",e[e.TUNNEL_SPARKS=29]="TUNNEL_SPARKS",e[e.BLASTER2=30]="BLASTER2",e[e.RAILTRAIL2=31]="RAILTRAIL2",e[e.FLAME=32]="FLAME",e[e.LIGHTNING=33]="LIGHTNING",e[e.DEBUGTRAIL=34]="DEBUGTRAIL",e[e.PLAIN_EXPLOSION=35]="PLAIN_EXPLOSION",e[e.FLASHLIGHT=36]="FLASHLIGHT",e[e.FORCEWALL=37]="FORCEWALL",e[e.HEATBEAM=38]="HEATBEAM",e[e.MONSTER_HEATBEAM=39]="MONSTER_HEATBEAM",e[e.STEAM=40]="STEAM",e[e.BUBBLETRAIL2=41]="BUBBLETRAIL2",e[e.MOREBLOOD=42]="MOREBLOOD",e[e.HEATBEAM_SPARKS=43]="HEATBEAM_SPARKS",e[e.HEATBEAM_STEAM=44]="HEATBEAM_STEAM",e[e.CHAINFIST_SMOKE=45]="CHAINFIST_SMOKE",e[e.ELECTRIC_SPARKS=46]="ELECTRIC_SPARKS",e[e.TRACKER_EXPLOSION=47]="TRACKER_EXPLOSION",e[e.TELEPORT_EFFECT=48]="TELEPORT_EFFECT",e[e.DBALL_GOAL=49]="DBALL_GOAL",e[e.WIDOWBEAMOUT=50]="WIDOWBEAMOUT",e[e.NUKEBLAST=51]="NUKEBLAST",e[e.WIDOWSPLASH=52]="WIDOWSPLASH",e[e.EXPLOSION1_BIG=53]="EXPLOSION1_BIG",e[e.EXPLOSION1_NP=54]="EXPLOSION1_NP",e[e.FLECHETTE=55]="FLECHETTE",e[e.BLUEHYPERBLASTER_KEX=56]="BLUEHYPERBLASTER_KEX",e[e.BFG_ZAP=57]="BFG_ZAP",e[e.BERSERK_SLAM=58]="BERSERK_SLAM",e[e.GRAPPLE_CABLE_2=59]="GRAPPLE_CABLE_2",e[e.POWER_SPLASH=60]="POWER_SPLASH",e[e.LIGHTNING_BEAM=61]="LIGHTNING_BEAM",e[e.EXPLOSION1_NL=62]="EXPLOSION1_NL",e[e.EXPLOSION2_NL=63]="EXPLOSION2_NL",e))(I||{});var bf=12,vf=9,Xx=Math.ceil(bf*vf/16),Sf=23,wf=2,Kx=Math.ceil(Sf*wf/16);var Af={};Ec(Af,{U_ANGLE1:()=>Cf,U_ANGLE2:()=>zf,U_ANGLE3:()=>kf,U_EFFECTS:()=>Pf,U_EVENT:()=>Nf,U_FRAME:()=>Df,U_MODEL:()=>Ef,U_MODEL2:()=>Hf,U_MODEL3:()=>Vf,U_MODEL4:()=>Gf,U_MOREBITS:()=>Uf,U_NUMBER:()=>Mf,U_ORIGIN1:()=>Tf,U_ORIGIN2:()=>If,U_ORIGIN3:()=>Rf,U_REMOVE:()=>Wf,U_RENDERFX:()=>Ff,U_SKIN:()=>Of,U_SOLID:()=>Bf,U_SOUND:()=>Lf});var Mf=1,Ef=2,Lf=4,Tf=8,If=16,Rf=32,Cf=64,zf=128,kf=256,Df=512,Of=1024,Pf=2048,Ff=4096,Bf=8192,Nf=16384,Uf=32768,Hf=1,Vf=2,Gf=4,Wf=32768;var Pn=class{constructor(e){e instanceof Uint8Array?this.view=new DataView(e.buffer,e.byteOffset,e.byteLength):this.view=new DataView(e),this.offset=0,this.length=this.view.byteLength}getPosition(){return this.offset}seek(e){if(e<0||e>this.length)throw new Error(`Seek out of bounds: ${e} (length: ${this.length})`);this.offset=e}hasMore(){return this.offset<this.length}readChar(){let e=this.view.getInt8(this.offset);return this.offset+=1,e}readByte(){let e=this.view.getUint8(this.offset);return this.offset+=1,e}readShort(){let e=this.view.getInt16(this.offset,!0);return this.offset+=2,e}readUShort(){let e=this.view.getUint16(this.offset,!0);return this.offset+=2,e}readLong(){let e=this.view.getInt32(this.offset,!0);return this.offset+=4,e}readULong(){let e=this.view.getUint32(this.offset,!0);return this.offset+=4,e}readFloat(){let e=this.view.getFloat32(this.offset,!0);return this.offset+=4,e}readString(){let e="";for(;this.offset<this.length;){let t=this.readChar();if(t===-1||t===0)break;e+=String.fromCharCode(t)}return e}readStringLine(){let e="";for(;this.offset<this.length;){let t=this.readChar();if(t===-1||t===0||t===10)break;e+=String.fromCharCode(t)}return e}readCoord(){return this.readShort()*(1/8)}readAngle(){return this.readChar()*(360/256)}readAngle16(){return this.readShort()*360/65536}readData(e){if(this.offset+e>this.length)throw new Error(`Read out of bounds: ${this.offset+e} (length: ${this.length})`);let t=new Uint8Array(this.view.buffer,this.view.byteOffset+this.offset,e);return this.offset+=e,new Uint8Array(t)}readPos(e){e.x=this.readCoord(),e.y=this.readCoord(),e.z=this.readCoord()}readDir(e){let t=this.readByte();if(t>=162){e.x=0,e.y=0,e.z=0;return}let r=ya[t];e.x=r[0],e.y=r[1],e.z=r[2]}},Xf=class{constructor(e=1400){typeof e=="number"?(this.buffer=new Uint8Array(e),this.fixed=!1):(this.buffer=e,this.fixed=!0),this.view=new DataView(this.buffer.buffer,this.buffer.byteOffset,this.buffer.byteLength),this.offset=0}ensureSpace(e){if(this.offset+e>this.buffer.byteLength){if(this.fixed)throw new Error(`Buffer overflow: capacity ${this.buffer.byteLength}, needed ${this.offset+e}`);let t=Math.max(this.buffer.byteLength*2,this.offset+e),r=new Uint8Array(t);r.set(this.buffer),this.buffer=r,this.view=new DataView(this.buffer.buffer,this.buffer.byteOffset,this.buffer.byteLength)}}writeByte(e){this.ensureSpace(1),this.view.setUint8(this.offset,e),this.offset+=1}writeChar(e){this.ensureSpace(1),this.view.setInt8(this.offset,e),this.offset+=1}writeShort(e){this.ensureSpace(2),this.view.setInt16(this.offset,e,!0),this.offset+=2}writeLong(e){this.ensureSpace(4),this.view.setInt32(this.offset,e,!0),this.offset+=4}writeFloat(e){this.ensureSpace(4),this.view.setFloat32(this.offset,e,!0),this.offset+=4}writeString(e){let t=e.length;this.ensureSpace(t+1);for(let r=0;r<t;r++)this.view.setUint8(this.offset+r,e.charCodeAt(r));this.view.setUint8(this.offset+t,0),this.offset+=t+1}writeCoord(e){this.writeShort(Math.trunc(e*8))}writeAngle(e){this.writeByte(Math.trunc(e*256/360)&255)}writeAngle16(e){this.writeShort(Math.trunc(e*65536/360)&65535)}writePos(e){this.writeCoord(e.x),this.writeCoord(e.y),this.writeCoord(e.z)}writeDir(e){let t=-1,r=0;if(e.x===0&&e.y===0&&e.z===0){this.writeByte(0);return}for(let n=0;n<ya.length;n++){let i=ya[n],o=e.x*i[0]+e.y*i[1]+e.z*i[2];o>t&&(t=o,r=n)}this.writeByte(r)}getData(){return this.buffer.slice(0,this.offset)}getBuffer(){return this.buffer}getOffset(){return this.offset}reset(){this.offset=0}};var Dn=class xe{constructor(){this.qport=0,this.incomingSequence=0,this.outgoingSequence=0,this.incomingAcknowledged=0,this.incomingReliableAcknowledged=!1,this.incomingReliableSequence=0,this.outgoingReliableSequence=0,this.reliableLength=0,this.lastReceived=0,this.lastSent=0,this.remoteAddress=null,this.reliableMessage=new Xf(xe.MAX_MSGLEN);let t=Date.now();this.lastReceived=t,this.lastSent=t,this.qport=Math.floor(Math.random()*65536)}setup(t,r=null){this.qport=t,this.remoteAddress=r,this.reset()}reset(){this.incomingSequence=0,this.outgoingSequence=0,this.incomingAcknowledged=0,this.incomingReliableAcknowledged=!1,this.incomingReliableSequence=0,this.outgoingReliableSequence=0,this.reliableLength=0,this.reliableMessage.reset(),this.lastReceived=Date.now(),this.lastSent=Date.now()}transmit(t){this.outgoingSequence++,this.lastSent=Date.now();let r=xe.PACKET_HEADER,n=this.reliableLength>0?this.reliableLength+2:0,i=t?t.length:0;r+n+i>xe.MAX_MSGLEN&&(i=xe.MAX_MSGLEN-r-n,i<0&&(i=0));let o=new ArrayBuffer(r+n+i),s=new DataView(o),a=new Uint8Array(o),d=this.outgoingSequence;this.reliableLength>0&&(d|=2147483648,(this.outgoingReliableSequence&1)!==0&&(d|=1073741824)),s.setUint32(0,d,!0);let l=this.incomingSequence;(this.incomingReliableSequence&1)!==0&&(l|=2147483648),s.setUint32(4,l,!0),s.setUint16(8,this.qport,!0);let c=r;if(this.reliableLength>0){s.setUint16(c,this.reliableLength,!0),c+=2;let u=this.reliableMessage.getBuffer().subarray(0,this.reliableLength);a.set(u,c),c+=this.reliableLength}if(t&&i>0){let h=t.slice(0,i);a.set(h,c)}return a}process(t){if(t.length<xe.PACKET_HEADER)return null;this.lastReceived=Date.now();let r=new DataView(t.buffer,t.byteOffset,t.byteLength),n=r.getUint32(0,!0),i=r.getUint32(4,!0),o=r.getUint16(8,!0);if(this.qport!==o)return null;let s=n&1073741823;if((s-this.incomingSequence|0)<=0)return null;this.incomingSequence=s;let a=i&2147483647,d=(i&2147483648)!==0;if(a>this.incomingAcknowledged&&(this.incomingAcknowledged=a),this.reliableLength>0){let m=d?1:0,g=this.outgoingReliableSequence&1;m!==g&&(this.reliableLength=0,this.reliableMessage.reset(),this.outgoingReliableSequence^=1)}let l=(n&2147483648)!==0,c=(n&1073741824)!==0?1:0,h=xe.PACKET_HEADER,u=null;if(l){if(h+2>t.byteLength)return null;let m=r.getUint16(h,!0);h+=2;let g=this.incomingReliableSequence&1;if(c===g){if(this.incomingReliableSequence++,h+m>t.byteLength)return null;u=t.slice(h,h+m)}h+=m}let f=t.slice(h);if(u&&u.length>0){let m=u.length+f.length,g=new Uint8Array(m);return g.set(u,0),g.set(f,u.length),g}return f||new Uint8Array(0)}canSendReliable(){return this.reliableLength===0}writeReliableByte(t){if(this.reliableLength+1>xe.MAX_MSGLEN-xe.HEADER_OVERHEAD)throw new Error("NetChan reliable buffer overflow");this.reliableMessage.writeByte(t),this.reliableLength++}writeReliableShort(t){if(this.reliableLength+2>xe.MAX_MSGLEN-xe.HEADER_OVERHEAD)throw new Error("NetChan reliable buffer overflow");this.reliableMessage.writeShort(t),this.reliableLength+=2}writeReliableLong(t){if(this.reliableLength+4>xe.MAX_MSGLEN-xe.HEADER_OVERHEAD)throw new Error("NetChan reliable buffer overflow");this.reliableMessage.writeLong(t),this.reliableLength+=4}writeReliableString(t){let r=t.length+1;if(this.reliableLength+r>xe.MAX_MSGLEN-xe.HEADER_OVERHEAD)throw new Error("NetChan reliable buffer overflow");this.reliableMessage.writeString(t),this.reliableLength+=r}getReliableData(){return this.reliableLength===0?new Uint8Array(0):this.reliableMessage.getBuffer().subarray(0,this.reliableLength)}needsKeepalive(t){return t-this.lastSent>1e3}isTimedOut(t,r=3e4){return t-this.lastReceived>r}};Dn.MAX_MSGLEN=1400;Dn.FRAGMENT_SIZE=1024;Dn.PACKET_HEADER=10;Dn.HEADER_OVERHEAD=Dn.PACKET_HEADER+2;var Nc=(e=>(e[e.Bullets=0]="Bullets",e[e.Shells=1]="Shells",e[e.Rockets=2]="Rockets",e[e.Grenades=3]="Grenades",e[e.Cells=4]="Cells",e[e.Slugs=5]="Slugs",e[e.MagSlugs=6]="MagSlugs",e[e.Trap=7]="Trap",e[e.Flechettes=8]="Flechettes",e[e.Tesla=9]="Tesla",e[e.Disruptor=10]="Disruptor",e[e.Prox=11]="Prox",e[e.Nuke=12]="Nuke",e[e.Rounds=13]="Rounds",e))(Nc||{}),$x=Object.keys(Nc).length/2;var Fn=32,ot=(e=>(e[e.Auto=0]="Auto",e[e.Weapon=1]="Weapon",e[e.Voice=2]="Voice",e[e.Item=3]="Item",e[e.Body=4]="Body",e[e.Aux=5]="Aux",e[e.Footstep=6]="Footstep",e[e.Aux3=7]="Aux3",e[e.NoPhsAdd=8]="NoPhsAdd",e[e.Reliable=16]="Reliable",e[e.ForcePos=32]="ForcePos",e))(ot||{}),Ta=-1,Bn=0,Ia=1,Ra=2,Lo=3,Dt=80,Ca=.003;function Ot(e){return e===Lo?e*.001:e*5e-4}function Nn(e){let t=Ot(e);return t<=0?Number.POSITIVE_INFINITY:Dt+1/t}var Un=class{constructor({name:t,defaultValue:r,description:n,flags:i=Ao.None,onChange:o}){this.modifiedCount=0;this.name=t,this.defaultValue=r,this.description=n,this.flags=i,this._value=r,this.onChange=o}get string(){return this._value}get number(){return Number(this._value)}get integer(){return Math.trunc(this.number)}get boolean(){return!!this.integer}set(t){if(this.flags&Ao.Latch){if(t===this._value){this.latched=void 0;return}if(this.latched===t)return;this.latched!==t&&(this.latched=t);return}this.apply(t)}reset(){this.latched=void 0,this.apply(this.defaultValue)}applyLatched(){if(this.latched===void 0)return!1;let t=this.latched;return this.latched=void 0,t===this._value?!1:(this.apply(t),!0)}apply(t){if(this._value===t)return;let r=this._value;this._value=t,this.modifiedCount+=1,this.onChange?.(this,r)}},Hr=class{constructor(){this.cvars=new Map}register(t){let r=this.cvars.get(t.name);if(r)return r;let n=new Un(t);return this.cvars.set(t.name,n),n}get(t){return this.cvars.get(t)}setValue(t,r){let n=this.get(t);if(!n)throw new Error(`Unknown cvar: ${t}`);return n.set(r),n}resetAll(){for(let t of this.cvars.values())t.reset()}applyLatched(){let t=!1;for(let r of this.cvars.values())t=r.applyLatched()||t;return t}list(){return[...this.cvars.values()].sort((t,r)=>t.name.localeCompare(r.name))}};var Vr=class{constructor(t,r,n={}){this.game=t;this.client=r;this.started=!1;this.commands=new Nr;this.cvars=new Hr;this.stepSimulation=t=>{this.previousFrame=this.latestFrame,this.latestFrame=this.game.frame(t,this.latestCommand)};this.renderClient=t=>{this.client&&(this.latestCommand=this.client.render({...t,previous:this.previousFrame,latest:this.latestFrame}))};let i=n.loop?.now?.()??Date.now();this.startTimeMs=n.startTimeMs??n.loop?.startTimeMs??i,this.loop=new cr({simulate:this.stepSimulation,render:this.renderClient},{...n.loop,startTimeMs:this.startTimeMs})}start(){if(!this.started){try{this.latestFrame=this.game.init(this.startTimeMs)??this.latestFrame,this.client?.init(this.latestFrame)}catch(t){throw this.game.shutdown(),this.client?.shutdown(),t}this.started=!0,this.loop.start()}}stop(){this.started&&(this.loop.stop(),this.client?.shutdown(),this.game.shutdown(),this.previousFrame=void 0,this.latestFrame=void 0,this.started=!1)}pump(t){this.loop.pump(t)}getLatestFrame(){return this.latestFrame}isRunning(){return this.loop.isRunning()}};function Kf(e){if(e<0||e>=q.MaxConfigStrings)throw new RangeError(`Configstring index ${e} is out of range (0-${q.MaxConfigStrings-1})`)}function Uc(e,t){let r=Bc(e);if(t.length>r)throw new RangeError(`Configstring ${e} exceeds maximum length (${t.length} > ${r}); limit is ${kn} chars per slot`)}var Gr=class{constructor(){this.values=new Map;this.modelCursor=q.Models;this.soundCursor=q.Sounds;this.imageCursor=q.Images;this.lightCursor=q.Lights;this.shadowLightCursor=q.ShadowLights;this.itemCursor=q.Items;this.playerSkinCursor=q.PlayerSkins;this.generalCursor=q.General}set(t,r){return Kf(t),Uc(t,r),this.values.set(t,r),t}get(t){return this.values.get(t)}getName(t){return this.get(t)}getAll(){let t=new Array(Fc).fill("");for(let[r,n]of this.values.entries())t[r]=n;return t}modelIndex(t){return this.register(t,q.Models,wa,"modelCursor")}soundIndex(t){return this.register(t,q.Sounds,Eo,"soundCursor")}findSoundIndex(t){for(let r=q.Sounds;r<q.Sounds+Eo;r+=1)if(this.values.get(r)===t)return r}imageIndex(t){return this.register(t,q.Images,Aa,"imageCursor")}lightIndex(t){return this.register(t,q.Lights,Sa,"lightCursor")}shadowLightIndex(t){return this.register(t,q.ShadowLights,La,"shadowLightCursor")}itemIndex(t){return this.register(t,q.Items,Ma,"itemCursor")}playerSkinIndex(t){return this.register(t,q.PlayerSkins,Mo,"playerSkinCursor")}generalIndex(t){return this.register(t,q.General,Ea,"generalCursor")}register(t,r,n,i){for(let a=r;a<r+n;a+=1)if(this.values.get(a)===t)return a;let o=this[i],s=r+n;if(o>=s)throw new RangeError(`Out of configstring slots for range starting at ${r}`);return Uc(o,t),this.values.set(o,t),this[i]=o+1,o}};var Wr=class{constructor(t){this.registry=t.registry,this.system=t.system,this.music=t.music,this.client=t.client}soundindex(t){return this.registry.registerName(t)}sound(t,r,n,i,o,s){this.system.play({entity:t,channel:r,soundIndex:n,volume:i,attenuation:o,timeOffsetMs:s}),this.triggerSubtitle(n)}positioned_sound(t,r,n,i){this.system.positionedSound(t,r,n,i),this.triggerSubtitle(r)}loop_sound(t,r,n,i,o){this.system.play({entity:t,channel:r,soundIndex:n,volume:i,attenuation:o,looping:!0}),this.triggerSubtitle(n)}stop_entity_sounds(t){this.system.stopEntitySounds(t)}set_listener(t){this.system.setListener(t)}play_music(t,r=!0){return this.music?this.music.play(t,{loop:r}):Promise.resolve()}pause_music(){this.music?.pause()}resume_music(){return this.music?.resume()??Promise.resolve()}stop_music(){this.music?.stop()}set_music_volume(t){this.music?.setVolume(t)}play_ambient(t,r,n){this.system.ambientSound(t,r,n),this.triggerSubtitle(r)}play_channel(t){this.system.play({...t}),this.triggerSubtitle(t.soundIndex)}triggerSubtitle(t){if(!this.client)return;let r=this.registry.getName(t);if(!r)return;let n=r.match(/\[(.*?)\]/);n&&this.client.showSubtitle(n[1],r)}};var Hn=class{constructor(t,r){this.engine=t;this.host=r;this.started=!1}start(){this.started||(this.engine.init(),this.host.start(),this.started=!0)}stop(){this.started&&(this.host.stop(),this.engine.shutdown(),this.started=!1)}pump(t){this.host.pump(t)}getLatestFrame(){return this.host.getLatestFrame()}isRunning(){return this.started&&this.host.isRunning()}};function Hc(e,t,r,n,i){let o=new Wr({...n,client:r}),s=new Vr(t,r,i);return{runtime:new Hn(e,s),audio:o}}var $f="PACK";function Zf(e,t,r){let n=[];for(let i=0;i<r;i+=1){let o=e.getUint8(t+i);if(o===0)break;n.push(o)}return String.fromCharCode(...n)}function ae(e){return e.replace(/\\/g,"/").replace(/^\/+/,"").toLowerCase()}function Yf(){let e=new Uint32Array(256);for(let t=0;t<256;t+=1){let r=t;for(let n=0;n<8;n+=1)r=(r&1)!==0?3988292384^r>>>1:r>>>1;e[t]=r>>>0}return e}var qf=Yf();function Vc(e){let t=4294967295;for(let r=0;r<e.length;r+=1){let n=e[r];t=qf[(t^n)&255]^t>>>8}return(t^4294967295)>>>0}var Ve=class extends Error{},Xr=class e{constructor(t,r,n,i){this.name=t;this.buffer=r;this.entries=new Map(n.map(o=>[o.name,o])),this.checksum=i,this.size=r.byteLength}static fromArrayBuffer(t,r){let n=new DataView(r);if(r.byteLength<12)throw new Ve("PAK buffer too small to contain header");let i=String.fromCharCode(n.getUint8(0),n.getUint8(1),n.getUint8(2),n.getUint8(3));if(i!==$f)throw new Ve(`Invalid PAK header magic: ${i}`);let o=n.getInt32(4,!0),s=n.getInt32(8,!0);if(o<12)throw new Ve(`Invalid directory offset: ${o}`);if(s<=0||s%64!==0)throw new Ve(`Invalid directory length: ${s}`);if(o+s>r.byteLength)throw new Ve("Directory exceeds buffer length");let d=s/64,l=[],c=new Map;for(let h=0;h<d;h+=1){let u=o+h*64,f=Zf(n,u,56),m=ae(f),g=n.getInt32(u+56,!0),p=n.getInt32(u+60,!0);if(g<0||p<0||g+p>r.byteLength)throw new Ve(`Invalid entry bounds for ${f||"<unnamed>"} (offset=${g}, length=${p})`);if(!m)throw new Ve(`Entry ${h} has an empty name`);let x={name:m,offset:g,length:p};c.set(m,x)}return l.push(...c.values()),new e(t,r,l,Vc(new Uint8Array(r)))}getEntry(t){return this.entries.get(ae(t))}listEntries(){return Array.from(this.entries.values())}readFile(t){let r=this.getEntry(t);if(!r)throw new Ve(`File not found in PAK: ${t}`);return new Uint8Array(this.buffer,r.offset,r.length)}validate(){return{checksum:this.checksum,entries:this.listEntries()}}};function Gc(e){return Vc(new Uint8Array(e))}var To=class{constructor(t=[]){this.mounts=[];this.files=new Map;t.forEach(r=>this.mountPak(r))}mountPak(t){this.mounts.push(t);for(let r of t.listEntries()){let n=ae(r.name);this.files.set(n,{archive:t,entry:r})}}get mountedPaks(){return[...this.mounts]}hasFile(t){return this.files.has(ae(t))}stat(t){let r=this.files.get(ae(t));if(r)return{path:r.entry.name,size:r.entry.length,sourcePak:r.archive.name}}async readFile(t){let r=this.files.get(ae(t));if(!r)throw new Error(`File not found in VFS: ${t}`);return r.archive.readFile(t)}list(t=""){let r=ae(t).replace(/\/+$|^\//g,""),n=[],i=new Set,o=r?`${r}/`:"";for(let s of this.files.values()){if(r&&!s.entry.name.startsWith(o))continue;let a=r?s.entry.name.slice(o.length):s.entry.name,d=a.indexOf("/");d===-1?n.push({path:s.entry.name,size:s.entry.length,sourcePak:s.archive.name}):i.add(a.slice(0,d))}return n.sort((s,a)=>s.path.localeCompare(a.path)),{files:n,directories:[...i].sort()}}findByExtension(t){let r=t.startsWith(".")?t.toLowerCase():`.${t.toLowerCase()}`,n=[];for(let i of this.files.values())i.entry.name.toLowerCase().endsWith(r)&&n.push({path:i.entry.name,size:i.entry.length,sourcePak:i.archive.name});return n.sort((i,o)=>i.path.localeCompare(o.path))}};var za=Object.freeze([{name:"pak0.pak",checksum:2378051181,description:"Base game assets"},{name:"pak0.pak@baseq2",checksum:2378051181,description:"Base game assets (baseq2)"},{name:"pak0.pak@rogue",checksum:3373211245,description:"Ground Zero (rogue) mission pack"},{name:"pak0.pak@xatrix",checksum:1358269824,description:"The Reckoning (xatrix) mission pack"}]),dr=class extends Error{constructor(r){super(r.status==="unknown"?`Unknown PAK not allowed: ${r.name}`:`PAK checksum mismatch for ${r.name}`);this.result=r;this.name="PakValidationError"}},Io=class{constructor(t=za){this.known=new Map;t.forEach(r=>this.known.set(this.normalizePakName(r.name),r))}validateArchive(t,r){let n=this.normalizePakName(r??("name"in t?t.name:"unknown")),i=t.checksum,o="size"in t?t.size:void 0,s=this.known.get(n);return s?s.checksum!==i?{name:n,checksum:i,expectedChecksum:s.checksum,status:"mismatch",size:o,description:s.description}:{name:n,checksum:i,expectedChecksum:s.checksum,status:"valid",size:o,description:s.description}:{name:n,checksum:i,status:"unknown",size:o}}assertValid(t,r){let n=this.validateArchive(t,r);if(n.status==="mismatch")throw new dr(n);return n}normalizePakName(t){let r=ae(t),n=r.split("/"),i=n.pop()??r,o=n.pop();return o?`${i}@${o}`:i}};var Pt=class extends Error{constructor(r,n){super(`Failed to ingest PAK: ${r}`);this.file=r;this.name="PakIngestionError",n instanceof Error&&n.stack&&(this.stack=n.stack),this.cause=n}};async function jf(e,t){if(typeof e.arrayBuffer=="function"){let r=await e.arrayBuffer();return t?.({file:"blob",loadedBytes:r.byteLength,totalBytes:r.byteLength,state:"reading"}),r}if(typeof FileReader<"u")return new Promise((r,n)=>{let i=new FileReader;i.onerror=()=>n(i.error??new Error("Unknown FileReader error")),i.onprogress=o=>{t?.({file:"blob",loadedBytes:o.loaded,totalBytes:o.total||e.size,state:"reading"})},i.onload=()=>{let o=i.result;o instanceof ArrayBuffer?r(o):n(new Error("Unexpected FileReader result"))},i.readAsArrayBuffer(e)});if(typeof Response<"u"){let r=await new Response(e).arrayBuffer();return t?.({file:"blob",loadedBytes:r.byteLength,totalBytes:r.byteLength,state:"reading"}),r}if(typeof e.stream=="function"){let r=e.stream().getReader(),n=[],i=0;for(;;){let{done:a,value:d}=await r.read();if(a)break;if(!d)continue;let l=d;n.push(l),i+=l.byteLength,t?.({file:"blob",loadedBytes:i,totalBytes:e.size,state:"reading"})}let o=new Uint8Array(i),s=0;for(let a of n)o.set(a,s),s+=a.byteLength;return o.buffer}throw new Pt("blob",new Error("Unsupported Blob type"))}async function Qf(e,t){if(e.data instanceof ArrayBuffer)return t?.({file:e.name,loadedBytes:e.data.byteLength,totalBytes:e.data.byteLength,state:"reading"}),e.data;if(e.data instanceof Blob){let n=e.data.size;return jf(e.data,i=>t?.({...i,file:e.name,totalBytes:n}))}let r=e.data.buffer.slice(e.data.byteOffset,e.data.byteOffset+e.data.byteLength);return t?.({file:e.name,loadedBytes:r.byteLength,totalBytes:r.byteLength,state:"reading"}),r}async function Ro(e,t,r){let n=typeof r=="function"?{onProgress:r}:r??{},i=n.persistIndexes??!!n.pakIndexStore,o=n.enforceValidation??!!n.validator,s=n.allowUnknownPaks??!0,a=n.stopOnError??!1,d=[];for(let l of t)try{let c=await Qf(l,n.onProgress),h=Xr.fromArrayBuffer(l.name,c),u=n.validator?.validateArchive(h);if(u){n.onValidationResult?.(u);let f=u.status==="mismatch",m=u.status==="unknown";if(f&&o||m&&!s){let g=new dr(u);if(n.onError?.(l.name,g),a)throw new Pt(l.name,g);d.push({archive:h,mounted:!1,validation:u});continue}}if(e.mountPak(h),i&&n.pakIndexStore)try{await n.pakIndexStore.persist(h)}catch(f){if(n.onError?.(l.name,f),a)throw new Pt(l.name,f)}n.onProgress?.({file:l.name,loadedBytes:c.byteLength,totalBytes:c.byteLength,state:"parsed"}),d.push({archive:h,mounted:!0,validation:u})}catch(c){if(n.onProgress?.({file:l.name,loadedBytes:0,totalBytes:0,state:"error"}),n.onError?.(l.name,c),a)throw new Pt(l.name,c)}return d}var Ft=class{constructor(t){this.capacity=t;this.map=new Map;if(t<=0)throw new RangeError("LRU cache capacity must be greater than zero")}get size(){return this.map.size}has(t){return this.map.has(t)}get(t){let r=this.map.get(t);if(r!==void 0)return this.map.delete(t),this.map.set(t,r),r}set(t,r){if(this.map.has(t)&&this.map.delete(t),this.map.set(t,r),this.map.size>this.capacity){let n=this.map.keys().next();n.done||this.map.delete(n.value)}}delete(t){return this.map.delete(t)}clear(){this.map.clear()}entries(){return Array.from(this.map.entries()).reverse().map(([t,r])=>({key:t,value:r}))}};function Jf(e){return Array.isArray(e)?e:Array.from(e)}function ka(e){return Jf(e).map(t=>({name:t.name,data:t}))}async function Wc(e,t,r){let n=ka(t);return Ro(e,n,r??{})}function Xc(e,t){let r=i=>{i.preventDefault(),i.dataTransfer?.dropEffect&&(i.dataTransfer.dropEffect="copy")},n=i=>{i.preventDefault();let o=i.dataTransfer?.files;o&&o.length>0&&t(Array.from(o))};return e.addEventListener("dragover",r),e.addEventListener("drop",n),()=>{e.removeEventListener("dragover",r),e.removeEventListener("drop",n)}}function Kc(e,t){let r=n=>{let i=n.target;!i||!i.files||i.files.length===0||(t(i.files),i.value="")};return e.addEventListener("change",r),()=>e.removeEventListener("change",r)}var eh="IBSP",th=38,Zc=19,rh=8+Zc*8;var j=class extends Error{},Kr=class{constructor(t){this.vfs=t}async load(t){let r=await this.vfs.readFile(t),n=new Uint8Array(r.byteLength);return n.set(r),Da(n.buffer)}};function Da(e){if(e.byteLength<rh)throw new j("BSP too small to contain header");let t=new DataView(e),r=String.fromCharCode(t.getUint8(0),t.getUint8(1),t.getUint8(2),t.getUint8(3));if(r!==eh)throw new j(`Invalid BSP magic ${r}`);let n=t.getInt32(4,!0);if(n!==th)throw new j(`Unsupported BSP version ${n}`);let i=new Map;for(let v=0;v<Zc;v+=1){let E=t.getInt32(8+v*8,!0),L=t.getInt32(12+v*8,!0);if(E<0||L<0||E+L>e.byteLength)throw new j(`Invalid lump bounds for index ${v}`);i.set(v,{offset:E,length:L})}let o={version:n,lumps:i},s=ih(e,i.get(0)),a=sh(e,i.get(1)),d=ah(e,i.get(2)),l=lh(e,i.get(4)),c=ch(e,i.get(5)),h=dh(e,i.get(6)),u=new Uint8Array(e,i.get(7).offset,i.get(7).length),f=_h(h,i.get(7)),m=uh(e,i.get(8)),g=fh(e,i.get(11)),p=hh(e,i.get(12)),x=mh(e,i.get(13)),S=ph(e,i.get(14)),_=gh(e,i.get(15)),y=yh(e,i.get(9),i.get(10),m),b=xh(e,i.get(3));return{header:o,entities:s,planes:a,vertices:d,nodes:l,texInfo:c,faces:h,lightMaps:u,lightMapInfo:f,leafs:m,leafLists:y,edges:g,surfEdges:p,models:x,brushes:S,brushSides:_,visibility:b,pickEntity(v){let E=null,L=1/0;for(let w of s.entities){let T=w.properties.model;if(!T||!T.startsWith("*"))continue;let z=parseInt(T.substring(1),10);if(isNaN(z)||z<0||z>=x.length)continue;let U=x[z],C=nh(v.origin,v.direction,U.mins,U.maxs);C!==null&&C<L&&(L=C,E={entity:w,model:U,distance:C})}return E}}}function nh(e,t,r,n){let i=0,o=1/0;for(let s=0;s<3;s++)if(Math.abs(t[s])<1e-8){if(e[s]<r[s]||e[s]>n[s])return null}else{let a=1/t[s],d=(r[s]-e[s])*a,l=(n[s]-e[s])*a;if(d>l){let c=d;d=l,l=c}if(i=Math.max(i,d),o=Math.min(o,l),i>o)return null}return i}function ih(e,t){let r=new TextDecoder().decode(new Uint8Array(e,t.offset,t.length)),n=oh(r),i=n.find(o=>o.classname==="worldspawn");return{raw:r,entities:n,worldspawn:i,getUniqueClassnames(){let o=new Set;for(let s of n)s.classname&&o.add(s.classname);return Array.from(o).sort()}}}function oh(e){let t=[],r=/\{([^}]*)\}/gms,n;for(;(n=r.exec(e))!==null;){let i=n[1],o={},s=/"([^\"]*)"\s+"([^\"]*)"/g,a;for(;(a=s.exec(i))!==null;)o[a[1]]=a[2];t.push({classname:o.classname,properties:o})}return t}function sh(e,t){let r=new DataView(e,t.offset,t.length),n=t.length/20;if(n%1!==0)throw new j("Plane lump has invalid length");let i=[];for(let o=0;o<n;o+=1){let s=[r.getFloat32(o*20,!0),r.getFloat32(o*20+4,!0),r.getFloat32(o*20+8,!0)],a=r.getFloat32(o*20+12,!0),d=r.getInt32(o*20+16,!0);i.push({normal:s,dist:a,type:d})}return i}function ah(e,t){let r=new DataView(e,t.offset,t.length),n=t.length/12;if(n%1!==0)throw new j("Vertex lump has invalid length");let i=[];for(let o=0;o<n;o+=1)i.push([r.getFloat32(o*12,!0),r.getFloat32(o*12+4,!0),r.getFloat32(o*12+8,!0)]);return i}function lh(e,t){let r=new DataView(e,t.offset,t.length),n=28,i=t.length/n;if(i%1!==0)throw new j("Node lump has invalid length");let o=[];for(let s=0;s<i;s+=1){let a=s*n,d=r.getInt32(a,!0),l=[r.getInt32(a+4,!0),r.getInt32(a+8,!0)],c=[r.getInt16(a+12,!0),r.getInt16(a+14,!0),r.getInt16(a+16,!0)],h=[r.getInt16(a+18,!0),r.getInt16(a+20,!0),r.getInt16(a+22,!0)],u=r.getUint16(a+24,!0),f=r.getUint16(a+26,!0);o.push({planeIndex:d,children:l,mins:c,maxs:h,firstFace:u,numFaces:f})}return o}function ch(e,t){let r=new DataView(e,t.offset,t.length),n=76,i=t.length/n;if(i%1!==0)throw new j("TexInfo lump has invalid length");let o=[];for(let s=0;s<i;s+=1){let a=s*n,d=[r.getFloat32(a,!0),r.getFloat32(a+4,!0),r.getFloat32(a+8,!0)],l=r.getFloat32(a+12,!0),c=[r.getFloat32(a+16,!0),r.getFloat32(a+20,!0),r.getFloat32(a+24,!0)],h=r.getFloat32(a+28,!0),u=r.getInt32(a+32,!0),f=r.getInt32(a+36,!0),m=new Uint8Array(e,t.offset+a+40,32),g=new TextDecoder("utf-8").decode(m).replace(/\0.*$/,""),p=r.getInt32(a+72,!0);o.push({s:d,sOffset:l,t:c,tOffset:h,flags:u,value:f,texture:g,nextTexInfo:p})}return o}function dh(e,t){let r=new DataView(e,t.offset,t.length),n=20,i=t.length/n;if(i%1!==0)throw new j("Face lump has invalid length");let o=[];for(let s=0;s<i;s+=1){let a=s*n,d=r.getUint16(a,!0),l=r.getInt16(a+2,!0),c=r.getInt32(a+4,!0),h=r.getInt16(a+8,!0),u=r.getInt16(a+10,!0),f=[r.getUint8(a+12),r.getUint8(a+13),r.getUint8(a+14),r.getUint8(a+15)],m=r.getInt32(a+16,!0);o.push({planeIndex:d,side:l,firstEdge:c,numEdges:h,texInfo:u,styles:f,lightOffset:m})}return o}function uh(e,t){let r=new DataView(e,t.offset,t.length),n=28,i=t.length/n;if(i%1!==0)throw new j("Leaf lump has invalid length");let o=[];for(let s=0;s<i;s+=1){let a=s*n,d=r.getInt32(a,!0),l=r.getInt16(a+4,!0),c=r.getInt16(a+6,!0),h=[r.getInt16(a+8,!0),r.getInt16(a+10,!0),r.getInt16(a+12,!0)],u=[r.getInt16(a+14,!0),r.getInt16(a+16,!0),r.getInt16(a+18,!0)],f=r.getUint16(a+20,!0),m=r.getUint16(a+22,!0),g=r.getUint16(a+24,!0),p=r.getUint16(a+26,!0);o.push({contents:d,cluster:l,area:c,mins:h,maxs:u,firstLeafFace:f,numLeafFaces:m,firstLeafBrush:g,numLeafBrushes:p})}return o}function fh(e,t){let r=new DataView(e,t.offset,t.length),n=4,i=t.length/n;if(i%1!==0)throw new j("Edge lump has invalid length");let o=[];for(let s=0;s<i;s+=1){let a=s*n;o.push({vertices:[r.getUint16(a,!0),r.getUint16(a+2,!0)]})}return o}function hh(e,t){let r=t.length/4;if(r%1!==0)throw new j("SurfEdge lump has invalid length");let n=new DataView(e,t.offset,t.length),i=new Int32Array(r);for(let o=0;o<r;o+=1)i[o]=n.getInt32(o*4,!0);return i}function mh(e,t){let r=new DataView(e,t.offset,t.length),n=48;if(t.length%n!==0)throw new j("Model lump has invalid length");let i=t.length/n,o=[];for(let s=0;s<i;s+=1){let a=s*n,d=[r.getFloat32(a,!0),r.getFloat32(a+4,!0),r.getFloat32(a+8,!0)],l=[r.getFloat32(a+12,!0),r.getFloat32(a+16,!0),r.getFloat32(a+20,!0)],c=[r.getFloat32(a+24,!0),r.getFloat32(a+28,!0),r.getFloat32(a+32,!0)],h=r.getInt32(a+36,!0),u=r.getInt32(a+40,!0),f=r.getInt32(a+44,!0);o.push({mins:d,maxs:l,origin:c,headNode:h,firstFace:u,numFaces:f})}return o}function ph(e,t){let r=new DataView(e,t.offset,t.length),n=12,i=t.length/n;if(i%1!==0)throw new j("Brush lump has invalid length");let o=[];for(let s=0;s<i;s+=1){let a=s*n;o.push({firstSide:r.getInt32(a,!0),numSides:r.getInt32(a+4,!0),contents:r.getInt32(a+8,!0)})}return o}function gh(e,t){let r=new DataView(e,t.offset,t.length),n=4,i=t.length/n;if(i%1!==0)throw new j("Brush side lump has invalid length");let o=[];for(let s=0;s<i;s+=1){let a=s*n;o.push({planeIndex:r.getUint16(a,!0),texInfo:r.getInt16(a+2,!0)})}return o}function yh(e,t,r,n){let i=[],o=[],s=t.length/2,a=r.length/2,d=new DataView(e,t.offset,t.length),l=new DataView(e,r.offset,r.length);for(let c of n){if(c.firstLeafFace+c.numLeafFaces>s)throw new j("Leaf faces reference data past lump bounds");if(c.firstLeafBrush+c.numLeafBrushes>a)throw new j("Leaf brushes reference data past lump bounds");let h=[];for(let f=0;f<c.numLeafFaces;f+=1)h.push(d.getUint16((c.firstLeafFace+f)*2,!0));let u=[];for(let f=0;f<c.numLeafBrushes;f+=1)u.push(l.getUint16((c.firstLeafBrush+f)*2,!0));i.push(h),o.push(u)}return{leafFaces:i,leafBrushes:o}}function xh(e,t){if(t.length===0)return;if(t.length<4)throw new j("Visibility lump too small");let r=new DataView(e,t.offset,t.length),n=r.getInt32(0,!0),i=4+n*8;if(n<0||i>t.length)throw new j("Visibility lump truncated");let o=4,s=[];for(let a=0;a<n;a+=1){let d=r.getInt32(o,!0),l=r.getInt32(o+4,!0);o+=8;let c=t.offset+d,h=t.offset+l,u=t.offset+t.length;if(d<0||l<0||c>=u||h>=u)throw new j("Visibility offsets out of range");s.push({pvs:$c(e,c,n,t),phs:$c(e,h,n,t)})}return{numClusters:n,clusters:s}}function $c(e,t,r,n){let i=Math.ceil(r/8),o=new Uint8Array(i),s=new Uint8Array(e),a=t,d=0,l=n.offset+n.length;for(;d<i;){if(a>=l)throw new j("Visibility data truncated");let c=s[a++];if(c!==0){o[d++]=c;continue}if(a>=l)throw new j("Visibility run exceeds lump bounds");let h=s[a++];for(let u=0;u<h&&d<i;u+=1)o[d++]=0}return o}function _h(e,t){return e.map(r=>{if(!(r.lightOffset<0))return{offset:r.lightOffset,length:Math.max(0,t.length-r.lightOffset)}})}function Co(e,t,r){if(e.lightOffset<0||e.lightOffset>=t.byteLength)return;let n=t.byteLength-e.lightOffset,i=Math.min(r?.length??n,n);if(!(i<=0))return t.subarray(e.lightOffset,e.lightOffset+i)}var bh=844121161,vh=8,Yc=68,Sh=[{x:-.525731,y:0,z:.850651},{x:-.442863,y:.238856,z:.864188},{x:-.295242,y:0,z:.955423},{x:-.309017,y:.5,z:.809017},{x:-.16246,y:.262866,z:.951056},{x:0,y:0,z:1},{x:0,y:.850651,z:.525731},{x:-.147621,y:.716567,z:.681718},{x:.147621,y:.716567,z:.681718},{x:0,y:.525731,z:.850651},{x:.309017,y:.5,z:.809017},{x:.525731,y:0,z:.850651},{x:.295242,y:0,z:.955423},{x:.442863,y:.238856,z:.864188},{x:.16246,y:.262866,z:.951056},{x:-.681718,y:.147621,z:.716567},{x:-.809017,y:.309017,z:.5},{x:-.587785,y:.425325,z:.688191},{x:-.850651,y:.525731,z:0},{x:-.864188,y:.442863,z:.238856},{x:-.716567,y:.681718,z:.147621},{x:-.688191,y:.587785,z:.425325},{x:-.5,y:.809017,z:.309017},{x:-.238856,y:.864188,z:.442863},{x:-.425325,y:.688191,z:.587785},{x:-.716567,y:.681718,z:-.147621},{x:-.5,y:.809017,z:-.309017},{x:-.525731,y:.850651,z:0},{x:0,y:.850651,z:-.525731},{x:-.238856,y:.864188,z:-.442863},{x:0,y:.955423,z:-.295242},{x:-.262866,y:.951056,z:-.16246},{x:0,y:1,z:0},{x:0,y:.955423,z:.295242},{x:-.262866,y:.951056,z:.16246},{x:.238856,y:.864188,z:.442863},{x:.262866,y:.951056,z:.16246},{x:.5,y:.809017,z:.309017},{x:.238856,y:.864188,z:-.442863},{x:.262866,y:.951056,z:-.16246},{x:.5,y:.809017,z:-.309017},{x:.850651,y:.525731,z:0},{x:.716567,y:.681718,z:.147621},{x:.716567,y:.681718,z:-.147621},{x:.525731,y:.850651,z:0},{x:.425325,y:.688191,z:.587785},{x:.864188,y:.442863,z:.238856},{x:.688191,y:.587785,z:.425325},{x:.809017,y:.309017,z:.5},{x:.681718,y:.147621,z:.716567},{x:.587785,y:.425325,z:.688191},{x:.955423,y:.295242,z:0},{x:1,y:0,z:0},{x:.951056,y:.16246,z:.262866},{x:.850651,y:-.525731,z:0},{x:.955423,y:-.295242,z:0},{x:.864188,y:-.442863,z:.238856},{x:.951056,y:-.16246,z:.262866},{x:.809017,y:-.309017,z:.5},{x:.681718,y:-.147621,z:.716567},{x:.850651,y:0,z:.525731},{x:.864188,y:.442863,z:-.238856},{x:.809017,y:.309017,z:-.5},{x:.951056,y:.16246,z:-.262866},{x:.525731,y:0,z:-.850651},{x:.681718,y:.147621,z:-.716567},{x:.681718,y:-.147621,z:-.716567},{x:.850651,y:0,z:-.525731},{x:.809017,y:-.309017,z:-.5},{x:.864188,y:-.442863,z:-.238856},{x:.951056,y:-.16246,z:-.262866},{x:.147621,y:.716567,z:-.681718},{x:.309017,y:.5,z:-.809017},{x:.425325,y:.688191,z:-.587785},{x:.442863,y:.238856,z:-.864188},{x:.587785,y:.425325,z:-.688191},{x:.688191,y:.587785,z:-.425325},{x:-.147621,y:.716567,z:-.681718},{x:-.309017,y:.5,z:-.809017},{x:0,y:.525731,z:-.850651},{x:-.525731,y:0,z:-.850651},{x:-.442863,y:.238856,z:-.864188},{x:-.295242,y:0,z:-.955423},{x:-.16246,y:.262866,z:-.951056},{x:0,y:0,z:-1},{x:.295242,y:0,z:-.955423},{x:.16246,y:.262866,z:-.951056},{x:-.442863,y:-.238856,z:-.864188},{x:-.309017,y:-.5,z:-.809017},{x:-.16246,y:-.262866,z:-.951056},{x:0,y:-.850651,z:-.525731},{x:-.147621,y:-.716567,z:-.681718},{x:.147621,y:-.716567,z:-.681718},{x:0,y:-.525731,z:-.850651},{x:.309017,y:-.5,z:-.809017},{x:.442863,y:-.238856,z:-.864188},{x:.16246,y:-.262866,z:-.951056},{x:.238856,y:-.864188,z:-.442863},{x:.5,y:-.809017,z:-.309017},{x:.425325,y:-.688191,z:-.587785},{x:.716567,y:-.681718,z:-.147621},{x:.688191,y:-.587785,z:-.425325},{x:.587785,y:-.425325,z:-.688191},{x:0,y:-.955423,z:-.295242},{x:0,y:-1,z:0},{x:.262866,y:-.951056,z:-.16246},{x:0,y:-.850651,z:.525731},{x:0,y:-.955423,z:.295242},{x:.238856,y:-.864188,z:.442863},{x:.262866,y:-.951056,z:.16246},{x:.5,y:-.809017,z:.309017},{x:.716567,y:-.681718,z:.147621},{x:.525731,y:-.850651,z:0},{x:-.238856,y:-.864188,z:-.442863},{x:-.5,y:-.809017,z:-.309017},{x:-.262866,y:-.951056,z:-.16246},{x:-.850651,y:-.525731,z:0},{x:-.716567,y:-.681718,z:-.147621},{x:-.716567,y:-.681718,z:.147621},{x:-.525731,y:-.850651,z:0},{x:-.5,y:-.809017,z:.309017},{x:-.238856,y:-.864188,z:.442863},{x:-.262866,y:-.951056,z:.16246},{x:-.864188,y:-.442863,z:.238856},{x:-.809017,y:-.309017,z:.5},{x:-.688191,y:-.587785,z:.425325},{x:-.681718,y:-.147621,z:.716567},{x:-.442863,y:-.238856,z:.864188},{x:-.587785,y:-.425325,z:.688191},{x:-.309017,y:-.5,z:.809017},{x:-.147621,y:-.716567,z:.681718},{x:-.425325,y:-.688191,z:.587785},{x:-.16246,y:-.262866,z:.951056},{x:.442863,y:-.238856,z:.864188},{x:.16246,y:-.262866,z:.951056},{x:.309017,y:-.5,z:.809017},{x:.147621,y:-.716567,z:.681718},{x:0,y:-.525731,z:.850651},{x:.425325,y:-.688191,z:.587785},{x:.587785,y:-.425325,z:.688191},{x:.688191,y:-.587785,z:.425325},{x:-.955423,y:.295242,z:0},{x:-.951056,y:.16246,z:.262866},{x:-1,y:0,z:0},{x:-.850651,y:0,z:.525731},{x:-.955423,y:-.295242,z:0},{x:-.951056,y:-.16246,z:.262866},{x:-.864188,y:.442863,z:-.238856},{x:-.951056,y:.16246,z:-.262866},{x:-.809017,y:.309017,z:-.5},{x:-.864188,y:-.442863,z:-.238856},{x:-.951056,y:-.16246,z:-.262866},{x:-.809017,y:-.309017,z:-.5},{x:-.681718,y:.147621,z:-.716567},{x:-.681718,y:-.147621,z:-.716567},{x:-.850651,y:0,z:-.525731},{x:-.688191,y:.587785,z:-.425325},{x:-.587785,y:.425325,z:-.688191},{x:-.425325,y:.688191,z:-.587785},{x:-.425325,y:-.688191,z:-.587785},{x:-.587785,y:-.425325,z:-.688191},{x:-.688191,y:-.587785,z:-.425325}],me=class extends Error{},$r=class{constructor(t){this.vfs=t;this.cache=new Map}async load(t){if(this.cache.has(t))return this.cache.get(t);let r=await this.vfs.readFile(t),n=new Uint8Array(r.byteLength);n.set(r);let i=Oa(n.buffer);return this.cache.set(t,i),i}get(t){return this.cache.get(t)}};function qc(e,t,r){let n=[];for(let i=0;i<r;i+=1){let o=e.getUint8(t+i);if(o===0)break;n.push(o)}return String.fromCharCode(...n)}function Vn(e,t,r,n){if(r!==0&&(t<Yc||t+r>e.byteLength))throw new me(`${n} section is out of bounds`)}function wh(e){if(e.byteLength<Yc)throw new me("MD2 buffer too small to contain header");let t=new DataView(e),r=t.getInt32(0,!0),n=t.getInt32(4,!0);if(r!==bh)throw new me(`Invalid MD2 ident: ${r}`);if(n!==vh)throw new me(`Unsupported MD2 version: ${n}`);let i={ident:r,version:n,skinWidth:t.getInt32(8,!0),skinHeight:t.getInt32(12,!0),frameSize:t.getInt32(16,!0),numSkins:t.getInt32(20,!0),numVertices:t.getInt32(24,!0),numTexCoords:t.getInt32(28,!0),numTriangles:t.getInt32(32,!0),numGlCommands:t.getInt32(36,!0),numFrames:t.getInt32(40,!0),offsetSkins:t.getInt32(44,!0),offsetTexCoords:t.getInt32(48,!0),offsetTriangles:t.getInt32(52,!0),offsetFrames:t.getInt32(56,!0),offsetGlCommands:t.getInt32(60,!0),offsetEnd:t.getInt32(64,!0),magic:r},o=40+i.numVertices*4;if(i.frameSize!==o)throw new me(`Unexpected frame size ${i.frameSize}, expected ${o}`);if(i.offsetEnd>e.byteLength)throw new me("MD2 offset_end exceeds buffer length");return i}function Ah(e,t){let r=t.numSkins*64;Vn(e,t.offsetSkins,r,"skins");let n=new DataView(e,t.offsetSkins,r),i=[];for(let o=0;o<t.numSkins;o+=1)i.push({name:qc(n,o*64,64)});return i}function Mh(e,t){let r=t.numTexCoords*4;Vn(e,t.offsetTexCoords,r,"texcoords");let n=new DataView(e,t.offsetTexCoords,r),i=[];for(let o=0;o<t.numTexCoords;o+=1){let s=o*4;i.push({s:n.getInt16(s,!0),t:n.getInt16(s+2,!0)})}return i}function Eh(e,t){let r=t.numTriangles*12;Vn(e,t.offsetTriangles,r,"triangles");let n=new DataView(e,t.offsetTriangles,r),i=[];for(let o=0;o<t.numTriangles;o+=1){let s=o*12,a=[n.getUint16(s,!0),n.getUint16(s+2,!0),n.getUint16(s+4,!0)],d=[n.getUint16(s+6,!0),n.getUint16(s+8,!0),n.getUint16(s+10,!0)];if(a.some(l=>l>=t.numVertices)||d.some(l=>l>=t.numTexCoords))throw new me("Triangle references out of range vertex or texcoord");i.push({vertexIndices:a,texCoordIndices:d})}return i}function Lh(e,t){let r=t.numFrames*t.frameSize;Vn(e,t.offsetFrames,r,"frames");let n=[];for(let i=0;i<t.numFrames;i+=1){let o=t.offsetFrames+i*t.frameSize,s=new DataView(e,o,t.frameSize),a={x:s.getFloat32(0,!0),y:s.getFloat32(4,!0),z:s.getFloat32(8,!0)},d={x:s.getFloat32(12,!0),y:s.getFloat32(16,!0),z:s.getFloat32(20,!0)},l=qc(s,24,16),c=[],h=1/0,u=1/0,f=1/0,m=-1/0,g=-1/0,p=-1/0;for(let x=0;x<t.numVertices;x+=1){let S=40+x*4,_=s.getUint8(S)*a.x+d.x,y=s.getUint8(S+1)*a.y+d.y,b=s.getUint8(S+2)*a.z+d.z;_<h&&(h=_),y<u&&(u=y),b<f&&(f=b),_>m&&(m=_),y>g&&(g=y),b>p&&(p=b);let A={x:_,y,z:b},v=s.getUint8(S+3),E=Sh[v];if(!E)throw new me(`Invalid normal index ${v} in frame ${l}`);c.push({position:A,normalIndex:v,normal:E})}n.push({name:l,vertices:c,minBounds:{x:h,y:u,z:f},maxBounds:{x:m,y:g,z:p}})}return n}function Th(e,t){let r=t.numGlCommands*4;if(Vn(e,t.offsetGlCommands,r,"gl commands"),r===0)return[];let n=new DataView(e,t.offsetGlCommands,r),i=[],o=0;for(;;){if(o+4>r)throw new me("GL command list ended unexpectedly");let s=n.getInt32(o,!0);if(o+=4,s===0)break;let a=Math.abs(s),d=[],l=a*12;if(o+l>r)throw new me("GL command vertex block exceeds buffer");for(let c=0;c<a;c+=1){let h=n.getFloat32(o,!0),u=n.getFloat32(o+4,!0),f=n.getInt32(o+8,!0);if(o+=12,f<0||f>=t.numVertices)throw new me("GL command references invalid vertex index");d.push({s:h,t:u,vertexIndex:f})}i.push({mode:s>0?"strip":"fan",vertices:d})}if(o!==r)throw new me("GL command list did not consume expected data");return i}function Oa(e){let t=wh(e),r=Ah(e,t),n=Mh(e,t),i=Eh(e,t),o=Lh(e,t),s=Th(e,t);return{header:t,skins:r,texCoords:n,triangles:i,frames:o,glCommands:s}}function jc(e){let t=[],r=0;for(;r<e.length;){let n=e[r].name,i=n.replace(/\d+$/,"")||n,o=r;for(;o+1<e.length&&(e[o+1].name.replace(/\d+$/,"")||e[o+1].name)===i;)o+=1;t.push({name:i,firstFrame:r,lastFrame:o}),r=o+1}return t}var Qc=860898377,Ih=15,Ge=class extends Error{constructor(t){super(t),this.name="Md3ParseError"}};function Gn(e,t,r){let n=new Uint8Array(e.buffer,e.byteOffset+t,r);return new TextDecoder("utf-8").decode(n).replace(/\0.*$/,"").trim()}function Rh(e){let t=(e>>8&255)*(2*Math.PI/255),r=(e&255)*(2*Math.PI/255),n=Math.sin(r);return{x:Math.cos(t)*n,y:Math.sin(t)*n,z:Math.cos(r)}}function zo(e,t,r,n){if(t<0||t+r>n)throw new Ge(`${e} exceeds buffer bounds`)}function Ch(e){let t=e.getInt32(0,!0);if(t!==Qc)throw new Ge(`Invalid MD3 ident: ${t}`);let r=e.getInt32(4,!0);if(r!==Ih)throw new Ge(`Unsupported MD3 version: ${r}`);let n=Gn(e,8,64),i=e.getInt32(72,!0),o=e.getInt32(76,!0),s=e.getInt32(80,!0),a=e.getInt32(84,!0),d=e.getInt32(88,!0),l=e.getInt32(92,!0),c=e.getInt32(96,!0),h=e.getInt32(100,!0),u=e.getInt32(104,!0);if(o<=0||a<0||s<0)throw new Ge("Invalid MD3 counts");return{ident:t,version:r,name:n,flags:i,numFrames:o,numTags:s,numSurfaces:a,numSkins:d,ofsFrames:l,ofsTags:c,ofsSurfaces:h,ofsEnd:u,magic:t}}function zh(e,t){let r=[];zo("Frames",t.ofsFrames,t.numFrames*56,e.byteLength);for(let i=0;i<t.numFrames;i+=1){let o=t.ofsFrames+i*56;r.push({minBounds:{x:e.getFloat32(o,!0),y:e.getFloat32(o+4,!0),z:e.getFloat32(o+8,!0)},maxBounds:{x:e.getFloat32(o+12,!0),y:e.getFloat32(o+16,!0),z:e.getFloat32(o+20,!0)},localOrigin:{x:e.getFloat32(o+24,!0),y:e.getFloat32(o+28,!0),z:e.getFloat32(o+32,!0)},radius:e.getFloat32(o+36,!0),name:Gn(e,o+40,16)})}return r}function kh(e,t){let r=[],i=t.numFrames*t.numTags*112;zo("Tags",t.ofsTags,i,e.byteLength);for(let o=0;o<t.numFrames;o+=1){let s=[];for(let a=0;a<t.numTags;a+=1){let d=t.ofsTags+(o*t.numTags+a)*112,l=d+64,c=l+12;s.push({name:Gn(e,d,64),origin:{x:e.getFloat32(l,!0),y:e.getFloat32(l+4,!0),z:e.getFloat32(l+8,!0)},axis:[{x:e.getFloat32(c,!0),y:e.getFloat32(c+4,!0),z:e.getFloat32(c+8,!0)},{x:e.getFloat32(c+12,!0),y:e.getFloat32(c+16,!0),z:e.getFloat32(c+20,!0)},{x:e.getFloat32(c+24,!0),y:e.getFloat32(c+28,!0),z:e.getFloat32(c+32,!0)}]})}r.push(s)}return r}function Dh(e,t){let r=e.getInt32(t,!0);if(r!==Qc)throw new Ge(`Invalid surface ident at ${t}: ${r}`);let n=Gn(e,t+4,64),i=e.getInt32(t+68,!0),o=e.getInt32(t+72,!0),s=e.getInt32(t+76,!0),a=e.getInt32(t+80,!0),d=e.getInt32(t+84,!0),l=e.getInt32(t+88,!0),c=e.getInt32(t+92,!0),h=e.getInt32(t+96,!0),u=e.getInt32(t+100,!0),f=e.getInt32(t+104,!0);if(o<=0||a<=0||d<=0)throw new Ge(`Invalid surface counts for ${n}`);let m=f;zo(`Surface ${n}`,t,m,e.byteLength);let g=[],p=t+l;for(let v=0;v<d;v+=1){let E=p+v*12;g.push({indices:[e.getInt32(E,!0),e.getInt32(E+4,!0),e.getInt32(E+8,!0)]})}let x=[],S=t+c;for(let v=0;v<s;v+=1){let E=S+v*68;x.push({name:Gn(e,E,64),shaderIndex:e.getInt32(E+64,!0)})}let _=[],y=t+h;for(let v=0;v<a;v+=1){let E=y+v*8;_.push({s:e.getFloat32(E,!0),t:e.getFloat32(E+4,!0)})}let b=[],A=t+u;for(let v=0;v<o;v+=1){let E=[];for(let L=0;L<a;L+=1){let w=A+(v*a+L)*8,T=e.getInt16(w,!0)/64,z=e.getInt16(w+2,!0)/64,U=e.getInt16(w+4,!0)/64,C=e.getUint16(w+6,!0);E.push({position:{x:T,y:z,z:U},latLng:C,normal:Rh(C)})}b.push(E)}return{surface:{name:n,flags:i,numFrames:o,shaders:x,triangles:g,texCoords:_,vertices:b},nextOffset:t+f}}function Pa(e){if(e.byteLength<108)throw new Ge("MD3 buffer too small for header");let t=new DataView(e),r=Ch(t);zo("MD3 end",r.ofsEnd,0,e.byteLength);let n=zh(t,r),i=kh(t,r),o=[],s=r.ofsSurfaces;for(let a=0;a<r.numSurfaces;a+=1){let{surface:d,nextOffset:l}=Dh(t,s);o.push(d),s=l}if(s!==r.ofsEnd)throw new Ge("Surface parsing did not reach ofsEnd");return{header:r,frames:n,tags:i,surfaces:o}}var Zr=class{constructor(t){this.vfs=t;this.cache=new Map}async load(t){if(this.cache.has(t))return this.cache.get(t);let r=await this.vfs.readFile(t),n=Pa(r.slice().buffer);return this.cache.set(t,n),n}get(t){return this.cache.get(t)}};var Oh=844317769,Ph=2,Jc=64,ed=12,Bt=class extends Error{};function Fh(e,t,r){let n=[];for(let i=0;i<r;i+=1){let o=e.getUint8(t+i);if(o===0)break;n.push(o)}return String.fromCharCode(...n)}function Fa(e){if(e.byteLength<ed)throw new Bt("Sprite buffer too small to contain header");let t=new DataView(e),r=t.getInt32(0,!0),n=t.getInt32(4,!0),i=t.getInt32(8,!0);if(r!==Oh)throw new Bt(`Invalid Sprite ident: ${r}`);if(n!==Ph)throw new Bt(`Unsupported Sprite version: ${n}`);let o=[],s=16+Jc,a=ed;for(let d=0;d<i;d+=1){if(a+s>e.byteLength)throw new Bt("Sprite frame data exceeds buffer length");let l=t.getInt32(a,!0),c=t.getInt32(a+4,!0),h=t.getInt32(a+8,!0),u=t.getInt32(a+12,!0),f=Fh(t,a+16,Jc);o.push({width:l,height:c,originX:h,originY:u,name:f}),a+=s}return{ident:r,version:n,numFrames:i,frames:o}}var Yr=class{constructor(t){this.vfs=t}async load(t){let r=await this.vfs.readFile(t),n=new Uint8Array(r.byteLength);return n.set(r),Fa(n.buffer)}};function td(e,t){let r=(e.sequence.end-e.sequence.start+1)/e.sequence.fps,n=e.sequence.loop!==!1,i=e.time+t;return n?i=(i%r+r)%r:i>r&&(i=r),{...e,time:Math.max(0,Math.min(i,r))}}function rd(e){let t=e.sequence.end-e.sequence.start+1,r=1/e.sequence.fps,n=e.sequence.loop!==!1,i=e.time/r;if(!n&&i>=t)return{frame0:e.sequence.end,frame1:e.sequence.end,lerp:0};let o=n?i%t:Math.min(i,t-1),s=Math.floor(o),a=e.sequence.start+s,d=s+1>=t?n?e.sequence.start:e.sequence.end:a+1,l=!n&&s>=t-1?0:o-s;return{frame0:a,frame1:d,lerp:l}}function nd(e){return{sequence:e,time:0}}function id(e,t,r){return{x:e.x+(t.x-e.x)*r,y:e.y+(t.y-e.y)*r,z:e.z+(t.z-e.z)*r}}var Wn=class extends Error{constructor(t){super(t),this.name="WalParseError"}};function ko(e){if(e.byteLength<100)throw new Wn("WAL buffer too small");let t=new DataView(e),r=new Uint8Array(e,0,32),n=new TextDecoder("utf-8").decode(r).replace(/\0.*$/,"").trim(),i=t.getInt32(32,!0),o=t.getInt32(36,!0),s=[t.getInt32(40,!0),t.getInt32(44,!0),t.getInt32(48,!0),t.getInt32(52,!0)],a=new Uint8Array(e,56,32),d=new TextDecoder("utf-8").decode(a).replace(/\0.*$/,"").trim(),l=t.getInt32(88,!0),c=t.getInt32(92,!0),h=t.getInt32(96,!0);if(i<=0||o<=0)throw new Wn("Invalid WAL dimensions");let u=[],f=i,m=o;for(let g=0;g<s.length;g+=1){let p=s[g],x=Math.max(1,f*m|0);if(p<=0||p+x>e.byteLength)throw new Wn(`Invalid WAL mip offset for level ${g}`);let S=new Uint8Array(e,p,x);u.push({level:g,width:f,height:m,data:S}),f=Math.max(1,f>>1),m=Math.max(1,m>>1)}return{name:n,width:i,height:o,mipmaps:u,animName:d,flags:l,contents:c,value:h}}var ur=class extends Error{constructor(t){super(t),this.name="PcxParseError"}};function Xn(e){if(e.byteLength<128)throw new ur("PCX buffer too small for header");let t=new DataView(e),r=t.getUint8(0),n=t.getUint8(2),i=t.getUint8(3),o=t.getUint16(4,!0),s=t.getUint16(6,!0),a=t.getUint16(8,!0),d=t.getUint16(10,!0);if(r!==10||n!==1)throw new ur("Unsupported PCX encoding");if(i!==8)throw new ur("Only 8bpp PCX files are supported");let l=a-o+1,c=d-s+1,h=t.getUint16(66,!0),u=e.byteLength-769;if(u<128||new DataView(e,u,1).getUint8(0)!==12)throw new ur("Missing PCX palette");let f=new Uint8Array(e,u+1,768),m=new Uint8Array(e,128,u-128),g=new Uint8Array(l*c),p=0,x=0;for(let S=0;S<c;S+=1){let _=0;for(;_<h&&p<m.length;){let y=1,b=m[p++];if((b&192)===192){if(y=b&63,p>=m.length)throw new ur("Unexpected end of PCX RLE data");b=m[p++]}for(let A=0;A<y&&_<h;A+=1)_<l&&(g[x++]=b),_+=1}}return{width:l,height:c,bitsPerPixel:i,pixels:g,palette:f}}function Do(e){let t=new Uint8Array(e.width*e.height*4);for(let r=0;r<e.pixels.length;r+=1){let n=e.pixels[r],i=n*3,o=r*4;t[o]=e.palette[i],t[o+1]=e.palette[i+1],t[o+2]=e.palette[i+2],t[o+3]=n===255?0:255}return t}var yt=class extends Error{constructor(t){super(t),this.name="TgaParseError"}};function Ba(e){let t=new DataView(e);if(e.byteLength<18)throw new yt("Buffer too small for TGA header");let r=t.getUint8(0),n=t.getUint8(1),i=t.getUint8(2),o=t.getUint16(12,!0),s=t.getUint16(14,!0),a=t.getUint8(16),d=t.getUint8(17);if(i!==2&&i!==10&&i!==3&&i!==11)throw new yt(`Unsupported TGA image type: ${i} (only RGB/Grayscale supported)`);if(a!==24&&a!==32&&a!==8)throw new yt(`Unsupported pixel depth: ${a} (only 8, 24, 32 bpp supported)`);let l=i>=9,c=i===3||i===11,h=a/8,u=18+r;if(n===1){let _=t.getUint16(5,!0),y=t.getUint8(7);u+=_*(y/8)}let f=o*s,m=new Uint8Array(f*4),g=(d&32)!==0,p=0,x=new Uint8Array(e),S=_=>{if(c){let y=x[u++];m[_]=y,m[_+1]=y,m[_+2]=y,m[_+3]=255}else{let y=x[u++],b=x[u++],A=x[u++],v=a===32?x[u++]:255;m[_]=A,m[_+1]=b,m[_+2]=y,m[_+3]=v}};if(l){let _=0;for(;_<f;){if(u>=e.byteLength)throw new yt("Unexpected end of TGA RLE data");let y=x[u++],b=(y&127)+1,A=(y&128)!==0;if(_+b>f)throw new yt("TGA RLE packet exceeds image bounds");if(A){let v=c?x[u]:x[u+2],E=c?x[u]:x[u+1],L=x[u],w=c?255:a===32?x[u+3]:255;u+=h;for(let T=0;T<b;T++){let z=(_+T)*4;m[z]=v,m[z+1]=E,m[z+2]=L,m[z+3]=w}}else for(let v=0;v<b;v++)S((_+v)*4);_+=b}}else for(let _=0;_<f;_++){if(u>=e.byteLength)throw new yt("Unexpected end of TGA data");S(_*4)}if(!g){let _=o*4,y=new Uint8Array(_);for(let b=0;b<s/2;b++){let A=b*_,v=(s-1-b)*_;y.set(m.subarray(A,A+_)),m.set(m.subarray(v,v+_),A),m.set(y,v)}}return{width:o,height:s,bitsPerPixel:32,pixels:m}}var qr=class{constructor(t={}){this.cache=new Ft(t.capacity??128)}get size(){return this.cache.size}get(t){return this.cache.get(t.toLowerCase())}set(t,r){this.cache.set(t.toLowerCase(),r)}clear(){this.cache.clear()}};function Na(e,t){let r=[];for(let n of e.mipmaps){let i=new Uint8Array(n.width*n.height*4);for(let o=0;o<n.data.length;o+=1){let s=n.data[o],a=s*3,d=o*4;i[d]=t[a],i[d+1]=t[a+1],i[d+2]=t[a+2],i[d+3]=s===255?0:255}r.push({level:n.level,width:n.width,height:n.height,rgba:i})}return{width:e.width,height:e.height,levels:r,source:"wal"}}function Oo(e){let t=Do(e),r={level:0,width:e.width,height:e.height,rgba:t};return{width:e.width,height:e.height,levels:[r],source:"pcx"}}function od(e){let t={level:0,width:e.width,height:e.height,rgba:e.pixels};return{width:e.width,height:e.height,levels:[t],source:"tga"}}function Po(e,t){return Na(ko(e),t)}var fr=class extends Error{constructor(t){super(t),this.name="WavParseError"}};function Ua(e,t,r){return new TextDecoder("ascii").decode(new Uint8Array(e.buffer,e.byteOffset+t,r))}function Fo(e){if(e.byteLength<44)throw new fr("WAV buffer too small");let t=new DataView(e);if(Ua(t,0,4)!=="RIFF"||Ua(t,8,4)!=="WAVE")throw new fr("Invalid WAV header");let r=12,n=-1,i=-1,o=0,s=0;for(;r+8<=e.byteLength;){let m=Ua(t,r,4),g=t.getUint32(r+4,!0),p=r+8;m==="fmt "?(n=p,o=g):m==="data"&&(i=p,s=g),r=p+g}if(n===-1||i===-1)throw new fr("Missing fmt or data chunk");let a=t.getUint16(n,!0),d=t.getUint16(n+2,!0),l=t.getUint32(n+4,!0),c=t.getUint16(n+14,!0);if(a!==1)throw new fr("Only PCM WAV is supported");let h=c/8,u=s/(h*d),f=new Float32Array(u*d);for(let m=0;m<u;m+=1)for(let g=0;g<d;g+=1){let p=m*d+g,x=i+p*h,S=0;if(c===8)S=t.getUint8(x),f[p]=(S-128)/128;else if(c===16)S=t.getInt16(x,!0),f[p]=S/32768;else if(c===24){let _=t.getUint8(x),y=t.getUint8(x+1),b=t.getInt8(x+2);S=_|y<<8|b<<16,f[p]=S/8388608}else throw new fr(`Unsupported bitsPerSample: ${c}`)}return{sampleRate:l,channels:d,bitsPerSample:c,samples:f}}var Bh=(e,t=4294967295,r=79764919)=>{let n=new Int32Array(256),i,o,s,a=t;for(i=0;i<256;i++){for(s=i<<24,o=8;o>0;--o)s=2147483648&s?s<<1^r:s<<1;n[i]=s}for(i=0;i<e.length;i++)a=a<<8^n[255&(a>>24^e[i])];return a};var Ha=(e,t=Bh)=>{let r=p=>new Uint8Array(p.length/2).map(((x,S)=>parseInt(p.substring(2*S,2*(S+1)),16))),n=p=>r(p)[0],i=new Map;[,8364,,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,,381,,,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,,382,376].forEach(((p,x)=>i.set(p,x)));let o=new Uint8Array(e.length),s,a,d,l=!1,c=0,h=42,u=e.length>13&&e.substring(0,9)==="dynEncode",f=0;u&&(f=11,a=n(e.substring(9,f)),a<=1&&(f+=2,h=n(e.substring(11,f))),a===1&&(f+=8,d=(p=>new DataView(r(p).buffer).getInt32(0,!0))(e.substring(13,f))));let m=256-h;for(let p=f;p<e.length;p++)if(s=e.charCodeAt(p),s!==61||l){if(s===92&&p<e.length-5&&u){let x=e.charCodeAt(p+1);x!==117&&x!==85||(s=parseInt(e.substring(p+2,p+6),16),p+=5)}if(s>255){let x=i.get(s);x&&(s=x+127)}l&&(l=!1,s-=64),o[c++]=s<h&&s>0?s+m:s-h}else l=!0;let g=o.subarray(0,c);if(u&&a===1){let p=t(g);if(p!==d){let x="Decode failed crc32 validation";throw console.error("`simple-yenc`\n",x+`
|
|
1
|
+
"use strict";var Quake2Engine=(()=>{var Gu=Object.create;var bo=Object.defineProperty;var Wu=Object.getOwnPropertyDescriptor;var Xu=Object.getOwnPropertyNames;var Ku=Object.getPrototypeOf,$u=Object.prototype.hasOwnProperty;var Zu=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),pa=(e,t)=>{for(var r in t)bo(e,r,{get:t[r],enumerable:!0})},Mc=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Xu(t))!$u.call(e,i)&&i!==r&&bo(e,i,{get:()=>t[i],enumerable:!(n=Wu(t,i))||n.enumerable});return e};var Yu=(e,t,r)=>(r=e!=null?Gu(Ku(e)):{},Mc(t||!e||!e.__esModule?bo(r,"default",{value:e,enumerable:!0}):r,e)),qu=e=>Mc(bo({},"__esModule",{value:!0}),e);var ad=Zu((G_,sd)=>{"use strict";sd.exports=Worker});var gx={};pa(gx,{ATTN_IDLE:()=>Ra,ATTN_LOOP_NONE:()=>Ta,ATTN_NONE:()=>Bn,ATTN_NORM:()=>Ia,ATTN_STATIC:()=>Lo,AssetDependencyError:()=>Er,AssetDependencyTracker:()=>Ui,AssetManager:()=>gs,AudioApi:()=>Wr,AudioContextController:()=>ys,AudioRegistry:()=>pn,AudioRegistryError:()=>Fi,AudioSystem:()=>As,BSP_SURFACE_FRAGMENT_SOURCE:()=>ml,BSP_SURFACE_VERTEX_SOURCE:()=>hl,BSP_VERTEX_LAYOUT:()=>dl,BspLoader:()=>Kr,BspParseError:()=>j,BspSurfacePipeline:()=>Ts,Camera:()=>ks,Command:()=>zn,CommandRegistry:()=>Nr,ConfigStringRegistry:()=>Gr,Cvar:()=>Un,CvarRegistry:()=>Hr,DemoPlaybackController:()=>po,DemoReader:()=>Lr,EngineHost:()=>Vr,EngineRuntime:()=>Hn,FixedTimestepLoop:()=>cr,Framebuffer:()=>Es,IndexBuffer:()=>ye,LruCache:()=>Ft,MAX_SOUND_CHANNELS:()=>Fn,MD2_FRAGMENT_SHADER:()=>vl,MD2_VERTEX_SHADER:()=>bl,MD3_FRAGMENT_SHADER:()=>Rl,MD3_VERTEX_SHADER:()=>Il,Md2Loader:()=>$r,Md2MeshBuffers:()=>Rs,Md2ParseError:()=>me,Md2Pipeline:()=>Cs,Md3Loader:()=>Zr,Md3ModelMesh:()=>Ds,Md3ParseError:()=>Ge,Md3Pipeline:()=>Os,Md3SurfaceMesh:()=>Gi,MusicSystem:()=>Ms,NetworkMessageParser:()=>Fr,PARTICLE_FRAGMENT_SHADER:()=>zl,PARTICLE_VERTEX_SHADER:()=>Cl,PROTOCOL_VERSION_RERELEASE:()=>qs,PakArchive:()=>Xr,PakIndexStore:()=>ps,PakIngestionError:()=>Pt,PakParseError:()=>Ve,PakValidationError:()=>dr,PakValidator:()=>Io,ParticleRenderer:()=>Fs,ParticleSystem:()=>Ps,PlaybackState:()=>ma,RERELEASE_KNOWN_PAKS:()=>za,SKYBOX_FRAGMENT_SHADER:()=>xl,SKYBOX_VERTEX_SHADER:()=>yl,SOUND_FULLVOLUME:()=>Dt,SOUND_LOOP_ATTENUATE:()=>Ca,ShaderProgram:()=>Ee,SkyboxPipeline:()=>Is,SoundChannel:()=>ot,SoundPrecache:()=>bs,SoundRegistry:()=>_s,SpriteLoader:()=>Yr,SpriteParseError:()=>Bt,Texture2D:()=>gn,TextureCache:()=>qr,TextureCubeMap:()=>yn,TgaParseError:()=>yt,U_ALPHA:()=>uc,U_ANGLE1:()=>oa,U_ANGLE2:()=>ea,U_ANGLE3:()=>ta,U_EFFECTS16:()=>ho,U_EFFECTS8:()=>co,U_EVENT:()=>na,U_FRAME16:()=>aa,U_FRAME8:()=>ra,U_INSTANCE_BITS:()=>hc,U_LOOP_ATTENUATION_HIGH:()=>pc,U_LOOP_VOLUME:()=>mc,U_MODEL:()=>sa,U_MODEL2:()=>la,U_MODEL3:()=>ca,U_MODEL4:()=>da,U_OLDORIGIN:()=>ua,U_OLD_FRAME_HIGH:()=>yc,U_ORIGIN1:()=>Qs,U_ORIGIN2:()=>Js,U_ORIGIN3:()=>ia,U_OWNER_HIGH:()=>gc,U_REMOVE:()=>dc,U_RENDERFX16:()=>fo,U_RENDERFX8:()=>lo,U_SCALE:()=>fc,U_SKIN16:()=>mo,U_SKIN8:()=>uo,U_SOLID:()=>ha,U_SOUND:()=>fa,VertexArray:()=>ze,VertexBuffer:()=>Le,VirtualFileSystem:()=>To,advanceAnimation:()=>td,applySurfaceState:()=>Zd,attenuationToDistanceMultiplier:()=>Ot,boxIntersectsFrustum:()=>Vi,buildBspGeometry:()=>Hd,buildMd2Geometry:()=>Sl,buildMd2VertexData:()=>wl,buildMd3SurfaceGeometry:()=>Ll,buildMd3VertexData:()=>Tl,calculateMaxAudibleDistance:()=>Nn,calculatePakChecksum:()=>Gc,computeFrameBlend:()=>rd,computeSkyScroll:()=>jd,createAnimationState:()=>nd,createAudioGraph:()=>xs,createBspSurfaces:()=>Ud,createEmptyEntityState:()=>Pr,createEmptyProtocolPlayerState:()=>js,createEngine:()=>px,createEngineRuntime:()=>Hc,createFaceLightmap:()=>Co,createInitialChannels:()=>vs,createProgramFromSources:()=>Nd,createWebGLContext:()=>Fd,decodeOgg:()=>ms,deriveSurfaceRenderState:()=>gl,extractFrustumPlanes:()=>Vd,filesToPakSources:()=>ka,findLeafForPoint:()=>fl,gatherVisibleFaces:()=>Kd,groupMd2Animations:()=>jc,ingestPakFiles:()=>Wc,ingestPaks:()=>Ro,interpolateMd3Tag:()=>p0,interpolateVec3:()=>id,parseBsp:()=>Da,parseMd2:()=>Oa,parseMd3:()=>Pa,parsePcx:()=>Xn,parseSprite:()=>Fa,parseTga:()=>Ba,parseWal:()=>ko,parseWalTexture:()=>Po,parseWav:()=>Fo,pcxToRgba:()=>Do,pickChannel:()=>Ss,preparePcxTexture:()=>Oo,removeViewTranslation:()=>qd,resolveLightStyles:()=>pl,spatializeOrigin:()=>ws,spawnBlood:()=>x0,spawnBulletImpact:()=>g0,spawnExplosion:()=>y0,spawnMuzzleFlash:()=>b0,spawnTeleportFlash:()=>_0,spawnTrail:()=>v0,walToRgba:()=>Na,wireDropTarget:()=>Xc,wireFileInput:()=>Kc});var ju=()=>typeof performance<"u"?performance.now():Date.now(),Qu=e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(()=>e()):setTimeout(e,25)},cr=class{constructor(t,r={}){this.callbacks=t;this.accumulatorMs=0;this.frame=0;this.running=!1;this.tick=()=>{if(!this.running)return;let t=this.options.now(),r=this.lastTimeMs===void 0?0:t-this.lastTimeMs;this.lastTimeMs=t,this.advance(r,t),this.running&&this.options.schedule(this.tick)};let n=r.fixedDeltaMs??25,i=r.maxSubSteps??5;this.options={fixedDeltaMs:n,maxSubSteps:i,maxDeltaMs:r.maxDeltaMs??n*i,startTimeMs:r.startTimeMs,now:r.now??ju,schedule:r.schedule??Qu}}start(){this.running||(this.running=!0,this.lastTimeMs=this.options.startTimeMs??this.options.now(),this.options.schedule(this.tick))}stop(){this.running=!1}pump(t){let r=(this.lastTimeMs??0)+t;this.lastTimeMs=r,this.advance(t,r)}isRunning(){return this.running}get frameNumber(){return this.frame}advance(t,r){let n=Math.min(Math.max(t,0),this.options.maxDeltaMs);this.accumulatorMs=Math.min(this.accumulatorMs+n,this.options.fixedDeltaMs*this.options.maxSubSteps);let i=0;for(;this.accumulatorMs>=this.options.fixedDeltaMs&&i<this.options.maxSubSteps;)this.frame+=1,this.callbacks.simulate({frame:this.frame,deltaMs:this.options.fixedDeltaMs,nowMs:r}),this.accumulatorMs-=this.options.fixedDeltaMs,i+=1;let o=this.options.fixedDeltaMs===0?0:this.accumulatorMs/this.options.fixedDeltaMs;this.callbacks.render?.({alpha:o,nowMs:r,accumulatorMs:this.accumulatorMs,frame:this.frame})}};var zn=class{constructor(t,r,n){this.name=t,this.callback=r,this.description=n}execute(t){this.callback(t)}},Nr=class{constructor(){this.commands=new Map}register(t,r,n){let i=new zn(t,r,n);return this.commands.set(t,i),i}get(t){return this.commands.get(t)}execute(t){let r=this.tokenize(t);if(r.length===0)return!1;let n=r[0],i=r.slice(1),o=this.get(n);return o?(o.execute(i),!0):!1}tokenize(t){return t.trim().split(/\s+/)}list(){return[...this.commands.values()].sort((t,r)=>t.name.localeCompare(r.name))}};var Ju=Object.defineProperty,Ec=(e,t)=>{for(var r in t)Ju(e,r,{get:t[r],enumerable:!0})},Lc={x:0,y:0,z:0};var bx=Math.PI/180;function Tc(e,t){return{x:e.x-t.x,y:e.y-t.y,z:e.z-t.z}}function ef(e,t){return{x:e.x*t,y:e.y*t,z:e.z*t}}function xa(e,t){return e.x*t.x+e.y*t.y+e.z*t.z}function tf(e){return xa(e,e)}function _a(e){return Math.sqrt(tf(e))}function Je(e){let t=_a(e);return t===0?e:ef(e,1/t)}var rf=Math.PI/180,vx=180/Math.PI,Ur=rf;var ya=[[-.525731,0,.850651],[-.442863,.238856,.864188],[-.295242,0,.955423],[-.309017,.5,.809017],[-.16246,.262866,.951056],[0,0,1],[0,.850651,.525731],[-.147621,.716567,.681718],[.147621,.716567,.681718],[0,.525731,.850651],[.309017,.5,.809017],[.525731,0,.850651],[.295242,0,.955423],[.442863,.238856,.864188],[.16246,.262866,.951056],[-.681718,.147621,.716567],[-.809017,.309017,.5],[-.587785,.425325,.688191],[-.850651,.525731,0],[-.864188,.442863,.238856],[-.716567,.681718,.147621],[-.688191,.587785,.425325],[-.5,.809017,.309017],[-.238856,.864188,.442863],[-.425325,.688191,.587785],[-.716567,.681718,-.147621],[-.5,.809017,-.309017],[-.525731,.850651,0],[0,.850651,-.525731],[-.238856,.864188,-.442863],[0,.955423,-.295242],[-.262866,.951056,-.16246],[0,1,0],[0,.955423,.295242],[-.262866,.951056,.16246],[.238856,.864188,.442863],[.262866,.951056,.16246],[.5,.809017,.309017],[.238856,.864188,-.442863],[.262866,.951056,-.16246],[.5,.809017,-.309017],[.850651,.525731,0],[.716567,.681718,.147621],[.716567,.681718,-.147621],[.525731,.850651,0],[.425325,.688191,.587785],[.864188,.442863,.238856],[.688191,.587785,.425325],[.809017,.309017,.5],[.681718,.147621,.716567],[.587785,.425325,.688191],[.955423,.295242,0],[1,0,0],[.951056,.16246,.262866],[.850651,-.525731,0],[.955423,-.295242,0],[.864188,-.442863,.238856],[.951056,-.16246,.262866],[.809017,-.309017,.5],[.681718,-.147621,.716567],[.850651,0,.525731],[.864188,.442863,-.238856],[.809017,.309017,-.5],[.951056,.16246,-.262866],[.525731,0,-.850651],[.681718,.147621,-.716567],[.681718,-.147621,-.716567],[.850651,0,-.525731],[.809017,-.309017,-.5],[.864188,-.442863,-.238856],[.951056,-.16246,-.262866],[.147621,.716567,-.681718],[.309017,.5,-.809017],[.425325,.688191,-.587785],[.442863,.238856,-.864188],[.587785,.425325,-.688191],[.688191,.587785,-.425325],[-.147621,.716567,-.681718],[-.309017,.5,-.809017],[0,.525731,-.850651],[-.525731,0,-.850651],[-.442863,.238856,-.864188],[-.295242,0,-.955423],[-.16246,.262866,-.951056],[0,0,-1],[.295242,0,-.955423],[.16246,.262866,-.951056],[-.442863,-.238856,-.864188],[-.309017,-.5,-.809017],[-.16246,-.262866,-.951056],[0,-.850651,-.525731],[-.147621,-.716567,-.681718],[.147621,-.716567,-.681718],[0,-.525731,-.850651],[.309017,-.5,-.809017],[.442863,-.238856,-.864188],[.16246,-.262866,-.951056],[.238856,-.864188,-.442863],[.5,-.809017,-.309017],[.425325,-.688191,-.587785],[.716567,-.681718,-.147621],[.688191,-.587785,-.425325],[.587785,-.425325,-.688191],[0,-.955423,-.295242],[0,-1,0],[.262866,-.951056,-.16246],[0,-.850651,.525731],[0,-.955423,.295242],[.238856,-.864188,.442863],[.262866,-.951056,.16246],[.5,-.809017,.309017],[.716567,-.681718,.147621],[.525731,-.850651,0],[-.238856,-.864188,-.442863],[-.5,-.809017,-.309017],[-.262866,-.951056,-.16246],[-.850651,-.525731,0],[-.716567,-.681718,-.147621],[-.716567,-.681718,.147621],[-.525731,-.850651,0],[-.5,-.809017,.309017],[-.238856,-.864188,.442863],[-.262866,-.951056,.16246],[-.864188,-.442863,.238856],[-.809017,-.309017,.5],[-.688191,-.587785,.425325],[-.681718,-.147621,.716567],[-.442863,-.238856,.864188],[-.587785,-.425325,.688191],[-.309017,-.5,.809017],[-.147621,-.716567,.681718],[-.425325,-.688191,.587785],[-.16246,-.262866,.951056],[.442863,-.238856,.864188],[.16246,-.262866,.951056],[.309017,-.5,.809017],[.147621,-.716567,.681718],[0,-.525731,.850651],[.425325,-.688191,.587785],[.587785,-.425325,.688191],[.688191,-.587785,.425325],[-.955423,.295242,0],[-.951056,.16246,.262866],[-1,0,0],[-.850651,0,.525731],[-.955423,-.295242,0],[-.951056,-.16246,.262866],[-.864188,.442863,-.238856],[-.951056,.16246,-.262866],[-.809017,.309017,-.5],[-.864188,-.442863,-.238856],[-.951056,-.16246,-.262866],[-.809017,-.309017,-.5],[-.681718,.147621,-.716567],[-.681718,-.147621,-.716567],[-.850651,0,-.525731],[-.688191,.587785,-.425325],[-.587785,.425325,-.688191],[-.425325,.688191,-.587785],[-.425325,-.688191,-.587785],[-.587785,-.425325,-.688191],[-.688191,-.587785,-.425325]];function nf(){return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function Ic(e,t){let r=t.x,n=t.y,i=t.z;return{x:e[0]*r+e[4]*n+e[8]*i+e[12],y:e[1]*r+e[5]*n+e[9]*i+e[13],z:e[2]*r+e[6]*n+e[10]*i+e[14]}}function Rc(e,t){let r=nf();return r[0]=t[0].x,r[1]=t[0].y,r[2]=t[0].z,r[4]=t[1].x,r[5]=t[1].y,r[6]=t[1].z,r[8]=t[2].x,r[9]=t[2].y,r[10]=t[2].z,r[12]=e.x,r[13]=e.y,r[14]=e.z,r}var it=1,kt=2;var ba=8,va=16,of=32;var sf=16384;var vo=65536,Cc=1<<17,af=1<<18,lf=1<<19,cf=1<<20,df=1<<21,uf=1<<22,ff=1<<23,Sx=1<<24,So=1<<25,hf=1<<26,wx=1<<27,Ax=1<<28,Mx=1<<29,wo=1<<30,Ex=1<<31;var On=0;var zc=4,kc=8,Dc=16,Oc=32,Pc=64;var Lx=1<<25,Tx=1<<28,Ix=1<<29,Rx=1<<30,Cx=1<<31;var zx=it|kt,kx=it|vo|kt|So|wo,Dx=it|vo|kt,Ox=it|Cc|kt|So|wo,Px=of|ba|va,Fx=it|va|ba,mf=it|So|wo|kt|hf,Bx=af|lf|cf|df|uf|ff,Nx=it|ba|va|So|wo,Ux=it|vo|kt,Hx=it|kt,Vx=it|vo|kt|Cc,Gx=mf|sf;var Wx=Number.MAX_SAFE_INTEGER-1;var Ao=(e=>(e[e.None=0]="None",e[e.Archive=1]="Archive",e[e.UserInfo=2]="UserInfo",e[e.ServerInfo=4]="ServerInfo",e[e.Latch=8]="Latch",e[e.Cheat=16]="Cheat",e))(Ao||{});var Mo=256;var Sa=256,wa=8192,Eo=2048,Aa=512,Ma=256,Ea=Mo*2,La=256,ga=32,kn=96;var q=(e=>(e[e.Name=0]="Name",e[e.CdTrack=1]="CdTrack",e[e.Sky=2]="Sky",e[e.SkyAxis=3]="SkyAxis",e[e.SkyRotate=4]="SkyRotate",e[e.StatusBar=5]="StatusBar",e[e.HealthBarName=55]="HealthBarName",e[e.CONFIG_N64_PHYSICS=56]="CONFIG_N64_PHYSICS",e[e.CONFIG_CTF_TEAMS=57]="CONFIG_CTF_TEAMS",e[e.CONFIG_COOP_RESPAWN_STRING=58]="CONFIG_COOP_RESPAWN_STRING",e[e.AirAccel=59]="AirAccel",e[e.MaxClients=60]="MaxClients",e[e.MapChecksum=61]="MapChecksum",e[e.Models=62]="Models",e[e.Sounds=62+wa]="Sounds",e[e.Images=e.Sounds+Eo]="Images",e[e.Lights=e.Images+Aa]="Lights",e[e.ShadowLights=e.Lights+Sa]="ShadowLights",e[e.Items=e.ShadowLights+La]="Items",e[e.PlayerSkins=e.Items+Ma]="PlayerSkins",e[e.General=e.PlayerSkins+Mo]="General",e[e.WheelWeapons=e.General+Ea]="WheelWeapons",e[e.WheelAmmo=e.WheelWeapons+ga]="WheelAmmo",e[e.WheelPowerups=e.WheelAmmo+ga]="WheelPowerups",e[e.CdLoopCount=e.WheelPowerups+ga]="CdLoopCount",e[e.GameStyle=e.CdLoopCount+1]="GameStyle",e[e.MaxConfigStrings=e.GameStyle+1]="MaxConfigStrings",e))(q||{}),Fc=q.MaxConfigStrings;function Bc(e){return e>=5&&e<59?kn*(59-e):e>=q.General&&e<q.WheelWeapons?kn*(q.MaxConfigStrings-e):kn}var pf={};Ec(pf,{addReplayFrame:()=>_f,createReplaySession:()=>xf,deserializeReplay:()=>yf,serializeReplay:()=>gf});function gf(e){return JSON.stringify(e,null,2)}function yf(e){let t=JSON.parse(e);if(!t.metadata||!Array.isArray(t.frames))throw new Error("Invalid replay format: missing metadata or frames");return t}function xf(e,t){return{metadata:{map:e,date:new Date().toISOString(),version:"1.0",seed:t},frames:[]}}function _f(e,t,r,n){e.frames.push({serverFrame:r,cmd:t,timestamp:Date.now()-n})}var O=(e=>(e[e.bad=0]="bad",e[e.muzzleflash=1]="muzzleflash",e[e.muzzleflash2=2]="muzzleflash2",e[e.temp_entity=3]="temp_entity",e[e.layout=4]="layout",e[e.inventory=5]="inventory",e[e.nop=6]="nop",e[e.disconnect=7]="disconnect",e[e.reconnect=8]="reconnect",e[e.sound=9]="sound",e[e.print=10]="print",e[e.stufftext=11]="stufftext",e[e.serverdata=12]="serverdata",e[e.configstring=13]="configstring",e[e.spawnbaseline=14]="spawnbaseline",e[e.centerprint=15]="centerprint",e[e.download=16]="download",e[e.playerinfo=17]="playerinfo",e[e.packetentities=18]="packetentities",e[e.deltapacketentities=19]="deltapacketentities",e[e.frame=20]="frame",e[e.splitclient=21]="splitclient",e[e.configblast=22]="configblast",e[e.spawnbaselineblast=23]="spawnbaselineblast",e[e.level_restart=24]="level_restart",e[e.damage=25]="damage",e[e.locprint=26]="locprint",e[e.fog=27]="fog",e[e.waitingforplayers=28]="waitingforplayers",e[e.bot_chat=29]="bot_chat",e[e.poi=30]="poi",e[e.help_path=31]="help_path",e[e.muzzleflash3=32]="muzzleflash3",e[e.achievement=33]="achievement",e))(O||{});var I=(e=>(e[e.GUNSHOT=0]="GUNSHOT",e[e.BLOOD=1]="BLOOD",e[e.BLASTER=2]="BLASTER",e[e.RAILTRAIL=3]="RAILTRAIL",e[e.SHOTGUN=4]="SHOTGUN",e[e.EXPLOSION1=5]="EXPLOSION1",e[e.EXPLOSION2=6]="EXPLOSION2",e[e.ROCKET_EXPLOSION=7]="ROCKET_EXPLOSION",e[e.GRENADE_EXPLOSION=8]="GRENADE_EXPLOSION",e[e.SPARKS=9]="SPARKS",e[e.SPLASH=10]="SPLASH",e[e.BUBBLETRAIL=11]="BUBBLETRAIL",e[e.SCREEN_SPARKS=12]="SCREEN_SPARKS",e[e.SHIELD_SPARKS=13]="SHIELD_SPARKS",e[e.BULLET_SPARKS=14]="BULLET_SPARKS",e[e.LASER_SPARKS=15]="LASER_SPARKS",e[e.PARASITE_ATTACK=16]="PARASITE_ATTACK",e[e.ROCKET_EXPLOSION_WATER=17]="ROCKET_EXPLOSION_WATER",e[e.GRENADE_EXPLOSION_WATER=18]="GRENADE_EXPLOSION_WATER",e[e.MEDIC_CABLE_ATTACK=19]="MEDIC_CABLE_ATTACK",e[e.BFG_EXPLOSION=20]="BFG_EXPLOSION",e[e.BFG_BIGEXPLOSION=21]="BFG_BIGEXPLOSION",e[e.BOSSTPORT=22]="BOSSTPORT",e[e.BFG_LASER=23]="BFG_LASER",e[e.GRAPPLE_CABLE=24]="GRAPPLE_CABLE",e[e.WELDING_SPARKS=25]="WELDING_SPARKS",e[e.GREENBLOOD=26]="GREENBLOOD",e[e.BLUEHYPERBLASTER=27]="BLUEHYPERBLASTER",e[e.PLASMA_EXPLOSION=28]="PLASMA_EXPLOSION",e[e.TUNNEL_SPARKS=29]="TUNNEL_SPARKS",e[e.BLASTER2=30]="BLASTER2",e[e.RAILTRAIL2=31]="RAILTRAIL2",e[e.FLAME=32]="FLAME",e[e.LIGHTNING=33]="LIGHTNING",e[e.DEBUGTRAIL=34]="DEBUGTRAIL",e[e.PLAIN_EXPLOSION=35]="PLAIN_EXPLOSION",e[e.FLASHLIGHT=36]="FLASHLIGHT",e[e.FORCEWALL=37]="FORCEWALL",e[e.HEATBEAM=38]="HEATBEAM",e[e.MONSTER_HEATBEAM=39]="MONSTER_HEATBEAM",e[e.STEAM=40]="STEAM",e[e.BUBBLETRAIL2=41]="BUBBLETRAIL2",e[e.MOREBLOOD=42]="MOREBLOOD",e[e.HEATBEAM_SPARKS=43]="HEATBEAM_SPARKS",e[e.HEATBEAM_STEAM=44]="HEATBEAM_STEAM",e[e.CHAINFIST_SMOKE=45]="CHAINFIST_SMOKE",e[e.ELECTRIC_SPARKS=46]="ELECTRIC_SPARKS",e[e.TRACKER_EXPLOSION=47]="TRACKER_EXPLOSION",e[e.TELEPORT_EFFECT=48]="TELEPORT_EFFECT",e[e.DBALL_GOAL=49]="DBALL_GOAL",e[e.WIDOWBEAMOUT=50]="WIDOWBEAMOUT",e[e.NUKEBLAST=51]="NUKEBLAST",e[e.WIDOWSPLASH=52]="WIDOWSPLASH",e[e.EXPLOSION1_BIG=53]="EXPLOSION1_BIG",e[e.EXPLOSION1_NP=54]="EXPLOSION1_NP",e[e.FLECHETTE=55]="FLECHETTE",e[e.BLUEHYPERBLASTER_KEX=56]="BLUEHYPERBLASTER_KEX",e[e.BFG_ZAP=57]="BFG_ZAP",e[e.BERSERK_SLAM=58]="BERSERK_SLAM",e[e.GRAPPLE_CABLE_2=59]="GRAPPLE_CABLE_2",e[e.POWER_SPLASH=60]="POWER_SPLASH",e[e.LIGHTNING_BEAM=61]="LIGHTNING_BEAM",e[e.EXPLOSION1_NL=62]="EXPLOSION1_NL",e[e.EXPLOSION2_NL=63]="EXPLOSION2_NL",e))(I||{});var bf=12,vf=9,Xx=Math.ceil(bf*vf/16),Sf=23,wf=2,Kx=Math.ceil(Sf*wf/16);var Af={};Ec(Af,{U_ANGLE1:()=>Cf,U_ANGLE2:()=>zf,U_ANGLE3:()=>kf,U_EFFECTS:()=>Pf,U_EVENT:()=>Nf,U_FRAME:()=>Df,U_MODEL:()=>Ef,U_MODEL2:()=>Hf,U_MODEL3:()=>Vf,U_MODEL4:()=>Gf,U_MOREBITS:()=>Uf,U_NUMBER:()=>Mf,U_ORIGIN1:()=>Tf,U_ORIGIN2:()=>If,U_ORIGIN3:()=>Rf,U_REMOVE:()=>Wf,U_RENDERFX:()=>Ff,U_SKIN:()=>Of,U_SOLID:()=>Bf,U_SOUND:()=>Lf});var Mf=1,Ef=2,Lf=4,Tf=8,If=16,Rf=32,Cf=64,zf=128,kf=256,Df=512,Of=1024,Pf=2048,Ff=4096,Bf=8192,Nf=16384,Uf=32768,Hf=1,Vf=2,Gf=4,Wf=32768;var Pn=class{constructor(e){e instanceof Uint8Array?this.view=new DataView(e.buffer,e.byteOffset,e.byteLength):this.view=new DataView(e),this.offset=0,this.length=this.view.byteLength}getPosition(){return this.offset}seek(e){if(e<0||e>this.length)throw new Error(`Seek out of bounds: ${e} (length: ${this.length})`);this.offset=e}hasMore(){return this.offset<this.length}readChar(){let e=this.view.getInt8(this.offset);return this.offset+=1,e}readByte(){let e=this.view.getUint8(this.offset);return this.offset+=1,e}readShort(){let e=this.view.getInt16(this.offset,!0);return this.offset+=2,e}readUShort(){let e=this.view.getUint16(this.offset,!0);return this.offset+=2,e}readLong(){let e=this.view.getInt32(this.offset,!0);return this.offset+=4,e}readULong(){let e=this.view.getUint32(this.offset,!0);return this.offset+=4,e}readFloat(){let e=this.view.getFloat32(this.offset,!0);return this.offset+=4,e}readString(){let e="";for(;this.offset<this.length;){let t=this.readChar();if(t===-1||t===0)break;e+=String.fromCharCode(t)}return e}readStringLine(){let e="";for(;this.offset<this.length;){let t=this.readChar();if(t===-1||t===0||t===10)break;e+=String.fromCharCode(t)}return e}readCoord(){return this.readShort()*(1/8)}readAngle(){return this.readChar()*(360/256)}readAngle16(){return this.readShort()*360/65536}readData(e){if(this.offset+e>this.length)throw new Error(`Read out of bounds: ${this.offset+e} (length: ${this.length})`);let t=new Uint8Array(this.view.buffer,this.view.byteOffset+this.offset,e);return this.offset+=e,new Uint8Array(t)}readPos(e){e.x=this.readCoord(),e.y=this.readCoord(),e.z=this.readCoord()}readDir(e){let t=this.readByte();if(t>=162){e.x=0,e.y=0,e.z=0;return}let r=ya[t];e.x=r[0],e.y=r[1],e.z=r[2]}},Xf=class{constructor(e=1400){typeof e=="number"?(this.buffer=new Uint8Array(e),this.fixed=!1):(this.buffer=e,this.fixed=!0),this.view=new DataView(this.buffer.buffer,this.buffer.byteOffset,this.buffer.byteLength),this.offset=0}ensureSpace(e){if(this.offset+e>this.buffer.byteLength){if(this.fixed)throw new Error(`Buffer overflow: capacity ${this.buffer.byteLength}, needed ${this.offset+e}`);let t=Math.max(this.buffer.byteLength*2,this.offset+e),r=new Uint8Array(t);r.set(this.buffer),this.buffer=r,this.view=new DataView(this.buffer.buffer,this.buffer.byteOffset,this.buffer.byteLength)}}writeByte(e){this.ensureSpace(1),this.view.setUint8(this.offset,e),this.offset+=1}writeChar(e){this.ensureSpace(1),this.view.setInt8(this.offset,e),this.offset+=1}writeShort(e){this.ensureSpace(2),this.view.setInt16(this.offset,e,!0),this.offset+=2}writeLong(e){this.ensureSpace(4),this.view.setInt32(this.offset,e,!0),this.offset+=4}writeFloat(e){this.ensureSpace(4),this.view.setFloat32(this.offset,e,!0),this.offset+=4}writeString(e){let t=e.length;this.ensureSpace(t+1);for(let r=0;r<t;r++)this.view.setUint8(this.offset+r,e.charCodeAt(r));this.view.setUint8(this.offset+t,0),this.offset+=t+1}writeCoord(e){this.writeShort(Math.trunc(e*8))}writeAngle(e){this.writeByte(Math.trunc(e*256/360)&255)}writeAngle16(e){this.writeShort(Math.trunc(e*65536/360)&65535)}writePos(e){this.writeCoord(e.x),this.writeCoord(e.y),this.writeCoord(e.z)}writeDir(e){let t=-1,r=0;if(e.x===0&&e.y===0&&e.z===0){this.writeByte(0);return}for(let n=0;n<ya.length;n++){let i=ya[n],o=e.x*i[0]+e.y*i[1]+e.z*i[2];o>t&&(t=o,r=n)}this.writeByte(r)}getData(){return this.buffer.slice(0,this.offset)}getBuffer(){return this.buffer}getOffset(){return this.offset}reset(){this.offset=0}};var Dn=class xe{constructor(){this.qport=0,this.incomingSequence=0,this.outgoingSequence=0,this.incomingAcknowledged=0,this.incomingReliableAcknowledged=!1,this.incomingReliableSequence=0,this.outgoingReliableSequence=0,this.reliableLength=0,this.lastReceived=0,this.lastSent=0,this.remoteAddress=null,this.reliableMessage=new Xf(xe.MAX_MSGLEN);let t=Date.now();this.lastReceived=t,this.lastSent=t,this.qport=Math.floor(Math.random()*65536)}setup(t,r=null){this.qport=t,this.remoteAddress=r,this.reset()}reset(){this.incomingSequence=0,this.outgoingSequence=0,this.incomingAcknowledged=0,this.incomingReliableAcknowledged=!1,this.incomingReliableSequence=0,this.outgoingReliableSequence=0,this.reliableLength=0,this.reliableMessage.reset(),this.lastReceived=Date.now(),this.lastSent=Date.now()}transmit(t){this.outgoingSequence++,this.lastSent=Date.now();let r=xe.PACKET_HEADER,n=this.reliableLength>0?this.reliableLength+2:0,i=t?t.length:0;r+n+i>xe.MAX_MSGLEN&&(i=xe.MAX_MSGLEN-r-n,i<0&&(i=0));let o=new ArrayBuffer(r+n+i),s=new DataView(o),a=new Uint8Array(o),d=this.outgoingSequence;this.reliableLength>0&&(d|=2147483648,(this.outgoingReliableSequence&1)!==0&&(d|=1073741824)),s.setUint32(0,d,!0);let l=this.incomingSequence;(this.incomingReliableSequence&1)!==0&&(l|=2147483648),s.setUint32(4,l,!0),s.setUint16(8,this.qport,!0);let c=r;if(this.reliableLength>0){s.setUint16(c,this.reliableLength,!0),c+=2;let u=this.reliableMessage.getBuffer().subarray(0,this.reliableLength);a.set(u,c),c+=this.reliableLength}if(t&&i>0){let h=t.slice(0,i);a.set(h,c)}return a}process(t){if(t.length<xe.PACKET_HEADER)return null;this.lastReceived=Date.now();let r=new DataView(t.buffer,t.byteOffset,t.byteLength),n=r.getUint32(0,!0),i=r.getUint32(4,!0),o=r.getUint16(8,!0);if(this.qport!==o)return null;let s=n&1073741823;if((s-this.incomingSequence|0)<=0)return null;this.incomingSequence=s;let a=i&2147483647,d=(i&2147483648)!==0;if(a>this.incomingAcknowledged&&(this.incomingAcknowledged=a),this.reliableLength>0){let m=d?1:0,g=this.outgoingReliableSequence&1;m!==g&&(this.reliableLength=0,this.reliableMessage.reset(),this.outgoingReliableSequence^=1)}let l=(n&2147483648)!==0,c=(n&1073741824)!==0?1:0,h=xe.PACKET_HEADER,u=null;if(l){if(h+2>t.byteLength)return null;let m=r.getUint16(h,!0);h+=2;let g=this.incomingReliableSequence&1;if(c===g){if(this.incomingReliableSequence++,h+m>t.byteLength)return null;u=t.slice(h,h+m)}h+=m}let f=t.slice(h);if(u&&u.length>0){let m=u.length+f.length,g=new Uint8Array(m);return g.set(u,0),g.set(f,u.length),g}return f||new Uint8Array(0)}canSendReliable(){return this.reliableLength===0}writeReliableByte(t){if(this.reliableLength+1>xe.MAX_MSGLEN-xe.HEADER_OVERHEAD)throw new Error("NetChan reliable buffer overflow");this.reliableMessage.writeByte(t),this.reliableLength++}writeReliableShort(t){if(this.reliableLength+2>xe.MAX_MSGLEN-xe.HEADER_OVERHEAD)throw new Error("NetChan reliable buffer overflow");this.reliableMessage.writeShort(t),this.reliableLength+=2}writeReliableLong(t){if(this.reliableLength+4>xe.MAX_MSGLEN-xe.HEADER_OVERHEAD)throw new Error("NetChan reliable buffer overflow");this.reliableMessage.writeLong(t),this.reliableLength+=4}writeReliableString(t){let r=t.length+1;if(this.reliableLength+r>xe.MAX_MSGLEN-xe.HEADER_OVERHEAD)throw new Error("NetChan reliable buffer overflow");this.reliableMessage.writeString(t),this.reliableLength+=r}getReliableData(){return this.reliableLength===0?new Uint8Array(0):this.reliableMessage.getBuffer().subarray(0,this.reliableLength)}needsKeepalive(t){return t-this.lastSent>1e3}isTimedOut(t,r=3e4){return t-this.lastReceived>r}};Dn.MAX_MSGLEN=1400;Dn.FRAGMENT_SIZE=1024;Dn.PACKET_HEADER=10;Dn.HEADER_OVERHEAD=Dn.PACKET_HEADER+2;var Nc=(e=>(e[e.Bullets=0]="Bullets",e[e.Shells=1]="Shells",e[e.Rockets=2]="Rockets",e[e.Grenades=3]="Grenades",e[e.Cells=4]="Cells",e[e.Slugs=5]="Slugs",e[e.MagSlugs=6]="MagSlugs",e[e.Trap=7]="Trap",e[e.Flechettes=8]="Flechettes",e[e.Tesla=9]="Tesla",e[e.Disruptor=10]="Disruptor",e[e.Prox=11]="Prox",e[e.Nuke=12]="Nuke",e[e.Rounds=13]="Rounds",e))(Nc||{}),$x=Object.keys(Nc).length/2;var Fn=32,ot=(e=>(e[e.Auto=0]="Auto",e[e.Weapon=1]="Weapon",e[e.Voice=2]="Voice",e[e.Item=3]="Item",e[e.Body=4]="Body",e[e.Aux=5]="Aux",e[e.Footstep=6]="Footstep",e[e.Aux3=7]="Aux3",e[e.NoPhsAdd=8]="NoPhsAdd",e[e.Reliable=16]="Reliable",e[e.ForcePos=32]="ForcePos",e))(ot||{}),Ta=-1,Bn=0,Ia=1,Ra=2,Lo=3,Dt=80,Ca=.003;function Ot(e){return e===Lo?e*.001:e*5e-4}function Nn(e){let t=Ot(e);return t<=0?Number.POSITIVE_INFINITY:Dt+1/t}var Un=class{constructor({name:t,defaultValue:r,description:n,flags:i=Ao.None,onChange:o}){this.modifiedCount=0;this.name=t,this.defaultValue=r,this.description=n,this.flags=i,this._value=r,this.onChange=o}get string(){return this._value}get number(){return Number(this._value)}get integer(){return Math.trunc(this.number)}get boolean(){return!!this.integer}set(t){if(this.flags&Ao.Latch){if(t===this._value){this.latched=void 0;return}if(this.latched===t)return;this.latched!==t&&(this.latched=t);return}this.apply(t)}reset(){this.latched=void 0,this.apply(this.defaultValue)}applyLatched(){if(this.latched===void 0)return!1;let t=this.latched;return this.latched=void 0,t===this._value?!1:(this.apply(t),!0)}apply(t){if(this._value===t)return;let r=this._value;this._value=t,this.modifiedCount+=1,this.onChange?.(this,r)}},Hr=class{constructor(){this.cvars=new Map}register(t){let r=this.cvars.get(t.name);if(r)return r;let n=new Un(t);return this.cvars.set(t.name,n),n}get(t){return this.cvars.get(t)}setValue(t,r){let n=this.get(t);if(!n)throw new Error(`Unknown cvar: ${t}`);return n.set(r),n}resetAll(){for(let t of this.cvars.values())t.reset()}applyLatched(){let t=!1;for(let r of this.cvars.values())t=r.applyLatched()||t;return t}list(){return[...this.cvars.values()].sort((t,r)=>t.name.localeCompare(r.name))}};var Vr=class{constructor(t,r,n={}){this.game=t;this.client=r;this.started=!1;this.commands=new Nr;this.cvars=new Hr;this.stepSimulation=t=>{this.previousFrame=this.latestFrame,this.latestFrame=this.game.frame(t,this.latestCommand)};this.renderClient=t=>{this.client&&(this.latestCommand=this.client.render({...t,previous:this.previousFrame,latest:this.latestFrame}))};let i=n.loop?.now?.()??Date.now();this.startTimeMs=n.startTimeMs??n.loop?.startTimeMs??i,this.loop=new cr({simulate:this.stepSimulation,render:this.renderClient},{...n.loop,startTimeMs:this.startTimeMs})}start(){if(!this.started){try{this.latestFrame=this.game.init(this.startTimeMs)??this.latestFrame,this.client?.init(this.latestFrame)}catch(t){throw this.game.shutdown(),this.client?.shutdown(),t}this.started=!0,this.loop.start()}}stop(){this.started&&(this.loop.stop(),this.client?.shutdown(),this.game.shutdown(),this.previousFrame=void 0,this.latestFrame=void 0,this.started=!1)}pump(t){this.loop.pump(t)}getLatestFrame(){return this.latestFrame}isRunning(){return this.loop.isRunning()}};function Kf(e){if(e<0||e>=q.MaxConfigStrings)throw new RangeError(`Configstring index ${e} is out of range (0-${q.MaxConfigStrings-1})`)}function Uc(e,t){let r=Bc(e);if(t.length>r)throw new RangeError(`Configstring ${e} exceeds maximum length (${t.length} > ${r}); limit is ${kn} chars per slot`)}var Gr=class{constructor(){this.values=new Map;this.modelCursor=q.Models;this.soundCursor=q.Sounds;this.imageCursor=q.Images;this.lightCursor=q.Lights;this.shadowLightCursor=q.ShadowLights;this.itemCursor=q.Items;this.playerSkinCursor=q.PlayerSkins;this.generalCursor=q.General}set(t,r){return Kf(t),Uc(t,r),this.values.set(t,r),t}get(t){return this.values.get(t)}getName(t){return this.get(t)}getAll(){let t=new Array(Fc).fill("");for(let[r,n]of this.values.entries())t[r]=n;return t}modelIndex(t){return this.register(t,q.Models,wa,"modelCursor")}soundIndex(t){return this.register(t,q.Sounds,Eo,"soundCursor")}findSoundIndex(t){for(let r=q.Sounds;r<q.Sounds+Eo;r+=1)if(this.values.get(r)===t)return r}imageIndex(t){return this.register(t,q.Images,Aa,"imageCursor")}lightIndex(t){return this.register(t,q.Lights,Sa,"lightCursor")}shadowLightIndex(t){return this.register(t,q.ShadowLights,La,"shadowLightCursor")}itemIndex(t){return this.register(t,q.Items,Ma,"itemCursor")}playerSkinIndex(t){return this.register(t,q.PlayerSkins,Mo,"playerSkinCursor")}generalIndex(t){return this.register(t,q.General,Ea,"generalCursor")}register(t,r,n,i){for(let a=r;a<r+n;a+=1)if(this.values.get(a)===t)return a;let o=this[i],s=r+n;if(o>=s)throw new RangeError(`Out of configstring slots for range starting at ${r}`);return Uc(o,t),this.values.set(o,t),this[i]=o+1,o}};var Wr=class{constructor(t){this.registry=t.registry,this.system=t.system,this.music=t.music,this.client=t.client}soundindex(t){return this.registry.registerName(t)}sound(t,r,n,i,o,s){this.system.play({entity:t,channel:r,soundIndex:n,volume:i,attenuation:o,timeOffsetMs:s}),this.triggerSubtitle(n)}positioned_sound(t,r,n,i){this.system.positionedSound(t,r,n,i),this.triggerSubtitle(r)}loop_sound(t,r,n,i,o){this.system.play({entity:t,channel:r,soundIndex:n,volume:i,attenuation:o,looping:!0}),this.triggerSubtitle(n)}stop_entity_sounds(t){this.system.stopEntitySounds(t)}set_listener(t){this.system.setListener(t)}play_music(t,r=!0){return this.music?this.music.play(t,{loop:r}):Promise.resolve()}pause_music(){this.music?.pause()}resume_music(){return this.music?.resume()??Promise.resolve()}stop_music(){this.music?.stop()}set_music_volume(t){this.music?.setVolume(t)}play_ambient(t,r,n){this.system.ambientSound(t,r,n),this.triggerSubtitle(r)}play_channel(t){this.system.play({...t}),this.triggerSubtitle(t.soundIndex)}triggerSubtitle(t){if(!this.client)return;let r=this.registry.getName(t);if(!r)return;let n=r.match(/\[(.*?)\]/);n&&this.client.showSubtitle(n[1],r)}};var Hn=class{constructor(t,r){this.engine=t;this.host=r;this.started=!1}start(){this.started||(this.engine.init(),this.host.start(),this.started=!0)}stop(){this.started&&(this.host.stop(),this.engine.shutdown(),this.started=!1)}pump(t){this.host.pump(t)}getLatestFrame(){return this.host.getLatestFrame()}isRunning(){return this.started&&this.host.isRunning()}};function Hc(e,t,r,n,i){let o=new Wr({...n,client:r}),s=new Vr(t,r,i);return{runtime:new Hn(e,s),audio:o}}var $f="PACK";function Zf(e,t,r){let n=[];for(let i=0;i<r;i+=1){let o=e.getUint8(t+i);if(o===0)break;n.push(o)}return String.fromCharCode(...n)}function ae(e){return e.replace(/\\/g,"/").replace(/^\/+/,"").toLowerCase()}function Yf(){let e=new Uint32Array(256);for(let t=0;t<256;t+=1){let r=t;for(let n=0;n<8;n+=1)r=(r&1)!==0?3988292384^r>>>1:r>>>1;e[t]=r>>>0}return e}var qf=Yf();function Vc(e){let t=4294967295;for(let r=0;r<e.length;r+=1){let n=e[r];t=qf[(t^n)&255]^t>>>8}return(t^4294967295)>>>0}var Ve=class extends Error{},Xr=class e{constructor(t,r,n,i){this.name=t;this.buffer=r;this.entries=new Map(n.map(o=>[o.name,o])),this.checksum=i,this.size=r.byteLength}static fromArrayBuffer(t,r){let n=new DataView(r);if(r.byteLength<12)throw new Ve("PAK buffer too small to contain header");let i=String.fromCharCode(n.getUint8(0),n.getUint8(1),n.getUint8(2),n.getUint8(3));if(i!==$f)throw new Ve(`Invalid PAK header magic: ${i}`);let o=n.getInt32(4,!0),s=n.getInt32(8,!0);if(o<12)throw new Ve(`Invalid directory offset: ${o}`);if(s<=0||s%64!==0)throw new Ve(`Invalid directory length: ${s}`);if(o+s>r.byteLength)throw new Ve("Directory exceeds buffer length");let d=s/64,l=[],c=new Map;for(let h=0;h<d;h+=1){let u=o+h*64,f=Zf(n,u,56),m=ae(f),g=n.getInt32(u+56,!0),p=n.getInt32(u+60,!0);if(g<0||p<0||g+p>r.byteLength)throw new Ve(`Invalid entry bounds for ${f||"<unnamed>"} (offset=${g}, length=${p})`);if(!m)throw new Ve(`Entry ${h} has an empty name`);let x={name:m,offset:g,length:p};c.set(m,x)}return l.push(...c.values()),new e(t,r,l,Vc(new Uint8Array(r)))}getEntry(t){return this.entries.get(ae(t))}listEntries(){return Array.from(this.entries.values())}readFile(t){let r=this.getEntry(t);if(!r)throw new Ve(`File not found in PAK: ${t}`);return new Uint8Array(this.buffer,r.offset,r.length)}validate(){return{checksum:this.checksum,entries:this.listEntries()}}};function Gc(e){return Vc(new Uint8Array(e))}var To=class{constructor(t=[]){this.mounts=[];this.files=new Map;t.forEach(r=>this.mountPak(r))}mountPak(t){this.mounts.push(t);for(let r of t.listEntries()){let n=ae(r.name);this.files.set(n,{archive:t,entry:r})}}get mountedPaks(){return[...this.mounts]}hasFile(t){return this.files.has(ae(t))}stat(t){let r=this.files.get(ae(t));if(r)return{path:r.entry.name,size:r.entry.length,sourcePak:r.archive.name}}async readFile(t){let r=this.files.get(ae(t));if(!r)throw new Error(`File not found in VFS: ${t}`);return r.archive.readFile(t)}list(t=""){let r=ae(t).replace(/\/+$|^\//g,""),n=[],i=new Set,o=r?`${r}/`:"";for(let s of this.files.values()){if(r&&!s.entry.name.startsWith(o))continue;let a=r?s.entry.name.slice(o.length):s.entry.name,d=a.indexOf("/");d===-1?n.push({path:s.entry.name,size:s.entry.length,sourcePak:s.archive.name}):i.add(a.slice(0,d))}return n.sort((s,a)=>s.path.localeCompare(a.path)),{files:n,directories:[...i].sort()}}findByExtension(t){let r=t.startsWith(".")?t.toLowerCase():`.${t.toLowerCase()}`,n=[];for(let i of this.files.values())i.entry.name.toLowerCase().endsWith(r)&&n.push({path:i.entry.name,size:i.entry.length,sourcePak:i.archive.name});return n.sort((i,o)=>i.path.localeCompare(o.path))}};var za=Object.freeze([{name:"pak0.pak",checksum:2378051181,description:"Base game assets"},{name:"pak0.pak@baseq2",checksum:2378051181,description:"Base game assets (baseq2)"},{name:"pak0.pak@rogue",checksum:3373211245,description:"Ground Zero (rogue) mission pack"},{name:"pak0.pak@xatrix",checksum:1358269824,description:"The Reckoning (xatrix) mission pack"}]),dr=class extends Error{constructor(r){super(r.status==="unknown"?`Unknown PAK not allowed: ${r.name}`:`PAK checksum mismatch for ${r.name}`);this.result=r;this.name="PakValidationError"}},Io=class{constructor(t=za){this.known=new Map;t.forEach(r=>this.known.set(this.normalizePakName(r.name),r))}validateArchive(t,r){let n=this.normalizePakName(r??("name"in t?t.name:"unknown")),i=t.checksum,o="size"in t?t.size:void 0,s=this.known.get(n);return s?s.checksum!==i?{name:n,checksum:i,expectedChecksum:s.checksum,status:"mismatch",size:o,description:s.description}:{name:n,checksum:i,expectedChecksum:s.checksum,status:"valid",size:o,description:s.description}:{name:n,checksum:i,status:"unknown",size:o}}assertValid(t,r){let n=this.validateArchive(t,r);if(n.status==="mismatch")throw new dr(n);return n}normalizePakName(t){let r=ae(t),n=r.split("/"),i=n.pop()??r,o=n.pop();return o?`${i}@${o}`:i}};var Pt=class extends Error{constructor(r,n){super(`Failed to ingest PAK: ${r}`);this.file=r;this.name="PakIngestionError",n instanceof Error&&n.stack&&(this.stack=n.stack),this.cause=n}};async function jf(e,t){if(typeof e.arrayBuffer=="function"){let r=await e.arrayBuffer();return t?.({file:"blob",loadedBytes:r.byteLength,totalBytes:r.byteLength,state:"reading"}),r}if(typeof FileReader<"u")return new Promise((r,n)=>{let i=new FileReader;i.onerror=()=>n(i.error??new Error("Unknown FileReader error")),i.onprogress=o=>{t?.({file:"blob",loadedBytes:o.loaded,totalBytes:o.total||e.size,state:"reading"})},i.onload=()=>{let o=i.result;o instanceof ArrayBuffer?r(o):n(new Error("Unexpected FileReader result"))},i.readAsArrayBuffer(e)});if(typeof Response<"u"){let r=await new Response(e).arrayBuffer();return t?.({file:"blob",loadedBytes:r.byteLength,totalBytes:r.byteLength,state:"reading"}),r}if(typeof e.stream=="function"){let r=e.stream().getReader(),n=[],i=0;for(;;){let{done:a,value:d}=await r.read();if(a)break;if(!d)continue;let l=d;n.push(l),i+=l.byteLength,t?.({file:"blob",loadedBytes:i,totalBytes:e.size,state:"reading"})}let o=new Uint8Array(i),s=0;for(let a of n)o.set(a,s),s+=a.byteLength;return o.buffer}throw new Pt("blob",new Error("Unsupported Blob type"))}async function Qf(e,t){if(e.data instanceof ArrayBuffer)return t?.({file:e.name,loadedBytes:e.data.byteLength,totalBytes:e.data.byteLength,state:"reading"}),e.data;if(e.data instanceof Blob){let n=e.data.size;return jf(e.data,i=>t?.({...i,file:e.name,totalBytes:n}))}let r=e.data.buffer.slice(e.data.byteOffset,e.data.byteOffset+e.data.byteLength);return t?.({file:e.name,loadedBytes:r.byteLength,totalBytes:r.byteLength,state:"reading"}),r}async function Ro(e,t,r){let n=typeof r=="function"?{onProgress:r}:r??{},i=n.persistIndexes??!!n.pakIndexStore,o=n.enforceValidation??!!n.validator,s=n.allowUnknownPaks??!0,a=n.stopOnError??!1,d=[];for(let l of t)try{let c=await Qf(l,n.onProgress),h=Xr.fromArrayBuffer(l.name,c),u=n.validator?.validateArchive(h);if(u){n.onValidationResult?.(u);let f=u.status==="mismatch",m=u.status==="unknown";if(f&&o||m&&!s){let g=new dr(u);if(n.onError?.(l.name,g),a)throw new Pt(l.name,g);d.push({archive:h,mounted:!1,validation:u});continue}}if(e.mountPak(h),i&&n.pakIndexStore)try{await n.pakIndexStore.persist(h)}catch(f){if(n.onError?.(l.name,f),a)throw new Pt(l.name,f)}n.onProgress?.({file:l.name,loadedBytes:c.byteLength,totalBytes:c.byteLength,state:"parsed"}),d.push({archive:h,mounted:!0,validation:u})}catch(c){if(n.onProgress?.({file:l.name,loadedBytes:0,totalBytes:0,state:"error"}),n.onError?.(l.name,c),a)throw new Pt(l.name,c)}return d}var Ft=class{constructor(t){this.capacity=t;this.map=new Map;if(t<=0)throw new RangeError("LRU cache capacity must be greater than zero")}get size(){return this.map.size}has(t){return this.map.has(t)}get(t){let r=this.map.get(t);if(r!==void 0)return this.map.delete(t),this.map.set(t,r),r}set(t,r){if(this.map.has(t)&&this.map.delete(t),this.map.set(t,r),this.map.size>this.capacity){let n=this.map.keys().next();n.done||this.map.delete(n.value)}}delete(t){return this.map.delete(t)}clear(){this.map.clear()}entries(){return Array.from(this.map.entries()).reverse().map(([t,r])=>({key:t,value:r}))}};function Jf(e){return Array.isArray(e)?e:Array.from(e)}function ka(e){return Jf(e).map(t=>({name:t.name,data:t}))}async function Wc(e,t,r){let n=ka(t);return Ro(e,n,r??{})}function Xc(e,t){let r=i=>{i.preventDefault(),i.dataTransfer?.dropEffect&&(i.dataTransfer.dropEffect="copy")},n=i=>{i.preventDefault();let o=i.dataTransfer?.files;o&&o.length>0&&t(Array.from(o))};return e.addEventListener("dragover",r),e.addEventListener("drop",n),()=>{e.removeEventListener("dragover",r),e.removeEventListener("drop",n)}}function Kc(e,t){let r=n=>{let i=n.target;!i||!i.files||i.files.length===0||(t(i.files),i.value="")};return e.addEventListener("change",r),()=>e.removeEventListener("change",r)}var eh="IBSP",th=38,Zc=19,rh=8+Zc*8;var j=class extends Error{},Kr=class{constructor(t){this.vfs=t}async load(t){let r=await this.vfs.readFile(t),n=new Uint8Array(r.byteLength);return n.set(r),Da(n.buffer)}};function Da(e){if(e.byteLength<rh)throw new j("BSP too small to contain header");let t=new DataView(e),r=String.fromCharCode(t.getUint8(0),t.getUint8(1),t.getUint8(2),t.getUint8(3));if(r!==eh)throw new j(`Invalid BSP magic ${r}`);let n=t.getInt32(4,!0);if(n!==th)throw new j(`Unsupported BSP version ${n}`);let i=new Map;for(let v=0;v<Zc;v+=1){let E=t.getInt32(8+v*8,!0),L=t.getInt32(12+v*8,!0);if(E<0||L<0||E+L>e.byteLength)throw new j(`Invalid lump bounds for index ${v}`);i.set(v,{offset:E,length:L})}let o={version:n,lumps:i},s=ih(e,i.get(0)),a=sh(e,i.get(1)),d=ah(e,i.get(2)),l=lh(e,i.get(4)),c=ch(e,i.get(5)),h=dh(e,i.get(6)),u=new Uint8Array(e,i.get(7).offset,i.get(7).length),f=_h(h,i.get(7)),m=uh(e,i.get(8)),g=fh(e,i.get(11)),p=hh(e,i.get(12)),x=mh(e,i.get(13)),S=ph(e,i.get(14)),_=gh(e,i.get(15)),y=yh(e,i.get(9),i.get(10),m),b=xh(e,i.get(3));return{header:o,entities:s,planes:a,vertices:d,nodes:l,texInfo:c,faces:h,lightMaps:u,lightMapInfo:f,leafs:m,leafLists:y,edges:g,surfEdges:p,models:x,brushes:S,brushSides:_,visibility:b,pickEntity(v){let E=null,L=1/0;for(let w of s.entities){let T=w.properties.model;if(!T||!T.startsWith("*"))continue;let z=parseInt(T.substring(1),10);if(isNaN(z)||z<0||z>=x.length)continue;let U=x[z],C=nh(v.origin,v.direction,U.mins,U.maxs);C!==null&&C<L&&(L=C,E={entity:w,model:U,distance:C})}return E}}}function nh(e,t,r,n){let i=0,o=1/0;for(let s=0;s<3;s++)if(Math.abs(t[s])<1e-8){if(e[s]<r[s]||e[s]>n[s])return null}else{let a=1/t[s],d=(r[s]-e[s])*a,l=(n[s]-e[s])*a;if(d>l){let c=d;d=l,l=c}if(i=Math.max(i,d),o=Math.min(o,l),i>o)return null}return i}function ih(e,t){let r=new TextDecoder().decode(new Uint8Array(e,t.offset,t.length)),n=oh(r),i=n.find(o=>o.classname==="worldspawn");return{raw:r,entities:n,worldspawn:i,getUniqueClassnames(){let o=new Set;for(let s of n)s.classname&&o.add(s.classname);return Array.from(o).sort()}}}function oh(e){let t=[],r=/\{([^}]*)\}/gms,n;for(;(n=r.exec(e))!==null;){let i=n[1],o={},s=/"([^\"]*)"\s+"([^\"]*)"/g,a;for(;(a=s.exec(i))!==null;)o[a[1]]=a[2];t.push({classname:o.classname,properties:o})}return t}function sh(e,t){let r=new DataView(e,t.offset,t.length),n=t.length/20;if(n%1!==0)throw new j("Plane lump has invalid length");let i=[];for(let o=0;o<n;o+=1){let s=[r.getFloat32(o*20,!0),r.getFloat32(o*20+4,!0),r.getFloat32(o*20+8,!0)],a=r.getFloat32(o*20+12,!0),d=r.getInt32(o*20+16,!0);i.push({normal:s,dist:a,type:d})}return i}function ah(e,t){let r=new DataView(e,t.offset,t.length),n=t.length/12;if(n%1!==0)throw new j("Vertex lump has invalid length");let i=[];for(let o=0;o<n;o+=1)i.push([r.getFloat32(o*12,!0),r.getFloat32(o*12+4,!0),r.getFloat32(o*12+8,!0)]);return i}function lh(e,t){let r=new DataView(e,t.offset,t.length),n=28,i=t.length/n;if(i%1!==0)throw new j("Node lump has invalid length");let o=[];for(let s=0;s<i;s+=1){let a=s*n,d=r.getInt32(a,!0),l=[r.getInt32(a+4,!0),r.getInt32(a+8,!0)],c=[r.getInt16(a+12,!0),r.getInt16(a+14,!0),r.getInt16(a+16,!0)],h=[r.getInt16(a+18,!0),r.getInt16(a+20,!0),r.getInt16(a+22,!0)],u=r.getUint16(a+24,!0),f=r.getUint16(a+26,!0);o.push({planeIndex:d,children:l,mins:c,maxs:h,firstFace:u,numFaces:f})}return o}function ch(e,t){let r=new DataView(e,t.offset,t.length),n=76,i=t.length/n;if(i%1!==0)throw new j("TexInfo lump has invalid length");let o=[];for(let s=0;s<i;s+=1){let a=s*n,d=[r.getFloat32(a,!0),r.getFloat32(a+4,!0),r.getFloat32(a+8,!0)],l=r.getFloat32(a+12,!0),c=[r.getFloat32(a+16,!0),r.getFloat32(a+20,!0),r.getFloat32(a+24,!0)],h=r.getFloat32(a+28,!0),u=r.getInt32(a+32,!0),f=r.getInt32(a+36,!0),m=new Uint8Array(e,t.offset+a+40,32),g=new TextDecoder("utf-8").decode(m).replace(/\0.*$/,""),p=r.getInt32(a+72,!0);o.push({s:d,sOffset:l,t:c,tOffset:h,flags:u,value:f,texture:g,nextTexInfo:p})}return o}function dh(e,t){let r=new DataView(e,t.offset,t.length),n=20,i=t.length/n;if(i%1!==0)throw new j("Face lump has invalid length");let o=[];for(let s=0;s<i;s+=1){let a=s*n,d=r.getUint16(a,!0),l=r.getInt16(a+2,!0),c=r.getInt32(a+4,!0),h=r.getInt16(a+8,!0),u=r.getInt16(a+10,!0),f=[r.getUint8(a+12),r.getUint8(a+13),r.getUint8(a+14),r.getUint8(a+15)],m=r.getInt32(a+16,!0);o.push({planeIndex:d,side:l,firstEdge:c,numEdges:h,texInfo:u,styles:f,lightOffset:m})}return o}function uh(e,t){let r=new DataView(e,t.offset,t.length),n=28,i=t.length/n;if(i%1!==0)throw new j("Leaf lump has invalid length");let o=[];for(let s=0;s<i;s+=1){let a=s*n,d=r.getInt32(a,!0),l=r.getInt16(a+4,!0),c=r.getInt16(a+6,!0),h=[r.getInt16(a+8,!0),r.getInt16(a+10,!0),r.getInt16(a+12,!0)],u=[r.getInt16(a+14,!0),r.getInt16(a+16,!0),r.getInt16(a+18,!0)],f=r.getUint16(a+20,!0),m=r.getUint16(a+22,!0),g=r.getUint16(a+24,!0),p=r.getUint16(a+26,!0);o.push({contents:d,cluster:l,area:c,mins:h,maxs:u,firstLeafFace:f,numLeafFaces:m,firstLeafBrush:g,numLeafBrushes:p})}return o}function fh(e,t){let r=new DataView(e,t.offset,t.length),n=4,i=t.length/n;if(i%1!==0)throw new j("Edge lump has invalid length");let o=[];for(let s=0;s<i;s+=1){let a=s*n;o.push({vertices:[r.getUint16(a,!0),r.getUint16(a+2,!0)]})}return o}function hh(e,t){let r=t.length/4;if(r%1!==0)throw new j("SurfEdge lump has invalid length");let n=new DataView(e,t.offset,t.length),i=new Int32Array(r);for(let o=0;o<r;o+=1)i[o]=n.getInt32(o*4,!0);return i}function mh(e,t){let r=new DataView(e,t.offset,t.length),n=48;if(t.length%n!==0)throw new j("Model lump has invalid length");let i=t.length/n,o=[];for(let s=0;s<i;s+=1){let a=s*n,d=[r.getFloat32(a,!0),r.getFloat32(a+4,!0),r.getFloat32(a+8,!0)],l=[r.getFloat32(a+12,!0),r.getFloat32(a+16,!0),r.getFloat32(a+20,!0)],c=[r.getFloat32(a+24,!0),r.getFloat32(a+28,!0),r.getFloat32(a+32,!0)],h=r.getInt32(a+36,!0),u=r.getInt32(a+40,!0),f=r.getInt32(a+44,!0);o.push({mins:d,maxs:l,origin:c,headNode:h,firstFace:u,numFaces:f})}return o}function ph(e,t){let r=new DataView(e,t.offset,t.length),n=12,i=t.length/n;if(i%1!==0)throw new j("Brush lump has invalid length");let o=[];for(let s=0;s<i;s+=1){let a=s*n;o.push({firstSide:r.getInt32(a,!0),numSides:r.getInt32(a+4,!0),contents:r.getInt32(a+8,!0)})}return o}function gh(e,t){let r=new DataView(e,t.offset,t.length),n=4,i=t.length/n;if(i%1!==0)throw new j("Brush side lump has invalid length");let o=[];for(let s=0;s<i;s+=1){let a=s*n;o.push({planeIndex:r.getUint16(a,!0),texInfo:r.getInt16(a+2,!0)})}return o}function yh(e,t,r,n){let i=[],o=[],s=t.length/2,a=r.length/2,d=new DataView(e,t.offset,t.length),l=new DataView(e,r.offset,r.length);for(let c of n){if(c.firstLeafFace+c.numLeafFaces>s)throw new j("Leaf faces reference data past lump bounds");if(c.firstLeafBrush+c.numLeafBrushes>a)throw new j("Leaf brushes reference data past lump bounds");let h=[];for(let f=0;f<c.numLeafFaces;f+=1)h.push(d.getUint16((c.firstLeafFace+f)*2,!0));let u=[];for(let f=0;f<c.numLeafBrushes;f+=1)u.push(l.getUint16((c.firstLeafBrush+f)*2,!0));i.push(h),o.push(u)}return{leafFaces:i,leafBrushes:o}}function xh(e,t){if(t.length===0)return;if(t.length<4)throw new j("Visibility lump too small");let r=new DataView(e,t.offset,t.length),n=r.getInt32(0,!0),i=4+n*8;if(n<0||i>t.length)throw new j("Visibility lump truncated");let o=4,s=[];for(let a=0;a<n;a+=1){let d=r.getInt32(o,!0),l=r.getInt32(o+4,!0);o+=8;let c=t.offset+d,h=t.offset+l,u=t.offset+t.length;if(d<0||l<0||c>=u||h>=u)throw new j("Visibility offsets out of range");s.push({pvs:$c(e,c,n,t),phs:$c(e,h,n,t)})}return{numClusters:n,clusters:s}}function $c(e,t,r,n){let i=Math.ceil(r/8),o=new Uint8Array(i),s=new Uint8Array(e),a=t,d=0,l=n.offset+n.length;for(;d<i;){if(a>=l)throw new j("Visibility data truncated");let c=s[a++];if(c!==0){o[d++]=c;continue}if(a>=l)throw new j("Visibility run exceeds lump bounds");let h=s[a++];for(let u=0;u<h&&d<i;u+=1)o[d++]=0}return o}function _h(e,t){return e.map(r=>{if(!(r.lightOffset<0))return{offset:r.lightOffset,length:Math.max(0,t.length-r.lightOffset)}})}function Co(e,t,r){if(e.lightOffset<0||e.lightOffset>=t.byteLength)return;let n=t.byteLength-e.lightOffset,i=Math.min(r?.length??n,n);if(!(i<=0))return t.subarray(e.lightOffset,e.lightOffset+i)}var bh=844121161,vh=8,Yc=68,Sh=[{x:-.525731,y:0,z:.850651},{x:-.442863,y:.238856,z:.864188},{x:-.295242,y:0,z:.955423},{x:-.309017,y:.5,z:.809017},{x:-.16246,y:.262866,z:.951056},{x:0,y:0,z:1},{x:0,y:.850651,z:.525731},{x:-.147621,y:.716567,z:.681718},{x:.147621,y:.716567,z:.681718},{x:0,y:.525731,z:.850651},{x:.309017,y:.5,z:.809017},{x:.525731,y:0,z:.850651},{x:.295242,y:0,z:.955423},{x:.442863,y:.238856,z:.864188},{x:.16246,y:.262866,z:.951056},{x:-.681718,y:.147621,z:.716567},{x:-.809017,y:.309017,z:.5},{x:-.587785,y:.425325,z:.688191},{x:-.850651,y:.525731,z:0},{x:-.864188,y:.442863,z:.238856},{x:-.716567,y:.681718,z:.147621},{x:-.688191,y:.587785,z:.425325},{x:-.5,y:.809017,z:.309017},{x:-.238856,y:.864188,z:.442863},{x:-.425325,y:.688191,z:.587785},{x:-.716567,y:.681718,z:-.147621},{x:-.5,y:.809017,z:-.309017},{x:-.525731,y:.850651,z:0},{x:0,y:.850651,z:-.525731},{x:-.238856,y:.864188,z:-.442863},{x:0,y:.955423,z:-.295242},{x:-.262866,y:.951056,z:-.16246},{x:0,y:1,z:0},{x:0,y:.955423,z:.295242},{x:-.262866,y:.951056,z:.16246},{x:.238856,y:.864188,z:.442863},{x:.262866,y:.951056,z:.16246},{x:.5,y:.809017,z:.309017},{x:.238856,y:.864188,z:-.442863},{x:.262866,y:.951056,z:-.16246},{x:.5,y:.809017,z:-.309017},{x:.850651,y:.525731,z:0},{x:.716567,y:.681718,z:.147621},{x:.716567,y:.681718,z:-.147621},{x:.525731,y:.850651,z:0},{x:.425325,y:.688191,z:.587785},{x:.864188,y:.442863,z:.238856},{x:.688191,y:.587785,z:.425325},{x:.809017,y:.309017,z:.5},{x:.681718,y:.147621,z:.716567},{x:.587785,y:.425325,z:.688191},{x:.955423,y:.295242,z:0},{x:1,y:0,z:0},{x:.951056,y:.16246,z:.262866},{x:.850651,y:-.525731,z:0},{x:.955423,y:-.295242,z:0},{x:.864188,y:-.442863,z:.238856},{x:.951056,y:-.16246,z:.262866},{x:.809017,y:-.309017,z:.5},{x:.681718,y:-.147621,z:.716567},{x:.850651,y:0,z:.525731},{x:.864188,y:.442863,z:-.238856},{x:.809017,y:.309017,z:-.5},{x:.951056,y:.16246,z:-.262866},{x:.525731,y:0,z:-.850651},{x:.681718,y:.147621,z:-.716567},{x:.681718,y:-.147621,z:-.716567},{x:.850651,y:0,z:-.525731},{x:.809017,y:-.309017,z:-.5},{x:.864188,y:-.442863,z:-.238856},{x:.951056,y:-.16246,z:-.262866},{x:.147621,y:.716567,z:-.681718},{x:.309017,y:.5,z:-.809017},{x:.425325,y:.688191,z:-.587785},{x:.442863,y:.238856,z:-.864188},{x:.587785,y:.425325,z:-.688191},{x:.688191,y:.587785,z:-.425325},{x:-.147621,y:.716567,z:-.681718},{x:-.309017,y:.5,z:-.809017},{x:0,y:.525731,z:-.850651},{x:-.525731,y:0,z:-.850651},{x:-.442863,y:.238856,z:-.864188},{x:-.295242,y:0,z:-.955423},{x:-.16246,y:.262866,z:-.951056},{x:0,y:0,z:-1},{x:.295242,y:0,z:-.955423},{x:.16246,y:.262866,z:-.951056},{x:-.442863,y:-.238856,z:-.864188},{x:-.309017,y:-.5,z:-.809017},{x:-.16246,y:-.262866,z:-.951056},{x:0,y:-.850651,z:-.525731},{x:-.147621,y:-.716567,z:-.681718},{x:.147621,y:-.716567,z:-.681718},{x:0,y:-.525731,z:-.850651},{x:.309017,y:-.5,z:-.809017},{x:.442863,y:-.238856,z:-.864188},{x:.16246,y:-.262866,z:-.951056},{x:.238856,y:-.864188,z:-.442863},{x:.5,y:-.809017,z:-.309017},{x:.425325,y:-.688191,z:-.587785},{x:.716567,y:-.681718,z:-.147621},{x:.688191,y:-.587785,z:-.425325},{x:.587785,y:-.425325,z:-.688191},{x:0,y:-.955423,z:-.295242},{x:0,y:-1,z:0},{x:.262866,y:-.951056,z:-.16246},{x:0,y:-.850651,z:.525731},{x:0,y:-.955423,z:.295242},{x:.238856,y:-.864188,z:.442863},{x:.262866,y:-.951056,z:.16246},{x:.5,y:-.809017,z:.309017},{x:.716567,y:-.681718,z:.147621},{x:.525731,y:-.850651,z:0},{x:-.238856,y:-.864188,z:-.442863},{x:-.5,y:-.809017,z:-.309017},{x:-.262866,y:-.951056,z:-.16246},{x:-.850651,y:-.525731,z:0},{x:-.716567,y:-.681718,z:-.147621},{x:-.716567,y:-.681718,z:.147621},{x:-.525731,y:-.850651,z:0},{x:-.5,y:-.809017,z:.309017},{x:-.238856,y:-.864188,z:.442863},{x:-.262866,y:-.951056,z:.16246},{x:-.864188,y:-.442863,z:.238856},{x:-.809017,y:-.309017,z:.5},{x:-.688191,y:-.587785,z:.425325},{x:-.681718,y:-.147621,z:.716567},{x:-.442863,y:-.238856,z:.864188},{x:-.587785,y:-.425325,z:.688191},{x:-.309017,y:-.5,z:.809017},{x:-.147621,y:-.716567,z:.681718},{x:-.425325,y:-.688191,z:.587785},{x:-.16246,y:-.262866,z:.951056},{x:.442863,y:-.238856,z:.864188},{x:.16246,y:-.262866,z:.951056},{x:.309017,y:-.5,z:.809017},{x:.147621,y:-.716567,z:.681718},{x:0,y:-.525731,z:.850651},{x:.425325,y:-.688191,z:.587785},{x:.587785,y:-.425325,z:.688191},{x:.688191,y:-.587785,z:.425325},{x:-.955423,y:.295242,z:0},{x:-.951056,y:.16246,z:.262866},{x:-1,y:0,z:0},{x:-.850651,y:0,z:.525731},{x:-.955423,y:-.295242,z:0},{x:-.951056,y:-.16246,z:.262866},{x:-.864188,y:.442863,z:-.238856},{x:-.951056,y:.16246,z:-.262866},{x:-.809017,y:.309017,z:-.5},{x:-.864188,y:-.442863,z:-.238856},{x:-.951056,y:-.16246,z:-.262866},{x:-.809017,y:-.309017,z:-.5},{x:-.681718,y:.147621,z:-.716567},{x:-.681718,y:-.147621,z:-.716567},{x:-.850651,y:0,z:-.525731},{x:-.688191,y:.587785,z:-.425325},{x:-.587785,y:.425325,z:-.688191},{x:-.425325,y:.688191,z:-.587785},{x:-.425325,y:-.688191,z:-.587785},{x:-.587785,y:-.425325,z:-.688191},{x:-.688191,y:-.587785,z:-.425325}],me=class extends Error{},$r=class{constructor(t){this.vfs=t;this.cache=new Map}async load(t){if(this.cache.has(t))return this.cache.get(t);let r=await this.vfs.readFile(t),n=new Uint8Array(r.byteLength);n.set(r);let i=Oa(n.buffer);return this.cache.set(t,i),i}get(t){return this.cache.get(t)}};function qc(e,t,r){let n=[];for(let i=0;i<r;i+=1){let o=e.getUint8(t+i);if(o===0)break;n.push(o)}return String.fromCharCode(...n)}function Vn(e,t,r,n){if(r!==0&&(t<Yc||t+r>e.byteLength))throw new me(`${n} section is out of bounds`)}function wh(e){if(e.byteLength<Yc)throw new me("MD2 buffer too small to contain header");let t=new DataView(e),r=t.getInt32(0,!0),n=t.getInt32(4,!0);if(r!==bh)throw new me(`Invalid MD2 ident: ${r}`);if(n!==vh)throw new me(`Unsupported MD2 version: ${n}`);let i={ident:r,version:n,skinWidth:t.getInt32(8,!0),skinHeight:t.getInt32(12,!0),frameSize:t.getInt32(16,!0),numSkins:t.getInt32(20,!0),numVertices:t.getInt32(24,!0),numTexCoords:t.getInt32(28,!0),numTriangles:t.getInt32(32,!0),numGlCommands:t.getInt32(36,!0),numFrames:t.getInt32(40,!0),offsetSkins:t.getInt32(44,!0),offsetTexCoords:t.getInt32(48,!0),offsetTriangles:t.getInt32(52,!0),offsetFrames:t.getInt32(56,!0),offsetGlCommands:t.getInt32(60,!0),offsetEnd:t.getInt32(64,!0),magic:r},o=40+i.numVertices*4;if(i.frameSize!==o)throw new me(`Unexpected frame size ${i.frameSize}, expected ${o}`);if(i.offsetEnd>e.byteLength)throw new me("MD2 offset_end exceeds buffer length");return i}function Ah(e,t){let r=t.numSkins*64;Vn(e,t.offsetSkins,r,"skins");let n=new DataView(e,t.offsetSkins,r),i=[];for(let o=0;o<t.numSkins;o+=1)i.push({name:qc(n,o*64,64)});return i}function Mh(e,t){let r=t.numTexCoords*4;Vn(e,t.offsetTexCoords,r,"texcoords");let n=new DataView(e,t.offsetTexCoords,r),i=[];for(let o=0;o<t.numTexCoords;o+=1){let s=o*4;i.push({s:n.getInt16(s,!0),t:n.getInt16(s+2,!0)})}return i}function Eh(e,t){let r=t.numTriangles*12;Vn(e,t.offsetTriangles,r,"triangles");let n=new DataView(e,t.offsetTriangles,r),i=[];for(let o=0;o<t.numTriangles;o+=1){let s=o*12,a=[n.getUint16(s,!0),n.getUint16(s+2,!0),n.getUint16(s+4,!0)],d=[n.getUint16(s+6,!0),n.getUint16(s+8,!0),n.getUint16(s+10,!0)];if(a.some(l=>l>=t.numVertices)||d.some(l=>l>=t.numTexCoords))throw new me("Triangle references out of range vertex or texcoord");i.push({vertexIndices:a,texCoordIndices:d})}return i}function Lh(e,t){let r=t.numFrames*t.frameSize;Vn(e,t.offsetFrames,r,"frames");let n=[];for(let i=0;i<t.numFrames;i+=1){let o=t.offsetFrames+i*t.frameSize,s=new DataView(e,o,t.frameSize),a={x:s.getFloat32(0,!0),y:s.getFloat32(4,!0),z:s.getFloat32(8,!0)},d={x:s.getFloat32(12,!0),y:s.getFloat32(16,!0),z:s.getFloat32(20,!0)},l=qc(s,24,16),c=[],h=1/0,u=1/0,f=1/0,m=-1/0,g=-1/0,p=-1/0;for(let x=0;x<t.numVertices;x+=1){let S=40+x*4,_=s.getUint8(S)*a.x+d.x,y=s.getUint8(S+1)*a.y+d.y,b=s.getUint8(S+2)*a.z+d.z;_<h&&(h=_),y<u&&(u=y),b<f&&(f=b),_>m&&(m=_),y>g&&(g=y),b>p&&(p=b);let A={x:_,y,z:b},v=s.getUint8(S+3),E=Sh[v];if(!E)throw new me(`Invalid normal index ${v} in frame ${l}`);c.push({position:A,normalIndex:v,normal:E})}n.push({name:l,vertices:c,minBounds:{x:h,y:u,z:f},maxBounds:{x:m,y:g,z:p}})}return n}function Th(e,t){let r=t.numGlCommands*4;if(Vn(e,t.offsetGlCommands,r,"gl commands"),r===0)return[];let n=new DataView(e,t.offsetGlCommands,r),i=[],o=0;for(;;){if(o+4>r)throw new me("GL command list ended unexpectedly");let s=n.getInt32(o,!0);if(o+=4,s===0)break;let a=Math.abs(s),d=[],l=a*12;if(o+l>r)throw new me("GL command vertex block exceeds buffer");for(let c=0;c<a;c+=1){let h=n.getFloat32(o,!0),u=n.getFloat32(o+4,!0),f=n.getInt32(o+8,!0);if(o+=12,f<0||f>=t.numVertices)throw new me("GL command references invalid vertex index");d.push({s:h,t:u,vertexIndex:f})}i.push({mode:s>0?"strip":"fan",vertices:d})}if(o!==r)throw new me("GL command list did not consume expected data");return i}function Oa(e){let t=wh(e),r=Ah(e,t),n=Mh(e,t),i=Eh(e,t),o=Lh(e,t),s=Th(e,t);return{header:t,skins:r,texCoords:n,triangles:i,frames:o,glCommands:s}}function jc(e){let t=[],r=0;for(;r<e.length;){let n=e[r].name,i=n.replace(/\d+$/,"")||n,o=r;for(;o+1<e.length&&(e[o+1].name.replace(/\d+$/,"")||e[o+1].name)===i;)o+=1;t.push({name:i,firstFrame:r,lastFrame:o}),r=o+1}return t}var Qc=860898377,Ih=15,Ge=class extends Error{constructor(t){super(t),this.name="Md3ParseError"}};function Gn(e,t,r){let n=new Uint8Array(e.buffer,e.byteOffset+t,r);return new TextDecoder("utf-8").decode(n).replace(/\0.*$/,"").trim()}function Rh(e){let t=(e>>8&255)*(2*Math.PI/255),r=(e&255)*(2*Math.PI/255),n=Math.sin(r);return{x:Math.cos(t)*n,y:Math.sin(t)*n,z:Math.cos(r)}}function zo(e,t,r,n){if(t<0||t+r>n)throw new Ge(`${e} exceeds buffer bounds`)}function Ch(e){let t=e.getInt32(0,!0);if(t!==Qc)throw new Ge(`Invalid MD3 ident: ${t}`);let r=e.getInt32(4,!0);if(r!==Ih)throw new Ge(`Unsupported MD3 version: ${r}`);let n=Gn(e,8,64),i=e.getInt32(72,!0),o=e.getInt32(76,!0),s=e.getInt32(80,!0),a=e.getInt32(84,!0),d=e.getInt32(88,!0),l=e.getInt32(92,!0),c=e.getInt32(96,!0),h=e.getInt32(100,!0),u=e.getInt32(104,!0);if(o<=0||a<0||s<0)throw new Ge("Invalid MD3 counts");return{ident:t,version:r,name:n,flags:i,numFrames:o,numTags:s,numSurfaces:a,numSkins:d,ofsFrames:l,ofsTags:c,ofsSurfaces:h,ofsEnd:u,magic:t}}function zh(e,t){let r=[];zo("Frames",t.ofsFrames,t.numFrames*56,e.byteLength);for(let i=0;i<t.numFrames;i+=1){let o=t.ofsFrames+i*56;r.push({minBounds:{x:e.getFloat32(o,!0),y:e.getFloat32(o+4,!0),z:e.getFloat32(o+8,!0)},maxBounds:{x:e.getFloat32(o+12,!0),y:e.getFloat32(o+16,!0),z:e.getFloat32(o+20,!0)},localOrigin:{x:e.getFloat32(o+24,!0),y:e.getFloat32(o+28,!0),z:e.getFloat32(o+32,!0)},radius:e.getFloat32(o+36,!0),name:Gn(e,o+40,16)})}return r}function kh(e,t){let r=[],i=t.numFrames*t.numTags*112;zo("Tags",t.ofsTags,i,e.byteLength);for(let o=0;o<t.numFrames;o+=1){let s=[];for(let a=0;a<t.numTags;a+=1){let d=t.ofsTags+(o*t.numTags+a)*112,l=d+64,c=l+12;s.push({name:Gn(e,d,64),origin:{x:e.getFloat32(l,!0),y:e.getFloat32(l+4,!0),z:e.getFloat32(l+8,!0)},axis:[{x:e.getFloat32(c,!0),y:e.getFloat32(c+4,!0),z:e.getFloat32(c+8,!0)},{x:e.getFloat32(c+12,!0),y:e.getFloat32(c+16,!0),z:e.getFloat32(c+20,!0)},{x:e.getFloat32(c+24,!0),y:e.getFloat32(c+28,!0),z:e.getFloat32(c+32,!0)}]})}r.push(s)}return r}function Dh(e,t){let r=e.getInt32(t,!0);if(r!==Qc)throw new Ge(`Invalid surface ident at ${t}: ${r}`);let n=Gn(e,t+4,64),i=e.getInt32(t+68,!0),o=e.getInt32(t+72,!0),s=e.getInt32(t+76,!0),a=e.getInt32(t+80,!0),d=e.getInt32(t+84,!0),l=e.getInt32(t+88,!0),c=e.getInt32(t+92,!0),h=e.getInt32(t+96,!0),u=e.getInt32(t+100,!0),f=e.getInt32(t+104,!0);if(o<=0||a<=0||d<=0)throw new Ge(`Invalid surface counts for ${n}`);let m=f;zo(`Surface ${n}`,t,m,e.byteLength);let g=[],p=t+l;for(let v=0;v<d;v+=1){let E=p+v*12;g.push({indices:[e.getInt32(E,!0),e.getInt32(E+4,!0),e.getInt32(E+8,!0)]})}let x=[],S=t+c;for(let v=0;v<s;v+=1){let E=S+v*68;x.push({name:Gn(e,E,64),shaderIndex:e.getInt32(E+64,!0)})}let _=[],y=t+h;for(let v=0;v<a;v+=1){let E=y+v*8;_.push({s:e.getFloat32(E,!0),t:e.getFloat32(E+4,!0)})}let b=[],A=t+u;for(let v=0;v<o;v+=1){let E=[];for(let L=0;L<a;L+=1){let w=A+(v*a+L)*8,T=e.getInt16(w,!0)/64,z=e.getInt16(w+2,!0)/64,U=e.getInt16(w+4,!0)/64,C=e.getUint16(w+6,!0);E.push({position:{x:T,y:z,z:U},latLng:C,normal:Rh(C)})}b.push(E)}return{surface:{name:n,flags:i,numFrames:o,shaders:x,triangles:g,texCoords:_,vertices:b},nextOffset:t+f}}function Pa(e){if(e.byteLength<108)throw new Ge("MD3 buffer too small for header");let t=new DataView(e),r=Ch(t);zo("MD3 end",r.ofsEnd,0,e.byteLength);let n=zh(t,r),i=kh(t,r),o=[],s=r.ofsSurfaces;for(let a=0;a<r.numSurfaces;a+=1){let{surface:d,nextOffset:l}=Dh(t,s);o.push(d),s=l}if(s!==r.ofsEnd)throw new Ge("Surface parsing did not reach ofsEnd");return{header:r,frames:n,tags:i,surfaces:o}}var Zr=class{constructor(t){this.vfs=t;this.cache=new Map}async load(t){if(this.cache.has(t))return this.cache.get(t);let r=await this.vfs.readFile(t),n=Pa(r.slice().buffer);return this.cache.set(t,n),n}get(t){return this.cache.get(t)}};var Oh=844317769,Ph=2,Jc=64,ed=12,Bt=class extends Error{};function Fh(e,t,r){let n=[];for(let i=0;i<r;i+=1){let o=e.getUint8(t+i);if(o===0)break;n.push(o)}return String.fromCharCode(...n)}function Fa(e){if(e.byteLength<ed)throw new Bt("Sprite buffer too small to contain header");let t=new DataView(e),r=t.getInt32(0,!0),n=t.getInt32(4,!0),i=t.getInt32(8,!0);if(r!==Oh)throw new Bt(`Invalid Sprite ident: ${r}`);if(n!==Ph)throw new Bt(`Unsupported Sprite version: ${n}`);let o=[],s=16+Jc,a=ed;for(let d=0;d<i;d+=1){if(a+s>e.byteLength)throw new Bt("Sprite frame data exceeds buffer length");let l=t.getInt32(a,!0),c=t.getInt32(a+4,!0),h=t.getInt32(a+8,!0),u=t.getInt32(a+12,!0),f=Fh(t,a+16,Jc);o.push({width:l,height:c,originX:h,originY:u,name:f}),a+=s}return{ident:r,version:n,numFrames:i,frames:o}}var Yr=class{constructor(t){this.vfs=t}async load(t){let r=await this.vfs.readFile(t),n=new Uint8Array(r.byteLength);return n.set(r),Fa(n.buffer)}};function td(e,t){let r=(e.sequence.end-e.sequence.start+1)/e.sequence.fps,n=e.sequence.loop!==!1,i=e.time+t;return n?i=(i%r+r)%r:i>r&&(i=r),{...e,time:Math.max(0,Math.min(i,r))}}function rd(e){let t=e.sequence.end-e.sequence.start+1,r=1/e.sequence.fps,n=e.sequence.loop!==!1,i=e.time/r;if(!n&&i>=t)return{frame0:e.sequence.end,frame1:e.sequence.end,lerp:0};let o=n?i%t:Math.min(i,t-1),s=Math.floor(o),a=e.sequence.start+s,d=s+1>=t?n?e.sequence.start:e.sequence.end:a+1,l=!n&&s>=t-1?0:o-s;return{frame0:a,frame1:d,lerp:l}}function nd(e){return{sequence:e,time:0}}function id(e,t,r){return{x:e.x+(t.x-e.x)*r,y:e.y+(t.y-e.y)*r,z:e.z+(t.z-e.z)*r}}var Wn=class extends Error{constructor(t){super(t),this.name="WalParseError"}};function ko(e){if(e.byteLength<100)throw new Wn("WAL buffer too small");let t=new DataView(e),r=new Uint8Array(e,0,32),n=new TextDecoder("utf-8").decode(r).replace(/\0.*$/,"").trim(),i=t.getInt32(32,!0),o=t.getInt32(36,!0),s=[t.getInt32(40,!0),t.getInt32(44,!0),t.getInt32(48,!0),t.getInt32(52,!0)],a=new Uint8Array(e,56,32),d=new TextDecoder("utf-8").decode(a).replace(/\0.*$/,"").trim(),l=t.getInt32(88,!0),c=t.getInt32(92,!0),h=t.getInt32(96,!0);if(i<=0||o<=0)throw new Wn("Invalid WAL dimensions");let u=[],f=i,m=o;for(let g=0;g<s.length;g+=1){let p=s[g],x=Math.max(1,f*m|0);if(p<=0||p+x>e.byteLength)throw new Wn(`Invalid WAL mip offset for level ${g}`);let S=new Uint8Array(e,p,x);u.push({level:g,width:f,height:m,data:S}),f=Math.max(1,f>>1),m=Math.max(1,m>>1)}return{name:n,width:i,height:o,mipmaps:u,animName:d,flags:l,contents:c,value:h}}var ur=class extends Error{constructor(t){super(t),this.name="PcxParseError"}};function Xn(e){if(e.byteLength<128)throw new ur("PCX buffer too small for header");let t=new DataView(e),r=t.getUint8(0),n=t.getUint8(2),i=t.getUint8(3),o=t.getUint16(4,!0),s=t.getUint16(6,!0),a=t.getUint16(8,!0),d=t.getUint16(10,!0);if(r!==10||n!==1)throw new ur("Unsupported PCX encoding");if(i!==8)throw new ur("Only 8bpp PCX files are supported");let l=a-o+1,c=d-s+1,h=t.getUint16(66,!0),u=e.byteLength-769;if(u<128||new DataView(e,u,1).getUint8(0)!==12)throw new ur("Missing PCX palette");let f=new Uint8Array(e,u+1,768),m=new Uint8Array(e,128,u-128),g=new Uint8Array(l*c),p=0,x=0;for(let S=0;S<c;S+=1){let _=0;for(;_<h&&p<m.length;){let y=1,b=m[p++];if((b&192)===192){if(y=b&63,p>=m.length)throw new ur("Unexpected end of PCX RLE data");b=m[p++]}for(let A=0;A<y&&_<h;A+=1)_<l&&(g[x++]=b),_+=1}}return{width:l,height:c,bitsPerPixel:i,pixels:g,palette:f}}function Do(e){let t=new Uint8Array(e.width*e.height*4);for(let r=0;r<e.pixels.length;r+=1){let n=e.pixels[r],i=n*3,o=r*4;t[o]=e.palette[i],t[o+1]=e.palette[i+1],t[o+2]=e.palette[i+2],t[o+3]=n===255?0:255}return t}var yt=class extends Error{constructor(t){super(t),this.name="TgaParseError"}};function Ba(e){let t=new DataView(e);if(e.byteLength<18)throw new yt("Buffer too small for TGA header");let r=t.getUint8(0),n=t.getUint8(1),i=t.getUint8(2),o=t.getUint16(12,!0),s=t.getUint16(14,!0),a=t.getUint8(16),d=t.getUint8(17);if(i!==2&&i!==10&&i!==3&&i!==11)throw new yt(`Unsupported TGA image type: ${i} (only RGB/Grayscale supported)`);if(a!==24&&a!==32&&a!==8)throw new yt(`Unsupported pixel depth: ${a} (only 8, 24, 32 bpp supported)`);let l=i>=9,c=i===3||i===11,h=a/8,u=18+r;if(n===1){let _=t.getUint16(5,!0),y=t.getUint8(7);u+=_*(y/8)}let f=o*s,m=new Uint8Array(f*4),g=(d&32)!==0,p=0,x=new Uint8Array(e),S=_=>{if(c){let y=x[u++];m[_]=y,m[_+1]=y,m[_+2]=y,m[_+3]=255}else{let y=x[u++],b=x[u++],A=x[u++],v=a===32?x[u++]:255;m[_]=A,m[_+1]=b,m[_+2]=y,m[_+3]=v}};if(l){let _=0;for(;_<f;){if(u>=e.byteLength)throw new yt("Unexpected end of TGA RLE data");let y=x[u++],b=(y&127)+1,A=(y&128)!==0;if(_+b>f)throw new yt("TGA RLE packet exceeds image bounds");if(A){let v=c?x[u]:x[u+2],E=c?x[u]:x[u+1],L=x[u],w=c?255:a===32?x[u+3]:255;u+=h;for(let T=0;T<b;T++){let z=(_+T)*4;m[z]=v,m[z+1]=E,m[z+2]=L,m[z+3]=w}}else for(let v=0;v<b;v++)S((_+v)*4);_+=b}}else for(let _=0;_<f;_++){if(u>=e.byteLength)throw new yt("Unexpected end of TGA data");S(_*4)}if(!g){let _=o*4,y=new Uint8Array(_);for(let b=0;b<s/2;b++){let A=b*_,v=(s-1-b)*_;y.set(m.subarray(A,A+_)),m.set(m.subarray(v,v+_),A),m.set(y,v)}}return{width:o,height:s,bitsPerPixel:32,pixels:m}}var qr=class{constructor(t={}){this.cache=new Ft(t.capacity??128)}get size(){return this.cache.size}get(t){return this.cache.get(t.toLowerCase())}set(t,r){this.cache.set(t.toLowerCase(),r)}clear(){this.cache.clear()}};function Na(e,t){let r=[];for(let n of e.mipmaps){let i=new Uint8Array(n.width*n.height*4);for(let o=0;o<n.data.length;o+=1){let s=n.data[o],a=s*3,d=o*4;i[d]=t[a],i[d+1]=t[a+1],i[d+2]=t[a+2],i[d+3]=s===255?0:255}r.push({level:n.level,width:n.width,height:n.height,rgba:i})}return{width:e.width,height:e.height,levels:r,source:"wal"}}function Oo(e){let t=Do(e),r={level:0,width:e.width,height:e.height,rgba:t};return{width:e.width,height:e.height,levels:[r],source:"pcx"}}function od(e){let t={level:0,width:e.width,height:e.height,rgba:e.pixels};return{width:e.width,height:e.height,levels:[t],source:"tga"}}function Po(e,t){return Na(ko(e),t)}var fr=class extends Error{constructor(t){super(t),this.name="WavParseError"}};function Ua(e,t,r){return new TextDecoder("ascii").decode(new Uint8Array(e.buffer,e.byteOffset+t,r))}function Fo(e){if(e.byteLength<44)throw new fr("WAV buffer too small");let t=new DataView(e);if(Ua(t,0,4)!=="RIFF"||Ua(t,8,4)!=="WAVE")throw new fr("Invalid WAV header");let r=12,n=-1,i=-1,o=0,s=0;for(;r+8<=e.byteLength;){let m=Ua(t,r,4),g=t.getUint32(r+4,!0),p=r+8;m==="fmt "?(n=p,o=g):m==="data"&&(i=p,s=g),r=p+g}if(n===-1||i===-1)throw new fr("Missing fmt or data chunk");let a=t.getUint16(n,!0),d=t.getUint16(n+2,!0),l=t.getUint32(n+4,!0),c=t.getUint16(n+14,!0);if(a!==1)throw new fr("Only PCM WAV is supported");let h=c/8,u=s/(h*d),f=new Float32Array(u*d);for(let m=0;m<u;m+=1)for(let g=0;g<d;g+=1){let p=m*d+g,x=i+p*h,S=0;if(c===8)S=t.getUint8(x),f[p]=(S-128)/128;else if(c===16)S=t.getInt16(x,!0),f[p]=S/32768;else if(c===24){let _=t.getUint8(x),y=t.getUint8(x+1),b=t.getInt8(x+2);S=_|y<<8|b<<16,f[p]=S/8388608}else throw new fr(`Unsupported bitsPerSample: ${c}`)}return{sampleRate:l,channels:d,bitsPerSample:c,samples:f}}var Bh=(e,t=4294967295,r=79764919)=>{let n=new Int32Array(256),i,o,s,a=t;for(i=0;i<256;i++){for(s=i<<24,o=8;o>0;--o)s=2147483648&s?s<<1^r:s<<1;n[i]=s}for(i=0;i<e.length;i++)a=a<<8^n[255&(a>>24^e[i])];return a};var Ha=(e,t=Bh)=>{let r=p=>new Uint8Array(p.length/2).map(((x,S)=>parseInt(p.substring(2*S,2*(S+1)),16))),n=p=>r(p)[0],i=new Map;[,8364,,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,,381,,,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,,382,376].forEach(((p,x)=>i.set(p,x)));let o=new Uint8Array(e.length),s,a,d,l=!1,c=0,h=42,u=e.length>13&&e.substring(0,9)==="dynEncode",f=0;u&&(f=11,a=n(e.substring(9,f)),a<=1&&(f+=2,h=n(e.substring(11,f))),a===1&&(f+=8,d=(p=>new DataView(r(p).buffer).getInt32(0,!0))(e.substring(13,f))));let m=256-h;for(let p=f;p<e.length;p++)if(s=e.charCodeAt(p),s!==61||l){if(s===92&&p<e.length-5&&u){let x=e.charCodeAt(p+1);x!==117&&x!==85||(s=parseInt(e.substring(p+2,p+6),16),p+=5)}if(s>255){let x=i.get(s);x&&(s=x+127)}l&&(l=!1,s-=64),o[c++]=s<h&&s>0?s+m:s-h}else l=!0;let g=o.subarray(0,c);if(u&&a===1){let p=t(g);if(p!==d){let x="Decode failed crc32 validation";throw console.error("`simple-yenc`\n",x+`
|
|
2
2
|
`,"Expected: "+d+"; Got: "+p+`
|
|
3
3
|
`,"Visit https://github.com/eshaz/simple-yenc for more information"),Error(x)}}return g};function te(){let e=Uint8Array,t=Float32Array;te.modules||Object.defineProperties(te,{modules:{value:new WeakMap},setModule:{value(r,n){te.modules.set(r,Promise.resolve(n))}},getModule:{value(r,n){let i=te.modules.get(r);return i||(n?i=WebAssembly.compile(Ha(n)):(n=r.wasm,i=te.inflateDynEncodeString(n).then(o=>WebAssembly.compile(o))),te.modules.set(r,i)),i}},concatFloat32:{value(r,n){let i=new t(n),o=0,s=0;for(;o<r.length;)i.set(r[o],s),s+=r[o++].length;return i}},getDecodedAudio:{value:(r,n,i,o,s)=>({errors:r,channelData:n,samplesDecoded:i,sampleRate:o,bitDepth:s})},getDecodedAudioMultiChannel:{value(r,n,i,o,s,a){let d=[],l,c;for(l=0;l<i;l++){let h=[];for(c=0;c<n.length;)h.push(n[c++][l]||[]);d.push(te.concatFloat32(h,o))}return te.getDecodedAudio(r,d,o,s,a)}},inflateDynEncodeString:{value(r){return r=Ha(r),new Promise(n=>{let i=String.raw`dynEncode012804c7886d()((()>+*§§)§,§§§§)§+§§§)§+.-()(*)-+)(.7*§)i¸¸,3§(i¸¸,3/G+.¡*(,(,3+)2å:-),§H(P*DI*H(P*@I++hH)H*r,hH(H(P*<J,i)^*<H,H(P*4U((I-H(H*i0J,^*DH+H-H*I+H,I*4)33H(H*H)^*DH(H+H)^*@H+i§H)i§3æ*).§K(iHI/+§H,iHn,§H+i(H+i(rCJ0I,H*I-+hH,,hH(H-V)(i)J.H.W)(i)c)(H,i)I,H-i*I-4)33i(I.*hH(V)(H+n5(H(i*I-i(I,i)I.+hH,i*J+iHn,hi(I-i*I,+hH,H/H-c)(H,iFn,hi(I,+hH,H0n5-H*V)(J(,hH/H(i)J(H(V)(J(i)c)(H)H(i)H,c)(3H*i*I*H,i)I,4(3(-H(H,W)(H-I-H,i*I,4)3(3(3H,H-I1H+I,H.i)H1V)(J.i(v5(33H.-H(H,i(c)(H,i*I,4)333)-§i*I*+§H*iHn,hi73H,H(i)8(H+J+H)P*(H*V)(J-r,§H)P*,H.i)H+H,i)V)(-H*i*I*H+i)I+H-H.I.H,H-i)I,4)333Ã+)-§iø7i(^*(iü7I,*h+hH+iDn,h*hilI+i)I,+hH+,hH+iô7H,c)(i)H+i´8W)(H,I,H+i*I+4)-+hH(H)8*J-i(p5.*h*h*hH-i')u,hH(P*(J+,hH(P*0J,H(P*,n50H+H,H-b((3H(P*0i)I.4)3H-i¨*n5*H-iÅ*s,hi73H-i)J+V)&+I,H(H+V)æ,8(I.H(H*8*J-i(p51H-i)J+i¸7V)(H(H+iø7V)(8(J/H(P*0J+s,hi73H+H,H.J,I.H(P*(m5(H.H(P*,s5.+hH,m5*H(P*(J.H+H.H+H/U((b((H(H(P*0i)J+^*0H,i)I,4(3(3H(H.^*03H-i¨*o5)33i(73(3(3-H,H+i)c)(H,i*I,H+i)I+4)33i)I-3H-3!2)0§K(i2J,L(H,H(^*(H,H*^*4H,i(^*0H,i(^*DH,j(_*<H,H)P*(^*,H,H+P*(^*8*h*h+hH,i)8(I3i§I**h*h*h*h*h*h*hH,i*8(6+(),03H,j(_*@i*I-H,P*<J.i,J(H,P*8J/s50H,H.i+J0^*<i¦I*H.H,P*4J1J.U(*H.U((J2i')o5/H.U()I.H,H(^*<H0H1U((H.i0J.i§i0i')o5/H/H.H2J*H(J.q50H,P*0J/H*I-H,P*(J0,hH,P*,H-q,hi)I-423+hH*m5+H/H0H(H1U((b((H/i)I/H(i)I(H*i)I*4(3(3H,H.^*<H,H-^*04*3iØ1U((5+i(I(i¨7i1^*(i$6iè1^*(i°7iè6^*(i¬7iÈ6^*(+hH(iÈ*n,hiÈ*I(+hH(i¨,n,hi¨,I(+hH(iØ,n,hiØ,I(+hH(iè,o,hH,i-H(i0c)(H(i*I(4)33iè1i1H,i-iÈ*8)Bi(I(+hH(ido,hH,i-H(i-c)(H(i*I(4)33iÈ6iè6H,i-iF8)BiØ1i)b((41-H,i-H(i/c)(H(i*I(4)3(3(-H,i-H(i1c)(H(i*I(4)3(3(-H,i-H(i0c)(H(i*I(4)3(3(3H,H/^*0H,H(^*<3i(I*4*3H,H,i¸)^*TH,H,iø-^*PH,H,iX^*LH,H,i(^*HH,i-8(I(H,i-8(I-i¥I*H,i,8(I.H(iErH-iEr5)H(i©*I1H-i)I0i(i;H.i,J(i(H(i(rCJ(J*H*i;sCI*i¨1I-H(I/+hH/,hH,i-H-V)(i)H,i+8(c)(H/i)I/H-i*I-H*i)I*4)-H(i)i¨1I/+hH(H*o,hH,i-H/V)(i)i(c)(H/i*I/H(i)I(4)33i¤I*H,iø-H,i¸)H,i-i;8)5+H0H1I2i(I-+hH-H2p,hH,H,iP8*J*i(p5-H*i7u,hH,i-H-i)H*c)(H-i)I-4*3i(I/i+I.i+I(*h*h*hH*i86*(*)3H-m,hi£I*403H-i)H,W)-I/i*I(4)3i3I.i/I(3H2H,H(8(H.J(H-J.p,hi¢I*4.3H,i-H-i)I*+hH(,hH*H/c)(H*i*I*H(i)I(4)-H.I-4+3(3(33H,W)1m,hiI*4,3H,iø-H,i¸)H,i-H18)J(,hi¡I*H(i(p5,H1H,V)ú-H,V)ø-o5,3H,i(H,iXH,i-H1i)H08)J(,hi I*H(i(p5,H0H,V)H,V)o5,3H,H,iPH,iH8+I*4+3(3(3H,i$6i¬78+I*3H*H3m5(3i)I-H*i(r5)3H)H,P*0^*(H+H,P*<^*(H*I-3H,i2L(H-33Á)+(i¨03b+(,(-(.(/(0(1(2(3(5(7(9(;(?(C(G(K(S([(c(k({(((«(Ë(ë((*)(iø03O)()()()(*(*(*(*(+(+(+(+(,(,(,(,(-(-(-(-(i¨13M8(9(:(((0(/(1(.(2(-(3(,(4(+(5(*(6()(7(T7*S7US0U `;te.getModule(te,i).then(o=>WebAssembly.instantiate(o,{})).then(({exports:o})=>{let s=new Map(Object.entries(o)),a=s.get("puff"),d=s.get("memory").buffer,l=new e(d),c=new DataView(d),h=s.get("__heap_base"),u=r.length,f=h;h+=4,c.setInt32(f,u,!0);let m=h;h+=u,l.set(r,m);let g=h;h+=4,c.setInt32(g,l.byteLength-h,!0),a(h,g,m,f),n(l.slice(h,h+c.getInt32(g,!0)))})})}}}),Object.defineProperty(this,"wasm",{enumerable:!0,get:()=>this._wasm}),this.getOutputChannels=(r,n,i)=>{let o=[],s=0;for(;s<n;)o.push(r.slice(s*i,s++*i+i));return o},this.allocateTypedArray=(r,n,i=!0)=>{let o=this._wasm.malloc(n.BYTES_PER_ELEMENT*r);return i&&this._pointers.add(o),{ptr:o,len:r,buf:new n(this._wasm.HEAP,o,r)}},this.free=()=>{this._pointers.forEach(r=>{this._wasm.free(r)}),this._pointers.clear()},this.codeToString=r=>{let n=[],i=new Uint8Array(this._wasm.HEAP);for(let o=i[r];o!==0;o=i[++r])n.push(o);return String.fromCharCode.apply(null,n)},this.addError=(r,n,i,o,s,a)=>{r.push({message:n,frameLength:i,frameNumber:o,inputBytes:s,outputSamples:a})},this.instantiate=(r,n)=>(n&&te.setModule(r,n),this._wasm=new r(te).instantiate(),this._pointers=new Set,this._wasm.ready.then(()=>this))}var ld=Yu(ad(),1);var Nh=()=>globalThis.Worker||ld.default,jr=class extends Nh(){constructor(t,r,n,i){te.modules||new te;let o=te.modules.get(n);if(!o){let s="text/javascript",a,d=`'use strict';(${((l,c,h)=>{let u,f,m=new Promise(g=>{f=g});self.onmessage=({data:{id:g,command:p,data:x}})=>{let S=m,_={id:g},y;p==="init"?(Object.defineProperties(l,{WASMAudioDecoderCommon:{value:c},EmscriptenWASM:{value:h},module:{value:x.module},isWebWorker:{value:!0}}),u=new l(x.options),f()):p==="free"?u.free():p==="ready"?S=S.then(()=>u.ready):p==="reset"?S=S.then(()=>u.reset()):(Object.assign(_,u[p](Array.isArray(x)?x.map(b=>new Uint8Array(b)):new Uint8Array(x))),y=_.channelData?_.channelData.map(b=>b.buffer):[]),S.then(()=>self.postMessage(_,y))}}).toString()})(${n}, ${te}, ${i})`;try{a=typeof process.versions.node<"u"}catch{}o=a?`data:${s};base64,${Buffer.from(d).toString("base64")}`:URL.createObjectURL(new Blob([d],{type:s})),te.modules.set(n,o)}super(o,{name:r}),this._id=Number.MIN_SAFE_INTEGER,this._enqueuedOperations=new Map,this.onmessage=({data:s})=>{let{id:a,...d}=s;this._enqueuedOperations.get(a)(d),this._enqueuedOperations.delete(a)},new i(te).getModule().then(s=>{this.postToDecoder("init",{module:s,options:t})})}async postToDecoder(t,r){return new Promise(n=>{this.postMessage({command:t,id:this._id,data:r}),this._enqueuedOperations.set(this._id++,n)})}get ready(){return this.postToDecoder("ready")}async free(){await this.postToDecoder("free").finally(()=>{this.terminate()})}async reset(){await this.postToDecoder("reset")}};var Bo=(e,t)=>{Object.defineProperty(e,"name",{value:t})};var re=Symbol,cd=", ",P=(()=>{let e="front",t="side",r="rear",n="left",i="center",o="right";return["",e+" ",t+" ",r+" "].map(s=>[[n,o],[n,o,i],[n,i,o],[i,n,o],[i]].flatMap(a=>a.map(d=>s+d).join(cd)))})(),st="LFE",Nt="monophonic (mono)",Ut="stereo",Kn="surround",ie=(e,...t)=>`${[Nt,Ut,`linear ${Kn}`,"quadraphonic",`5.0 ${Kn}`,`5.1 ${Kn}`,`6.1 ${Kn}`,`7.1 ${Kn}`][e-1]} (${t.join(cd)})`,$n=[Nt,ie(2,P[0][0]),ie(3,P[0][2]),ie(4,P[1][0],P[3][0]),ie(5,P[1][2],P[3][0]),ie(6,P[1][2],P[3][0],st),ie(7,P[1][2],P[2][0],P[3][4],st),ie(8,P[1][2],P[2][0],P[3][0],st)],dd=192e3,ud=176400,No=96e3,Uo=88200,fd=64e3,Ht=48e3,Qr=44100,Jr=32e3,en=24e3,tn=22050,rn=16e3,Ho=12e3,Vo=11025,nn=8e3,hd=7350,et="absoluteGranulePosition",N="bandwidth",_e="bitDepth",be="bitrate",Zn=be+"Maximum",Yn=be+"Minimum",qn=be+"Nominal",at="buffer",jn=at+"Fullness",ee="codec",ve=ee+"Frames",Qn="coupledStreamCount",on="crc",Jn=on+"16",ei=on+"32",Q="data",D="description",lt="duration",sn="emphasis",ti="hasOpusPadding",De="header",Vt="isContinuedPacket",ri="isCopyrighted",Gt="isFirstPage",ni="isHome",Oe="isLastPage",xt="isOriginal",_t="isPrivate",ii="isVbr",Re="layer",M="length",B="mode",bt=B+"Extension",Go="mpeg",vt=Go+"Version",oi="numberAACFrames",si="outputGain",hr="preSkip",ai="profile",Wo=re(),St="protection",Va="rawData",We="segments",H="subarray",Wt="version",mr="vorbis",li=mr+"Comments",an=mr+"Setup",Xo="block",ci=Xo+"ingStrategy",Ko=re(),wt=Xo+"Size",Xt=Xo+"size0",Kt=Xo+"size1",di=re(),$o="channel",At=$o+"MappingFamily",ui=$o+"MappingTable",Se=$o+"Mode",fi=re(),k=$o+"s",md="copyright",hi=md+"Id",mi=md+"IdStart",Mt="frame",Et=Mt+"Count",Ce=Mt+"Length",Zo="Number",Lt=Mt+Zo,ct=Mt+"Padding",F=Mt+"Size",pd="Rate",pi="inputSample"+pd,Ga="page",pr=Ga+"Checksum",ln=re(),$t=Ga+"SegmentTable",le=Ga+"Sequence"+Zo,Wa="sample",gi=Wa+Zo,G=Wa+pd,dt=re(),W=Wa+"s",Yo="stream",yi=Yo+"Count",xi=Yo+"Info",ut=Yo+"Serial"+Zo,Xa=Yo+"StructureVersion",Ka="total",gr=Ka+"BytesOut",yr=Ka+"Duration",xr=Ka+"Samples",K=re(),Xe=re(),_i=re(),Zt=re(),tt=re(),qo=re(),$a=re(),Yt=re(),Z=re(),Ke=re(),$e=re(),ft=re(),qt=re(),jo=re(),rt=re(),nt=re(),Ze=re(),Qo=re(),we=Uint8Array,jt=DataView,Y="reserved",Ae="bad",cn="free",bi="none",Jo="16bit CRC";var Za=(e,t,r)=>{for(let n=0;n<e[M];n++){let i=t(n);for(let o=8;o>0;o--)i=r(i);e[n]=i}return e},Hh=Za(new we(256),e=>e,e=>e&128?7^e<<1:e<<1),oe=[Za(new Uint16Array(256),e=>e<<8,e=>e<<1^(e&32768?32773:0))],se=[Za(new Uint32Array(256),e=>e,e=>e>>>1^(e&1)*3988292384)];for(let e=0;e<15;e++){oe.push(new Uint16Array(256)),se.push(new Uint32Array(256));for(let t=0;t<=255;t++)oe[e+1][t]=oe[0][oe[e][t]>>>8]^oe[e][t]<<8,se[e+1][t]=se[e][t]>>>8^se[0][se[e][t]&255]}var yd=e=>{let t=0,r=e[M];for(let n=0;n!==r;n++)t=Hh[t^e[n]];return t},xd=e=>{let t=e[M],r=t-16,n=0,i=0;for(;i<=r;)n^=e[i++]<<8|e[i++],n=oe[15][n>>8]^oe[14][n&255]^oe[13][e[i++]]^oe[12][e[i++]]^oe[11][e[i++]]^oe[10][e[i++]]^oe[9][e[i++]]^oe[8][e[i++]]^oe[7][e[i++]]^oe[6][e[i++]]^oe[5][e[i++]]^oe[4][e[i++]]^oe[3][e[i++]]^oe[2][e[i++]]^oe[1][e[i++]]^oe[0][e[i++]];for(;i!==t;)n=(n&255)<<8^oe[0][n>>8^e[i++]];return n},_d=e=>{let t=e[M],r=t-16,n=0,i=0;for(;i<=r;)n=se[15][(e[i++]^n)&255]^se[14][(e[i++]^n>>>8)&255]^se[13][(e[i++]^n>>>16)&255]^se[12][e[i++]^n>>>24]^se[11][e[i++]]^se[10][e[i++]]^se[9][e[i++]]^se[8][e[i++]]^se[7][e[i++]]^se[6][e[i++]]^se[5][e[i++]]^se[4][e[i++]]^se[3][e[i++]]^se[2][e[i++]]^se[1][e[i++]]^se[0][e[i++]];for(;i!==t;)n=se[0][(n^e[i++])&255]^n>>>8;return n^-1},Si=(...e)=>{let t=new we(e.reduce((r,n)=>r+n[M],0));return e.reduce((r,n)=>(t.set(n,r),r+n[M]),0),t},Pe=e=>String.fromCharCode(...e),gd=[0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15],vi=e=>gd[e&15]<<4|gd[e>>4],es=class{constructor(t){this._data=t,this._pos=t[M]*8}set position(t){this._pos=t}get position(){return this._pos}read(t){let r=Math.floor(this._pos/8),n=this._pos%8;return this._pos-=t,(vi(this._data[r-1])<<8)+vi(this._data[r])>>7-n&255}},bd=(e,t)=>{try{return e.getBigInt64(t,!0)}catch{let r=e.getUint8(t+7)&128?-1:1,n=e.getUint32(t,!0),i=e.getUint32(t+4,!0);return r===-1&&(n=~n+1,i=~i+1),i>1048575&&console.warn("This platform does not support BigInt"),r*(n+i*2**32)}};var wi=class{constructor(t,r){this._onCodecHeader=t,this._onCodecUpdate=r,this[rt]()}[nt](){this._isEnabled=!0}[rt](){this._headerCache=new Map,this._codecUpdateData=new WeakMap,this._codecHeaderSent=!1,this._codecShouldUpdate=!1,this._bitrate=null,this._isEnabled=!1}[jo](t,r){if(this._onCodecUpdate){this._bitrate!==t&&(this._bitrate=t,this._codecShouldUpdate=!0);let n=this._codecUpdateData.get(this._headerCache.get(this._currentHeader));this._codecShouldUpdate&&n&&this._onCodecUpdate({bitrate:t,...n},r),this._codecShouldUpdate=!1}}[Z](t){let r=this._headerCache.get(t);return r&&this._updateCurrentHeader(t),r}[Ke](t,r,n){this._isEnabled&&(this._codecHeaderSent||(this._onCodecHeader({...r}),this._codecHeaderSent=!0),this._updateCurrentHeader(t),this._headerCache.set(t,r),this._codecUpdateData.set(r,n))}_updateCurrentHeader(t){this._onCodecUpdate&&t!==this._currentHeader&&(this._codecShouldUpdate=!0,this._currentHeader=t)}};var ue=new WeakMap,pe=new WeakMap;var Me=class{constructor(t,r){this._codecParser=t,this._headerCache=r}*[$a](){let t;do{if(t=yield*this.Frame[$e](this._codecParser,this._headerCache,0),t)return t;this._codecParser[Xe](1)}while(!0)}*[Yt](t){let r=yield*this[$a](),n=pe.get(r)[M];if(t||this._codecParser._flushing||(yield*this.Header[Z](this._codecParser,this._headerCache,n)))return this._headerCache[nt](),this._codecParser[Xe](n),this._codecParser[Zt](r),r;this._codecParser[tt](`Missing ${Mt} at ${n} bytes from current position.`,`Dropping current ${Mt} and trying again.`),this._headerCache[rt](),this._codecParser[Xe](1)}};var _r=class{constructor(t,r){pe.set(this,{[De]:t}),this[Q]=r}};var Fe=class extends _r{static*[$e](t,r,n,i,o){let s=yield*t[Z](n,i,o);if(s){let a=ue.get(s)[Ce],d=ue.get(s)[W],l=(yield*n[K](a,o))[H](0,a);return new r(s,l,d)}else return null}constructor(t,r,n){super(t,r),this[De]=t,this[W]=n,this[lt]=n/t[G]*1e3,this[Lt]=null,this[gr]=null,this[xr]=null,this[yr]=null,pe.get(this)[M]=r[M]}};var Ya="unsynchronizationFlag",qa="extendedHeaderFlag",ja="experimentalFlag",Qa="footerPresent",Ai=class e{static*getID3v2Header(t,r,n){let o={},s=yield*t[K](3,n);if(s[0]!==73||s[1]!==68||s[2]!==51||(s=yield*t[K](10,n),o[Wt]=`id3v2.${s[3]}.${s[4]}`,s[5]&15)||(o[Ya]=!!(s[5]&128),o[qa]=!!(s[5]&64),o[ja]=!!(s[5]&32),o[Qa]=!!(s[5]&16),s[6]&128||s[7]&128||s[8]&128||s[9]&128))return null;let a=s[6]<<21|s[7]<<14|s[8]<<7|s[9];return o[M]=10+a,new e(o)}constructor(t){this[Wt]=t[Wt],this[Ya]=t[Ya],this[qa]=t[qa],this[ja]=t[ja],this[Qa]=t[Qa],this[M]=t[M]}};var Be=class{constructor(t){ue.set(this,t),this[_e]=t[_e],this[be]=null,this[k]=t[k],this[Se]=t[Se],this[G]=t[G]}};var Md={0:[cn,cn,cn,cn,cn],16:[32,32,32,32,8],240:[Ae,Ae,Ae,Ae,Ae]},ts=(e,t,r)=>8*((e+r)%t+t)*(1<<(e+r)/t)-8*t*(t/8|0);for(let e=2;e<15;e++)Md[e<<4]=[e*32,ts(e,4,0),ts(e,4,-1),ts(e,8,4),ts(e,8,0)];var Vh=0,Gh=1,Wh=2,Xh=3,vd=4,rs="bands ",ns=" to 31",Sd={0:rs+4+ns,16:rs+8+ns,32:rs+12+ns,48:rs+16+ns},br="bitrateIndex",Mi="v2",ls="v1",is="Intensity stereo ",os=", MS stereo ",ss="on",as="off",Kh={0:is+as+os+as,16:is+ss+os+as,32:is+as+os+ss,48:is+ss+os+ss},Ja={0:{[D]:Y},2:{[D]:"Layer III",[ct]:1,[bt]:Kh,[ls]:{[br]:Wh,[W]:1152},[Mi]:{[br]:vd,[W]:576}},4:{[D]:"Layer II",[ct]:1,[bt]:Sd,[W]:1152,[ls]:{[br]:Gh},[Mi]:{[br]:vd}},6:{[D]:"Layer I",[ct]:4,[bt]:Sd,[W]:384,[ls]:{[br]:Vh},[Mi]:{[br]:Xh}}},el="MPEG Version ",wd="ISO/IEC ",$h={0:{[D]:`${el}2.5 (later extension of MPEG 2)`,[Re]:Mi,[G]:{0:Vo,4:Ho,8:nn,12:Y}},8:{[D]:Y},16:{[D]:`${el}2 (${wd}13818-3)`,[Re]:Mi,[G]:{0:tn,4:en,8:rn,12:Y}},24:{[D]:`${el}1 (${wd}11172-3)`,[Re]:ls,[G]:{0:Qr,4:Ht,8:Jr,12:Y}},length:M},Zh={0:Jo,1:bi},Yh={0:bi,1:"50/15 ms",2:Y,3:"CCIT J.17"},Ad={0:{[k]:2,[D]:Ut},64:{[k]:2,[D]:"joint "+Ut},128:{[k]:2,[D]:"dual channel"},192:{[k]:1,[D]:Nt}},vr=class e extends Be{static*[Z](t,r,n){let i={},o=yield*Ai.getID3v2Header(t,r,n);o&&(yield*t[K](o[M],n),t[Xe](o[M]));let s=yield*t[K](4,n),a=Pe(s[H](0,4)),d=r[Z](a);if(d)return new e(d);if(s[0]!==255||s[1]<224)return null;let l=$h[s[1]&24];if(l[D]===Y)return null;let c=s[1]&6;if(Ja[c][D]===Y)return null;let h={...Ja[c],...Ja[c][l[Re]]};if(i[vt]=l[D],i[Re]=h[D],i[W]=h[W],i[St]=Zh[s[1]&1],i[M]=4,i[be]=Md[s[2]&240][h[br]],i[be]===Ae||(i[G]=l[G][s[2]&12],i[G]===Y)||(i[ct]=s[2]&2&&h[ct],i[_t]=!!(s[2]&1),i[Ce]=Math.floor(125*i[be]*i[W]/i[G]+i[ct]),!i[Ce]))return null;let u=s[3]&192;if(i[Se]=Ad[u][D],i[k]=Ad[u][k],i[bt]=h[bt][s[3]&48],i[ri]=!!(s[3]&8),i[xt]=!!(s[3]&4),i[sn]=Yh[s[3]&3],i[sn]===Y)return null;i[_e]=16;{let{length:f,frameLength:m,samples:g,...p}=i;r[Ke](a,i,p)}return new e(i)}constructor(t){super(t),this[be]=t[be],this[sn]=t[sn],this[ct]=t[ct],this[ri]=t[ri],this[xt]=t[xt],this[_t]=t[_t],this[Re]=t[Re],this[bt]=t[bt],this[vt]=t[vt],this[St]=t[St]}};var Ei=class e extends Fe{static*[$e](t,r,n){return yield*super[$e](vr,e,t,r,n)}constructor(t,r,n){super(t,r,n)}};var Li=class extends Me{constructor(t,r,n){super(t,r),this.Frame=Ei,this.Header=vr,n(this[ee])}get[ee](){return Go}*[ft](){return yield*this[Yt]()}};var qh={0:"MPEG-4",8:"MPEG-2"},jh={0:"valid",2:Ae,4:Ae,6:Ae},Qh={0:Jo,1:bi},Jh={0:"AAC Main",64:"AAC LC (Low Complexity)",128:"AAC SSR (Scalable Sample Rate)",192:"AAC LTP (Long Term Prediction)"},em={0:No,4:Uo,8:fd,12:Ht,16:Qr,20:Jr,24:en,28:tn,32:rn,36:Ho,40:Vo,44:nn,48:hd,52:Y,56:Y,60:"frequency is written explicitly"},Ed={0:{[k]:0,[D]:"Defined in AOT Specific Config"},64:{[k]:1,[D]:Nt},128:{[k]:2,[D]:ie(2,P[0][0])},192:{[k]:3,[D]:ie(3,P[1][3])},256:{[k]:4,[D]:ie(4,P[1][3],P[3][4])},320:{[k]:5,[D]:ie(5,P[1][3],P[3][0])},384:{[k]:6,[D]:ie(6,P[1][3],P[3][0],st)},448:{[k]:8,[D]:ie(8,P[1][3],P[2][0],P[3][0],st)}},Sr=class e extends Be{static*[Z](t,r,n){let i={},o=yield*t[K](7,n),s=Pe([o[0],o[1],o[2],o[3]&252|o[6]&3]),a=r[Z](s);if(a)Object.assign(i,a);else{if(o[0]!==255||o[1]<240||(i[vt]=qh[o[1]&8],i[Re]=jh[o[1]&6],i[Re]===Ae))return null;let l=o[1]&1;i[St]=Qh[l],i[M]=l?7:9,i[Wo]=o[2]&192,i[dt]=o[2]&60;let c=o[2]&2;if(i[ai]=Jh[i[Wo]],i[G]=em[i[dt]],i[G]===Y)return null;i[_t]=!!c,i[fi]=(o[2]<<8|o[3])&448,i[Se]=Ed[i[fi]][D],i[k]=Ed[i[fi]][k],i[xt]=!!(o[3]&32),i[ni]=!!(o[3]&8),i[hi]=!!(o[3]&8),i[mi]=!!(o[3]&4),i[_e]=16,i[W]=1024,i[oi]=o[6]&3;{let{length:h,channelModeBits:u,profileBits:f,sampleRateBits:m,frameLength:g,samples:p,numberAACFrames:x,...S}=i;r[Ke](s,i,S)}}if(i[Ce]=(o[3]<<11|o[4]<<3|o[5]>>5)&8191,!i[Ce])return null;let d=(o[5]<<6|o[6]>>2)&2047;return i[jn]=d===2047?"VBR":d,new e(i)}constructor(t){super(t),this[hi]=t[hi],this[mi]=t[mi],this[jn]=t[jn],this[ni]=t[ni],this[xt]=t[xt],this[_t]=t[_t],this[Re]=t[Re],this[M]=t[M],this[vt]=t[vt],this[oi]=t[oi],this[ai]=t[ai],this[St]=t[St]}get audioSpecificConfig(){let t=ue.get(this),r=t[Wo]+64<<5|t[dt]<<5|t[fi]>>3,n=new we(2);return new jt(n[at]).setUint16(0,r,!1),n}};var Ti=class e extends Fe{static*[$e](t,r,n){return yield*super[$e](Sr,e,t,r,n)}constructor(t,r,n){super(t,r,n)}};var Ii=class extends Me{constructor(t,r,n){super(t,r),this.Frame=Ti,this.Header=Sr,n(this[ee])}get[ee](){return"aac"}*[ft](){return yield*this[Yt]()}};var Qt=class e extends Fe{static _getFrameFooterCrc16(t){return(t[t[M]-2]<<8)+t[t[M]-1]}static[Qo](t){let r=e._getFrameFooterCrc16(t),n=xd(t[H](0,-2));return r===n}constructor(t,r,n){r[xi]=n,r[Jn]=e._getFrameFooterCrc16(t),super(r,t,ue.get(r)[W])}};var Ld="get from STREAMINFO metadata block",tm={0:"Fixed",1:"Variable"},Td={0:Y,16:192};for(let e=2;e<16;e++)Td[e<<4]=e<6?576*2**(e-2):2**e;var rm={0:Ld,1:Uo,2:ud,3:dd,4:nn,5:rn,6:tn,7:en,8:Jr,9:Qr,10:Ht,11:No,15:Ae},nm={0:{[k]:1,[D]:Nt},16:{[k]:2,[D]:ie(2,P[0][0])},32:{[k]:3,[D]:ie(3,P[0][1])},48:{[k]:4,[D]:ie(4,P[1][0],P[3][0])},64:{[k]:5,[D]:ie(5,P[1][1],P[3][0])},80:{[k]:6,[D]:ie(6,P[1][1],st,P[3][0])},96:{[k]:7,[D]:ie(7,P[1][1],st,P[3][4],P[2][0])},112:{[k]:8,[D]:ie(8,P[1][1],st,P[3][0],P[2][0])},128:{[k]:2,[D]:`${Ut} (left, diff)`},144:{[k]:2,[D]:`${Ut} (diff, right)`},160:{[k]:2,[D]:`${Ut} (avg, diff)`},176:Y,192:Y,208:Y,224:Y,240:Y},im={0:Ld,2:8,4:12,6:Y,8:16,10:20,12:24,14:Y},Jt=class e extends Be{static _decodeUTF8Int(t){if(t[0]>254)return null;if(t[0]<128)return{value:t[0],length:1};let r=1;for(let s=64;s&t[0];s>>=1)r++;let n=r-1,i=0,o=0;for(;n>0;o+=6,n--){if((t[n]&192)!==128)return null;i|=(t[n]&63)<<o}return i|=(t[n]&127>>r)<<o,{value:i,length:r}}static[Ze](t,r){let n={[K]:function*(){return t}};return e[Z](n,r,0).next().value}static*[Z](t,r,n){let i=yield*t[K](6,n);if(i[0]!==255||!(i[1]===248||i[1]===249))return null;let o={},s=Pe(i[H](0,4)),a=r[Z](s);if(a)Object.assign(o,a);else{if(o[Ko]=i[1]&1,o[ci]=tm[o[Ko]],o[di]=i[2]&240,o[dt]=i[2]&15,o[wt]=Td[o[di]],o[wt]===Y||(o[G]=rm[o[dt]],o[G]===Ae)||i[3]&1)return null;let l=nm[i[3]&240];if(l===Y||(o[k]=l[k],o[Se]=l[D],o[_e]=im[i[3]&14],o[_e]===Y))return null}o[M]=5,i=yield*t[K](o[M]+8,n);let d=e._decodeUTF8Int(i[H](4));if(!d||(o[Ko]?o[gi]=d.value:o[Lt]=d.value,o[M]+=d[M],o[di]===96?(i[M]<o[M]&&(i=yield*t[K](o[M],n)),o[wt]=i[o[M]-1]+1,o[M]+=1):o[di]===112&&(i[M]<o[M]&&(i=yield*t[K](o[M],n)),o[wt]=(i[o[M]-1]<<8)+i[o[M]]+1,o[M]+=2),o[W]=o[wt],o[dt]===12?(i[M]<o[M]&&(i=yield*t[K](o[M],n)),o[G]=i[o[M]-1]*1e3,o[M]+=1):o[dt]===13?(i[M]<o[M]&&(i=yield*t[K](o[M],n)),o[G]=(i[o[M]-1]<<8)+i[o[M]],o[M]+=2):o[dt]===14&&(i[M]<o[M]&&(i=yield*t[K](o[M],n)),o[G]=((i[o[M]-1]<<8)+i[o[M]])*10,o[M]+=2),i[M]<o[M]&&(i=yield*t[K](o[M],n)),o[on]=i[o[M]-1],o[on]!==yd(i[H](0,o[M]-1))))return null;if(!a){let{blockingStrategyBits:l,frameNumber:c,sampleNumber:h,samples:u,sampleRateBits:f,blockSizeBits:m,crc:g,length:p,...x}=o;r[Ke](s,o,x)}return new e(o)}constructor(t){super(t),this[Jn]=null,this[ci]=t[ci],this[wt]=t[wt],this[Lt]=t[Lt],this[gi]=t[gi],this[xi]=null}};var om=2,sm=512*1024,wr=class extends Me{constructor(t,r,n){super(t,r),this.Frame=Qt,this.Header=Jt,n(this[ee])}get[ee](){return"flac"}*_getNextFrameSyncOffset(t){let r=yield*this._codecParser[K](2,0),n=r[M]-2;for(;t<n;){if(r[t]===255){let o=r[t+1];if(o===248||o===249)break;o!==255&&t++}t++}return t}*[ft](){do{let t=yield*Jt[Z](this._codecParser,this._headerCache,0);if(t){let r=ue.get(t)[M]+om;for(;r<=sm;){if(this._codecParser._flushing||(yield*Jt[Z](this._codecParser,this._headerCache,r))){let n=yield*this._codecParser[K](r);if(this._codecParser._flushing||(n=n[H](0,r)),Qt[Qo](n)){let i=new Qt(n,t);return this._headerCache[nt](),this._codecParser[Xe](r),this._codecParser[Zt](i),i}}r=yield*this._getNextFrameSyncOffset(r+1)}this._codecParser[tt](`Unable to sync FLAC frame after searching ${r} bytes.`),this._codecParser[Xe](r)}else this._codecParser[Xe](yield*this._getNextFrameSyncOffset(1))}while(!0)}[qt](t){return t[le]===0?(this._headerCache[nt](),this._streamInfo=t[Q][H](13)):t[le]===1||(t[ve]=pe.get(t)[We].map(r=>{let n=Jt[Ze](r,this._headerCache);if(n)return new Qt(r,n,this._streamInfo);this._codecParser[tt]("Failed to parse Ogg FLAC frame","Skipping invalid FLAC frame")}).filter(r=>!!r)),t}};var Ar=class e{static*[Z](t,r,n){let i={},o=yield*t[K](28,n);if(o[0]!==79||o[1]!==103||o[2]!==103||o[3]!==83||(i[Xa]=o[4],o[5]&248))return null;i[Oe]=!!(o[5]&4),i[Gt]=!!(o[5]&2),i[Vt]=!!(o[5]&1);let a=new jt(we.from(o[H](0,28))[at]);i[et]=bd(a,6),i[ut]=a.getInt32(14,!0),i[le]=a.getInt32(18,!0),i[pr]=a.getInt32(22,!0);let d=o[26];i[M]=d+27,o=yield*t[K](i[M],n),i[Ce]=0,i[$t]=[],i[ln]=we.from(o[H](27,i[M]));for(let l=0,c=0;l<d;l++){let h=i[ln][l];i[Ce]+=h,c+=h,(h!==255||l===d-1)&&(i[$t].push(c),c=0)}return new e(i)}constructor(t){ue.set(this,t),this[et]=t[et],this[Vt]=t[Vt],this[Gt]=t[Gt],this[Oe]=t[Oe],this[$t]=t[$t],this[le]=t[le],this[pr]=t[pr],this[ut]=t[ut]}};var Ri=class e extends _r{static*[$e](t,r,n){let i=yield*Ar[Z](t,r,n);if(i){let o=ue.get(i)[Ce],s=ue.get(i)[M],a=s+o,d=(yield*t[K](a,0))[H](0,a),l=d[H](s,a);return new e(i,l,d)}else return null}constructor(t,r,n){super(t,r),pe.get(this)[M]=n[M],this[ve]=[],this[Va]=n,this[et]=t[et],this[ei]=t[pr],this[lt]=0,this[Vt]=t[Vt],this[Gt]=t[Gt],this[Oe]=t[Oe],this[le]=t[le],this[W]=0,this[ut]=t[ut]}};var dn=class extends Fe{constructor(t,r,n){super(r,t,n)}};var Id={0:$n.slice(0,2),1:$n},Ye="SILK-only",ge="CELT-only",cs="Hybrid",er="narrowband",ds="medium-band",tr="wideband",un="super-wideband",fn="fullband",am={0:{[B]:Ye,[N]:er,[F]:10},8:{[B]:Ye,[N]:er,[F]:20},16:{[B]:Ye,[N]:er,[F]:40},24:{[B]:Ye,[N]:er,[F]:60},32:{[B]:Ye,[N]:ds,[F]:10},40:{[B]:Ye,[N]:ds,[F]:20},48:{[B]:Ye,[N]:ds,[F]:40},56:{[B]:Ye,[N]:ds,[F]:60},64:{[B]:Ye,[N]:tr,[F]:10},72:{[B]:Ye,[N]:tr,[F]:20},80:{[B]:Ye,[N]:tr,[F]:40},88:{[B]:Ye,[N]:tr,[F]:60},96:{[B]:cs,[N]:un,[F]:10},104:{[B]:cs,[N]:un,[F]:20},112:{[B]:cs,[N]:fn,[F]:10},120:{[B]:cs,[N]:fn,[F]:20},128:{[B]:ge,[N]:er,[F]:2.5},136:{[B]:ge,[N]:er,[F]:5},144:{[B]:ge,[N]:er,[F]:10},152:{[B]:ge,[N]:er,[F]:20},160:{[B]:ge,[N]:tr,[F]:2.5},168:{[B]:ge,[N]:tr,[F]:5},176:{[B]:ge,[N]:tr,[F]:10},184:{[B]:ge,[N]:tr,[F]:20},192:{[B]:ge,[N]:un,[F]:2.5},200:{[B]:ge,[N]:un,[F]:5},208:{[B]:ge,[N]:un,[F]:10},216:{[B]:ge,[N]:un,[F]:20},224:{[B]:ge,[N]:fn,[F]:2.5},232:{[B]:ge,[N]:fn,[F]:5},240:{[B]:ge,[N]:fn,[F]:10},248:{[B]:ge,[N]:fn,[F]:20}},hn=class e extends Be{static[Ze](t,r,n){let i={};if(i[k]=t[9],i[At]=t[18],i[M]=i[At]!==0?21+i[k]:19,t[M]<i[M])throw new Error("Out of data while inside an Ogg Page");let o=r[0]&3,s=o===3?2:1,a=Pe(t[H](0,i[M]))+Pe(r[H](0,s)),d=n[Z](a);if(d)return new e(d);if(a.substr(0,8)!=="OpusHead"||t[8]!==1)return null;i[Q]=we.from(t[H](0,i[M]));let l=new jt(i[Q][at]);if(i[_e]=16,i[hr]=l.getUint16(10,!0),i[pi]=l.getUint32(12,!0),i[G]=Ht,i[si]=l.getInt16(16,!0),i[At]in Id&&(i[Se]=Id[i[At]][i[k]-1],!i[Se]))return null;i[At]!==0&&(i[yi]=t[19],i[Qn]=t[20],i[ui]=[...t[H](21,i[k]+21)]);let c=am[248&r[0]];switch(i[B]=c[B],i[N]=c[N],i[F]=c[F],o){case 0:i[Et]=1;break;case 1:case 2:i[Et]=2;break;case 3:i[ii]=!!(128&r[1]),i[ti]=!!(64&r[1]),i[Et]=63&r[1];break;default:return null}{let{length:h,data:u,channelMappingFamily:f,...m}=i;n[Ke](a,i,m)}return new e(i)}constructor(t){super(t),this[Q]=t[Q],this[N]=t[N],this[At]=t[At],this[ui]=t[ui],this[Qn]=t[Qn],this[Et]=t[Et],this[F]=t[F],this[ti]=t[ti],this[pi]=t[pi],this[ii]=t[ii],this[B]=t[B],this[si]=t[si],this[hr]=t[hr],this[yi]=t[yi]}};var Ci=class extends Me{constructor(t,r,n){super(t,r),this.Frame=dn,this.Header=hn,n(this[ee]),this._identificationHeader=null,this._preSkipRemaining=null}get[ee](){return"opus"}[qt](t){return t[le]===0?(this._headerCache[nt](),this._identificationHeader=t[Q]):t[le]===1||(t[ve]=pe.get(t)[We].map(r=>{let n=hn[Ze](this._identificationHeader,r,this._headerCache);if(n){this._preSkipRemaining===null&&(this._preSkipRemaining=n[hr]);let i=n[F]*n[Et]/1e3*n[G];return this._preSkipRemaining>0&&(this._preSkipRemaining-=i,i=this._preSkipRemaining<0?-this._preSkipRemaining:0),new dn(r,n,i)}this._codecParser[qo]("Failed to parse Ogg Opus Header","Not a valid Ogg Opus file")})),t}};var mn=class extends Fe{constructor(t,r,n){super(r,t,n)}};var tl={};for(let e=0;e<8;e++)tl[e+6]=2**(6+e);var zi=class e extends Be{static[Ze](t,r,n,i){if(t[M]<30)throw new Error("Out of data while inside an Ogg Page");let o=Pe(t[H](0,30)),s=r[Z](o);if(s)return new e(s);let a={[M]:30};if(o.substr(0,7)!=="vorbis")return null;a[Q]=we.from(t[H](0,30));let d=new jt(a[Q][at]);if(a[Wt]=d.getUint32(7,!0),a[Wt]!==0||(a[k]=t[11],a[Se]=$n[a[k]-1]||"application defined",a[G]=d.getUint32(12,!0),a[Zn]=d.getInt32(16,!0),a[qn]=d.getInt32(20,!0),a[Yn]=d.getInt32(24,!0),a[Kt]=tl[(t[28]&240)>>4],a[Xt]=tl[t[28]&15],a[Xt]>a[Kt])||t[29]!==1)return null;a[_e]=32,a[an]=i,a[li]=n;{let{length:l,data:c,version:h,vorbisSetup:u,vorbisComments:f,...m}=a;r[Ke](o,a,m)}return new e(a)}constructor(t){super(t),this[Zn]=t[Zn],this[Yn]=t[Yn],this[qn]=t[qn],this[Xt]=t[Xt],this[Kt]=t[Kt],this[Q]=t[Q],this[li]=t[li],this[an]=t[an]}};var ki=class extends Me{constructor(t,r,n){super(t,r),this.Frame=mn,n(this[ee]),this._identificationHeader=null,this._setupComplete=!1,this._prevBlockSize=null}get[ee](){return mr}[qt](t){t[ve]=[];for(let r of pe.get(t)[We])if(r[0]===1)this._headerCache[nt](),this._identificationHeader=t[Q],this._setupComplete=!1;else if(r[0]===3)this._vorbisComments=r;else if(r[0]===5)this._vorbisSetup=r,this._mode=this._parseSetupHeader(r),this._setupComplete=!0;else if(this._setupComplete){let n=zi[Ze](this._identificationHeader,this._headerCache,this._vorbisComments,this._vorbisSetup);n?t[ve].push(new mn(r,n,this._getSamples(r,n))):this._codecParser[logError]("Failed to parse Ogg Vorbis Header","Not a valid Ogg Vorbis file")}return t}_getSamples(t,r){let i=this._mode.blockFlags[t[0]>>1&this._mode.mask]?r[Kt]:r[Xt],o=this._prevBlockSize===null?0:(this._prevBlockSize+i)/4;return this._prevBlockSize=i,o}_parseSetupHeader(t){let r=new es(t),n={count:0,blockFlags:[]};for(;(r.read(1)&1)!==1;);let i;for(;n.count<64&&r.position>0;){vi(r.read(8));let o=0;for(;r.read(8)===0&&o++<3;);if(o===4)i=r.read(7),n.blockFlags.unshift(i&1),r.position+=6,n.count++;else{((vi(i)&126)>>1)+1!==n.count&&this._codecParser[tt]("vorbis derived mode count did not match actual mode count");break}}return n.mask=(1<<Math.log2(n.count))-1,n}};var rl=class{constructor(t,r,n){this._codecParser=t,this._headerCache=r,this._onCodec=n,this._continuedPacket=new we,this._codec=null,this._isSupported=null,this._previousAbsoluteGranulePosition=null}get[ee](){return this._codec||""}_updateCodec(t,r){this._codec!==t&&(this._headerCache[rt](),this._parser=new r(this._codecParser,this._headerCache,this._onCodec),this._codec=t)}_checkCodecSupport({data:t}){let r=Pe(t[H](0,8));switch(r){case"fishead\0":return!1;case"OpusHead":return this._updateCodec("opus",Ci),!0;case(/^\x7fFLAC/.test(r)&&r):return this._updateCodec("flac",wr),!0;case(/^\x01vorbis/.test(r)&&r):return this._updateCodec(mr,ki),!0;default:return!1}}_checkPageSequenceNumber(t){t[le]!==this._pageSequenceNumber+1&&this._pageSequenceNumber>1&&t[le]>1&&this._codecParser[tt]("Unexpected gap in Ogg Page Sequence Number.",`Expected: ${this._pageSequenceNumber+1}, Got: ${t[le]}`),this._pageSequenceNumber=t[le]}_parsePage(t){this._isSupported===null&&(this._pageSequenceNumber=t[le],this._isSupported=this._checkCodecSupport(t)),this._checkPageSequenceNumber(t);let r=pe.get(t),n=ue.get(r[De]),i=0;if(r[We]=n[$t].map(o=>t[Q][H](i,i+=o)),this._continuedPacket[M]&&(r[We][0]=Si(this._continuedPacket,r[We][0]),this._continuedPacket=new we),n[ln][n[ln][M]-1]===255&&(this._continuedPacket=Si(this._continuedPacket,r[We].pop())),this._previousAbsoluteGranulePosition!==null&&(t[W]=Number(t[et]-this._previousAbsoluteGranulePosition)),this._previousAbsoluteGranulePosition=t[et],this._isSupported){let o=this._parser[qt](t);return this._codecParser[Zt](o),o}else return t}},Di=class extends Me{constructor(t,r,n){super(t,r),this._onCodec=n,this.Frame=Ri,this.Header=Ar,this._streams=new Map,this._currentSerialNumber=null}get[ee](){let t=this._streams.get(this._currentSerialNumber);return t?t.codec:""}*[ft](){let t=yield*this[Yt](!0);this._currentSerialNumber=t[ut];let r=this._streams.get(this._currentSerialNumber);return r||(r=new rl(this._codecParser,this._headerCache,this._onCodec),this._streams.set(this._currentSerialNumber,r)),t[Oe]&&this._streams.delete(this._currentSerialNumber),r._parsePage(t)}};var nl=()=>{},Oi=class{constructor(t,{onCodec:r,onCodecHeader:n,onCodecUpdate:i,enableLogging:o=!1,enableFrameCRC32:s=!0}={}){this._inputMimeType=t,this._onCodec=r||nl,this._onCodecHeader=n||nl,this._onCodecUpdate=i,this._enableLogging=o,this._crc32=s?_d:nl,this[rt]()}get[ee](){return this._parser?this._parser[ee]:""}[rt](){this._headerCache=new wi(this._onCodecHeader,this._onCodecUpdate),this._generator=this._getGenerator(),this._generator.next()}*flush(){this._flushing=!0;for(let t=this._generator.next();t.value;t=this._generator.next())yield t.value;this._flushing=!1,this[rt]()}*parseChunk(t){for(let r=this._generator.next(t);r.value;r=this._generator.next())yield r.value}parseAll(t){return[...this.parseChunk(t),...this.flush()]}*_getGenerator(){if(this._inputMimeType.match(/aac/))this._parser=new Ii(this,this._headerCache,this._onCodec);else if(this._inputMimeType.match(/mpeg/))this._parser=new Li(this,this._headerCache,this._onCodec);else if(this._inputMimeType.match(/flac/))this._parser=new wr(this,this._headerCache,this._onCodec);else if(this._inputMimeType.match(/ogg/))this._parser=new Di(this,this._headerCache,this._onCodec);else throw new Error(`Unsupported Codec ${mimeType}`);for(this._frameNumber=0,this._currentReadPosition=0,this._totalBytesIn=0,this._totalBytesOut=0,this._totalSamples=0,this._sampleRate=void 0,this._rawData=new Uint8Array(0);;){let t=yield*this._parser[ft]();t&&(yield t)}}*[K](t=0,r=0){let n;for(;this._rawData[M]<=t+r;){if(n=yield,this._flushing)return this._rawData[H](r);n&&(this._totalBytesIn+=n[M],this._rawData=Si(this._rawData,n))}return this._rawData[H](r)}[Xe](t){this._currentReadPosition+=t,this._rawData=this._rawData[H](t)}[_i](t){this._sampleRate=t[De][G],t[De][be]=t[lt]>0?Math.round(t[Q][M]/t[lt])*8:0,t[Lt]=this._frameNumber++,t[gr]=this._totalBytesOut,t[xr]=this._totalSamples,t[yr]=this._totalSamples/this._sampleRate*1e3,t[ei]=this._crc32(t[Q]),this._headerCache[jo](t[De][be],t[yr]),this._totalBytesOut+=t[Q][M],this._totalSamples+=t[W]}[Zt](t){if(t[ve]){if(t[Oe]){let r=t[W];t[ve].forEach(n=>{let i=n[W];r<i&&(n[W]=r>0?r:0,n[lt]=n[W]/n[De][G]*1e3),r-=i,this[_i](n)})}else t[W]=0,t[ve].forEach(r=>{t[W]+=r[W],this[_i](r)});t[lt]=t[W]/this._sampleRate*1e3||0,t[xr]=this._totalSamples,t[yr]=this._totalSamples/this._sampleRate*1e3||0,t[gr]=this._totalBytesOut}else this[_i](t)}_log(t,r){if(this._enableLogging){let n=[`${ee}: ${this[ee]}`,`inputMimeType: ${this._inputMimeType}`,`readPosition: ${this._currentReadPosition}`,`totalBytesIn: ${this._totalBytesIn}`,`${gr}: ${this._totalBytesOut}`],i=Math.max(...n.map(o=>o[M]));r.push(`--stats--${"-".repeat(i-9)}`,...n,"-".repeat(i)),t("codec-parser",r.reduce((o,s)=>o+`
|
|
4
4
|
`+s,""))}}[tt](...t){this._log(console.warn,t)}[qo](...t){this._log(console.error,t)}};var Rd=Oi;var us=ve;var fs=Q;var Cd=De;var zd=Oe;var kd=an;var Dd=xr;function Tt(e){var t=t;function r(){}t={};function n(R){throw R}var i,o,s,a,d,l,c,h,u,f,m;function g(){var R=m.buffer;i=new Int8Array(R),o=new Int16Array(R),a=new Uint8Array(R),d=new Uint16Array(R),s=new Int32Array(R),l=new Uint32Array(R),c=new Float32Array(R),h=new Float64Array(R),u=new BigInt64Array(R),f=new BigUint64Array(R)}for(var p=R=>{for(var He,Cn,Br=0,yo=0,xo=R.length,_o=new Uint8Array((xo*3>>2)-(R[xo-2]=="=")-(R[xo-1]=="="));Br<xo;Br+=4,yo+=3)He=$[R.charCodeAt(Br+1)],Cn=$[R.charCodeAt(Br+2)],_o[yo]=$[R.charCodeAt(Br)]<<2|He>>4,_o[yo+1]=He<<4|Cn>>2,_o[yo+2]=Cn<<6|$[R.charCodeAt(Br+3)];return _o},x=()=>n(""),S=()=>{},_={},y=R=>R(),b=()=>performance.now(),A=(R,He)=>{if(_[R]&&(clearTimeout(_[R].id),delete _[R]),!He)return 0;var Cn=setTimeout(()=>{delete _[R],y(()=>Ac(R,b()))},He);return _[R]={id:Cn,timeout_ms:He},0},v=Math.atan,E=Math.cos,L=Math.exp,w=Math.log,T=Math.pow,z=Math.sin,U=R=>{var He=a.length;return R>>>=0,!1},C=R=>{throw`exit(${R})`},$=new Uint8Array(123),Ie=25;Ie>=0;--Ie)$[48+Ie]=52+Ie,$[65+Ie]=Ie,$[97+Ie]=26+Ie;$[43]=62,$[47]=63;var lr={e:x,d:S,f:A,b:v,a:E,i:L,h:w,g:T,c:z,k:U,j:C};function go(R){Rn=R.n,xc=R.o,_c=R.p,bc=R.q,vc=R.r,Sc=R.s,wc=R.t,Ac=R.v}var Rn,xc,_c,bc,vc,Sc,wc,Ac;function Hu(R){R.m()}Tt.wasm||Object.defineProperty(Tt,"wasm",{get:()=>String.raw`dynEncode012091253f87dì%nä= 4&¿nÝØäÂLÚªã9ÚØ[äº\ ¼¡³R=}L]Èÿ2 ÿù¶J1jj¡é,zäV|i¸Qk¹=
|