quake2ts 0.0.75 → 0.0.77
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 +1 -1
- package/packages/client/dist/browser/index.global.js.map +1 -1
- package/packages/client/dist/cjs/index.cjs.map +1 -1
- 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 +10 -10
- package/packages/engine/dist/browser/index.global.js.map +1 -1
- package/packages/engine/dist/cjs/index.cjs.map +1 -1
- package/packages/engine/dist/esm/index.js.map +1 -1
- package/packages/engine/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/engine/dist/types/demo/parser.d.ts +45 -0
- package/packages/engine/dist/types/demo/parser.d.ts.map +1 -0
- package/packages/engine/dist/types/demo/playback.d.ts +22 -0
- package/packages/engine/dist/types/demo/playback.d.ts.map +1 -0
- package/packages/engine/dist/types/demo/reader.d.ts +15 -0
- package/packages/engine/dist/types/demo/reader.d.ts.map +1 -0
- package/packages/game/dist/browser/index.global.js +1 -1
- package/packages/game/dist/browser/index.global.js.map +1 -1
- package/packages/game/dist/cjs/index.cjs.map +1 -1
- package/packages/game/dist/esm/index.js.map +1 -1
- package/packages/game/dist/tsconfig.tsbuildinfo +1 -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 +209 -0
- package/packages/shared/dist/cjs/index.cjs.map +1 -1
- package/packages/shared/dist/esm/index.js +205 -0
- package/packages/shared/dist/esm/index.js.map +1 -1
- package/packages/shared/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/shared/dist/types/index.d.ts +1 -0
- package/packages/shared/dist/types/index.d.ts.map +1 -1
- package/packages/shared/dist/types/io/binaryStream.d.ts +31 -0
- package/packages/shared/dist/types/io/binaryStream.d.ts.map +1 -0
- package/packages/shared/dist/types/protocol/index.d.ts +2 -0
- package/packages/shared/dist/types/protocol/index.d.ts.map +1 -1
- package/packages/shared/dist/types/protocol/ops.d.ts +31 -0
- package/packages/shared/dist/types/protocol/ops.d.ts.map +1 -0
- package/packages/shared/dist/types/protocol/tempEntity.d.ts +59 -0
- package/packages/shared/dist/types/protocol/tempEntity.d.ts.map +1 -0
- package/packages/tools/dist/tsconfig.tsbuildinfo +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";var Quake2Engine=(()=>{var Rc=Object.create;var Un=Object.defineProperty;var Bc=Object.getOwnPropertyDescriptor;var kc=Object.getOwnPropertyNames;var Dc=Object.getPrototypeOf,Hc=Object.prototype.hasOwnProperty;var Oc=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),di=(t,e)=>{for(var r in e)Un(t,r,{get:e[r],enumerable:!0})},Ts=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of kc(e))!Hc.call(t,o)&&o!==r&&Un(t,o,{get:()=>e[o],enumerable:!(n=Bc(e,o))||n.enumerable});return t};var Nc=(t,e,r)=>(r=t!=null?Rc(Dc(t)):{},Ts(e||!t||!t.__esModule?Un(r,"default",{value:t,enumerable:!0}):r,t)),Vc=t=>Ts(Un({},"__esModule",{value:!0}),t);var ma=Oc((Dm,ua)=>{"use strict";ua.exports=Worker});var Au={};di(Au,{ATTN_IDLE:()=>Ga,ATTN_LOOP_NONE:()=>Va,ATTN_NONE:()=>No,ATTN_NORM:()=>Ua,ATTN_STATIC:()=>Wa,AssetDependencyError:()=>jt,AssetDependencyTracker:()=>Rn,AssetManager:()=>Ho,AudioApi:()=>Qo,AudioContextController:()=>Uo,AudioRegistry:()=>Ar,AudioRegistryError:()=>In,AudioSystem:()=>jo,BSP_SURFACE_FRAGMENT_SOURCE:()=>os,BSP_SURFACE_VERTEX_SOURCE:()=>ns,BSP_VERTEX_LAYOUT:()=>es,BspLoader:()=>Zn,BspParseError:()=>q,BspSurfacePipeline:()=>ei,Camera:()=>ii,ConfigStringRegistry:()=>er,Cvar:()=>Br,CvarRegistry:()=>jn,EngineHost:()=>Jt,EngineRuntime:()=>Rr,FixedTimestepLoop:()=>Ft,Framebuffer:()=>Jo,IndexBuffer:()=>De,LruCache:()=>mt,MAX_SOUND_CHANNELS:()=>$i,MD2_FRAGMENT_SHADER:()=>us,MD2_VERTEX_SHADER:()=>ds,MD3_FRAGMENT_SHADER:()=>bs,MD3_VERTEX_SHADER:()=>vs,Md2Loader:()=>rr,Md2MeshBuffers:()=>ri,Md2ParseError:()=>ae,Md2Pipeline:()=>ni,Md3Loader:()=>nr,Md3ModelMesh:()=>si,Md3ParseError:()=>Te,Md3Pipeline:()=>ai,Md3SurfaceMesh:()=>Dn,MusicSystem:()=>$o,PARTICLE_FRAGMENT_SHADER:()=>Ms,PARTICLE_VERTEX_SHADER:()=>Ss,PakArchive:()=>tr,PakIndexStore:()=>Do,PakIngestionError:()=>ut,PakParseError:()=>Ce,PakValidationError:()=>Pt,PakValidator:()=>Qn,ParticleRenderer:()=>li,ParticleSystem:()=>ci,RERELEASE_KNOWN_PAKS:()=>Mi,SKYBOX_FRAGMENT_SHADER:()=>cs,SKYBOX_VERTEX_SHADER:()=>as,SOUND_FULLVOLUME:()=>_r,SOUND_LOOP_ATTENUATE:()=>Xa,ShaderProgram:()=>ge,SkyboxPipeline:()=>ti,SoundChannel:()=>Oo,SoundPrecache:()=>Xo,SoundRegistry:()=>Wo,SpriteLoader:()=>or,SpriteParseError:()=>ft,Texture2D:()=>wr,TextureCache:()=>ir,TextureCubeMap:()=>Lr,VertexArray:()=>Me,VertexBuffer:()=>xe,VirtualFileSystem:()=>$n,advanceAnimation:()=>oa,applySurfaceState:()=>oc,attenuationToDistanceMultiplier:()=>$t,boxIntersectsFrustum:()=>kn,buildBspGeometry:()=>Qa,buildMd2Geometry:()=>ms,buildMd2VertexData:()=>fs,buildMd3SurfaceGeometry:()=>gs,buildMd3VertexData:()=>xs,calculateMaxAudibleDistance:()=>Vo,calculatePakChecksum:()=>qs,computeFrameBlend:()=>ia,computeSkyScroll:()=>ac,createAnimationState:()=>sa,createAudioGraph:()=>Go,createBspSurfaces:()=>$a,createEngine:()=>Mu,createEngineRuntime:()=>Ws,createFaceLightmap:()=>eo,createInitialChannels:()=>qo,createProgramFromSources:()=>ja,createWebGLContext:()=>Ya,decodeOgg:()=>ko,deriveSurfaceRenderState:()=>ss,extractFrustumPlanes:()=>Ja,filesToPakSources:()=>Ai,findLeafForPoint:()=>rs,gatherVisibleFaces:()=>rc,groupMd2Animations:()=>ea,ingestPakFiles:()=>Ys,ingestPaks:()=>Jn,interpolateMd3Tag:()=>wc,interpolateVec3:()=>aa,parseBsp:()=>_i,parseMd2:()=>wi,parseMd3:()=>Li,parsePcx:()=>ca,parseSprite:()=>Ei,parseWal:()=>ro,parseWalTexture:()=>da,parseWav:()=>oo,pcxToRgba:()=>no,pickChannel:()=>Yo,preparePcxTexture:()=>la,removeViewTranslation:()=>sc,resolveLightStyles:()=>is,spatializeOrigin:()=>Ko,spawnBlood:()=>zc,spawnBulletImpact:()=>Lc,spawnExplosion:()=>Ec,spawnMuzzleFlash:()=>Tc,spawnTeleportFlash:()=>Cc,spawnTrail:()=>Ic,walToRgba:()=>zi,wireDropTarget:()=>Ks,wireFileInput:()=>js});var Uc=()=>typeof performance<"u"?performance.now():Date.now(),Gc=t=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(()=>t()):setTimeout(t,25)},Ft=class{constructor(e,r={}){this.callbacks=e;this.accumulatorMs=0;this.frame=0;this.running=!1;this.tick=()=>{if(!this.running)return;let e=this.options.now(),r=this.lastTimeMs===void 0?0:e-this.lastTimeMs;this.lastTimeMs=e,this.advance(r,e),this.running&&this.options.schedule(this.tick)};let n=r.fixedDeltaMs??25,o=r.maxSubSteps??5;this.options={fixedDeltaMs:n,maxSubSteps:o,maxDeltaMs:r.maxDeltaMs??n*o,startTimeMs:r.startTimeMs,now:r.now??Uc,schedule:r.schedule??Gc}}start(){this.running||(this.running=!0,this.lastTimeMs=this.options.startTimeMs??this.options.now(),this.options.schedule(this.tick))}stop(){this.running=!1}pump(e){let r=(this.lastTimeMs??0)+e;this.lastTimeMs=r,this.advance(e,r)}isRunning(){return this.running}get frameNumber(){return this.frame}advance(e,r){let n=Math.min(Math.max(e,0),this.options.maxDeltaMs);this.accumulatorMs=Math.min(this.accumulatorMs+n,this.options.fixedDeltaMs*this.options.maxSubSteps);let o=0;for(;this.accumulatorMs>=this.options.fixedDeltaMs&&o<this.options.maxSubSteps;)this.frame+=1,this.callbacks.simulate({frame:this.frame,deltaMs:this.options.fixedDeltaMs,nowMs:r}),this.accumulatorMs-=this.options.fixedDeltaMs,o+=1;let i=this.options.fixedDeltaMs===0?0:this.accumulatorMs/this.options.fixedDeltaMs;this.callbacks.render?.({alpha:i,nowMs:r,accumulatorMs:this.accumulatorMs,frame:this.frame})}};var Jt=class{constructor(e,r,n={}){this.game=e;this.client=r;this.started=!1;this.stepSimulation=e=>{this.previousFrame=this.latestFrame,this.latestFrame=this.game.frame(e,this.latestCommand)};this.renderClient=e=>{this.client&&(this.latestCommand=this.client.render({...e,previous:this.previousFrame,latest:this.latestFrame}))};let o=n.loop?.now?.()??Date.now();this.startTimeMs=n.startTimeMs??n.loop?.startTimeMs??o,this.loop=new Ft({simulate:this.stepSimulation,render:this.renderClient},{...n.loop,startTimeMs:this.startTimeMs})}start(){this.started||(this.latestFrame=this.game.init(this.startTimeMs)??this.latestFrame,this.client?.init(this.latestFrame),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(e){this.loop.pump(e)}getLatestFrame(){return this.latestFrame}isRunning(){return this.loop.isRunning()}};var Is={x:0,y:0,z:0};var zu=Math.PI/180;function Fs(t,e){return{x:t.x-e.x,y:t.y-e.y,z:t.z-e.z}}function Wc(t,e){return{x:t.x*e,y:t.y*e,z:t.z*e}}function mi(t,e){return t.x*e.x+t.y*e.y+t.z*e.z}function Xc(t){return mi(t,t)}function fi(t){return Math.sqrt(Xc(t))}function Oe(t){let e=fi(t);return e===0?t:Wc(t,1/e)}var qc=Math.PI/180,Cu=180/Math.PI,Zt=qc;function Yc(){return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function Ps(t,e){let r=e.x,n=e.y,o=e.z;return{x:t[0]*r+t[4]*n+t[8]*o+t[12],y:t[1]*r+t[5]*n+t[9]*o+t[13],z:t[2]*r+t[6]*n+t[10]*o+t[14]}}function Rs(t,e){let r=Yc();return r[0]=e[0].x,r[1]=e[0].y,r[2]=e[0].z,r[4]=e[1].x,r[5]=e[1].y,r[6]=e[1].z,r[8]=e[2].x,r[9]=e[2].y,r[10]=e[2].z,r[12]=t.x,r[13]=t.y,r[14]=t.z,r}var We=1,dt=2;var pi=8,hi=16,Kc=32;var jc=16384;var Gn=65536,Bs=1<<17,$c=1<<18,Qc=1<<19,Jc=1<<20,Zc=1<<21,el=1<<22,tl=1<<23,Tu=1<<24,Wn=1<<25,rl=1<<26,Iu=1<<27,Fu=1<<28,Pu=1<<29,Xn=1<<30,Ru=1<<31;var Pr=0;var ks=4,Ds=8,Hs=16,Os=32,Ns=64;var Bu=1<<25,ku=1<<28,Du=1<<29,Hu=1<<30,Ou=1<<31;var Nu=We|dt,Vu=We|Gn|dt|Wn|Xn,Uu=We|Gn|dt,Gu=We|Bs|dt|Wn|Xn,Wu=Kc|pi|hi,Xu=We|hi|pi,nl=We|Wn|Xn|dt|rl,qu=$c|Qc|Jc|Zc|el|tl,Yu=We|pi|hi|Wn|Xn,Ku=We|Gn|dt,ju=We|dt,$u=We|Gn|dt|Bs,Qu=nl|jc;var Ju=Number.MAX_SAFE_INTEGER-1;var qn=(t=>(t[t.None=0]="None",t[t.Archive=1]="Archive",t[t.UserInfo=2]="UserInfo",t[t.ServerInfo=4]="ServerInfo",t[t.Latch=8]="Latch",t[t.Cheat=16]="Cheat",t))(qn||{});var Yn=256;var yi=256,gi=8192,Kn=2048,xi=512,vi=256,bi=Yn*2,Si=256,ui=32,Fr=96;var X=(t=>(t[t.Name=0]="Name",t[t.CdTrack=1]="CdTrack",t[t.Sky=2]="Sky",t[t.SkyAxis=3]="SkyAxis",t[t.SkyRotate=4]="SkyRotate",t[t.StatusBar=5]="StatusBar",t[t.AirAccel=59]="AirAccel",t[t.MaxClients=60]="MaxClients",t[t.MapChecksum=61]="MapChecksum",t[t.Models=62]="Models",t[t.Sounds=62+gi]="Sounds",t[t.Images=t.Sounds+Kn]="Images",t[t.Lights=t.Images+xi]="Lights",t[t.ShadowLights=t.Lights+yi]="ShadowLights",t[t.Items=t.ShadowLights+Si]="Items",t[t.PlayerSkins=t.Items+vi]="PlayerSkins",t[t.General=t.PlayerSkins+Yn]="General",t[t.WheelWeapons=t.General+bi]="WheelWeapons",t[t.WheelAmmo=t.WheelWeapons+ui]="WheelAmmo",t[t.WheelPowerups=t.WheelAmmo+ui]="WheelPowerups",t[t.CdLoopCount=t.WheelPowerups+ui]="CdLoopCount",t[t.GameStyle=t.CdLoopCount+1]="GameStyle",t[t.MaxConfigStrings=t.GameStyle+1]="MaxConfigStrings",t))(X||{}),Vs=X.MaxConfigStrings;function Us(t){return t>=5&&t<59?Fr*(59-t):t>=X.General&&t<X.WheelWeapons?Fr*(X.MaxConfigStrings-t):Fr}function ol(t){if(t<0||t>=X.MaxConfigStrings)throw new RangeError(`Configstring index ${t} is out of range (0-${X.MaxConfigStrings-1})`)}function Gs(t,e){let r=Us(t);if(e.length>r)throw new RangeError(`Configstring ${t} exceeds maximum length (${e.length} > ${r}); limit is ${Fr} chars per slot`)}var er=class{constructor(){this.values=new Map;this.modelCursor=X.Models;this.soundCursor=X.Sounds;this.imageCursor=X.Images;this.lightCursor=X.Lights;this.shadowLightCursor=X.ShadowLights;this.itemCursor=X.Items;this.playerSkinCursor=X.PlayerSkins;this.generalCursor=X.General}set(e,r){return ol(e),Gs(e,r),this.values.set(e,r),e}get(e){return this.values.get(e)}getAll(){let e=new Array(Vs).fill("");for(let[r,n]of this.values.entries())e[r]=n;return e}modelIndex(e){return this.register(e,X.Models,gi,"modelCursor")}soundIndex(e){return this.register(e,X.Sounds,Kn,"soundCursor")}findSoundIndex(e){for(let r=X.Sounds;r<X.Sounds+Kn;r+=1)if(this.values.get(r)===e)return r}imageIndex(e){return this.register(e,X.Images,xi,"imageCursor")}lightIndex(e){return this.register(e,X.Lights,yi,"lightCursor")}shadowLightIndex(e){return this.register(e,X.ShadowLights,Si,"shadowLightCursor")}itemIndex(e){return this.register(e,X.Items,vi,"itemCursor")}playerSkinIndex(e){return this.register(e,X.PlayerSkins,Yn,"playerSkinCursor")}generalIndex(e){return this.register(e,X.General,bi,"generalCursor")}register(e,r,n,o){for(let a=r;a<r+n;a+=1)if(this.values.get(a)===e)return a;let i=this[o],s=r+n;if(i>=s)throw new RangeError(`Out of configstring slots for range starting at ${r}`);return Gs(i,e),this.values.set(i,e),this[o]=i+1,i}};var Rr=class{constructor(e,r){this.engine=e;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(e){this.host.pump(e)}getLatestFrame(){return this.host.getLatestFrame()}isRunning(){return this.started&&this.host.isRunning()}};function Ws(t,e,r,n){return new Rr(t,new Jt(e,r,n))}var Br=class{constructor({name:e,defaultValue:r,description:n,flags:o=qn.None,onChange:i}){this.modifiedCount=0;this.name=e,this.defaultValue=r,this.description=n,this.flags=o,this._value=r,this.onChange=i}get string(){return this._value}get number(){return Number(this._value)}get integer(){return Math.trunc(this.number)}get boolean(){return!!this.integer}set(e){if(this.flags&qn.Latch){if(e===this._value){this.latched=void 0;return}if(this.latched===e)return;this.latched!==e&&(this.latched=e);return}this.apply(e)}reset(){this.latched=void 0,this.apply(this.defaultValue)}applyLatched(){if(this.latched===void 0)return!1;let e=this.latched;return this.latched=void 0,e===this._value?!1:(this.apply(e),!0)}apply(e){if(this._value===e)return;let r=this._value;this._value=e,this.modifiedCount+=1,this.onChange?.(this,r)}},jn=class{constructor(){this.cvars=new Map}register(e){let r=this.cvars.get(e.name);if(r)return r;let n=new Br(e);return this.cvars.set(e.name,n),n}get(e){return this.cvars.get(e)}setValue(e,r){let n=this.get(e);if(!n)throw new Error(`Unknown cvar: ${e}`);return n.set(r),n}resetAll(){for(let e of this.cvars.values())e.reset()}applyLatched(){let e=!1;for(let r of this.cvars.values())e=r.applyLatched()||e;return e}list(){return[...this.cvars.values()].sort((e,r)=>e.name.localeCompare(r.name))}};var il="PACK";function sl(t,e,r){let n=[];for(let o=0;o<r;o+=1){let i=t.getUint8(e+o);if(i===0)break;n.push(i)}return String.fromCharCode(...n)}function re(t){return t.replace(/\\/g,"/").replace(/^\/+/,"").toLowerCase()}function al(){let t=new Uint32Array(256);for(let e=0;e<256;e+=1){let r=e;for(let n=0;n<8;n+=1)r=(r&1)!==0?3988292384^r>>>1:r>>>1;t[e]=r>>>0}return t}var cl=al();function Xs(t){let e=4294967295;for(let r=0;r<t.length;r+=1){let n=t[r];e=cl[(e^n)&255]^e>>>8}return(e^4294967295)>>>0}var Ce=class extends Error{},tr=class t{constructor(e,r,n,o){this.name=e;this.buffer=r;this.entries=new Map(n.map(i=>[i.name,i])),this.checksum=o,this.size=r.byteLength}static fromArrayBuffer(e,r){let n=new DataView(r);if(r.byteLength<12)throw new Ce("PAK buffer too small to contain header");let o=String.fromCharCode(n.getUint8(0),n.getUint8(1),n.getUint8(2),n.getUint8(3));if(o!==il)throw new Ce(`Invalid PAK header magic: ${o}`);let i=n.getInt32(4,!0),s=n.getInt32(8,!0);if(i<12)throw new Ce(`Invalid directory offset: ${i}`);if(s<=0||s%64!==0)throw new Ce(`Invalid directory length: ${s}`);if(i+s>r.byteLength)throw new Ce("Directory exceeds buffer length");let c=s/64,l=[],d=new Map;for(let u=0;u<c;u+=1){let m=i+u*64,f=sl(n,m,56),h=re(f),y=n.getInt32(m+56,!0),p=n.getInt32(m+60,!0);if(y<0||p<0||y+p>r.byteLength)throw new Ce(`Invalid entry bounds for ${f||"<unnamed>"} (offset=${y}, length=${p})`);if(!h)throw new Ce(`Entry ${u} has an empty name`);let g={name:h,offset:y,length:p};d.set(h,g)}return l.push(...d.values()),new t(e,r,l,Xs(new Uint8Array(r)))}getEntry(e){return this.entries.get(re(e))}listEntries(){return Array.from(this.entries.values())}readFile(e){let r=this.getEntry(e);if(!r)throw new Ce(`File not found in PAK: ${e}`);return new Uint8Array(this.buffer,r.offset,r.length)}validate(){return{checksum:this.checksum,entries:this.listEntries()}}};function qs(t){return Xs(new Uint8Array(t))}var $n=class{constructor(e=[]){this.mounts=[];this.files=new Map;e.forEach(r=>this.mountPak(r))}mountPak(e){this.mounts.push(e);for(let r of e.listEntries()){let n=re(r.name);this.files.set(n,{archive:e,entry:r})}}get mountedPaks(){return[...this.mounts]}hasFile(e){return this.files.has(re(e))}stat(e){let r=this.files.get(re(e));if(r)return{path:r.entry.name,size:r.entry.length,sourcePak:r.archive.name}}async readFile(e){let r=this.files.get(re(e));if(!r)throw new Error(`File not found in VFS: ${e}`);return r.archive.readFile(e)}list(e=""){let r=re(e).replace(/\/+$|^\//g,""),n=[],o=new Set,i=r?`${r}/`:"";for(let s of this.files.values()){if(r&&!s.entry.name.startsWith(i))continue;let a=r?s.entry.name.slice(i.length):s.entry.name,c=a.indexOf("/");c===-1?n.push({path:s.entry.name,size:s.entry.length,sourcePak:s.archive.name}):o.add(a.slice(0,c))}return n.sort((s,a)=>s.path.localeCompare(a.path)),{files:n,directories:[...o].sort()}}findByExtension(e){let r=e.startsWith(".")?e.toLowerCase():`.${e.toLowerCase()}`,n=[];for(let o of this.files.values())o.entry.name.toLowerCase().endsWith(r)&&n.push({path:o.entry.name,size:o.entry.length,sourcePak:o.archive.name});return n.sort((o,i)=>o.path.localeCompare(i.path))}};var Mi=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"}]),Pt=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"}},Qn=class{constructor(e=Mi){this.known=new Map;e.forEach(r=>this.known.set(this.normalizePakName(r.name),r))}validateArchive(e,r){let n=this.normalizePakName(r??("name"in e?e.name:"unknown")),o=e.checksum,i="size"in e?e.size:void 0,s=this.known.get(n);return s?s.checksum!==o?{name:n,checksum:o,expectedChecksum:s.checksum,status:"mismatch",size:i,description:s.description}:{name:n,checksum:o,expectedChecksum:s.checksum,status:"valid",size:i,description:s.description}:{name:n,checksum:o,status:"unknown",size:i}}assertValid(e,r){let n=this.validateArchive(e,r);if(n.status==="mismatch")throw new Pt(n);return n}normalizePakName(e){let r=re(e),n=r.split("/"),o=n.pop()??r,i=n.pop();return i?`${o}@${i}`:o}};var ut=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 ll(t,e){if(typeof t.arrayBuffer=="function"){let r=await t.arrayBuffer();return e?.({file:"blob",loadedBytes:r.byteLength,totalBytes:r.byteLength,state:"reading"}),r}if(typeof FileReader<"u")return new Promise((r,n)=>{let o=new FileReader;o.onerror=()=>n(o.error??new Error("Unknown FileReader error")),o.onprogress=i=>{e?.({file:"blob",loadedBytes:i.loaded,totalBytes:i.total||t.size,state:"reading"})},o.onload=()=>{let i=o.result;i instanceof ArrayBuffer?r(i):n(new Error("Unexpected FileReader result"))},o.readAsArrayBuffer(t)});if(typeof Response<"u"){let r=await new Response(t).arrayBuffer();return e?.({file:"blob",loadedBytes:r.byteLength,totalBytes:r.byteLength,state:"reading"}),r}if(typeof t.stream=="function"){let r=t.stream().getReader(),n=[],o=0;for(;;){let{done:a,value:c}=await r.read();if(a)break;if(!c)continue;let l=c;n.push(l),o+=l.byteLength,e?.({file:"blob",loadedBytes:o,totalBytes:t.size,state:"reading"})}let i=new Uint8Array(o),s=0;for(let a of n)i.set(a,s),s+=a.byteLength;return i.buffer}throw new ut("blob",new Error("Unsupported Blob type"))}async function dl(t,e){if(t.data instanceof ArrayBuffer)return e?.({file:t.name,loadedBytes:t.data.byteLength,totalBytes:t.data.byteLength,state:"reading"}),t.data;if(t.data instanceof Blob){let n=t.data.size;return ll(t.data,o=>e?.({...o,file:t.name,totalBytes:n}))}let r=t.data.buffer.slice(t.data.byteOffset,t.data.byteOffset+t.data.byteLength);return e?.({file:t.name,loadedBytes:r.byteLength,totalBytes:r.byteLength,state:"reading"}),r}async function Jn(t,e,r){let n=typeof r=="function"?{onProgress:r}:r??{},o=n.persistIndexes??!!n.pakIndexStore,i=n.enforceValidation??!!n.validator,s=n.allowUnknownPaks??!0,a=n.stopOnError??!1,c=[];for(let l of e)try{let d=await dl(l,n.onProgress),u=tr.fromArrayBuffer(l.name,d),m=n.validator?.validateArchive(u);if(m){n.onValidationResult?.(m);let f=m.status==="mismatch",h=m.status==="unknown";if(f&&i||h&&!s){let y=new Pt(m);if(n.onError?.(l.name,y),a)throw new ut(l.name,y);c.push({archive:u,mounted:!1,validation:m});continue}}if(t.mountPak(u),o&&n.pakIndexStore)try{await n.pakIndexStore.persist(u)}catch(f){if(n.onError?.(l.name,f),a)throw new ut(l.name,f)}n.onProgress?.({file:l.name,loadedBytes:d.byteLength,totalBytes:d.byteLength,state:"parsed"}),c.push({archive:u,mounted:!0,validation:m})}catch(d){if(n.onProgress?.({file:l.name,loadedBytes:0,totalBytes:0,state:"error"}),n.onError?.(l.name,d),a)throw new ut(l.name,d)}return c}var mt=class{constructor(e){this.capacity=e;this.map=new Map;if(e<=0)throw new RangeError("LRU cache capacity must be greater than zero")}get size(){return this.map.size}has(e){return this.map.has(e)}get(e){let r=this.map.get(e);if(r!==void 0)return this.map.delete(e),this.map.set(e,r),r}set(e,r){if(this.map.has(e)&&this.map.delete(e),this.map.set(e,r),this.map.size>this.capacity){let n=this.map.keys().next();n.done||this.map.delete(n.value)}}delete(e){return this.map.delete(e)}clear(){this.map.clear()}entries(){return Array.from(this.map.entries()).reverse().map(([e,r])=>({key:e,value:r}))}};function ul(t){return Array.isArray(t)?t:Array.from(t)}function Ai(t){return ul(t).map(e=>({name:e.name,data:e}))}async function Ys(t,e,r){let n=Ai(e);return Jn(t,n,r??{})}function Ks(t,e){let r=o=>{o.preventDefault(),o.dataTransfer?.dropEffect&&(o.dataTransfer.dropEffect="copy")},n=o=>{o.preventDefault();let i=o.dataTransfer?.files;i&&i.length>0&&e(Array.from(i))};return t.addEventListener("dragover",r),t.addEventListener("drop",n),()=>{t.removeEventListener("dragover",r),t.removeEventListener("drop",n)}}function js(t,e){let r=n=>{let o=n.target;!o||!o.files||o.files.length===0||(e(o.files),o.value="")};return t.addEventListener("change",r),()=>t.removeEventListener("change",r)}var ml="IBSP",fl=38,Qs=19,pl=8+Qs*8;var q=class extends Error{},Zn=class{constructor(e){this.vfs=e}async load(e){let r=await this.vfs.readFile(e),n=new Uint8Array(r.byteLength);return n.set(r),_i(n.buffer)}};function _i(t){if(t.byteLength<pl)throw new q("BSP too small to contain header");let e=new DataView(t),r=String.fromCharCode(e.getUint8(0),e.getUint8(1),e.getUint8(2),e.getUint8(3));if(r!==ml)throw new q(`Invalid BSP magic ${r}`);let n=e.getInt32(4,!0);if(n!==fl)throw new q(`Unsupported BSP version ${n}`);let o=new Map;for(let A=0;A<Qs;A+=1){let _=e.getInt32(8+A*8,!0),L=e.getInt32(12+A*8,!0);if(_<0||L<0||_+L>t.byteLength)throw new q(`Invalid lump bounds for index ${A}`);o.set(A,{offset:_,length:L})}let i={version:n,lumps:o},s=hl(t,o.get(0)),a=gl(t,o.get(1)),c=xl(t,o.get(2)),l=vl(t,o.get(4)),d=bl(t,o.get(5)),u=Sl(t,o.get(6)),m=new Uint8Array(t,o.get(7).offset,o.get(7).length),f=Tl(u,o.get(7)),h=Ml(t,o.get(8)),y=Al(t,o.get(11)),p=_l(t,o.get(12)),g=wl(t,o.get(13)),S=Ll(t,o.get(14)),v=El(t,o.get(15)),M=zl(t,o.get(9),o.get(10),h),b=Cl(t,o.get(3));return{header:i,entities:s,planes:a,vertices:c,nodes:l,texInfo:d,faces:u,lightMaps:m,lightMapInfo:f,leafs:h,leafLists:M,edges:y,surfEdges:p,models:g,brushes:S,brushSides:v,visibility:b}}function hl(t,e){let r=new TextDecoder().decode(new Uint8Array(t,e.offset,e.length)),n=yl(r),o=n.find(i=>i.classname==="worldspawn");return{raw:r,entities:n,worldspawn:o}}function yl(t){let e=[],r=/\{([^}]*)\}/gms,n;for(;(n=r.exec(t))!==null;){let o=n[1],i={},s=/"([^\"]*)"\s+"([^\"]*)"/g,a;for(;(a=s.exec(o))!==null;)i[a[1]]=a[2];e.push({classname:i.classname,properties:i})}return e}function gl(t,e){let r=new DataView(t,e.offset,e.length),n=e.length/20;if(n%1!==0)throw new q("Plane lump has invalid length");let o=[];for(let i=0;i<n;i+=1){let s=[r.getFloat32(i*20,!0),r.getFloat32(i*20+4,!0),r.getFloat32(i*20+8,!0)],a=r.getFloat32(i*20+12,!0),c=r.getInt32(i*20+16,!0);o.push({normal:s,dist:a,type:c})}return o}function xl(t,e){let r=new DataView(t,e.offset,e.length),n=e.length/12;if(n%1!==0)throw new q("Vertex lump has invalid length");let o=[];for(let i=0;i<n;i+=1)o.push([r.getFloat32(i*12,!0),r.getFloat32(i*12+4,!0),r.getFloat32(i*12+8,!0)]);return o}function vl(t,e){let r=new DataView(t,e.offset,e.length),n=36,o=e.length/n;if(o%1!==0)throw new q("Node lump has invalid length");let i=[];for(let s=0;s<o;s+=1){let a=s*n,c=r.getInt32(a,!0),l=[r.getInt32(a+4,!0),r.getInt32(a+8,!0)],d=[r.getInt16(a+12,!0),r.getInt16(a+14,!0),r.getInt16(a+16,!0)],u=[r.getInt16(a+18,!0),r.getInt16(a+20,!0),r.getInt16(a+22,!0)],m=r.getUint16(a+24,!0),f=r.getUint16(a+26,!0);i.push({planeIndex:c,children:l,mins:d,maxs:u,firstFace:m,numFaces:f})}return i}function bl(t,e){let r=new DataView(t,e.offset,e.length),n=76,o=e.length/n;if(o%1!==0)throw new q("TexInfo lump has invalid length");let i=[];for(let s=0;s<o;s+=1){let a=s*n,c=[r.getFloat32(a,!0),r.getFloat32(a+4,!0),r.getFloat32(a+8,!0)],l=r.getFloat32(a+12,!0),d=[r.getFloat32(a+16,!0),r.getFloat32(a+20,!0),r.getFloat32(a+24,!0)],u=r.getFloat32(a+28,!0),m=r.getInt32(a+32,!0),f=r.getInt32(a+36,!0),h=new Uint8Array(t,e.offset+a+40,32),y=new TextDecoder("utf-8").decode(h).replace(/\0.*$/,""),p=r.getInt32(a+72,!0);i.push({s:c,sOffset:l,t:d,tOffset:u,flags:m,value:f,texture:y,nextTexInfo:p})}return i}function Sl(t,e){let r=new DataView(t,e.offset,e.length),n=20,o=e.length/n;if(o%1!==0)throw new q("Face lump has invalid length");let i=[];for(let s=0;s<o;s+=1){let a=s*n,c=r.getUint16(a,!0),l=r.getInt16(a+2,!0),d=r.getInt32(a+4,!0),u=r.getInt16(a+8,!0),m=r.getInt16(a+10,!0),f=[r.getUint8(a+12),r.getUint8(a+13),r.getUint8(a+14),r.getUint8(a+15)],h=r.getInt32(a+16,!0);i.push({planeIndex:c,side:l,firstEdge:d,numEdges:u,texInfo:m,styles:f,lightOffset:h})}return i}function Ml(t,e){let r=new DataView(t,e.offset,e.length),n=28,o=e.length/n;if(o%1!==0)throw new q("Leaf lump has invalid length");let i=[];for(let s=0;s<o;s+=1){let a=s*n,c=r.getInt32(a,!0),l=r.getInt16(a+4,!0),d=r.getInt16(a+6,!0),u=[r.getInt16(a+8,!0),r.getInt16(a+10,!0),r.getInt16(a+12,!0)],m=[r.getInt16(a+14,!0),r.getInt16(a+16,!0),r.getInt16(a+18,!0)],f=r.getUint16(a+20,!0),h=r.getUint16(a+22,!0),y=r.getUint16(a+24,!0),p=r.getUint16(a+26,!0);i.push({contents:c,cluster:l,area:d,mins:u,maxs:m,firstLeafFace:f,numLeafFaces:h,firstLeafBrush:y,numLeafBrushes:p})}return i}function Al(t,e){let r=new DataView(t,e.offset,e.length),n=4,o=e.length/n;if(o%1!==0)throw new q("Edge lump has invalid length");let i=[];for(let s=0;s<o;s+=1){let a=s*n;i.push({vertices:[r.getUint16(a,!0),r.getUint16(a+2,!0)]})}return i}function _l(t,e){let r=e.length/4;if(r%1!==0)throw new q("SurfEdge lump has invalid length");let n=new DataView(t,e.offset,e.length),o=new Int32Array(r);for(let i=0;i<r;i+=1)o[i]=n.getInt32(i*4,!0);return o}function wl(t,e){let r=new DataView(t,e.offset,e.length),n=48;if(e.length%n!==0)throw new q("Model lump has invalid length");let o=e.length/n,i=[];for(let s=0;s<o;s+=1){let a=s*n,c=[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)],d=[r.getFloat32(a+24,!0),r.getFloat32(a+28,!0),r.getFloat32(a+32,!0)],u=r.getInt32(a+36,!0),m=r.getInt32(a+40,!0),f=r.getInt32(a+44,!0);i.push({mins:c,maxs:l,origin:d,headNode:u,firstFace:m,numFaces:f})}return i}function Ll(t,e){let r=new DataView(t,e.offset,e.length),n=12,o=e.length/n;if(o%1!==0)throw new q("Brush lump has invalid length");let i=[];for(let s=0;s<o;s+=1){let a=s*n;i.push({firstSide:r.getInt32(a,!0),numSides:r.getInt32(a+4,!0),contents:r.getInt32(a+8,!0)})}return i}function El(t,e){let r=new DataView(t,e.offset,e.length),n=8,o=e.length/n;if(o%1!==0)throw new q("Brush side lump has invalid length");let i=[];for(let s=0;s<o;s+=1){let a=s*n;i.push({planeIndex:r.getUint16(a,!0),texInfo:r.getInt16(a+2,!0)})}return i}function zl(t,e,r,n){let o=[],i=[],s=e.length/2,a=r.length/2,c=new DataView(t,e.offset,e.length),l=new DataView(t,r.offset,r.length);for(let d of n){if(d.firstLeafFace+d.numLeafFaces>s)throw new q("Leaf faces reference data past lump bounds");if(d.firstLeafBrush+d.numLeafBrushes>a)throw new q("Leaf brushes reference data past lump bounds");let u=[];for(let f=0;f<d.numLeafFaces;f+=1)u.push(c.getUint16((d.firstLeafFace+f)*2,!0));let m=[];for(let f=0;f<d.numLeafBrushes;f+=1)m.push(l.getUint16((d.firstLeafBrush+f)*2,!0));o.push(u),i.push(m)}return{leafFaces:o,leafBrushes:i}}function Cl(t,e){if(e.length===0)return;if(e.length<4)throw new q("Visibility lump too small");let r=new DataView(t,e.offset,e.length),n=r.getInt32(0,!0),o=4+n*8;if(n<0||o>e.length)throw new q("Visibility lump truncated");let i=4,s=[];for(let a=0;a<n;a+=1){let c=r.getInt32(i,!0),l=r.getInt32(i+4,!0);i+=8;let d=e.offset+c,u=e.offset+l,m=e.offset+e.length;if(c<0||l<0||d>=m||u>=m)throw new q("Visibility offsets out of range");s.push({pvs:$s(t,d,n,e),phs:$s(t,u,n,e)})}return{numClusters:n,clusters:s}}function $s(t,e,r,n){let o=Math.ceil(r/8),i=new Uint8Array(o),s=new Uint8Array(t),a=e,c=0,l=n.offset+n.length;for(;c<o;){if(a>=l)throw new q("Visibility data truncated");let d=s[a++];if(d!==0){i[c++]=d;continue}if(a>=l)throw new q("Visibility run exceeds lump bounds");let u=s[a++];for(let m=0;m<u&&c<o;m+=1)i[c++]=0}return i}function Tl(t,e){return t.map(r=>{if(!(r.lightOffset<0))return{offset:r.lightOffset,length:Math.max(0,e.length-r.lightOffset)}})}function eo(t,e,r){if(t.lightOffset<0||t.lightOffset>=e.byteLength)return;let n=e.byteLength-t.lightOffset,o=Math.min(r?.length??n,n);if(!(o<=0))return e.subarray(t.lightOffset,t.lightOffset+o)}var Il=844121161,Fl=8,Js=68,Pl=[{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}],ae=class extends Error{},rr=class{constructor(e){this.vfs=e}async load(e){let r=await this.vfs.readFile(e),n=new Uint8Array(r.byteLength);return n.set(r),wi(n.buffer)}};function Zs(t,e,r){let n=[];for(let o=0;o<r;o+=1){let i=t.getUint8(e+o);if(i===0)break;n.push(i)}return String.fromCharCode(...n)}function kr(t,e,r,n){if(r!==0&&(e<Js||e+r>t.byteLength))throw new ae(`${n} section is out of bounds`)}function Rl(t){if(t.byteLength<Js)throw new ae("MD2 buffer too small to contain header");let e=new DataView(t),r=e.getInt32(0,!0),n=e.getInt32(4,!0);if(r!==Il)throw new ae(`Invalid MD2 ident: ${r}`);if(n!==Fl)throw new ae(`Unsupported MD2 version: ${n}`);let o={ident:r,version:n,skinWidth:e.getInt32(8,!0),skinHeight:e.getInt32(12,!0),frameSize:e.getInt32(16,!0),numSkins:e.getInt32(20,!0),numVertices:e.getInt32(24,!0),numTexCoords:e.getInt32(28,!0),numTriangles:e.getInt32(32,!0),numGlCommands:e.getInt32(36,!0),numFrames:e.getInt32(40,!0),offsetSkins:e.getInt32(44,!0),offsetTexCoords:e.getInt32(48,!0),offsetTriangles:e.getInt32(52,!0),offsetFrames:e.getInt32(56,!0),offsetGlCommands:e.getInt32(60,!0),offsetEnd:e.getInt32(64,!0)},i=40+o.numVertices*4;if(o.frameSize!==i)throw new ae(`Unexpected frame size ${o.frameSize}, expected ${i}`);if(o.offsetEnd>t.byteLength)throw new ae("MD2 offset_end exceeds buffer length");return o}function Bl(t,e){let r=e.numSkins*64;kr(t,e.offsetSkins,r,"skins");let n=new DataView(t,e.offsetSkins,r),o=[];for(let i=0;i<e.numSkins;i+=1)o.push({name:Zs(n,i*64,64)});return o}function kl(t,e){let r=e.numTexCoords*4;kr(t,e.offsetTexCoords,r,"texcoords");let n=new DataView(t,e.offsetTexCoords,r),o=[];for(let i=0;i<e.numTexCoords;i+=1){let s=i*4;o.push({s:n.getInt16(s,!0),t:n.getInt16(s+2,!0)})}return o}function Dl(t,e){let r=e.numTriangles*12;kr(t,e.offsetTriangles,r,"triangles");let n=new DataView(t,e.offsetTriangles,r),o=[];for(let i=0;i<e.numTriangles;i+=1){let s=i*12,a=[n.getUint16(s,!0),n.getUint16(s+2,!0),n.getUint16(s+4,!0)],c=[n.getUint16(s+6,!0),n.getUint16(s+8,!0),n.getUint16(s+10,!0)];if(a.some(l=>l>=e.numVertices)||c.some(l=>l>=e.numTexCoords))throw new ae("Triangle references out of range vertex or texcoord");o.push({vertexIndices:a,texCoordIndices:c})}return o}function Hl(t,e){let r=e.numFrames*e.frameSize;kr(t,e.offsetFrames,r,"frames");let n=[];for(let o=0;o<e.numFrames;o+=1){let i=e.offsetFrames+o*e.frameSize,s=new DataView(t,i,e.frameSize),a={x:s.getFloat32(0,!0),y:s.getFloat32(4,!0),z:s.getFloat32(8,!0)},c={x:s.getFloat32(12,!0),y:s.getFloat32(16,!0),z:s.getFloat32(20,!0)},l=Zs(s,24,16),d=[];for(let u=0;u<e.numVertices;u+=1){let m=40+u*4,f={x:s.getUint8(m)*a.x+c.x,y:s.getUint8(m+1)*a.y+c.y,z:s.getUint8(m+2)*a.z+c.z},h=s.getUint8(m+3),y=Pl[h];if(!y)throw new ae(`Invalid normal index ${h} in frame ${l}`);d.push({position:f,normalIndex:h,normal:y})}n.push({name:l,vertices:d})}return n}function Ol(t,e){let r=e.numGlCommands*4;if(kr(t,e.offsetGlCommands,r,"gl commands"),r===0)return[];let n=new DataView(t,e.offsetGlCommands,r),o=[],i=0;for(;;){if(i+4>r)throw new ae("GL command list ended unexpectedly");let s=n.getInt32(i,!0);if(i+=4,s===0)break;let a=Math.abs(s),c=[],l=a*12;if(i+l>r)throw new ae("GL command vertex block exceeds buffer");for(let d=0;d<a;d+=1){let u=n.getFloat32(i,!0),m=n.getFloat32(i+4,!0),f=n.getInt32(i+8,!0);if(i+=12,f<0||f>=e.numVertices)throw new ae("GL command references invalid vertex index");c.push({s:u,t:m,vertexIndex:f})}o.push({mode:s>0?"strip":"fan",vertices:c})}if(i!==r)throw new ae("GL command list did not consume expected data");return o}function wi(t){let e=Rl(t),r=Bl(t,e),n=kl(t,e),o=Dl(t,e),i=Hl(t,e),s=Ol(t,e);return{header:e,skins:r,texCoords:n,triangles:o,frames:i,glCommands:s}}function ea(t){let e=[],r=0;for(;r<t.length;){let n=t[r].name,o=n.replace(/\d+$/,"")||n,i=r;for(;i+1<t.length&&(t[i+1].name.replace(/\d+$/,"")||t[i+1].name)===o;)i+=1;e.push({name:o,firstFrame:r,lastFrame:i}),r=i+1}return e}var ta=860898377,Nl=15,Te=class extends Error{constructor(e){super(e),this.name="Md3ParseError"}};function Dr(t,e,r){let n=new Uint8Array(t.buffer,t.byteOffset+e,r);return new TextDecoder("utf-8").decode(n).replace(/\0.*$/,"").trim()}function Vl(t){let e=(t>>8&255)*(2*Math.PI/255),r=(t&255)*(2*Math.PI/255),n=Math.sin(r);return{x:Math.cos(e)*n,y:Math.sin(e)*n,z:Math.cos(r)}}function to(t,e,r,n){if(e<0||e+r>n)throw new Te(`${t} exceeds buffer bounds`)}function Ul(t){let e=t.getInt32(0,!0);if(e!==ta)throw new Te(`Invalid MD3 ident: ${e}`);let r=t.getInt32(4,!0);if(r!==Nl)throw new Te(`Unsupported MD3 version: ${r}`);let n=Dr(t,8,64),o=t.getInt32(72,!0),i=t.getInt32(76,!0),s=t.getInt32(80,!0),a=t.getInt32(84,!0),c=t.getInt32(88,!0),l=t.getInt32(92,!0),d=t.getInt32(96,!0),u=t.getInt32(100,!0),m=t.getInt32(104,!0);if(i<=0||a<0||s<0)throw new Te("Invalid MD3 counts");return{ident:e,version:r,name:n,flags:o,numFrames:i,numTags:s,numSurfaces:a,numSkins:c,ofsFrames:l,ofsTags:d,ofsSurfaces:u,ofsEnd:m}}function Gl(t,e){let r=[];to("Frames",e.ofsFrames,e.numFrames*56,t.byteLength);for(let o=0;o<e.numFrames;o+=1){let i=e.ofsFrames+o*56;r.push({minBounds:{x:t.getFloat32(i,!0),y:t.getFloat32(i+4,!0),z:t.getFloat32(i+8,!0)},maxBounds:{x:t.getFloat32(i+12,!0),y:t.getFloat32(i+16,!0),z:t.getFloat32(i+20,!0)},localOrigin:{x:t.getFloat32(i+24,!0),y:t.getFloat32(i+28,!0),z:t.getFloat32(i+32,!0)},radius:t.getFloat32(i+36,!0),name:Dr(t,i+40,16)})}return r}function Wl(t,e){let r=[],o=e.numFrames*e.numTags*112;to("Tags",e.ofsTags,o,t.byteLength);for(let i=0;i<e.numFrames;i+=1){let s=[];for(let a=0;a<e.numTags;a+=1){let c=e.ofsTags+(i*e.numTags+a)*112,l=c+64,d=l+12;s.push({name:Dr(t,c,64),origin:{x:t.getFloat32(l,!0),y:t.getFloat32(l+4,!0),z:t.getFloat32(l+8,!0)},axis:[{x:t.getFloat32(d,!0),y:t.getFloat32(d+4,!0),z:t.getFloat32(d+8,!0)},{x:t.getFloat32(d+12,!0),y:t.getFloat32(d+16,!0),z:t.getFloat32(d+20,!0)},{x:t.getFloat32(d+24,!0),y:t.getFloat32(d+28,!0),z:t.getFloat32(d+32,!0)}]})}r.push(s)}return r}function Xl(t,e){let r=t.getInt32(e,!0);if(r!==ta)throw new Te(`Invalid surface ident at ${e}: ${r}`);let n=Dr(t,e+4,64),o=t.getInt32(e+68,!0),i=t.getInt32(e+72,!0),s=t.getInt32(e+76,!0),a=t.getInt32(e+80,!0),c=t.getInt32(e+84,!0),l=t.getInt32(e+88,!0),d=t.getInt32(e+92,!0),u=t.getInt32(e+96,!0),m=t.getInt32(e+100,!0),f=t.getInt32(e+104,!0);if(i<=0||a<=0||c<=0)throw new Te(`Invalid surface counts for ${n}`);let h=f;to(`Surface ${n}`,e,h,t.byteLength);let y=[],p=e+l;for(let _=0;_<c;_+=1){let L=p+_*12;y.push({indices:[t.getInt32(L,!0),t.getInt32(L+4,!0),t.getInt32(L+8,!0)]})}let g=[],S=e+d;for(let _=0;_<s;_+=1){let L=S+_*68;g.push({name:Dr(t,L,64),shaderIndex:t.getInt32(L+64,!0)})}let v=[],M=e+u;for(let _=0;_<a;_+=1){let L=M+_*8;v.push({s:t.getFloat32(L,!0),t:t.getFloat32(L+4,!0)})}let b=[],A=e+m;for(let _=0;_<i;_+=1){let L=[];for(let I=0;I<a;I+=1){let w=A+(_*a+I)*8,O=t.getInt16(w,!0)/64,U=t.getInt16(w+2,!0)/64,V=t.getInt16(w+4,!0)/64,F=t.getUint16(w+6,!0);L.push({position:{x:O,y:U,z:V},latLng:F,normal:Vl(F)})}b.push(L)}return{surface:{name:n,flags:o,numFrames:i,shaders:g,triangles:y,texCoords:v,vertices:b},nextOffset:e+f}}function Li(t){if(t.byteLength<108)throw new Te("MD3 buffer too small for header");let e=new DataView(t),r=Ul(e);to("MD3 end",r.ofsEnd,0,t.byteLength);let n=Gl(e,r),o=Wl(e,r),i=[],s=r.ofsSurfaces;for(let a=0;a<r.numSurfaces;a+=1){let{surface:c,nextOffset:l}=Xl(e,s);i.push(c),s=l}if(s!==r.ofsEnd)throw new Te("Surface parsing did not reach ofsEnd");return{header:r,frames:n,tags:o,surfaces:i}}var nr=class{constructor(e){this.vfs=e}async load(e){let r=await this.vfs.readFile(e);return Li(r.slice().buffer)}};var ql=1229214514,Yl=2,ra=64,na=12,ft=class extends Error{};function Kl(t,e,r){let n=[];for(let o=0;o<r;o+=1){let i=t.getUint8(e+o);if(i===0)break;n.push(i)}return String.fromCharCode(...n)}function Ei(t){if(t.byteLength<na)throw new ft("Sprite buffer too small to contain header");let e=new DataView(t),r=e.getInt32(0,!0),n=e.getInt32(4,!0),o=e.getInt32(8,!0);if(r!==ql)throw new ft(`Invalid Sprite ident: ${r}`);if(n!==Yl)throw new ft(`Unsupported Sprite version: ${n}`);let i=[],s=16+ra,a=na;for(let c=0;c<o;c+=1){if(a+s>t.byteLength)throw new ft("Sprite frame data exceeds buffer length");let l=e.getInt32(a,!0),d=e.getInt32(a+4,!0),u=e.getInt32(a+8,!0),m=e.getInt32(a+12,!0),f=Kl(e,a+16,ra);i.push({width:l,height:d,originX:u,originY:m,name:f}),a+=s}return{ident:r,version:n,numFrames:o,frames:i}}var or=class{constructor(e){this.vfs=e}async load(e){let r=await this.vfs.readFile(e),n=new Uint8Array(r.byteLength);return n.set(r),Ei(n.buffer)}};function oa(t,e){let r=(t.sequence.end-t.sequence.start+1)/t.sequence.fps,n=t.sequence.loop!==!1,o=t.time+e;return n?o=(o%r+r)%r:o>r&&(o=r),{...t,time:Math.max(0,Math.min(o,r))}}function ia(t){let e=t.sequence.end-t.sequence.start+1,r=1/t.sequence.fps,n=t.sequence.loop!==!1,o=t.time/r;if(!n&&o>=e)return{frame:t.sequence.end,nextFrame:t.sequence.end,lerp:0};let i=n?o%e:Math.min(o,e-1),s=Math.floor(i),a=t.sequence.start+s,c=s+1>=e?n?t.sequence.start:t.sequence.end:a+1,l=!n&&s>=e-1?0:i-s;return{frame:a,nextFrame:c,lerp:l}}function sa(t){return{sequence:t,time:0}}function aa(t,e,r){return{x:t.x+(e.x-t.x)*r,y:t.y+(e.y-t.y)*r,z:t.z+(e.z-t.z)*r}}var Hr=class extends Error{constructor(e){super(e),this.name="WalParseError"}};function ro(t){if(t.byteLength<100)throw new Hr("WAL buffer too small");let e=new DataView(t),r=new Uint8Array(t,0,32),n=new TextDecoder("utf-8").decode(r).replace(/\0.*$/,"").trim(),o=e.getInt32(32,!0),i=e.getInt32(36,!0),s=[e.getInt32(40,!0),e.getInt32(44,!0),e.getInt32(48,!0),e.getInt32(52,!0)],a=new Uint8Array(t,56,32),c=new TextDecoder("utf-8").decode(a).replace(/\0.*$/,"").trim(),l=e.getInt32(88,!0),d=e.getInt32(92,!0),u=e.getInt32(96,!0);if(o<=0||i<=0)throw new Hr("Invalid WAL dimensions");let m=[],f=o,h=i;for(let y=0;y<s.length;y+=1){let p=s[y],g=Math.max(1,f*h|0);if(p<=0||p+g>t.byteLength)throw new Hr(`Invalid WAL mip offset for level ${y}`);let S=new Uint8Array(t,p,g);m.push({level:y,width:f,height:h,data:S}),f=Math.max(1,f>>1),h=Math.max(1,h>>1)}return{name:n,width:o,height:i,mipmaps:m,animName:c,flags:l,contents:d,value:u}}var Rt=class extends Error{constructor(e){super(e),this.name="PcxParseError"}};function ca(t){if(t.byteLength<128)throw new Rt("PCX buffer too small for header");let e=new DataView(t),r=e.getUint8(0),n=e.getUint8(2),o=e.getUint8(3),i=e.getUint16(4,!0),s=e.getUint16(6,!0),a=e.getUint16(8,!0),c=e.getUint16(10,!0);if(r!==10||n!==1)throw new Rt("Unsupported PCX encoding");if(o!==8)throw new Rt("Only 8bpp PCX files are supported");let l=a-i+1,d=c-s+1,u=e.getUint16(66,!0),m=t.byteLength-769;if(m<128||new DataView(t,m,1).getUint8(0)!==12)throw new Rt("Missing PCX palette");let f=new Uint8Array(t,m+1,768),h=new Uint8Array(t,128,m-128),y=new Uint8Array(l*d),p=0,g=0;for(let S=0;S<d;S+=1){let v=0;for(;v<u&&p<h.length;){let M=1,b=h[p++];if((b&192)===192){if(M=b&63,p>=h.length)throw new Rt("Unexpected end of PCX RLE data");b=h[p++]}for(let A=0;A<M&&v<u;A+=1)v<l&&(y[g++]=b),v+=1}}return{width:l,height:d,bitsPerPixel:o,pixels:y,palette:f}}function no(t){let e=new Uint8Array(t.width*t.height*4);for(let r=0;r<t.pixels.length;r+=1){let n=t.pixels[r],o=n*3,i=r*4;e[i]=t.palette[o],e[i+1]=t.palette[o+1],e[i+2]=t.palette[o+2],e[i+3]=n===255?0:255}return e}var ir=class{constructor(e={}){this.cache=new mt(e.capacity??128)}get size(){return this.cache.size}get(e){return this.cache.get(e.toLowerCase())}set(e,r){this.cache.set(e.toLowerCase(),r)}clear(){this.cache.clear()}};function zi(t,e){let r=[];for(let n of t.mipmaps){let o=new Uint8Array(n.width*n.height*4);for(let i=0;i<n.data.length;i+=1){let s=n.data[i],a=s*3,c=i*4;o[c]=e[a],o[c+1]=e[a+1],o[c+2]=e[a+2],o[c+3]=s===255?0:255}r.push({level:n.level,width:n.width,height:n.height,rgba:o})}return{width:t.width,height:t.height,levels:r,source:"wal"}}function la(t){let e=no(t),r={level:0,width:t.width,height:t.height,rgba:e};return{width:t.width,height:t.height,levels:[r],source:"pcx"}}function da(t,e){return zi(ro(t),e)}var Bt=class extends Error{constructor(e){super(e),this.name="WavParseError"}};function Ci(t,e,r){return new TextDecoder("ascii").decode(new Uint8Array(t.buffer,t.byteOffset+e,r))}function oo(t){if(t.byteLength<44)throw new Bt("WAV buffer too small");let e=new DataView(t);if(Ci(e,0,4)!=="RIFF"||Ci(e,8,4)!=="WAVE")throw new Bt("Invalid WAV header");let r=12,n=-1,o=-1,i=0,s=0;for(;r+8<=t.byteLength;){let h=Ci(e,r,4),y=e.getUint32(r+4,!0),p=r+8;h==="fmt "?(n=p,i=y):h==="data"&&(o=p,s=y),r=p+y}if(n===-1||o===-1)throw new Bt("Missing fmt or data chunk");let a=e.getUint16(n,!0),c=e.getUint16(n+2,!0),l=e.getUint32(n+4,!0),d=e.getUint16(n+14,!0);if(a!==1)throw new Bt("Only PCM WAV is supported");let u=d/8,m=s/(u*c),f=new Float32Array(m*c);for(let h=0;h<m;h+=1)for(let y=0;y<c;y+=1){let p=h*c+y,g=o+p*u,S=0;if(d===8)S=e.getUint8(g),f[p]=(S-128)/128;else if(d===16)S=e.getInt16(g,!0),f[p]=S/32768;else if(d===24){let v=e.getUint8(g),M=e.getUint8(g+1),b=e.getInt8(g+2);S=v|M<<8|b<<16,f[p]=S/8388608}else throw new Bt(`Unsupported bitsPerSample: ${d}`)}return{sampleRate:l,channels:c,bitsPerSample:d,samples:f}}var jl=(t,e=4294967295,r=79764919)=>{let n=new Int32Array(256),o,i,s,a=e;for(o=0;o<256;o++){for(s=o<<24,i=8;i>0;--i)s=2147483648&s?s<<1^r:s<<1;n[o]=s}for(o=0;o<t.length;o++)a=a<<8^n[255&(a>>24^t[o])];return a};var Ti=(t,e=jl)=>{let r=p=>new Uint8Array(p.length/2).map(((g,S)=>parseInt(p.substring(2*S,2*(S+1)),16))),n=p=>r(p)[0],o=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,g)=>o.set(p,g)));let i=new Uint8Array(t.length),s,a,c,l=!1,d=0,u=42,m=t.length>13&&t.substring(0,9)==="dynEncode",f=0;m&&(f=11,a=n(t.substring(9,f)),a<=1&&(f+=2,u=n(t.substring(11,f))),a===1&&(f+=8,c=(p=>new DataView(r(p).buffer).getInt32(0,!0))(t.substring(13,f))));let h=256-u;for(let p=f;p<t.length;p++)if(s=t.charCodeAt(p),s!==61||l){if(s===92&&p<t.length-5&&m){let g=t.charCodeAt(p+1);g!==117&&g!==85||(s=parseInt(t.substring(p+2,p+6),16),p+=5)}if(s>255){let g=o.get(s);g&&(s=g+127)}l&&(l=!1,s-=64),i[d++]=s<u&&s>0?s+h:s-u}else l=!0;let y=i.subarray(0,d);if(m&&a===1){let p=e(y);if(p!==c){let g="Decode failed crc32 validation";throw console.error("`simple-yenc`\n",g+`
|
|
2
|
-
`,"Expected: "+c+"; Got: "+
|
|
3
|
-
`,"Visit https://github.com/eshaz/simple-yenc for more information"),Error(g)}}return y};function Q(){let t=Uint8Array,e=Float32Array;Q.modules||Object.defineProperties(Q,{modules:{value:new WeakMap},setModule:{value(r,n){Q.modules.set(r,Promise.resolve(n))}},getModule:{value(r,n){let o=Q.modules.get(r);return o||(n?o=WebAssembly.compile(Ti(n)):(n=r.wasm,o=Q.inflateDynEncodeString(n).then(i=>WebAssembly.compile(i))),Q.modules.set(r,o)),o}},concatFloat32:{value(r,n){let o=new e(n),i=0,s=0;for(;i<r.length;)o.set(r[i],s),s+=r[i++].length;return o}},getDecodedAudio:{value:(r,n,o,i,s)=>({errors:r,channelData:n,samplesDecoded:o,sampleRate:i,bitDepth:s})},getDecodedAudioMultiChannel:{value(r,n,o,i,s,a){let c=[],l,d;for(l=0;l<o;l++){let u=[];for(d=0;d<n.length;)u.push(n[d++][l]||[]);c.push(Q.concatFloat32(u,i))}return Q.getDecodedAudio(r,c,i,s,a)}},inflateDynEncodeString:{value(r){return r=Ti(r),new Promise(n=>{let o=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 `;Q.getModule(Q,o).then(i=>WebAssembly.instantiate(i,{})).then(({exports:i})=>{let s=new Map(Object.entries(i)),a=s.get("puff"),c=s.get("memory").buffer,l=new t(c),d=new DataView(c),u=s.get("__heap_base"),m=r.length,f=u;u+=4,d.setInt32(f,m,!0);let h=u;u+=m,l.set(r,h);let y=u;u+=4,d.setInt32(y,l.byteLength-u,!0),a(u,y,h,f),n(l.slice(u,u+d.getInt32(y,!0)))})})}}}),Object.defineProperty(this,"wasm",{enumerable:!0,get:()=>this._wasm}),this.getOutputChannels=(r,n,o)=>{let i=[],s=0;for(;s<n;)i.push(r.slice(s*o,s++*o+o));return i},this.allocateTypedArray=(r,n,o=!0)=>{let i=this._wasm.malloc(n.BYTES_PER_ELEMENT*r);return o&&this._pointers.add(i),{ptr:i,len:r,buf:new n(this._wasm.HEAP,i,r)}},this.free=()=>{this._pointers.forEach(r=>{this._wasm.free(r)}),this._pointers.clear()},this.codeToString=r=>{let n=[],o=new Uint8Array(this._wasm.HEAP);for(let i=o[r];i!==0;i=o[++r])n.push(i);return String.fromCharCode.apply(null,n)},this.addError=(r,n,o,i,s,a)=>{r.push({message:n,frameLength:o,frameNumber:i,inputBytes:s,outputSamples:a})},this.instantiate=(r,n)=>(n&&Q.setModule(r,n),this._wasm=new r(Q).instantiate(),this._pointers=new Set,this._wasm.ready.then(()=>this))}var fa=Nc(ma(),1);var $l=()=>globalThis.Worker||fa.default,sr=class extends $l(){constructor(e,r,n,o){Q.modules||new Q;let i=Q.modules.get(n);if(!i){let s="text/javascript",a,c=`'use strict';(${((l,d,u)=>{let m,f,h=new Promise(y=>{f=y});self.onmessage=({data:{id:y,command:p,data:g}})=>{let S=h,v={id:y},M;p==="init"?(Object.defineProperties(l,{WASMAudioDecoderCommon:{value:d},EmscriptenWASM:{value:u},module:{value:g.module},isWebWorker:{value:!0}}),m=new l(g.options),f()):p==="free"?m.free():p==="ready"?S=S.then(()=>m.ready):p==="reset"?S=S.then(()=>m.reset()):(Object.assign(v,m[p](Array.isArray(g)?g.map(b=>new Uint8Array(b)):new Uint8Array(g))),M=v.channelData?v.channelData.map(b=>b.buffer):[]),S.then(()=>self.postMessage(v,M))}}).toString()})(${n}, ${Q}, ${o})`;try{a=typeof process.versions.node<"u"}catch{}i=a?`data:${s};base64,${Buffer.from(c).toString("base64")}`:URL.createObjectURL(new Blob([c],{type:s})),Q.modules.set(n,i)}super(i,{name:r}),this._id=Number.MIN_SAFE_INTEGER,this._enqueuedOperations=new Map,this.onmessage=({data:s})=>{let{id:a,...c}=s;this._enqueuedOperations.get(a)(c),this._enqueuedOperations.delete(a)},new o(Q).getModule().then(s=>{this.postToDecoder("init",{module:s,options:e})})}async postToDecoder(e,r){return new Promise(n=>{this.postMessage({command:e,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 io=(t,e)=>{Object.defineProperty(t,"name",{value:e})};var J=Symbol,pa=", ",T=(()=>{let t="front",e="side",r="rear",n="left",o="center",i="right";return["",t+" ",e+" ",r+" "].map(s=>[[n,i],[n,i,o],[n,o,i],[o,n,i],[o]].flatMap(a=>a.map(c=>s+c).join(pa)))})(),Xe="LFE",pt="monophonic (mono)",ht="stereo",Or="surround",Z=(t,...e)=>`${[pt,ht,`linear ${Or}`,"quadraphonic",`5.0 ${Or}`,`5.1 ${Or}`,`6.1 ${Or}`,`7.1 ${Or}`][t-1]} (${e.join(pa)})`,Nr=[pt,Z(2,T[0][0]),Z(3,T[0][2]),Z(4,T[1][0],T[3][0]),Z(5,T[1][2],T[3][0]),Z(6,T[1][2],T[3][0],Xe),Z(7,T[1][2],T[2][0],T[3][4],Xe),Z(8,T[1][2],T[2][0],T[3][0],Xe)],ha=192e3,ya=176400,so=96e3,ao=88200,ga=64e3,yt=48e3,ar=44100,cr=32e3,lr=24e3,dr=22050,ur=16e3,co=12e3,lo=11025,mr=8e3,xa=7350,Ne="absoluteGranulePosition",B="bandwidth",de="bitDepth",ue="bitrate",Vr=ue+"Maximum",Ur=ue+"Minimum",Gr=ue+"Nominal",qe="buffer",Wr=qe+"Fullness",j="codec",me=j+"Frames",Xr="coupledStreamCount",fr="crc",qr=fr+"16",Yr=fr+"32",Y="data",C="description",Ye="duration",pr="emphasis",Kr="hasOpusPadding",Ae="header",gt="isContinuedPacket",jr="isCopyrighted",xt="isFirstPage",$r="isHome",_e="isLastPage",Je="isOriginal",Ze="isPrivate",Qr="isVbr",be="layer",x="length",R="mode",et=R+"Extension",uo="mpeg",tt=uo+"Version",Jr="numberAACFrames",Zr="outputGain",kt="preSkip",en="profile",mo=J(),rt="protection",Ii="rawData",Ie="segments",k="subarray",vt="version",Dt="vorbis",tn=Dt+"Comments",hr=Dt+"Setup",fo="block",rn=fo+"ingStrategy",po=J(),nt=fo+"Size",bt=fo+"size0",St=fo+"size1",nn=J(),ho="channel",ot=ho+"MappingFamily",on=ho+"MappingTable",fe=ho+"Mode",sn=J(),z=ho+"s",va="copyright",an=va+"Id",cn=va+"IdStart",it="frame",st=it+"Count",Se=it+"Length",yo="Number",at=it+yo,Ke=it+"Padding",P=it+"Size",ba="Rate",ln="inputSample"+ba,Fi="page",Ht=Fi+"Checksum",yr=J(),Mt=Fi+"SegmentTable",ne=Fi+"Sequence"+yo,Pi="sample",dn=Pi+yo,D=Pi+ba,je=J(),H=Pi+"s",go="stream",un=go+"Count",mn=go+"Info",$e=go+"Serial"+yo,Ri=go+"StructureVersion",Bi="total",Ot=Bi+"BytesOut",Nt=Bi+"Duration",Vt=Bi+"Samples",N=J(),Fe=J(),fn=J(),At=J(),Ve=J(),xo=J(),ki=J(),_t=J(),G=J(),Pe=J(),Re=J(),Qe=J(),wt=J(),vo=J(),Ue=J(),Ge=J(),Be=J(),bo=J(),pe=Uint8Array,Lt=DataView,W="reserved",he="bad",gr="free",pn="none",So="16bit CRC";var Di=(t,e,r)=>{for(let n=0;n<t[x];n++){let o=e(n);for(let i=8;i>0;i--)o=r(o);t[n]=o}return t},Jl=Di(new pe(256),t=>t,t=>t&128?7^t<<1:t<<1),ee=[Di(new Uint16Array(256),t=>t<<8,t=>t<<1^(t&32768?32773:0))],te=[Di(new Uint32Array(256),t=>t,t=>t>>>1^(t&1)*3988292384)];for(let t=0;t<15;t++){ee.push(new Uint16Array(256)),te.push(new Uint32Array(256));for(let e=0;e<=255;e++)ee[t+1][e]=ee[0][ee[t][e]>>>8]^ee[t][e]<<8,te[t+1][e]=te[t][e]>>>8^te[0][te[t][e]&255]}var Ma=t=>{let e=0,r=t[x];for(let n=0;n!==r;n++)e=Jl[e^t[n]];return e},Aa=t=>{let e=t[x],r=e-16,n=0,o=0;for(;o<=r;)n^=t[o++]<<8|t[o++],n=ee[15][n>>8]^ee[14][n&255]^ee[13][t[o++]]^ee[12][t[o++]]^ee[11][t[o++]]^ee[10][t[o++]]^ee[9][t[o++]]^ee[8][t[o++]]^ee[7][t[o++]]^ee[6][t[o++]]^ee[5][t[o++]]^ee[4][t[o++]]^ee[3][t[o++]]^ee[2][t[o++]]^ee[1][t[o++]]^ee[0][t[o++]];for(;o!==e;)n=(n&255)<<8^ee[0][n>>8^t[o++]];return n},_a=t=>{let e=t[x],r=e-16,n=0,o=0;for(;o<=r;)n=te[15][(t[o++]^n)&255]^te[14][(t[o++]^n>>>8)&255]^te[13][(t[o++]^n>>>16)&255]^te[12][t[o++]^n>>>24]^te[11][t[o++]]^te[10][t[o++]]^te[9][t[o++]]^te[8][t[o++]]^te[7][t[o++]]^te[6][t[o++]]^te[5][t[o++]]^te[4][t[o++]]^te[3][t[o++]]^te[2][t[o++]]^te[1][t[o++]]^te[0][t[o++]];for(;o!==e;)n=te[0][(n^t[o++])&255]^n>>>8;return n^-1},yn=(...t)=>{let e=new pe(t.reduce((r,n)=>r+n[x],0));return t.reduce((r,n)=>(e.set(n,r),r+n[x]),0),e},we=t=>String.fromCharCode(...t),Sa=[0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15],hn=t=>Sa[t&15]<<4|Sa[t>>4],Mo=class{constructor(e){this._data=e,this._pos=e[x]*8}set position(e){this._pos=e}get position(){return this._pos}read(e){let r=Math.floor(this._pos/8),n=this._pos%8;return this._pos-=e,(hn(this._data[r-1])<<8)+hn(this._data[r])>>7-n&255}},wa=(t,e)=>{try{return t.getBigInt64(e,!0)}catch{let r=t.getUint8(e+7)&128?-1:1,n=t.getUint32(e,!0),o=t.getUint32(e+4,!0);return r===-1&&(n=~n+1,o=~o+1),o>1048575&&console.warn("This platform does not support BigInt"),r*(n+o*2**32)}};var gn=class{constructor(e,r){this._onCodecHeader=e,this._onCodecUpdate=r,this[Ue]()}[Ge](){this._isEnabled=!0}[Ue](){this._headerCache=new Map,this._codecUpdateData=new WeakMap,this._codecHeaderSent=!1,this._codecShouldUpdate=!1,this._bitrate=null,this._isEnabled=!1}[vo](e,r){if(this._onCodecUpdate){this._bitrate!==e&&(this._bitrate=e,this._codecShouldUpdate=!0);let n=this._codecUpdateData.get(this._headerCache.get(this._currentHeader));this._codecShouldUpdate&&n&&this._onCodecUpdate({bitrate:e,...n},r),this._codecShouldUpdate=!1}}[G](e){let r=this._headerCache.get(e);return r&&this._updateCurrentHeader(e),r}[Pe](e,r,n){this._isEnabled&&(this._codecHeaderSent||(this._onCodecHeader({...r}),this._codecHeaderSent=!0),this._updateCurrentHeader(e),this._headerCache.set(e,r),this._codecUpdateData.set(r,n))}_updateCurrentHeader(e){this._onCodecUpdate&&e!==this._currentHeader&&(this._codecShouldUpdate=!0,this._currentHeader=e)}};var se=new WeakMap,ce=new WeakMap;var ye=class{constructor(e,r){this._codecParser=e,this._headerCache=r}*[ki](){let e;do{if(e=yield*this.Frame[Re](this._codecParser,this._headerCache,0),e)return e;this._codecParser[Fe](1)}while(!0)}*[_t](e){let r=yield*this[ki](),n=ce.get(r)[x];if(e||this._codecParser._flushing||(yield*this.Header[G](this._codecParser,this._headerCache,n)))return this._headerCache[Ge](),this._codecParser[Fe](n),this._codecParser[At](r),r;this._codecParser[Ve](`Missing ${it} at ${n} bytes from current position.`,`Dropping current ${it} and trying again.`),this._headerCache[Ue](),this._codecParser[Fe](1)}};var Ut=class{constructor(e,r){ce.set(this,{[Ae]:e}),this[Y]=r}};var Le=class extends Ut{static*[Re](e,r,n,o,i){let s=yield*e[G](n,o,i);if(s){let a=se.get(s)[Se],c=se.get(s)[H],l=(yield*n[N](a,i))[k](0,a);return new r(s,l,c)}else return null}constructor(e,r,n){super(e,r),this[Ae]=e,this[H]=n,this[Ye]=n/e[D]*1e3,this[at]=null,this[Ot]=null,this[Vt]=null,this[Nt]=null,ce.get(this)[x]=r[x]}};var Hi="unsynchronizationFlag",Oi="extendedHeaderFlag",Ni="experimentalFlag",Vi="footerPresent",xn=class t{static*getID3v2Header(e,r,n){let i={},s=yield*e[N](3,n);if(s[0]!==73||s[1]!==68||s[2]!==51||(s=yield*e[N](10,n),i[vt]=`id3v2.${s[3]}.${s[4]}`,s[5]&15)||(i[Hi]=!!(s[5]&128),i[Oi]=!!(s[5]&64),i[Ni]=!!(s[5]&32),i[Vi]=!!(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 i[x]=10+a,new t(i)}constructor(e){this[vt]=e[vt],this[Hi]=e[Hi],this[Oi]=e[Oi],this[Ni]=e[Ni],this[Vi]=e[Vi],this[x]=e[x]}};var Ee=class{constructor(e){se.set(this,e),this[de]=e[de],this[ue]=null,this[z]=e[z],this[fe]=e[fe],this[D]=e[D]}};var Ta={0:[gr,gr,gr,gr,gr],16:[32,32,32,32,8],240:[he,he,he,he,he]},Ao=(t,e,r)=>8*((t+r)%e+e)*(1<<(t+r)/e)-8*e*(e/8|0);for(let t=2;t<15;t++)Ta[t<<4]=[t*32,Ao(t,4,0),Ao(t,4,-1),Ao(t,8,4),Ao(t,8,0)];var Zl=0,ed=1,td=2,rd=3,La=4,_o="bands ",wo=" to 31",Ea={0:_o+4+wo,16:_o+8+wo,32:_o+12+wo,48:_o+16+wo},Gt="bitrateIndex",vn="v2",To="v1",Lo="Intensity stereo ",Eo=", MS stereo ",zo="on",Co="off",nd={0:Lo+Co+Eo+Co,16:Lo+zo+Eo+Co,32:Lo+Co+Eo+zo,48:Lo+zo+Eo+zo},Ui={0:{[C]:W},2:{[C]:"Layer III",[Ke]:1,[et]:nd,[To]:{[Gt]:td,[H]:1152},[vn]:{[Gt]:La,[H]:576}},4:{[C]:"Layer II",[Ke]:1,[et]:Ea,[H]:1152,[To]:{[Gt]:ed},[vn]:{[Gt]:La}},6:{[C]:"Layer I",[Ke]:4,[et]:Ea,[H]:384,[To]:{[Gt]:Zl},[vn]:{[Gt]:rd}}},Gi="MPEG Version ",za="ISO/IEC ",od={0:{[C]:`${Gi}2.5 (later extension of MPEG 2)`,[be]:vn,[D]:{0:lo,4:co,8:mr,12:W}},8:{[C]:W},16:{[C]:`${Gi}2 (${za}13818-3)`,[be]:vn,[D]:{0:dr,4:lr,8:ur,12:W}},24:{[C]:`${Gi}1 (${za}11172-3)`,[be]:To,[D]:{0:ar,4:yt,8:cr,12:W}},length:x},id={0:So,1:pn},sd={0:pn,1:"50/15 ms",2:W,3:"CCIT J.17"},Ca={0:{[z]:2,[C]:ht},64:{[z]:2,[C]:"joint "+ht},128:{[z]:2,[C]:"dual channel"},192:{[z]:1,[C]:pt}},Wt=class t extends Ee{static*[G](e,r,n){let o={},i=yield*xn.getID3v2Header(e,r,n);i&&(yield*e[N](i[x],n),e[Fe](i[x]));let s=yield*e[N](4,n),a=we(s[k](0,4)),c=r[G](a);if(c)return new t(c);if(s[0]!==255||s[1]<224)return null;let l=od[s[1]&24];if(l[C]===W)return null;let d=s[1]&6;if(Ui[d][C]===W)return null;let u={...Ui[d],...Ui[d][l[be]]};if(o[tt]=l[C],o[be]=u[C],o[H]=u[H],o[rt]=id[s[1]&1],o[x]=4,o[ue]=Ta[s[2]&240][u[Gt]],o[ue]===he||(o[D]=l[D][s[2]&12],o[D]===W)||(o[Ke]=s[2]&2&&u[Ke],o[Ze]=!!(s[2]&1),o[Se]=Math.floor(125*o[ue]*o[H]/o[D]+o[Ke]),!o[Se]))return null;let m=s[3]&192;if(o[fe]=Ca[m][C],o[z]=Ca[m][z],o[et]=u[et][s[3]&48],o[jr]=!!(s[3]&8),o[Je]=!!(s[3]&4),o[pr]=sd[s[3]&3],o[pr]===W)return null;o[de]=16;{let{length:f,frameLength:h,samples:y,...p}=o;r[Pe](a,o,p)}return new t(o)}constructor(e){super(e),this[ue]=e[ue],this[pr]=e[pr],this[Ke]=e[Ke],this[jr]=e[jr],this[Je]=e[Je],this[Ze]=e[Ze],this[be]=e[be],this[et]=e[et],this[tt]=e[tt],this[rt]=e[rt]}};var bn=class t extends Le{static*[Re](e,r,n){return yield*super[Re](Wt,t,e,r,n)}constructor(e,r,n){super(e,r,n)}};var Sn=class extends ye{constructor(e,r,n){super(e,r),this.Frame=bn,this.Header=Wt,n(this[j])}get[j](){return uo}*[Qe](){return yield*this[_t]()}};var ad={0:"MPEG-4",8:"MPEG-2"},cd={0:"valid",2:he,4:he,6:he},ld={0:So,1:pn},dd={0:"AAC Main",64:"AAC LC (Low Complexity)",128:"AAC SSR (Scalable Sample Rate)",192:"AAC LTP (Long Term Prediction)"},ud={0:so,4:ao,8:ga,12:yt,16:ar,20:cr,24:lr,28:dr,32:ur,36:co,40:lo,44:mr,48:xa,52:W,56:W,60:"frequency is written explicitly"},Ia={0:{[z]:0,[C]:"Defined in AOT Specific Config"},64:{[z]:1,[C]:pt},128:{[z]:2,[C]:Z(2,T[0][0])},192:{[z]:3,[C]:Z(3,T[1][3])},256:{[z]:4,[C]:Z(4,T[1][3],T[3][4])},320:{[z]:5,[C]:Z(5,T[1][3],T[3][0])},384:{[z]:6,[C]:Z(6,T[1][3],T[3][0],Xe)},448:{[z]:8,[C]:Z(8,T[1][3],T[2][0],T[3][0],Xe)}},Xt=class t extends Ee{static*[G](e,r,n){let o={},i=yield*e[N](7,n),s=we([i[0],i[1],i[2],i[3]&252|i[6]&3]),a=r[G](s);if(a)Object.assign(o,a);else{if(i[0]!==255||i[1]<240||(o[tt]=ad[i[1]&8],o[be]=cd[i[1]&6],o[be]===he))return null;let l=i[1]&1;o[rt]=ld[l],o[x]=l?7:9,o[mo]=i[2]&192,o[je]=i[2]&60;let d=i[2]&2;if(o[en]=dd[o[mo]],o[D]=ud[o[je]],o[D]===W)return null;o[Ze]=!!d,o[sn]=(i[2]<<8|i[3])&448,o[fe]=Ia[o[sn]][C],o[z]=Ia[o[sn]][z],o[Je]=!!(i[3]&32),o[$r]=!!(i[3]&8),o[an]=!!(i[3]&8),o[cn]=!!(i[3]&4),o[de]=16,o[H]=1024,o[Jr]=i[6]&3;{let{length:u,channelModeBits:m,profileBits:f,sampleRateBits:h,frameLength:y,samples:p,numberAACFrames:g,...S}=o;r[Pe](s,o,S)}}if(o[Se]=(i[3]<<11|i[4]<<3|i[5]>>5)&8191,!o[Se])return null;let c=(i[5]<<6|i[6]>>2)&2047;return o[Wr]=c===2047?"VBR":c,new t(o)}constructor(e){super(e),this[an]=e[an],this[cn]=e[cn],this[Wr]=e[Wr],this[$r]=e[$r],this[Je]=e[Je],this[Ze]=e[Ze],this[be]=e[be],this[x]=e[x],this[tt]=e[tt],this[Jr]=e[Jr],this[en]=e[en],this[rt]=e[rt]}get audioSpecificConfig(){let e=se.get(this),r=e[mo]+64<<5|e[je]<<5|e[sn]>>3,n=new pe(2);return new Lt(n[qe]).setUint16(0,r,!1),n}};var Mn=class t extends Le{static*[Re](e,r,n){return yield*super[Re](Xt,t,e,r,n)}constructor(e,r,n){super(e,r,n)}};var An=class extends ye{constructor(e,r,n){super(e,r),this.Frame=Mn,this.Header=Xt,n(this[j])}get[j](){return"aac"}*[Qe](){return yield*this[_t]()}};var Et=class t extends Le{static _getFrameFooterCrc16(e){return(e[e[x]-2]<<8)+e[e[x]-1]}static[bo](e){let r=t._getFrameFooterCrc16(e),n=Aa(e[k](0,-2));return r===n}constructor(e,r,n){r[mn]=n,r[qr]=t._getFrameFooterCrc16(e),super(r,e,se.get(r)[H])}};var Fa="get from STREAMINFO metadata block",md={0:"Fixed",1:"Variable"},Pa={0:W,16:192};for(let t=2;t<16;t++)Pa[t<<4]=t<6?576*2**(t-2):2**t;var fd={0:Fa,1:ao,2:ya,3:ha,4:mr,5:ur,6:dr,7:lr,8:cr,9:ar,10:yt,11:so,15:he},pd={0:{[z]:1,[C]:pt},16:{[z]:2,[C]:Z(2,T[0][0])},32:{[z]:3,[C]:Z(3,T[0][1])},48:{[z]:4,[C]:Z(4,T[1][0],T[3][0])},64:{[z]:5,[C]:Z(5,T[1][1],T[3][0])},80:{[z]:6,[C]:Z(6,T[1][1],Xe,T[3][0])},96:{[z]:7,[C]:Z(7,T[1][1],Xe,T[3][4],T[2][0])},112:{[z]:8,[C]:Z(8,T[1][1],Xe,T[3][0],T[2][0])},128:{[z]:2,[C]:`${ht} (left, diff)`},144:{[z]:2,[C]:`${ht} (diff, right)`},160:{[z]:2,[C]:`${ht} (avg, diff)`},176:W,192:W,208:W,224:W,240:W},hd={0:Fa,2:8,4:12,6:W,8:16,10:20,12:24,14:W},zt=class t extends Ee{static _decodeUTF8Int(e){if(e[0]>254)return null;if(e[0]<128)return{value:e[0],length:1};let r=1;for(let s=64;s&e[0];s>>=1)r++;let n=r-1,o=0,i=0;for(;n>0;i+=6,n--){if((e[n]&192)!==128)return null;o|=(e[n]&63)<<i}return o|=(e[n]&127>>r)<<i,{value:o,length:r}}static[Be](e,r){let n={[N]:function*(){return e}};return t[G](n,r,0).next().value}static*[G](e,r,n){let o=yield*e[N](6,n);if(o[0]!==255||!(o[1]===248||o[1]===249))return null;let i={},s=we(o[k](0,4)),a=r[G](s);if(a)Object.assign(i,a);else{if(i[po]=o[1]&1,i[rn]=md[i[po]],i[nn]=o[2]&240,i[je]=o[2]&15,i[nt]=Pa[i[nn]],i[nt]===W||(i[D]=fd[i[je]],i[D]===he)||o[3]&1)return null;let l=pd[o[3]&240];if(l===W||(i[z]=l[z],i[fe]=l[C],i[de]=hd[o[3]&14],i[de]===W))return null}i[x]=5,o=yield*e[N](i[x]+8,n);let c=t._decodeUTF8Int(o[k](4));if(!c||(i[po]?i[dn]=c.value:i[at]=c.value,i[x]+=c[x],i[nn]===96?(o[x]<i[x]&&(o=yield*e[N](i[x],n)),i[nt]=o[i[x]-1]+1,i[x]+=1):i[nn]===112&&(o[x]<i[x]&&(o=yield*e[N](i[x],n)),i[nt]=(o[i[x]-1]<<8)+o[i[x]]+1,i[x]+=2),i[H]=i[nt],i[je]===12?(o[x]<i[x]&&(o=yield*e[N](i[x],n)),i[D]=o[i[x]-1]*1e3,i[x]+=1):i[je]===13?(o[x]<i[x]&&(o=yield*e[N](i[x],n)),i[D]=(o[i[x]-1]<<8)+o[i[x]],i[x]+=2):i[je]===14&&(o[x]<i[x]&&(o=yield*e[N](i[x],n)),i[D]=((o[i[x]-1]<<8)+o[i[x]])*10,i[x]+=2),o[x]<i[x]&&(o=yield*e[N](i[x],n)),i[fr]=o[i[x]-1],i[fr]!==Ma(o[k](0,i[x]-1))))return null;if(!a){let{blockingStrategyBits:l,frameNumber:d,sampleNumber:u,samples:m,sampleRateBits:f,blockSizeBits:h,crc:y,length:p,...g}=i;r[Pe](s,i,g)}return new t(i)}constructor(e){super(e),this[qr]=null,this[rn]=e[rn],this[nt]=e[nt],this[at]=e[at],this[dn]=e[dn],this[mn]=null}};var yd=2,gd=512*1024,qt=class extends ye{constructor(e,r,n){super(e,r),this.Frame=Et,this.Header=zt,n(this[j])}get[j](){return"flac"}*_getNextFrameSyncOffset(e){let r=yield*this._codecParser[N](2,0),n=r[x]-2;for(;e<n;){if(r[e]===255){let i=r[e+1];if(i===248||i===249)break;i!==255&&e++}e++}return e}*[Qe](){do{let e=yield*zt[G](this._codecParser,this._headerCache,0);if(e){let r=se.get(e)[x]+yd;for(;r<=gd;){if(this._codecParser._flushing||(yield*zt[G](this._codecParser,this._headerCache,r))){let n=yield*this._codecParser[N](r);if(this._codecParser._flushing||(n=n[k](0,r)),Et[bo](n)){let o=new Et(n,e);return this._headerCache[Ge](),this._codecParser[Fe](r),this._codecParser[At](o),o}}r=yield*this._getNextFrameSyncOffset(r+1)}this._codecParser[Ve](`Unable to sync FLAC frame after searching ${r} bytes.`),this._codecParser[Fe](r)}else this._codecParser[Fe](yield*this._getNextFrameSyncOffset(1))}while(!0)}[wt](e){return e[ne]===0?(this._headerCache[Ge](),this._streamInfo=e[Y][k](13)):e[ne]===1||(e[me]=ce.get(e)[Ie].map(r=>{let n=zt[Be](r,this._headerCache);if(n)return new Et(r,n,this._streamInfo);this._codecParser[Ve]("Failed to parse Ogg FLAC frame","Skipping invalid FLAC frame")}).filter(r=>!!r)),e}};var Yt=class t{static*[G](e,r,n){let o={},i=yield*e[N](28,n);if(i[0]!==79||i[1]!==103||i[2]!==103||i[3]!==83||(o[Ri]=i[4],i[5]&248))return null;o[_e]=!!(i[5]&4),o[xt]=!!(i[5]&2),o[gt]=!!(i[5]&1);let a=new Lt(pe.from(i[k](0,28))[qe]);o[Ne]=wa(a,6),o[$e]=a.getInt32(14,!0),o[ne]=a.getInt32(18,!0),o[Ht]=a.getInt32(22,!0);let c=i[26];o[x]=c+27,i=yield*e[N](o[x],n),o[Se]=0,o[Mt]=[],o[yr]=pe.from(i[k](27,o[x]));for(let l=0,d=0;l<c;l++){let u=o[yr][l];o[Se]+=u,d+=u,(u!==255||l===c-1)&&(o[Mt].push(d),d=0)}return new t(o)}constructor(e){se.set(this,e),this[Ne]=e[Ne],this[gt]=e[gt],this[xt]=e[xt],this[_e]=e[_e],this[Mt]=e[Mt],this[ne]=e[ne],this[Ht]=e[Ht],this[$e]=e[$e]}};var _n=class t extends Ut{static*[Re](e,r,n){let o=yield*Yt[G](e,r,n);if(o){let i=se.get(o)[Se],s=se.get(o)[x],a=s+i,c=(yield*e[N](a,0))[k](0,a),l=c[k](s,a);return new t(o,l,c)}else return null}constructor(e,r,n){super(e,r),ce.get(this)[x]=n[x],this[me]=[],this[Ii]=n,this[Ne]=e[Ne],this[Yr]=e[Ht],this[Ye]=0,this[gt]=e[gt],this[xt]=e[xt],this[_e]=e[_e],this[ne]=e[ne],this[H]=0,this[$e]=e[$e]}};var xr=class extends Le{constructor(e,r,n){super(r,e,n)}};var Ra={0:Nr.slice(0,2),1:Nr},ke="SILK-only",le="CELT-only",Io="Hybrid",Ct="narrowband",Fo="medium-band",Tt="wideband",vr="super-wideband",br="fullband",xd={0:{[R]:ke,[B]:Ct,[P]:10},8:{[R]:ke,[B]:Ct,[P]:20},16:{[R]:ke,[B]:Ct,[P]:40},24:{[R]:ke,[B]:Ct,[P]:60},32:{[R]:ke,[B]:Fo,[P]:10},40:{[R]:ke,[B]:Fo,[P]:20},48:{[R]:ke,[B]:Fo,[P]:40},56:{[R]:ke,[B]:Fo,[P]:60},64:{[R]:ke,[B]:Tt,[P]:10},72:{[R]:ke,[B]:Tt,[P]:20},80:{[R]:ke,[B]:Tt,[P]:40},88:{[R]:ke,[B]:Tt,[P]:60},96:{[R]:Io,[B]:vr,[P]:10},104:{[R]:Io,[B]:vr,[P]:20},112:{[R]:Io,[B]:br,[P]:10},120:{[R]:Io,[B]:br,[P]:20},128:{[R]:le,[B]:Ct,[P]:2.5},136:{[R]:le,[B]:Ct,[P]:5},144:{[R]:le,[B]:Ct,[P]:10},152:{[R]:le,[B]:Ct,[P]:20},160:{[R]:le,[B]:Tt,[P]:2.5},168:{[R]:le,[B]:Tt,[P]:5},176:{[R]:le,[B]:Tt,[P]:10},184:{[R]:le,[B]:Tt,[P]:20},192:{[R]:le,[B]:vr,[P]:2.5},200:{[R]:le,[B]:vr,[P]:5},208:{[R]:le,[B]:vr,[P]:10},216:{[R]:le,[B]:vr,[P]:20},224:{[R]:le,[B]:br,[P]:2.5},232:{[R]:le,[B]:br,[P]:5},240:{[R]:le,[B]:br,[P]:10},248:{[R]:le,[B]:br,[P]:20}},Sr=class t extends Ee{static[Be](e,r,n){let o={};if(o[z]=e[9],o[ot]=e[18],o[x]=o[ot]!==0?21+o[z]:19,e[x]<o[x])throw new Error("Out of data while inside an Ogg Page");let i=r[0]&3,s=i===3?2:1,a=we(e[k](0,o[x]))+we(r[k](0,s)),c=n[G](a);if(c)return new t(c);if(a.substr(0,8)!=="OpusHead"||e[8]!==1)return null;o[Y]=pe.from(e[k](0,o[x]));let l=new Lt(o[Y][qe]);if(o[de]=16,o[kt]=l.getUint16(10,!0),o[ln]=l.getUint32(12,!0),o[D]=yt,o[Zr]=l.getInt16(16,!0),o[ot]in Ra&&(o[fe]=Ra[o[ot]][o[z]-1],!o[fe]))return null;o[ot]!==0&&(o[un]=e[19],o[Xr]=e[20],o[on]=[...e[k](21,o[z]+21)]);let d=xd[248&r[0]];switch(o[R]=d[R],o[B]=d[B],o[P]=d[P],i){case 0:o[st]=1;break;case 1:case 2:o[st]=2;break;case 3:o[Qr]=!!(128&r[1]),o[Kr]=!!(64&r[1]),o[st]=63&r[1];break;default:return null}{let{length:u,data:m,channelMappingFamily:f,...h}=o;n[Pe](a,o,h)}return new t(o)}constructor(e){super(e),this[Y]=e[Y],this[B]=e[B],this[ot]=e[ot],this[on]=e[on],this[Xr]=e[Xr],this[st]=e[st],this[P]=e[P],this[Kr]=e[Kr],this[ln]=e[ln],this[Qr]=e[Qr],this[R]=e[R],this[Zr]=e[Zr],this[kt]=e[kt],this[un]=e[un]}};var wn=class extends ye{constructor(e,r,n){super(e,r),this.Frame=xr,this.Header=Sr,n(this[j]),this._identificationHeader=null,this._preSkipRemaining=null}get[j](){return"opus"}[wt](e){return e[ne]===0?(this._headerCache[Ge](),this._identificationHeader=e[Y]):e[ne]===1||(e[me]=ce.get(e)[Ie].map(r=>{let n=Sr[Be](this._identificationHeader,r,this._headerCache);if(n){this._preSkipRemaining===null&&(this._preSkipRemaining=n[kt]);let o=n[P]*n[st]/1e3*n[D];return this._preSkipRemaining>0&&(this._preSkipRemaining-=o,o=this._preSkipRemaining<0?-this._preSkipRemaining:0),new xr(r,n,o)}this._codecParser[xo]("Failed to parse Ogg Opus Header","Not a valid Ogg Opus file")})),e}};var Mr=class extends Le{constructor(e,r,n){super(r,e,n)}};var Wi={};for(let t=0;t<8;t++)Wi[t+6]=2**(6+t);var Ln=class t extends Ee{static[Be](e,r,n,o){if(e[x]<30)throw new Error("Out of data while inside an Ogg Page");let i=we(e[k](0,30)),s=r[G](i);if(s)return new t(s);let a={[x]:30};if(i.substr(0,7)!=="vorbis")return null;a[Y]=pe.from(e[k](0,30));let c=new Lt(a[Y][qe]);if(a[vt]=c.getUint32(7,!0),a[vt]!==0||(a[z]=e[11],a[fe]=Nr[a[z]-1]||"application defined",a[D]=c.getUint32(12,!0),a[Vr]=c.getInt32(16,!0),a[Gr]=c.getInt32(20,!0),a[Ur]=c.getInt32(24,!0),a[St]=Wi[(e[28]&240)>>4],a[bt]=Wi[e[28]&15],a[bt]>a[St])||e[29]!==1)return null;a[de]=32,a[hr]=o,a[tn]=n;{let{length:l,data:d,version:u,vorbisSetup:m,vorbisComments:f,...h}=a;r[Pe](i,a,h)}return new t(a)}constructor(e){super(e),this[Vr]=e[Vr],this[Ur]=e[Ur],this[Gr]=e[Gr],this[bt]=e[bt],this[St]=e[St],this[Y]=e[Y],this[tn]=e[tn],this[hr]=e[hr]}};var En=class extends ye{constructor(e,r,n){super(e,r),this.Frame=Mr,n(this[j]),this._identificationHeader=null,this._setupComplete=!1,this._prevBlockSize=null}get[j](){return Dt}[wt](e){e[me]=[];for(let r of ce.get(e)[Ie])if(r[0]===1)this._headerCache[Ge](),this._identificationHeader=e[Y],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=Ln[Be](this._identificationHeader,this._headerCache,this._vorbisComments,this._vorbisSetup);n?e[me].push(new Mr(r,n,this._getSamples(r,n))):this._codecParser[logError]("Failed to parse Ogg Vorbis Header","Not a valid Ogg Vorbis file")}return e}_getSamples(e,r){let o=this._mode.blockFlags[e[0]>>1&this._mode.mask]?r[St]:r[bt],i=this._prevBlockSize===null?0:(this._prevBlockSize+o)/4;return this._prevBlockSize=o,i}_parseSetupHeader(e){let r=new Mo(e),n={count:0,blockFlags:[]};for(;(r.read(1)&1)!==1;);let o;for(;n.count<64&&r.position>0;){hn(r.read(8));let i=0;for(;r.read(8)===0&&i++<3;);if(i===4)o=r.read(7),n.blockFlags.unshift(o&1),r.position+=6,n.count++;else{((hn(o)&126)>>1)+1!==n.count&&this._codecParser[Ve]("vorbis derived mode count did not match actual mode count");break}}return n.mask=(1<<Math.log2(n.count))-1,n}};var Xi=class{constructor(e,r,n){this._codecParser=e,this._headerCache=r,this._onCodec=n,this._continuedPacket=new pe,this._codec=null,this._isSupported=null,this._previousAbsoluteGranulePosition=null}get[j](){return this._codec||""}_updateCodec(e,r){this._codec!==e&&(this._headerCache[Ue](),this._parser=new r(this._codecParser,this._headerCache,this._onCodec),this._codec=e)}_checkCodecSupport({data:e}){let r=we(e[k](0,8));switch(r){case"fishead\0":return!1;case"OpusHead":return this._updateCodec("opus",wn),!0;case(/^\x7fFLAC/.test(r)&&r):return this._updateCodec("flac",qt),!0;case(/^\x01vorbis/.test(r)&&r):return this._updateCodec(Dt,En),!0;default:return!1}}_checkPageSequenceNumber(e){e[ne]!==this._pageSequenceNumber+1&&this._pageSequenceNumber>1&&e[ne]>1&&this._codecParser[Ve]("Unexpected gap in Ogg Page Sequence Number.",`Expected: ${this._pageSequenceNumber+1}, Got: ${e[ne]}`),this._pageSequenceNumber=e[ne]}_parsePage(e){this._isSupported===null&&(this._pageSequenceNumber=e[ne],this._isSupported=this._checkCodecSupport(e)),this._checkPageSequenceNumber(e);let r=ce.get(e),n=se.get(r[Ae]),o=0;if(r[Ie]=n[Mt].map(i=>e[Y][k](o,o+=i)),this._continuedPacket[x]&&(r[Ie][0]=yn(this._continuedPacket,r[Ie][0]),this._continuedPacket=new pe),n[yr][n[yr][x]-1]===255&&(this._continuedPacket=yn(this._continuedPacket,r[Ie].pop())),this._previousAbsoluteGranulePosition!==null&&(e[H]=Number(e[Ne]-this._previousAbsoluteGranulePosition)),this._previousAbsoluteGranulePosition=e[Ne],this._isSupported){let i=this._parser[wt](e);return this._codecParser[At](i),i}else return e}},zn=class extends ye{constructor(e,r,n){super(e,r),this._onCodec=n,this.Frame=_n,this.Header=Yt,this._streams=new Map,this._currentSerialNumber=null}get[j](){let e=this._streams.get(this._currentSerialNumber);return e?e.codec:""}*[Qe](){let e=yield*this[_t](!0);this._currentSerialNumber=e[$e];let r=this._streams.get(this._currentSerialNumber);return r||(r=new Xi(this._codecParser,this._headerCache,this._onCodec),this._streams.set(this._currentSerialNumber,r)),e[_e]&&this._streams.delete(this._currentSerialNumber),r._parsePage(e)}};var qi=()=>{},Cn=class{constructor(e,{onCodec:r,onCodecHeader:n,onCodecUpdate:o,enableLogging:i=!1,enableFrameCRC32:s=!0}={}){this._inputMimeType=e,this._onCodec=r||qi,this._onCodecHeader=n||qi,this._onCodecUpdate=o,this._enableLogging=i,this._crc32=s?_a:qi,this[Ue]()}get[j](){return this._parser?this._parser[j]:""}[Ue](){this._headerCache=new gn(this._onCodecHeader,this._onCodecUpdate),this._generator=this._getGenerator(),this._generator.next()}*flush(){this._flushing=!0;for(let e=this._generator.next();e.value;e=this._generator.next())yield e.value;this._flushing=!1,this[Ue]()}*parseChunk(e){for(let r=this._generator.next(e);r.value;r=this._generator.next())yield r.value}parseAll(e){return[...this.parseChunk(e),...this.flush()]}*_getGenerator(){if(this._inputMimeType.match(/aac/))this._parser=new An(this,this._headerCache,this._onCodec);else if(this._inputMimeType.match(/mpeg/))this._parser=new Sn(this,this._headerCache,this._onCodec);else if(this._inputMimeType.match(/flac/))this._parser=new qt(this,this._headerCache,this._onCodec);else if(this._inputMimeType.match(/ogg/))this._parser=new zn(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 e=yield*this._parser[Qe]();e&&(yield e)}}*[N](e=0,r=0){let n;for(;this._rawData[x]<=e+r;){if(n=yield,this._flushing)return this._rawData[k](r);n&&(this._totalBytesIn+=n[x],this._rawData=yn(this._rawData,n))}return this._rawData[k](r)}[Fe](e){this._currentReadPosition+=e,this._rawData=this._rawData[k](e)}[fn](e){this._sampleRate=e[Ae][D],e[Ae][ue]=e[Ye]>0?Math.round(e[Y][x]/e[Ye])*8:0,e[at]=this._frameNumber++,e[Ot]=this._totalBytesOut,e[Vt]=this._totalSamples,e[Nt]=this._totalSamples/this._sampleRate*1e3,e[Yr]=this._crc32(e[Y]),this._headerCache[vo](e[Ae][ue],e[Nt]),this._totalBytesOut+=e[Y][x],this._totalSamples+=e[H]}[At](e){if(e[me]){if(e[_e]){let r=e[H];e[me].forEach(n=>{let o=n[H];r<o&&(n[H]=r>0?r:0,n[Ye]=n[H]/n[Ae][D]*1e3),r-=o,this[fn](n)})}else e[H]=0,e[me].forEach(r=>{e[H]+=r[H],this[fn](r)});e[Ye]=e[H]/this._sampleRate*1e3||0,e[Vt]=this._totalSamples,e[Nt]=this._totalSamples/this._sampleRate*1e3||0,e[Ot]=this._totalBytesOut}else this[fn](e)}_log(e,r){if(this._enableLogging){let n=[`${j}: ${this[j]}`,`inputMimeType: ${this._inputMimeType}`,`readPosition: ${this._currentReadPosition}`,`totalBytesIn: ${this._totalBytesIn}`,`${Ot}: ${this._totalBytesOut}`],o=Math.max(...n.map(i=>i[x]));r.push(`--stats--${"-".repeat(o-9)}`,...n,"-".repeat(o)),e("codec-parser",r.reduce((i,s)=>i+`
|
|
4
|
-
`+s,""))}}[Ve](...e){this._log(console.warn,e)}[xo](...e){this._log(console.error,e)}};var Ba=
|
|
1
|
+
"use strict";var Quake2Engine=(()=>{var Rc=Object.create;var Un=Object.defineProperty;var Bc=Object.getOwnPropertyDescriptor;var Oc=Object.getOwnPropertyNames;var Dc=Object.getPrototypeOf,kc=Object.prototype.hasOwnProperty;var Hc=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),di=(t,e)=>{for(var r in e)Un(t,r,{get:e[r],enumerable:!0})},Ps=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Oc(e))!kc.call(t,o)&&o!==r&&Un(t,o,{get:()=>e[o],enumerable:!(n=Bc(e,o))||n.enumerable});return t};var Nc=(t,e,r)=>(r=t!=null?Rc(Dc(t)):{},Ps(e||!t||!t.__esModule?Un(r,"default",{value:t,enumerable:!0}):r,t)),Vc=t=>Ps(Un({},"__esModule",{value:!0}),t);var fa=Hc((kf,ua)=>{"use strict";ua.exports=Worker});var A0={};di(A0,{ATTN_IDLE:()=>Ga,ATTN_LOOP_NONE:()=>Va,ATTN_NONE:()=>No,ATTN_NORM:()=>Ua,ATTN_STATIC:()=>Wa,AssetDependencyError:()=>jt,AssetDependencyTracker:()=>Rn,AssetManager:()=>ko,AudioApi:()=>Qo,AudioContextController:()=>Uo,AudioRegistry:()=>Ar,AudioRegistryError:()=>Fn,AudioSystem:()=>jo,BSP_SURFACE_FRAGMENT_SOURCE:()=>os,BSP_SURFACE_VERTEX_SOURCE:()=>ns,BSP_VERTEX_LAYOUT:()=>es,BspLoader:()=>Zn,BspParseError:()=>K,BspSurfacePipeline:()=>ei,Camera:()=>ii,ConfigStringRegistry:()=>er,Cvar:()=>Br,CvarRegistry:()=>jn,EngineHost:()=>Jt,EngineRuntime:()=>Rr,FixedTimestepLoop:()=>Ct,Framebuffer:()=>Jo,IndexBuffer:()=>De,LruCache:()=>ft,MAX_SOUND_CHANNELS:()=>$i,MD2_FRAGMENT_SHADER:()=>us,MD2_VERTEX_SHADER:()=>ds,MD3_FRAGMENT_SHADER:()=>vs,MD3_VERTEX_SHADER:()=>bs,Md2Loader:()=>rr,Md2MeshBuffers:()=>ri,Md2ParseError:()=>ae,Md2Pipeline:()=>ni,Md3Loader:()=>nr,Md3ModelMesh:()=>si,Md3ParseError:()=>Pe,Md3Pipeline:()=>ai,Md3SurfaceMesh:()=>Dn,MusicSystem:()=>$o,PARTICLE_FRAGMENT_SHADER:()=>Ms,PARTICLE_VERTEX_SHADER:()=>Ss,PakArchive:()=>tr,PakIndexStore:()=>Do,PakIngestionError:()=>ut,PakParseError:()=>ze,PakValidationError:()=>Tt,PakValidator:()=>Qn,ParticleRenderer:()=>li,ParticleSystem:()=>ci,RERELEASE_KNOWN_PAKS:()=>Mi,SKYBOX_FRAGMENT_SHADER:()=>cs,SKYBOX_VERTEX_SHADER:()=>as,SOUND_FULLVOLUME:()=>_r,SOUND_LOOP_ATTENUATE:()=>Xa,ShaderProgram:()=>ge,SkyboxPipeline:()=>ti,SoundChannel:()=>Ho,SoundPrecache:()=>Xo,SoundRegistry:()=>Wo,SpriteLoader:()=>or,SpriteParseError:()=>mt,Texture2D:()=>wr,TextureCache:()=>ir,TextureCubeMap:()=>Lr,VertexArray:()=>Me,VertexBuffer:()=>xe,VirtualFileSystem:()=>$n,advanceAnimation:()=>oa,applySurfaceState:()=>oc,attenuationToDistanceMultiplier:()=>$t,boxIntersectsFrustum:()=>On,buildBspGeometry:()=>Qa,buildMd2Geometry:()=>fs,buildMd2VertexData:()=>ms,buildMd3SurfaceGeometry:()=>gs,buildMd3VertexData:()=>xs,calculateMaxAudibleDistance:()=>Vo,calculatePakChecksum:()=>Ks,computeFrameBlend:()=>ia,computeSkyScroll:()=>ac,createAnimationState:()=>sa,createAudioGraph:()=>Go,createBspSurfaces:()=>$a,createEngine:()=>M0,createEngineRuntime:()=>Ws,createFaceLightmap:()=>eo,createInitialChannels:()=>Ko,createProgramFromSources:()=>ja,createWebGLContext:()=>Ya,decodeOgg:()=>Oo,deriveSurfaceRenderState:()=>ss,extractFrustumPlanes:()=>Ja,filesToPakSources:()=>Ai,findLeafForPoint:()=>rs,gatherVisibleFaces:()=>rc,groupMd2Animations:()=>ea,ingestPakFiles:()=>Ys,ingestPaks:()=>Jn,interpolateMd3Tag:()=>wc,interpolateVec3:()=>aa,parseBsp:()=>_i,parseMd2:()=>wi,parseMd3:()=>Li,parsePcx:()=>ca,parseSprite:()=>Ei,parseWal:()=>ro,parseWalTexture:()=>da,parseWav:()=>oo,pcxToRgba:()=>no,pickChannel:()=>Yo,preparePcxTexture:()=>la,removeViewTranslation:()=>sc,resolveLightStyles:()=>is,spatializeOrigin:()=>qo,spawnBlood:()=>Ic,spawnBulletImpact:()=>Lc,spawnExplosion:()=>Ec,spawnMuzzleFlash:()=>Pc,spawnTeleportFlash:()=>zc,spawnTrail:()=>Fc,walToRgba:()=>Ii,wireDropTarget:()=>qs,wireFileInput:()=>js});var Uc=()=>typeof performance<"u"?performance.now():Date.now(),Gc=t=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(()=>t()):setTimeout(t,25)},Ct=class{constructor(e,r={}){this.callbacks=e;this.accumulatorMs=0;this.frame=0;this.running=!1;this.tick=()=>{if(!this.running)return;let e=this.options.now(),r=this.lastTimeMs===void 0?0:e-this.lastTimeMs;this.lastTimeMs=e,this.advance(r,e),this.running&&this.options.schedule(this.tick)};let n=r.fixedDeltaMs??25,o=r.maxSubSteps??5;this.options={fixedDeltaMs:n,maxSubSteps:o,maxDeltaMs:r.maxDeltaMs??n*o,startTimeMs:r.startTimeMs,now:r.now??Uc,schedule:r.schedule??Gc}}start(){this.running||(this.running=!0,this.lastTimeMs=this.options.startTimeMs??this.options.now(),this.options.schedule(this.tick))}stop(){this.running=!1}pump(e){let r=(this.lastTimeMs??0)+e;this.lastTimeMs=r,this.advance(e,r)}isRunning(){return this.running}get frameNumber(){return this.frame}advance(e,r){let n=Math.min(Math.max(e,0),this.options.maxDeltaMs);this.accumulatorMs=Math.min(this.accumulatorMs+n,this.options.fixedDeltaMs*this.options.maxSubSteps);let o=0;for(;this.accumulatorMs>=this.options.fixedDeltaMs&&o<this.options.maxSubSteps;)this.frame+=1,this.callbacks.simulate({frame:this.frame,deltaMs:this.options.fixedDeltaMs,nowMs:r}),this.accumulatorMs-=this.options.fixedDeltaMs,o+=1;let i=this.options.fixedDeltaMs===0?0:this.accumulatorMs/this.options.fixedDeltaMs;this.callbacks.render?.({alpha:i,nowMs:r,accumulatorMs:this.accumulatorMs,frame:this.frame})}};var Jt=class{constructor(e,r,n={}){this.game=e;this.client=r;this.started=!1;this.stepSimulation=e=>{this.previousFrame=this.latestFrame,this.latestFrame=this.game.frame(e,this.latestCommand)};this.renderClient=e=>{this.client&&(this.latestCommand=this.client.render({...e,previous:this.previousFrame,latest:this.latestFrame}))};let o=n.loop?.now?.()??Date.now();this.startTimeMs=n.startTimeMs??n.loop?.startTimeMs??o,this.loop=new Ct({simulate:this.stepSimulation,render:this.renderClient},{...n.loop,startTimeMs:this.startTimeMs})}start(){this.started||(this.latestFrame=this.game.init(this.startTimeMs)??this.latestFrame,this.client?.init(this.latestFrame),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(e){this.loop.pump(e)}getLatestFrame(){return this.latestFrame}isRunning(){return this.loop.isRunning()}};var Fs={x:0,y:0,z:0};var I0=Math.PI/180;function Cs(t,e){return{x:t.x-e.x,y:t.y-e.y,z:t.z-e.z}}function Wc(t,e){return{x:t.x*e,y:t.y*e,z:t.z*e}}function fi(t,e){return t.x*e.x+t.y*e.y+t.z*e.z}function Xc(t){return fi(t,t)}function mi(t){return Math.sqrt(Xc(t))}function He(t){let e=mi(t);return e===0?t:Wc(t,1/e)}var Kc=Math.PI/180,z0=180/Math.PI,Zt=Kc;function Yc(){return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function Ts(t,e){let r=e.x,n=e.y,o=e.z;return{x:t[0]*r+t[4]*n+t[8]*o+t[12],y:t[1]*r+t[5]*n+t[9]*o+t[13],z:t[2]*r+t[6]*n+t[10]*o+t[14]}}function Rs(t,e){let r=Yc();return r[0]=e[0].x,r[1]=e[0].y,r[2]=e[0].z,r[4]=e[1].x,r[5]=e[1].y,r[6]=e[1].z,r[8]=e[2].x,r[9]=e[2].y,r[10]=e[2].z,r[12]=t.x,r[13]=t.y,r[14]=t.z,r}var We=1,dt=2;var hi=8,pi=16,qc=32;var jc=16384;var Gn=65536,Bs=1<<17,$c=1<<18,Qc=1<<19,Jc=1<<20,Zc=1<<21,el=1<<22,tl=1<<23,P0=1<<24,Wn=1<<25,rl=1<<26,F0=1<<27,C0=1<<28,T0=1<<29,Xn=1<<30,R0=1<<31;var Tr=0;var Os=4,Ds=8,ks=16,Hs=32,Ns=64;var B0=1<<25,O0=1<<28,D0=1<<29,k0=1<<30,H0=1<<31;var N0=We|dt,V0=We|Gn|dt|Wn|Xn,U0=We|Gn|dt,G0=We|Bs|dt|Wn|Xn,W0=qc|hi|pi,X0=We|pi|hi,nl=We|Wn|Xn|dt|rl,K0=$c|Qc|Jc|Zc|el|tl,Y0=We|hi|pi|Wn|Xn,q0=We|Gn|dt,j0=We|dt,$0=We|Gn|dt|Bs,Q0=nl|jc;var J0=Number.MAX_SAFE_INTEGER-1;var Kn=(t=>(t[t.None=0]="None",t[t.Archive=1]="Archive",t[t.UserInfo=2]="UserInfo",t[t.ServerInfo=4]="ServerInfo",t[t.Latch=8]="Latch",t[t.Cheat=16]="Cheat",t))(Kn||{});var Yn=256;var yi=256,gi=8192,qn=2048,xi=512,bi=256,vi=Yn*2,Si=256,ui=32,Cr=96;var X=(t=>(t[t.Name=0]="Name",t[t.CdTrack=1]="CdTrack",t[t.Sky=2]="Sky",t[t.SkyAxis=3]="SkyAxis",t[t.SkyRotate=4]="SkyRotate",t[t.StatusBar=5]="StatusBar",t[t.AirAccel=59]="AirAccel",t[t.MaxClients=60]="MaxClients",t[t.MapChecksum=61]="MapChecksum",t[t.Models=62]="Models",t[t.Sounds=62+gi]="Sounds",t[t.Images=t.Sounds+qn]="Images",t[t.Lights=t.Images+xi]="Lights",t[t.ShadowLights=t.Lights+yi]="ShadowLights",t[t.Items=t.ShadowLights+Si]="Items",t[t.PlayerSkins=t.Items+bi]="PlayerSkins",t[t.General=t.PlayerSkins+Yn]="General",t[t.WheelWeapons=t.General+vi]="WheelWeapons",t[t.WheelAmmo=t.WheelWeapons+ui]="WheelAmmo",t[t.WheelPowerups=t.WheelAmmo+ui]="WheelPowerups",t[t.CdLoopCount=t.WheelPowerups+ui]="CdLoopCount",t[t.GameStyle=t.CdLoopCount+1]="GameStyle",t[t.MaxConfigStrings=t.GameStyle+1]="MaxConfigStrings",t))(X||{}),Vs=X.MaxConfigStrings;function Us(t){return t>=5&&t<59?Cr*(59-t):t>=X.General&&t<X.WheelWeapons?Cr*(X.MaxConfigStrings-t):Cr}function ol(t){if(t<0||t>=X.MaxConfigStrings)throw new RangeError(`Configstring index ${t} is out of range (0-${X.MaxConfigStrings-1})`)}function Gs(t,e){let r=Us(t);if(e.length>r)throw new RangeError(`Configstring ${t} exceeds maximum length (${e.length} > ${r}); limit is ${Cr} chars per slot`)}var er=class{constructor(){this.values=new Map;this.modelCursor=X.Models;this.soundCursor=X.Sounds;this.imageCursor=X.Images;this.lightCursor=X.Lights;this.shadowLightCursor=X.ShadowLights;this.itemCursor=X.Items;this.playerSkinCursor=X.PlayerSkins;this.generalCursor=X.General}set(e,r){return ol(e),Gs(e,r),this.values.set(e,r),e}get(e){return this.values.get(e)}getAll(){let e=new Array(Vs).fill("");for(let[r,n]of this.values.entries())e[r]=n;return e}modelIndex(e){return this.register(e,X.Models,gi,"modelCursor")}soundIndex(e){return this.register(e,X.Sounds,qn,"soundCursor")}findSoundIndex(e){for(let r=X.Sounds;r<X.Sounds+qn;r+=1)if(this.values.get(r)===e)return r}imageIndex(e){return this.register(e,X.Images,xi,"imageCursor")}lightIndex(e){return this.register(e,X.Lights,yi,"lightCursor")}shadowLightIndex(e){return this.register(e,X.ShadowLights,Si,"shadowLightCursor")}itemIndex(e){return this.register(e,X.Items,bi,"itemCursor")}playerSkinIndex(e){return this.register(e,X.PlayerSkins,Yn,"playerSkinCursor")}generalIndex(e){return this.register(e,X.General,vi,"generalCursor")}register(e,r,n,o){for(let a=r;a<r+n;a+=1)if(this.values.get(a)===e)return a;let i=this[o],s=r+n;if(i>=s)throw new RangeError(`Out of configstring slots for range starting at ${r}`);return Gs(i,e),this.values.set(i,e),this[o]=i+1,i}};var Rr=class{constructor(e,r){this.engine=e;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(e){this.host.pump(e)}getLatestFrame(){return this.host.getLatestFrame()}isRunning(){return this.started&&this.host.isRunning()}};function Ws(t,e,r,n){return new Rr(t,new Jt(e,r,n))}var Br=class{constructor({name:e,defaultValue:r,description:n,flags:o=Kn.None,onChange:i}){this.modifiedCount=0;this.name=e,this.defaultValue=r,this.description=n,this.flags=o,this._value=r,this.onChange=i}get string(){return this._value}get number(){return Number(this._value)}get integer(){return Math.trunc(this.number)}get boolean(){return!!this.integer}set(e){if(this.flags&Kn.Latch){if(e===this._value){this.latched=void 0;return}if(this.latched===e)return;this.latched!==e&&(this.latched=e);return}this.apply(e)}reset(){this.latched=void 0,this.apply(this.defaultValue)}applyLatched(){if(this.latched===void 0)return!1;let e=this.latched;return this.latched=void 0,e===this._value?!1:(this.apply(e),!0)}apply(e){if(this._value===e)return;let r=this._value;this._value=e,this.modifiedCount+=1,this.onChange?.(this,r)}},jn=class{constructor(){this.cvars=new Map}register(e){let r=this.cvars.get(e.name);if(r)return r;let n=new Br(e);return this.cvars.set(e.name,n),n}get(e){return this.cvars.get(e)}setValue(e,r){let n=this.get(e);if(!n)throw new Error(`Unknown cvar: ${e}`);return n.set(r),n}resetAll(){for(let e of this.cvars.values())e.reset()}applyLatched(){let e=!1;for(let r of this.cvars.values())e=r.applyLatched()||e;return e}list(){return[...this.cvars.values()].sort((e,r)=>e.name.localeCompare(r.name))}};var il="PACK";function sl(t,e,r){let n=[];for(let o=0;o<r;o+=1){let i=t.getUint8(e+o);if(i===0)break;n.push(i)}return String.fromCharCode(...n)}function re(t){return t.replace(/\\/g,"/").replace(/^\/+/,"").toLowerCase()}function al(){let t=new Uint32Array(256);for(let e=0;e<256;e+=1){let r=e;for(let n=0;n<8;n+=1)r=(r&1)!==0?3988292384^r>>>1:r>>>1;t[e]=r>>>0}return t}var cl=al();function Xs(t){let e=4294967295;for(let r=0;r<t.length;r+=1){let n=t[r];e=cl[(e^n)&255]^e>>>8}return(e^4294967295)>>>0}var ze=class extends Error{},tr=class t{constructor(e,r,n,o){this.name=e;this.buffer=r;this.entries=new Map(n.map(i=>[i.name,i])),this.checksum=o,this.size=r.byteLength}static fromArrayBuffer(e,r){let n=new DataView(r);if(r.byteLength<12)throw new ze("PAK buffer too small to contain header");let o=String.fromCharCode(n.getUint8(0),n.getUint8(1),n.getUint8(2),n.getUint8(3));if(o!==il)throw new ze(`Invalid PAK header magic: ${o}`);let i=n.getInt32(4,!0),s=n.getInt32(8,!0);if(i<12)throw new ze(`Invalid directory offset: ${i}`);if(s<=0||s%64!==0)throw new ze(`Invalid directory length: ${s}`);if(i+s>r.byteLength)throw new ze("Directory exceeds buffer length");let c=s/64,l=[],d=new Map;for(let u=0;u<c;u+=1){let f=i+u*64,m=sl(n,f,56),p=re(m),y=n.getInt32(f+56,!0),h=n.getInt32(f+60,!0);if(y<0||h<0||y+h>r.byteLength)throw new ze(`Invalid entry bounds for ${m||"<unnamed>"} (offset=${y}, length=${h})`);if(!p)throw new ze(`Entry ${u} has an empty name`);let g={name:p,offset:y,length:h};d.set(p,g)}return l.push(...d.values()),new t(e,r,l,Xs(new Uint8Array(r)))}getEntry(e){return this.entries.get(re(e))}listEntries(){return Array.from(this.entries.values())}readFile(e){let r=this.getEntry(e);if(!r)throw new ze(`File not found in PAK: ${e}`);return new Uint8Array(this.buffer,r.offset,r.length)}validate(){return{checksum:this.checksum,entries:this.listEntries()}}};function Ks(t){return Xs(new Uint8Array(t))}var $n=class{constructor(e=[]){this.mounts=[];this.files=new Map;e.forEach(r=>this.mountPak(r))}mountPak(e){this.mounts.push(e);for(let r of e.listEntries()){let n=re(r.name);this.files.set(n,{archive:e,entry:r})}}get mountedPaks(){return[...this.mounts]}hasFile(e){return this.files.has(re(e))}stat(e){let r=this.files.get(re(e));if(r)return{path:r.entry.name,size:r.entry.length,sourcePak:r.archive.name}}async readFile(e){let r=this.files.get(re(e));if(!r)throw new Error(`File not found in VFS: ${e}`);return r.archive.readFile(e)}list(e=""){let r=re(e).replace(/\/+$|^\//g,""),n=[],o=new Set,i=r?`${r}/`:"";for(let s of this.files.values()){if(r&&!s.entry.name.startsWith(i))continue;let a=r?s.entry.name.slice(i.length):s.entry.name,c=a.indexOf("/");c===-1?n.push({path:s.entry.name,size:s.entry.length,sourcePak:s.archive.name}):o.add(a.slice(0,c))}return n.sort((s,a)=>s.path.localeCompare(a.path)),{files:n,directories:[...o].sort()}}findByExtension(e){let r=e.startsWith(".")?e.toLowerCase():`.${e.toLowerCase()}`,n=[];for(let o of this.files.values())o.entry.name.toLowerCase().endsWith(r)&&n.push({path:o.entry.name,size:o.entry.length,sourcePak:o.archive.name});return n.sort((o,i)=>o.path.localeCompare(i.path))}};var Mi=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"}]),Tt=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"}},Qn=class{constructor(e=Mi){this.known=new Map;e.forEach(r=>this.known.set(this.normalizePakName(r.name),r))}validateArchive(e,r){let n=this.normalizePakName(r??("name"in e?e.name:"unknown")),o=e.checksum,i="size"in e?e.size:void 0,s=this.known.get(n);return s?s.checksum!==o?{name:n,checksum:o,expectedChecksum:s.checksum,status:"mismatch",size:i,description:s.description}:{name:n,checksum:o,expectedChecksum:s.checksum,status:"valid",size:i,description:s.description}:{name:n,checksum:o,status:"unknown",size:i}}assertValid(e,r){let n=this.validateArchive(e,r);if(n.status==="mismatch")throw new Tt(n);return n}normalizePakName(e){let r=re(e),n=r.split("/"),o=n.pop()??r,i=n.pop();return i?`${o}@${i}`:o}};var ut=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 ll(t,e){if(typeof t.arrayBuffer=="function"){let r=await t.arrayBuffer();return e?.({file:"blob",loadedBytes:r.byteLength,totalBytes:r.byteLength,state:"reading"}),r}if(typeof FileReader<"u")return new Promise((r,n)=>{let o=new FileReader;o.onerror=()=>n(o.error??new Error("Unknown FileReader error")),o.onprogress=i=>{e?.({file:"blob",loadedBytes:i.loaded,totalBytes:i.total||t.size,state:"reading"})},o.onload=()=>{let i=o.result;i instanceof ArrayBuffer?r(i):n(new Error("Unexpected FileReader result"))},o.readAsArrayBuffer(t)});if(typeof Response<"u"){let r=await new Response(t).arrayBuffer();return e?.({file:"blob",loadedBytes:r.byteLength,totalBytes:r.byteLength,state:"reading"}),r}if(typeof t.stream=="function"){let r=t.stream().getReader(),n=[],o=0;for(;;){let{done:a,value:c}=await r.read();if(a)break;if(!c)continue;let l=c;n.push(l),o+=l.byteLength,e?.({file:"blob",loadedBytes:o,totalBytes:t.size,state:"reading"})}let i=new Uint8Array(o),s=0;for(let a of n)i.set(a,s),s+=a.byteLength;return i.buffer}throw new ut("blob",new Error("Unsupported Blob type"))}async function dl(t,e){if(t.data instanceof ArrayBuffer)return e?.({file:t.name,loadedBytes:t.data.byteLength,totalBytes:t.data.byteLength,state:"reading"}),t.data;if(t.data instanceof Blob){let n=t.data.size;return ll(t.data,o=>e?.({...o,file:t.name,totalBytes:n}))}let r=t.data.buffer.slice(t.data.byteOffset,t.data.byteOffset+t.data.byteLength);return e?.({file:t.name,loadedBytes:r.byteLength,totalBytes:r.byteLength,state:"reading"}),r}async function Jn(t,e,r){let n=typeof r=="function"?{onProgress:r}:r??{},o=n.persistIndexes??!!n.pakIndexStore,i=n.enforceValidation??!!n.validator,s=n.allowUnknownPaks??!0,a=n.stopOnError??!1,c=[];for(let l of e)try{let d=await dl(l,n.onProgress),u=tr.fromArrayBuffer(l.name,d),f=n.validator?.validateArchive(u);if(f){n.onValidationResult?.(f);let m=f.status==="mismatch",p=f.status==="unknown";if(m&&i||p&&!s){let y=new Tt(f);if(n.onError?.(l.name,y),a)throw new ut(l.name,y);c.push({archive:u,mounted:!1,validation:f});continue}}if(t.mountPak(u),o&&n.pakIndexStore)try{await n.pakIndexStore.persist(u)}catch(m){if(n.onError?.(l.name,m),a)throw new ut(l.name,m)}n.onProgress?.({file:l.name,loadedBytes:d.byteLength,totalBytes:d.byteLength,state:"parsed"}),c.push({archive:u,mounted:!0,validation:f})}catch(d){if(n.onProgress?.({file:l.name,loadedBytes:0,totalBytes:0,state:"error"}),n.onError?.(l.name,d),a)throw new ut(l.name,d)}return c}var ft=class{constructor(e){this.capacity=e;this.map=new Map;if(e<=0)throw new RangeError("LRU cache capacity must be greater than zero")}get size(){return this.map.size}has(e){return this.map.has(e)}get(e){let r=this.map.get(e);if(r!==void 0)return this.map.delete(e),this.map.set(e,r),r}set(e,r){if(this.map.has(e)&&this.map.delete(e),this.map.set(e,r),this.map.size>this.capacity){let n=this.map.keys().next();n.done||this.map.delete(n.value)}}delete(e){return this.map.delete(e)}clear(){this.map.clear()}entries(){return Array.from(this.map.entries()).reverse().map(([e,r])=>({key:e,value:r}))}};function ul(t){return Array.isArray(t)?t:Array.from(t)}function Ai(t){return ul(t).map(e=>({name:e.name,data:e}))}async function Ys(t,e,r){let n=Ai(e);return Jn(t,n,r??{})}function qs(t,e){let r=o=>{o.preventDefault(),o.dataTransfer?.dropEffect&&(o.dataTransfer.dropEffect="copy")},n=o=>{o.preventDefault();let i=o.dataTransfer?.files;i&&i.length>0&&e(Array.from(i))};return t.addEventListener("dragover",r),t.addEventListener("drop",n),()=>{t.removeEventListener("dragover",r),t.removeEventListener("drop",n)}}function js(t,e){let r=n=>{let o=n.target;!o||!o.files||o.files.length===0||(e(o.files),o.value="")};return t.addEventListener("change",r),()=>t.removeEventListener("change",r)}var fl="IBSP",ml=38,Qs=19,hl=8+Qs*8;var K=class extends Error{},Zn=class{constructor(e){this.vfs=e}async load(e){let r=await this.vfs.readFile(e),n=new Uint8Array(r.byteLength);return n.set(r),_i(n.buffer)}};function _i(t){if(t.byteLength<hl)throw new K("BSP too small to contain header");let e=new DataView(t),r=String.fromCharCode(e.getUint8(0),e.getUint8(1),e.getUint8(2),e.getUint8(3));if(r!==fl)throw new K(`Invalid BSP magic ${r}`);let n=e.getInt32(4,!0);if(n!==ml)throw new K(`Unsupported BSP version ${n}`);let o=new Map;for(let A=0;A<Qs;A+=1){let _=e.getInt32(8+A*8,!0),L=e.getInt32(12+A*8,!0);if(_<0||L<0||_+L>t.byteLength)throw new K(`Invalid lump bounds for index ${A}`);o.set(A,{offset:_,length:L})}let i={version:n,lumps:o},s=pl(t,o.get(0)),a=gl(t,o.get(1)),c=xl(t,o.get(2)),l=bl(t,o.get(4)),d=vl(t,o.get(5)),u=Sl(t,o.get(6)),f=new Uint8Array(t,o.get(7).offset,o.get(7).length),m=Pl(u,o.get(7)),p=Ml(t,o.get(8)),y=Al(t,o.get(11)),h=_l(t,o.get(12)),g=wl(t,o.get(13)),S=Ll(t,o.get(14)),b=El(t,o.get(15)),M=Il(t,o.get(9),o.get(10),p),v=zl(t,o.get(3));return{header:i,entities:s,planes:a,vertices:c,nodes:l,texInfo:d,faces:u,lightMaps:f,lightMapInfo:m,leafs:p,leafLists:M,edges:y,surfEdges:h,models:g,brushes:S,brushSides:b,visibility:v}}function pl(t,e){let r=new TextDecoder().decode(new Uint8Array(t,e.offset,e.length)),n=yl(r),o=n.find(i=>i.classname==="worldspawn");return{raw:r,entities:n,worldspawn:o}}function yl(t){let e=[],r=/\{([^}]*)\}/gms,n;for(;(n=r.exec(t))!==null;){let o=n[1],i={},s=/"([^\"]*)"\s+"([^\"]*)"/g,a;for(;(a=s.exec(o))!==null;)i[a[1]]=a[2];e.push({classname:i.classname,properties:i})}return e}function gl(t,e){let r=new DataView(t,e.offset,e.length),n=e.length/20;if(n%1!==0)throw new K("Plane lump has invalid length");let o=[];for(let i=0;i<n;i+=1){let s=[r.getFloat32(i*20,!0),r.getFloat32(i*20+4,!0),r.getFloat32(i*20+8,!0)],a=r.getFloat32(i*20+12,!0),c=r.getInt32(i*20+16,!0);o.push({normal:s,dist:a,type:c})}return o}function xl(t,e){let r=new DataView(t,e.offset,e.length),n=e.length/12;if(n%1!==0)throw new K("Vertex lump has invalid length");let o=[];for(let i=0;i<n;i+=1)o.push([r.getFloat32(i*12,!0),r.getFloat32(i*12+4,!0),r.getFloat32(i*12+8,!0)]);return o}function bl(t,e){let r=new DataView(t,e.offset,e.length),n=36,o=e.length/n;if(o%1!==0)throw new K("Node lump has invalid length");let i=[];for(let s=0;s<o;s+=1){let a=s*n,c=r.getInt32(a,!0),l=[r.getInt32(a+4,!0),r.getInt32(a+8,!0)],d=[r.getInt16(a+12,!0),r.getInt16(a+14,!0),r.getInt16(a+16,!0)],u=[r.getInt16(a+18,!0),r.getInt16(a+20,!0),r.getInt16(a+22,!0)],f=r.getUint16(a+24,!0),m=r.getUint16(a+26,!0);i.push({planeIndex:c,children:l,mins:d,maxs:u,firstFace:f,numFaces:m})}return i}function vl(t,e){let r=new DataView(t,e.offset,e.length),n=76,o=e.length/n;if(o%1!==0)throw new K("TexInfo lump has invalid length");let i=[];for(let s=0;s<o;s+=1){let a=s*n,c=[r.getFloat32(a,!0),r.getFloat32(a+4,!0),r.getFloat32(a+8,!0)],l=r.getFloat32(a+12,!0),d=[r.getFloat32(a+16,!0),r.getFloat32(a+20,!0),r.getFloat32(a+24,!0)],u=r.getFloat32(a+28,!0),f=r.getInt32(a+32,!0),m=r.getInt32(a+36,!0),p=new Uint8Array(t,e.offset+a+40,32),y=new TextDecoder("utf-8").decode(p).replace(/\0.*$/,""),h=r.getInt32(a+72,!0);i.push({s:c,sOffset:l,t:d,tOffset:u,flags:f,value:m,texture:y,nextTexInfo:h})}return i}function Sl(t,e){let r=new DataView(t,e.offset,e.length),n=20,o=e.length/n;if(o%1!==0)throw new K("Face lump has invalid length");let i=[];for(let s=0;s<o;s+=1){let a=s*n,c=r.getUint16(a,!0),l=r.getInt16(a+2,!0),d=r.getInt32(a+4,!0),u=r.getInt16(a+8,!0),f=r.getInt16(a+10,!0),m=[r.getUint8(a+12),r.getUint8(a+13),r.getUint8(a+14),r.getUint8(a+15)],p=r.getInt32(a+16,!0);i.push({planeIndex:c,side:l,firstEdge:d,numEdges:u,texInfo:f,styles:m,lightOffset:p})}return i}function Ml(t,e){let r=new DataView(t,e.offset,e.length),n=28,o=e.length/n;if(o%1!==0)throw new K("Leaf lump has invalid length");let i=[];for(let s=0;s<o;s+=1){let a=s*n,c=r.getInt32(a,!0),l=r.getInt16(a+4,!0),d=r.getInt16(a+6,!0),u=[r.getInt16(a+8,!0),r.getInt16(a+10,!0),r.getInt16(a+12,!0)],f=[r.getInt16(a+14,!0),r.getInt16(a+16,!0),r.getInt16(a+18,!0)],m=r.getUint16(a+20,!0),p=r.getUint16(a+22,!0),y=r.getUint16(a+24,!0),h=r.getUint16(a+26,!0);i.push({contents:c,cluster:l,area:d,mins:u,maxs:f,firstLeafFace:m,numLeafFaces:p,firstLeafBrush:y,numLeafBrushes:h})}return i}function Al(t,e){let r=new DataView(t,e.offset,e.length),n=4,o=e.length/n;if(o%1!==0)throw new K("Edge lump has invalid length");let i=[];for(let s=0;s<o;s+=1){let a=s*n;i.push({vertices:[r.getUint16(a,!0),r.getUint16(a+2,!0)]})}return i}function _l(t,e){let r=e.length/4;if(r%1!==0)throw new K("SurfEdge lump has invalid length");let n=new DataView(t,e.offset,e.length),o=new Int32Array(r);for(let i=0;i<r;i+=1)o[i]=n.getInt32(i*4,!0);return o}function wl(t,e){let r=new DataView(t,e.offset,e.length),n=48;if(e.length%n!==0)throw new K("Model lump has invalid length");let o=e.length/n,i=[];for(let s=0;s<o;s+=1){let a=s*n,c=[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)],d=[r.getFloat32(a+24,!0),r.getFloat32(a+28,!0),r.getFloat32(a+32,!0)],u=r.getInt32(a+36,!0),f=r.getInt32(a+40,!0),m=r.getInt32(a+44,!0);i.push({mins:c,maxs:l,origin:d,headNode:u,firstFace:f,numFaces:m})}return i}function Ll(t,e){let r=new DataView(t,e.offset,e.length),n=12,o=e.length/n;if(o%1!==0)throw new K("Brush lump has invalid length");let i=[];for(let s=0;s<o;s+=1){let a=s*n;i.push({firstSide:r.getInt32(a,!0),numSides:r.getInt32(a+4,!0),contents:r.getInt32(a+8,!0)})}return i}function El(t,e){let r=new DataView(t,e.offset,e.length),n=8,o=e.length/n;if(o%1!==0)throw new K("Brush side lump has invalid length");let i=[];for(let s=0;s<o;s+=1){let a=s*n;i.push({planeIndex:r.getUint16(a,!0),texInfo:r.getInt16(a+2,!0)})}return i}function Il(t,e,r,n){let o=[],i=[],s=e.length/2,a=r.length/2,c=new DataView(t,e.offset,e.length),l=new DataView(t,r.offset,r.length);for(let d of n){if(d.firstLeafFace+d.numLeafFaces>s)throw new K("Leaf faces reference data past lump bounds");if(d.firstLeafBrush+d.numLeafBrushes>a)throw new K("Leaf brushes reference data past lump bounds");let u=[];for(let m=0;m<d.numLeafFaces;m+=1)u.push(c.getUint16((d.firstLeafFace+m)*2,!0));let f=[];for(let m=0;m<d.numLeafBrushes;m+=1)f.push(l.getUint16((d.firstLeafBrush+m)*2,!0));o.push(u),i.push(f)}return{leafFaces:o,leafBrushes:i}}function zl(t,e){if(e.length===0)return;if(e.length<4)throw new K("Visibility lump too small");let r=new DataView(t,e.offset,e.length),n=r.getInt32(0,!0),o=4+n*8;if(n<0||o>e.length)throw new K("Visibility lump truncated");let i=4,s=[];for(let a=0;a<n;a+=1){let c=r.getInt32(i,!0),l=r.getInt32(i+4,!0);i+=8;let d=e.offset+c,u=e.offset+l,f=e.offset+e.length;if(c<0||l<0||d>=f||u>=f)throw new K("Visibility offsets out of range");s.push({pvs:$s(t,d,n,e),phs:$s(t,u,n,e)})}return{numClusters:n,clusters:s}}function $s(t,e,r,n){let o=Math.ceil(r/8),i=new Uint8Array(o),s=new Uint8Array(t),a=e,c=0,l=n.offset+n.length;for(;c<o;){if(a>=l)throw new K("Visibility data truncated");let d=s[a++];if(d!==0){i[c++]=d;continue}if(a>=l)throw new K("Visibility run exceeds lump bounds");let u=s[a++];for(let f=0;f<u&&c<o;f+=1)i[c++]=0}return i}function Pl(t,e){return t.map(r=>{if(!(r.lightOffset<0))return{offset:r.lightOffset,length:Math.max(0,e.length-r.lightOffset)}})}function eo(t,e,r){if(t.lightOffset<0||t.lightOffset>=e.byteLength)return;let n=e.byteLength-t.lightOffset,o=Math.min(r?.length??n,n);if(!(o<=0))return e.subarray(t.lightOffset,t.lightOffset+o)}var Fl=844121161,Cl=8,Js=68,Tl=[{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}],ae=class extends Error{},rr=class{constructor(e){this.vfs=e}async load(e){let r=await this.vfs.readFile(e),n=new Uint8Array(r.byteLength);return n.set(r),wi(n.buffer)}};function Zs(t,e,r){let n=[];for(let o=0;o<r;o+=1){let i=t.getUint8(e+o);if(i===0)break;n.push(i)}return String.fromCharCode(...n)}function Or(t,e,r,n){if(r!==0&&(e<Js||e+r>t.byteLength))throw new ae(`${n} section is out of bounds`)}function Rl(t){if(t.byteLength<Js)throw new ae("MD2 buffer too small to contain header");let e=new DataView(t),r=e.getInt32(0,!0),n=e.getInt32(4,!0);if(r!==Fl)throw new ae(`Invalid MD2 ident: ${r}`);if(n!==Cl)throw new ae(`Unsupported MD2 version: ${n}`);let o={ident:r,version:n,skinWidth:e.getInt32(8,!0),skinHeight:e.getInt32(12,!0),frameSize:e.getInt32(16,!0),numSkins:e.getInt32(20,!0),numVertices:e.getInt32(24,!0),numTexCoords:e.getInt32(28,!0),numTriangles:e.getInt32(32,!0),numGlCommands:e.getInt32(36,!0),numFrames:e.getInt32(40,!0),offsetSkins:e.getInt32(44,!0),offsetTexCoords:e.getInt32(48,!0),offsetTriangles:e.getInt32(52,!0),offsetFrames:e.getInt32(56,!0),offsetGlCommands:e.getInt32(60,!0),offsetEnd:e.getInt32(64,!0)},i=40+o.numVertices*4;if(o.frameSize!==i)throw new ae(`Unexpected frame size ${o.frameSize}, expected ${i}`);if(o.offsetEnd>t.byteLength)throw new ae("MD2 offset_end exceeds buffer length");return o}function Bl(t,e){let r=e.numSkins*64;Or(t,e.offsetSkins,r,"skins");let n=new DataView(t,e.offsetSkins,r),o=[];for(let i=0;i<e.numSkins;i+=1)o.push({name:Zs(n,i*64,64)});return o}function Ol(t,e){let r=e.numTexCoords*4;Or(t,e.offsetTexCoords,r,"texcoords");let n=new DataView(t,e.offsetTexCoords,r),o=[];for(let i=0;i<e.numTexCoords;i+=1){let s=i*4;o.push({s:n.getInt16(s,!0),t:n.getInt16(s+2,!0)})}return o}function Dl(t,e){let r=e.numTriangles*12;Or(t,e.offsetTriangles,r,"triangles");let n=new DataView(t,e.offsetTriangles,r),o=[];for(let i=0;i<e.numTriangles;i+=1){let s=i*12,a=[n.getUint16(s,!0),n.getUint16(s+2,!0),n.getUint16(s+4,!0)],c=[n.getUint16(s+6,!0),n.getUint16(s+8,!0),n.getUint16(s+10,!0)];if(a.some(l=>l>=e.numVertices)||c.some(l=>l>=e.numTexCoords))throw new ae("Triangle references out of range vertex or texcoord");o.push({vertexIndices:a,texCoordIndices:c})}return o}function kl(t,e){let r=e.numFrames*e.frameSize;Or(t,e.offsetFrames,r,"frames");let n=[];for(let o=0;o<e.numFrames;o+=1){let i=e.offsetFrames+o*e.frameSize,s=new DataView(t,i,e.frameSize),a={x:s.getFloat32(0,!0),y:s.getFloat32(4,!0),z:s.getFloat32(8,!0)},c={x:s.getFloat32(12,!0),y:s.getFloat32(16,!0),z:s.getFloat32(20,!0)},l=Zs(s,24,16),d=[];for(let u=0;u<e.numVertices;u+=1){let f=40+u*4,m={x:s.getUint8(f)*a.x+c.x,y:s.getUint8(f+1)*a.y+c.y,z:s.getUint8(f+2)*a.z+c.z},p=s.getUint8(f+3),y=Tl[p];if(!y)throw new ae(`Invalid normal index ${p} in frame ${l}`);d.push({position:m,normalIndex:p,normal:y})}n.push({name:l,vertices:d})}return n}function Hl(t,e){let r=e.numGlCommands*4;if(Or(t,e.offsetGlCommands,r,"gl commands"),r===0)return[];let n=new DataView(t,e.offsetGlCommands,r),o=[],i=0;for(;;){if(i+4>r)throw new ae("GL command list ended unexpectedly");let s=n.getInt32(i,!0);if(i+=4,s===0)break;let a=Math.abs(s),c=[],l=a*12;if(i+l>r)throw new ae("GL command vertex block exceeds buffer");for(let d=0;d<a;d+=1){let u=n.getFloat32(i,!0),f=n.getFloat32(i+4,!0),m=n.getInt32(i+8,!0);if(i+=12,m<0||m>=e.numVertices)throw new ae("GL command references invalid vertex index");c.push({s:u,t:f,vertexIndex:m})}o.push({mode:s>0?"strip":"fan",vertices:c})}if(i!==r)throw new ae("GL command list did not consume expected data");return o}function wi(t){let e=Rl(t),r=Bl(t,e),n=Ol(t,e),o=Dl(t,e),i=kl(t,e),s=Hl(t,e);return{header:e,skins:r,texCoords:n,triangles:o,frames:i,glCommands:s}}function ea(t){let e=[],r=0;for(;r<t.length;){let n=t[r].name,o=n.replace(/\d+$/,"")||n,i=r;for(;i+1<t.length&&(t[i+1].name.replace(/\d+$/,"")||t[i+1].name)===o;)i+=1;e.push({name:o,firstFrame:r,lastFrame:i}),r=i+1}return e}var ta=860898377,Nl=15,Pe=class extends Error{constructor(e){super(e),this.name="Md3ParseError"}};function Dr(t,e,r){let n=new Uint8Array(t.buffer,t.byteOffset+e,r);return new TextDecoder("utf-8").decode(n).replace(/\0.*$/,"").trim()}function Vl(t){let e=(t>>8&255)*(2*Math.PI/255),r=(t&255)*(2*Math.PI/255),n=Math.sin(r);return{x:Math.cos(e)*n,y:Math.sin(e)*n,z:Math.cos(r)}}function to(t,e,r,n){if(e<0||e+r>n)throw new Pe(`${t} exceeds buffer bounds`)}function Ul(t){let e=t.getInt32(0,!0);if(e!==ta)throw new Pe(`Invalid MD3 ident: ${e}`);let r=t.getInt32(4,!0);if(r!==Nl)throw new Pe(`Unsupported MD3 version: ${r}`);let n=Dr(t,8,64),o=t.getInt32(72,!0),i=t.getInt32(76,!0),s=t.getInt32(80,!0),a=t.getInt32(84,!0),c=t.getInt32(88,!0),l=t.getInt32(92,!0),d=t.getInt32(96,!0),u=t.getInt32(100,!0),f=t.getInt32(104,!0);if(i<=0||a<0||s<0)throw new Pe("Invalid MD3 counts");return{ident:e,version:r,name:n,flags:o,numFrames:i,numTags:s,numSurfaces:a,numSkins:c,ofsFrames:l,ofsTags:d,ofsSurfaces:u,ofsEnd:f}}function Gl(t,e){let r=[];to("Frames",e.ofsFrames,e.numFrames*56,t.byteLength);for(let o=0;o<e.numFrames;o+=1){let i=e.ofsFrames+o*56;r.push({minBounds:{x:t.getFloat32(i,!0),y:t.getFloat32(i+4,!0),z:t.getFloat32(i+8,!0)},maxBounds:{x:t.getFloat32(i+12,!0),y:t.getFloat32(i+16,!0),z:t.getFloat32(i+20,!0)},localOrigin:{x:t.getFloat32(i+24,!0),y:t.getFloat32(i+28,!0),z:t.getFloat32(i+32,!0)},radius:t.getFloat32(i+36,!0),name:Dr(t,i+40,16)})}return r}function Wl(t,e){let r=[],o=e.numFrames*e.numTags*112;to("Tags",e.ofsTags,o,t.byteLength);for(let i=0;i<e.numFrames;i+=1){let s=[];for(let a=0;a<e.numTags;a+=1){let c=e.ofsTags+(i*e.numTags+a)*112,l=c+64,d=l+12;s.push({name:Dr(t,c,64),origin:{x:t.getFloat32(l,!0),y:t.getFloat32(l+4,!0),z:t.getFloat32(l+8,!0)},axis:[{x:t.getFloat32(d,!0),y:t.getFloat32(d+4,!0),z:t.getFloat32(d+8,!0)},{x:t.getFloat32(d+12,!0),y:t.getFloat32(d+16,!0),z:t.getFloat32(d+20,!0)},{x:t.getFloat32(d+24,!0),y:t.getFloat32(d+28,!0),z:t.getFloat32(d+32,!0)}]})}r.push(s)}return r}function Xl(t,e){let r=t.getInt32(e,!0);if(r!==ta)throw new Pe(`Invalid surface ident at ${e}: ${r}`);let n=Dr(t,e+4,64),o=t.getInt32(e+68,!0),i=t.getInt32(e+72,!0),s=t.getInt32(e+76,!0),a=t.getInt32(e+80,!0),c=t.getInt32(e+84,!0),l=t.getInt32(e+88,!0),d=t.getInt32(e+92,!0),u=t.getInt32(e+96,!0),f=t.getInt32(e+100,!0),m=t.getInt32(e+104,!0);if(i<=0||a<=0||c<=0)throw new Pe(`Invalid surface counts for ${n}`);let p=m;to(`Surface ${n}`,e,p,t.byteLength);let y=[],h=e+l;for(let _=0;_<c;_+=1){let L=h+_*12;y.push({indices:[t.getInt32(L,!0),t.getInt32(L+4,!0),t.getInt32(L+8,!0)]})}let g=[],S=e+d;for(let _=0;_<s;_+=1){let L=S+_*68;g.push({name:Dr(t,L,64),shaderIndex:t.getInt32(L+64,!0)})}let b=[],M=e+u;for(let _=0;_<a;_+=1){let L=M+_*8;b.push({s:t.getFloat32(L,!0),t:t.getFloat32(L+4,!0)})}let v=[],A=e+f;for(let _=0;_<i;_+=1){let L=[];for(let F=0;F<a;F+=1){let w=A+(_*a+F)*8,H=t.getInt16(w,!0)/64,U=t.getInt16(w+2,!0)/64,V=t.getInt16(w+4,!0)/64,C=t.getUint16(w+6,!0);L.push({position:{x:H,y:U,z:V},latLng:C,normal:Vl(C)})}v.push(L)}return{surface:{name:n,flags:o,numFrames:i,shaders:g,triangles:y,texCoords:b,vertices:v},nextOffset:e+m}}function Li(t){if(t.byteLength<108)throw new Pe("MD3 buffer too small for header");let e=new DataView(t),r=Ul(e);to("MD3 end",r.ofsEnd,0,t.byteLength);let n=Gl(e,r),o=Wl(e,r),i=[],s=r.ofsSurfaces;for(let a=0;a<r.numSurfaces;a+=1){let{surface:c,nextOffset:l}=Xl(e,s);i.push(c),s=l}if(s!==r.ofsEnd)throw new Pe("Surface parsing did not reach ofsEnd");return{header:r,frames:n,tags:o,surfaces:i}}var nr=class{constructor(e){this.vfs=e}async load(e){let r=await this.vfs.readFile(e);return Li(r.slice().buffer)}};var Kl=1229214514,Yl=2,ra=64,na=12,mt=class extends Error{};function ql(t,e,r){let n=[];for(let o=0;o<r;o+=1){let i=t.getUint8(e+o);if(i===0)break;n.push(i)}return String.fromCharCode(...n)}function Ei(t){if(t.byteLength<na)throw new mt("Sprite buffer too small to contain header");let e=new DataView(t),r=e.getInt32(0,!0),n=e.getInt32(4,!0),o=e.getInt32(8,!0);if(r!==Kl)throw new mt(`Invalid Sprite ident: ${r}`);if(n!==Yl)throw new mt(`Unsupported Sprite version: ${n}`);let i=[],s=16+ra,a=na;for(let c=0;c<o;c+=1){if(a+s>t.byteLength)throw new mt("Sprite frame data exceeds buffer length");let l=e.getInt32(a,!0),d=e.getInt32(a+4,!0),u=e.getInt32(a+8,!0),f=e.getInt32(a+12,!0),m=ql(e,a+16,ra);i.push({width:l,height:d,originX:u,originY:f,name:m}),a+=s}return{ident:r,version:n,numFrames:o,frames:i}}var or=class{constructor(e){this.vfs=e}async load(e){let r=await this.vfs.readFile(e),n=new Uint8Array(r.byteLength);return n.set(r),Ei(n.buffer)}};function oa(t,e){let r=(t.sequence.end-t.sequence.start+1)/t.sequence.fps,n=t.sequence.loop!==!1,o=t.time+e;return n?o=(o%r+r)%r:o>r&&(o=r),{...t,time:Math.max(0,Math.min(o,r))}}function ia(t){let e=t.sequence.end-t.sequence.start+1,r=1/t.sequence.fps,n=t.sequence.loop!==!1,o=t.time/r;if(!n&&o>=e)return{frame:t.sequence.end,nextFrame:t.sequence.end,lerp:0};let i=n?o%e:Math.min(o,e-1),s=Math.floor(i),a=t.sequence.start+s,c=s+1>=e?n?t.sequence.start:t.sequence.end:a+1,l=!n&&s>=e-1?0:i-s;return{frame:a,nextFrame:c,lerp:l}}function sa(t){return{sequence:t,time:0}}function aa(t,e,r){return{x:t.x+(e.x-t.x)*r,y:t.y+(e.y-t.y)*r,z:t.z+(e.z-t.z)*r}}var kr=class extends Error{constructor(e){super(e),this.name="WalParseError"}};function ro(t){if(t.byteLength<100)throw new kr("WAL buffer too small");let e=new DataView(t),r=new Uint8Array(t,0,32),n=new TextDecoder("utf-8").decode(r).replace(/\0.*$/,"").trim(),o=e.getInt32(32,!0),i=e.getInt32(36,!0),s=[e.getInt32(40,!0),e.getInt32(44,!0),e.getInt32(48,!0),e.getInt32(52,!0)],a=new Uint8Array(t,56,32),c=new TextDecoder("utf-8").decode(a).replace(/\0.*$/,"").trim(),l=e.getInt32(88,!0),d=e.getInt32(92,!0),u=e.getInt32(96,!0);if(o<=0||i<=0)throw new kr("Invalid WAL dimensions");let f=[],m=o,p=i;for(let y=0;y<s.length;y+=1){let h=s[y],g=Math.max(1,m*p|0);if(h<=0||h+g>t.byteLength)throw new kr(`Invalid WAL mip offset for level ${y}`);let S=new Uint8Array(t,h,g);f.push({level:y,width:m,height:p,data:S}),m=Math.max(1,m>>1),p=Math.max(1,p>>1)}return{name:n,width:o,height:i,mipmaps:f,animName:c,flags:l,contents:d,value:u}}var Rt=class extends Error{constructor(e){super(e),this.name="PcxParseError"}};function ca(t){if(t.byteLength<128)throw new Rt("PCX buffer too small for header");let e=new DataView(t),r=e.getUint8(0),n=e.getUint8(2),o=e.getUint8(3),i=e.getUint16(4,!0),s=e.getUint16(6,!0),a=e.getUint16(8,!0),c=e.getUint16(10,!0);if(r!==10||n!==1)throw new Rt("Unsupported PCX encoding");if(o!==8)throw new Rt("Only 8bpp PCX files are supported");let l=a-i+1,d=c-s+1,u=e.getUint16(66,!0),f=t.byteLength-769;if(f<128||new DataView(t,f,1).getUint8(0)!==12)throw new Rt("Missing PCX palette");let m=new Uint8Array(t,f+1,768),p=new Uint8Array(t,128,f-128),y=new Uint8Array(l*d),h=0,g=0;for(let S=0;S<d;S+=1){let b=0;for(;b<u&&h<p.length;){let M=1,v=p[h++];if((v&192)===192){if(M=v&63,h>=p.length)throw new Rt("Unexpected end of PCX RLE data");v=p[h++]}for(let A=0;A<M&&b<u;A+=1)b<l&&(y[g++]=v),b+=1}}return{width:l,height:d,bitsPerPixel:o,pixels:y,palette:m}}function no(t){let e=new Uint8Array(t.width*t.height*4);for(let r=0;r<t.pixels.length;r+=1){let n=t.pixels[r],o=n*3,i=r*4;e[i]=t.palette[o],e[i+1]=t.palette[o+1],e[i+2]=t.palette[o+2],e[i+3]=n===255?0:255}return e}var ir=class{constructor(e={}){this.cache=new ft(e.capacity??128)}get size(){return this.cache.size}get(e){return this.cache.get(e.toLowerCase())}set(e,r){this.cache.set(e.toLowerCase(),r)}clear(){this.cache.clear()}};function Ii(t,e){let r=[];for(let n of t.mipmaps){let o=new Uint8Array(n.width*n.height*4);for(let i=0;i<n.data.length;i+=1){let s=n.data[i],a=s*3,c=i*4;o[c]=e[a],o[c+1]=e[a+1],o[c+2]=e[a+2],o[c+3]=s===255?0:255}r.push({level:n.level,width:n.width,height:n.height,rgba:o})}return{width:t.width,height:t.height,levels:r,source:"wal"}}function la(t){let e=no(t),r={level:0,width:t.width,height:t.height,rgba:e};return{width:t.width,height:t.height,levels:[r],source:"pcx"}}function da(t,e){return Ii(ro(t),e)}var Bt=class extends Error{constructor(e){super(e),this.name="WavParseError"}};function zi(t,e,r){return new TextDecoder("ascii").decode(new Uint8Array(t.buffer,t.byteOffset+e,r))}function oo(t){if(t.byteLength<44)throw new Bt("WAV buffer too small");let e=new DataView(t);if(zi(e,0,4)!=="RIFF"||zi(e,8,4)!=="WAVE")throw new Bt("Invalid WAV header");let r=12,n=-1,o=-1,i=0,s=0;for(;r+8<=t.byteLength;){let p=zi(e,r,4),y=e.getUint32(r+4,!0),h=r+8;p==="fmt "?(n=h,i=y):p==="data"&&(o=h,s=y),r=h+y}if(n===-1||o===-1)throw new Bt("Missing fmt or data chunk");let a=e.getUint16(n,!0),c=e.getUint16(n+2,!0),l=e.getUint32(n+4,!0),d=e.getUint16(n+14,!0);if(a!==1)throw new Bt("Only PCM WAV is supported");let u=d/8,f=s/(u*c),m=new Float32Array(f*c);for(let p=0;p<f;p+=1)for(let y=0;y<c;y+=1){let h=p*c+y,g=o+h*u,S=0;if(d===8)S=e.getUint8(g),m[h]=(S-128)/128;else if(d===16)S=e.getInt16(g,!0),m[h]=S/32768;else if(d===24){let b=e.getUint8(g),M=e.getUint8(g+1),v=e.getInt8(g+2);S=b|M<<8|v<<16,m[h]=S/8388608}else throw new Bt(`Unsupported bitsPerSample: ${d}`)}return{sampleRate:l,channels:c,bitsPerSample:d,samples:m}}var jl=(t,e=4294967295,r=79764919)=>{let n=new Int32Array(256),o,i,s,a=e;for(o=0;o<256;o++){for(s=o<<24,i=8;i>0;--i)s=2147483648&s?s<<1^r:s<<1;n[o]=s}for(o=0;o<t.length;o++)a=a<<8^n[255&(a>>24^t[o])];return a};var Pi=(t,e=jl)=>{let r=h=>new Uint8Array(h.length/2).map(((g,S)=>parseInt(h.substring(2*S,2*(S+1)),16))),n=h=>r(h)[0],o=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(((h,g)=>o.set(h,g)));let i=new Uint8Array(t.length),s,a,c,l=!1,d=0,u=42,f=t.length>13&&t.substring(0,9)==="dynEncode",m=0;f&&(m=11,a=n(t.substring(9,m)),a<=1&&(m+=2,u=n(t.substring(11,m))),a===1&&(m+=8,c=(h=>new DataView(r(h).buffer).getInt32(0,!0))(t.substring(13,m))));let p=256-u;for(let h=m;h<t.length;h++)if(s=t.charCodeAt(h),s!==61||l){if(s===92&&h<t.length-5&&f){let g=t.charCodeAt(h+1);g!==117&&g!==85||(s=parseInt(t.substring(h+2,h+6),16),h+=5)}if(s>255){let g=o.get(s);g&&(s=g+127)}l&&(l=!1,s-=64),i[d++]=s<u&&s>0?s+p:s-u}else l=!0;let y=i.subarray(0,d);if(f&&a===1){let h=e(y);if(h!==c){let g="Decode failed crc32 validation";throw console.error("`simple-yenc`\n",g+`
|
|
2
|
+
`,"Expected: "+c+"; Got: "+h+`
|
|
3
|
+
`,"Visit https://github.com/eshaz/simple-yenc for more information"),Error(g)}}return y};function Q(){let t=Uint8Array,e=Float32Array;Q.modules||Object.defineProperties(Q,{modules:{value:new WeakMap},setModule:{value(r,n){Q.modules.set(r,Promise.resolve(n))}},getModule:{value(r,n){let o=Q.modules.get(r);return o||(n?o=WebAssembly.compile(Pi(n)):(n=r.wasm,o=Q.inflateDynEncodeString(n).then(i=>WebAssembly.compile(i))),Q.modules.set(r,o)),o}},concatFloat32:{value(r,n){let o=new e(n),i=0,s=0;for(;i<r.length;)o.set(r[i],s),s+=r[i++].length;return o}},getDecodedAudio:{value:(r,n,o,i,s)=>({errors:r,channelData:n,samplesDecoded:o,sampleRate:i,bitDepth:s})},getDecodedAudioMultiChannel:{value(r,n,o,i,s,a){let c=[],l,d;for(l=0;l<o;l++){let u=[];for(d=0;d<n.length;)u.push(n[d++][l]||[]);c.push(Q.concatFloat32(u,i))}return Q.getDecodedAudio(r,c,i,s,a)}},inflateDynEncodeString:{value(r){return r=Pi(r),new Promise(n=>{let o=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 `;Q.getModule(Q,o).then(i=>WebAssembly.instantiate(i,{})).then(({exports:i})=>{let s=new Map(Object.entries(i)),a=s.get("puff"),c=s.get("memory").buffer,l=new t(c),d=new DataView(c),u=s.get("__heap_base"),f=r.length,m=u;u+=4,d.setInt32(m,f,!0);let p=u;u+=f,l.set(r,p);let y=u;u+=4,d.setInt32(y,l.byteLength-u,!0),a(u,y,p,m),n(l.slice(u,u+d.getInt32(y,!0)))})})}}}),Object.defineProperty(this,"wasm",{enumerable:!0,get:()=>this._wasm}),this.getOutputChannels=(r,n,o)=>{let i=[],s=0;for(;s<n;)i.push(r.slice(s*o,s++*o+o));return i},this.allocateTypedArray=(r,n,o=!0)=>{let i=this._wasm.malloc(n.BYTES_PER_ELEMENT*r);return o&&this._pointers.add(i),{ptr:i,len:r,buf:new n(this._wasm.HEAP,i,r)}},this.free=()=>{this._pointers.forEach(r=>{this._wasm.free(r)}),this._pointers.clear()},this.codeToString=r=>{let n=[],o=new Uint8Array(this._wasm.HEAP);for(let i=o[r];i!==0;i=o[++r])n.push(i);return String.fromCharCode.apply(null,n)},this.addError=(r,n,o,i,s,a)=>{r.push({message:n,frameLength:o,frameNumber:i,inputBytes:s,outputSamples:a})},this.instantiate=(r,n)=>(n&&Q.setModule(r,n),this._wasm=new r(Q).instantiate(),this._pointers=new Set,this._wasm.ready.then(()=>this))}var ma=Nc(fa(),1);var $l=()=>globalThis.Worker||ma.default,sr=class extends $l(){constructor(e,r,n,o){Q.modules||new Q;let i=Q.modules.get(n);if(!i){let s="text/javascript",a,c=`'use strict';(${((l,d,u)=>{let f,m,p=new Promise(y=>{m=y});self.onmessage=({data:{id:y,command:h,data:g}})=>{let S=p,b={id:y},M;h==="init"?(Object.defineProperties(l,{WASMAudioDecoderCommon:{value:d},EmscriptenWASM:{value:u},module:{value:g.module},isWebWorker:{value:!0}}),f=new l(g.options),m()):h==="free"?f.free():h==="ready"?S=S.then(()=>f.ready):h==="reset"?S=S.then(()=>f.reset()):(Object.assign(b,f[h](Array.isArray(g)?g.map(v=>new Uint8Array(v)):new Uint8Array(g))),M=b.channelData?b.channelData.map(v=>v.buffer):[]),S.then(()=>self.postMessage(b,M))}}).toString()})(${n}, ${Q}, ${o})`;try{a=typeof process.versions.node<"u"}catch{}i=a?`data:${s};base64,${Buffer.from(c).toString("base64")}`:URL.createObjectURL(new Blob([c],{type:s})),Q.modules.set(n,i)}super(i,{name:r}),this._id=Number.MIN_SAFE_INTEGER,this._enqueuedOperations=new Map,this.onmessage=({data:s})=>{let{id:a,...c}=s;this._enqueuedOperations.get(a)(c),this._enqueuedOperations.delete(a)},new o(Q).getModule().then(s=>{this.postToDecoder("init",{module:s,options:e})})}async postToDecoder(e,r){return new Promise(n=>{this.postMessage({command:e,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 io=(t,e)=>{Object.defineProperty(t,"name",{value:e})};var J=Symbol,ha=", ",P=(()=>{let t="front",e="side",r="rear",n="left",o="center",i="right";return["",t+" ",e+" ",r+" "].map(s=>[[n,i],[n,i,o],[n,o,i],[o,n,i],[o]].flatMap(a=>a.map(c=>s+c).join(ha)))})(),Xe="LFE",ht="monophonic (mono)",pt="stereo",Hr="surround",Z=(t,...e)=>`${[ht,pt,`linear ${Hr}`,"quadraphonic",`5.0 ${Hr}`,`5.1 ${Hr}`,`6.1 ${Hr}`,`7.1 ${Hr}`][t-1]} (${e.join(ha)})`,Nr=[ht,Z(2,P[0][0]),Z(3,P[0][2]),Z(4,P[1][0],P[3][0]),Z(5,P[1][2],P[3][0]),Z(6,P[1][2],P[3][0],Xe),Z(7,P[1][2],P[2][0],P[3][4],Xe),Z(8,P[1][2],P[2][0],P[3][0],Xe)],pa=192e3,ya=176400,so=96e3,ao=88200,ga=64e3,yt=48e3,ar=44100,cr=32e3,lr=24e3,dr=22050,ur=16e3,co=12e3,lo=11025,fr=8e3,xa=7350,Ne="absoluteGranulePosition",B="bandwidth",de="bitDepth",ue="bitrate",Vr=ue+"Maximum",Ur=ue+"Minimum",Gr=ue+"Nominal",Ke="buffer",Wr=Ke+"Fullness",j="codec",fe=j+"Frames",Xr="coupledStreamCount",mr="crc",Kr=mr+"16",Yr=mr+"32",Y="data",z="description",Ye="duration",hr="emphasis",qr="hasOpusPadding",Ae="header",gt="isContinuedPacket",jr="isCopyrighted",xt="isFirstPage",$r="isHome",_e="isLastPage",Je="isOriginal",Ze="isPrivate",Qr="isVbr",ve="layer",x="length",R="mode",et=R+"Extension",uo="mpeg",tt=uo+"Version",Jr="numberAACFrames",Zr="outputGain",Ot="preSkip",en="profile",fo=J(),rt="protection",Fi="rawData",Fe="segments",O="subarray",bt="version",Dt="vorbis",tn=Dt+"Comments",pr=Dt+"Setup",mo="block",rn=mo+"ingStrategy",ho=J(),nt=mo+"Size",vt=mo+"size0",St=mo+"size1",nn=J(),po="channel",ot=po+"MappingFamily",on=po+"MappingTable",me=po+"Mode",sn=J(),I=po+"s",ba="copyright",an=ba+"Id",cn=ba+"IdStart",it="frame",st=it+"Count",Se=it+"Length",yo="Number",at=it+yo,qe=it+"Padding",T=it+"Size",va="Rate",ln="inputSample"+va,Ci="page",kt=Ci+"Checksum",yr=J(),Mt=Ci+"SegmentTable",ne=Ci+"Sequence"+yo,Ti="sample",dn=Ti+yo,D=Ti+va,je=J(),k=Ti+"s",go="stream",un=go+"Count",fn=go+"Info",$e=go+"Serial"+yo,Ri=go+"StructureVersion",Bi="total",Ht=Bi+"BytesOut",Nt=Bi+"Duration",Vt=Bi+"Samples",N=J(),Ce=J(),mn=J(),At=J(),Ve=J(),xo=J(),Oi=J(),_t=J(),G=J(),Te=J(),Re=J(),Qe=J(),wt=J(),bo=J(),Ue=J(),Ge=J(),Be=J(),vo=J(),he=Uint8Array,Lt=DataView,W="reserved",pe="bad",gr="free",hn="none",So="16bit CRC";var Di=(t,e,r)=>{for(let n=0;n<t[x];n++){let o=e(n);for(let i=8;i>0;i--)o=r(o);t[n]=o}return t},Jl=Di(new he(256),t=>t,t=>t&128?7^t<<1:t<<1),ee=[Di(new Uint16Array(256),t=>t<<8,t=>t<<1^(t&32768?32773:0))],te=[Di(new Uint32Array(256),t=>t,t=>t>>>1^(t&1)*3988292384)];for(let t=0;t<15;t++){ee.push(new Uint16Array(256)),te.push(new Uint32Array(256));for(let e=0;e<=255;e++)ee[t+1][e]=ee[0][ee[t][e]>>>8]^ee[t][e]<<8,te[t+1][e]=te[t][e]>>>8^te[0][te[t][e]&255]}var Ma=t=>{let e=0,r=t[x];for(let n=0;n!==r;n++)e=Jl[e^t[n]];return e},Aa=t=>{let e=t[x],r=e-16,n=0,o=0;for(;o<=r;)n^=t[o++]<<8|t[o++],n=ee[15][n>>8]^ee[14][n&255]^ee[13][t[o++]]^ee[12][t[o++]]^ee[11][t[o++]]^ee[10][t[o++]]^ee[9][t[o++]]^ee[8][t[o++]]^ee[7][t[o++]]^ee[6][t[o++]]^ee[5][t[o++]]^ee[4][t[o++]]^ee[3][t[o++]]^ee[2][t[o++]]^ee[1][t[o++]]^ee[0][t[o++]];for(;o!==e;)n=(n&255)<<8^ee[0][n>>8^t[o++]];return n},_a=t=>{let e=t[x],r=e-16,n=0,o=0;for(;o<=r;)n=te[15][(t[o++]^n)&255]^te[14][(t[o++]^n>>>8)&255]^te[13][(t[o++]^n>>>16)&255]^te[12][t[o++]^n>>>24]^te[11][t[o++]]^te[10][t[o++]]^te[9][t[o++]]^te[8][t[o++]]^te[7][t[o++]]^te[6][t[o++]]^te[5][t[o++]]^te[4][t[o++]]^te[3][t[o++]]^te[2][t[o++]]^te[1][t[o++]]^te[0][t[o++]];for(;o!==e;)n=te[0][(n^t[o++])&255]^n>>>8;return n^-1},yn=(...t)=>{let e=new he(t.reduce((r,n)=>r+n[x],0));return t.reduce((r,n)=>(e.set(n,r),r+n[x]),0),e},we=t=>String.fromCharCode(...t),Sa=[0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15],pn=t=>Sa[t&15]<<4|Sa[t>>4],Mo=class{constructor(e){this._data=e,this._pos=e[x]*8}set position(e){this._pos=e}get position(){return this._pos}read(e){let r=Math.floor(this._pos/8),n=this._pos%8;return this._pos-=e,(pn(this._data[r-1])<<8)+pn(this._data[r])>>7-n&255}},wa=(t,e)=>{try{return t.getBigInt64(e,!0)}catch{let r=t.getUint8(e+7)&128?-1:1,n=t.getUint32(e,!0),o=t.getUint32(e+4,!0);return r===-1&&(n=~n+1,o=~o+1),o>1048575&&console.warn("This platform does not support BigInt"),r*(n+o*2**32)}};var gn=class{constructor(e,r){this._onCodecHeader=e,this._onCodecUpdate=r,this[Ue]()}[Ge](){this._isEnabled=!0}[Ue](){this._headerCache=new Map,this._codecUpdateData=new WeakMap,this._codecHeaderSent=!1,this._codecShouldUpdate=!1,this._bitrate=null,this._isEnabled=!1}[bo](e,r){if(this._onCodecUpdate){this._bitrate!==e&&(this._bitrate=e,this._codecShouldUpdate=!0);let n=this._codecUpdateData.get(this._headerCache.get(this._currentHeader));this._codecShouldUpdate&&n&&this._onCodecUpdate({bitrate:e,...n},r),this._codecShouldUpdate=!1}}[G](e){let r=this._headerCache.get(e);return r&&this._updateCurrentHeader(e),r}[Te](e,r,n){this._isEnabled&&(this._codecHeaderSent||(this._onCodecHeader({...r}),this._codecHeaderSent=!0),this._updateCurrentHeader(e),this._headerCache.set(e,r),this._codecUpdateData.set(r,n))}_updateCurrentHeader(e){this._onCodecUpdate&&e!==this._currentHeader&&(this._codecShouldUpdate=!0,this._currentHeader=e)}};var se=new WeakMap,ce=new WeakMap;var ye=class{constructor(e,r){this._codecParser=e,this._headerCache=r}*[Oi](){let e;do{if(e=yield*this.Frame[Re](this._codecParser,this._headerCache,0),e)return e;this._codecParser[Ce](1)}while(!0)}*[_t](e){let r=yield*this[Oi](),n=ce.get(r)[x];if(e||this._codecParser._flushing||(yield*this.Header[G](this._codecParser,this._headerCache,n)))return this._headerCache[Ge](),this._codecParser[Ce](n),this._codecParser[At](r),r;this._codecParser[Ve](`Missing ${it} at ${n} bytes from current position.`,`Dropping current ${it} and trying again.`),this._headerCache[Ue](),this._codecParser[Ce](1)}};var Ut=class{constructor(e,r){ce.set(this,{[Ae]:e}),this[Y]=r}};var Le=class extends Ut{static*[Re](e,r,n,o,i){let s=yield*e[G](n,o,i);if(s){let a=se.get(s)[Se],c=se.get(s)[k],l=(yield*n[N](a,i))[O](0,a);return new r(s,l,c)}else return null}constructor(e,r,n){super(e,r),this[Ae]=e,this[k]=n,this[Ye]=n/e[D]*1e3,this[at]=null,this[Ht]=null,this[Vt]=null,this[Nt]=null,ce.get(this)[x]=r[x]}};var ki="unsynchronizationFlag",Hi="extendedHeaderFlag",Ni="experimentalFlag",Vi="footerPresent",xn=class t{static*getID3v2Header(e,r,n){let i={},s=yield*e[N](3,n);if(s[0]!==73||s[1]!==68||s[2]!==51||(s=yield*e[N](10,n),i[bt]=`id3v2.${s[3]}.${s[4]}`,s[5]&15)||(i[ki]=!!(s[5]&128),i[Hi]=!!(s[5]&64),i[Ni]=!!(s[5]&32),i[Vi]=!!(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 i[x]=10+a,new t(i)}constructor(e){this[bt]=e[bt],this[ki]=e[ki],this[Hi]=e[Hi],this[Ni]=e[Ni],this[Vi]=e[Vi],this[x]=e[x]}};var Ee=class{constructor(e){se.set(this,e),this[de]=e[de],this[ue]=null,this[I]=e[I],this[me]=e[me],this[D]=e[D]}};var Pa={0:[gr,gr,gr,gr,gr],16:[32,32,32,32,8],240:[pe,pe,pe,pe,pe]},Ao=(t,e,r)=>8*((t+r)%e+e)*(1<<(t+r)/e)-8*e*(e/8|0);for(let t=2;t<15;t++)Pa[t<<4]=[t*32,Ao(t,4,0),Ao(t,4,-1),Ao(t,8,4),Ao(t,8,0)];var Zl=0,ed=1,td=2,rd=3,La=4,_o="bands ",wo=" to 31",Ea={0:_o+4+wo,16:_o+8+wo,32:_o+12+wo,48:_o+16+wo},Gt="bitrateIndex",bn="v2",Po="v1",Lo="Intensity stereo ",Eo=", MS stereo ",Io="on",zo="off",nd={0:Lo+zo+Eo+zo,16:Lo+Io+Eo+zo,32:Lo+zo+Eo+Io,48:Lo+Io+Eo+Io},Ui={0:{[z]:W},2:{[z]:"Layer III",[qe]:1,[et]:nd,[Po]:{[Gt]:td,[k]:1152},[bn]:{[Gt]:La,[k]:576}},4:{[z]:"Layer II",[qe]:1,[et]:Ea,[k]:1152,[Po]:{[Gt]:ed},[bn]:{[Gt]:La}},6:{[z]:"Layer I",[qe]:4,[et]:Ea,[k]:384,[Po]:{[Gt]:Zl},[bn]:{[Gt]:rd}}},Gi="MPEG Version ",Ia="ISO/IEC ",od={0:{[z]:`${Gi}2.5 (later extension of MPEG 2)`,[ve]:bn,[D]:{0:lo,4:co,8:fr,12:W}},8:{[z]:W},16:{[z]:`${Gi}2 (${Ia}13818-3)`,[ve]:bn,[D]:{0:dr,4:lr,8:ur,12:W}},24:{[z]:`${Gi}1 (${Ia}11172-3)`,[ve]:Po,[D]:{0:ar,4:yt,8:cr,12:W}},length:x},id={0:So,1:hn},sd={0:hn,1:"50/15 ms",2:W,3:"CCIT J.17"},za={0:{[I]:2,[z]:pt},64:{[I]:2,[z]:"joint "+pt},128:{[I]:2,[z]:"dual channel"},192:{[I]:1,[z]:ht}},Wt=class t extends Ee{static*[G](e,r,n){let o={},i=yield*xn.getID3v2Header(e,r,n);i&&(yield*e[N](i[x],n),e[Ce](i[x]));let s=yield*e[N](4,n),a=we(s[O](0,4)),c=r[G](a);if(c)return new t(c);if(s[0]!==255||s[1]<224)return null;let l=od[s[1]&24];if(l[z]===W)return null;let d=s[1]&6;if(Ui[d][z]===W)return null;let u={...Ui[d],...Ui[d][l[ve]]};if(o[tt]=l[z],o[ve]=u[z],o[k]=u[k],o[rt]=id[s[1]&1],o[x]=4,o[ue]=Pa[s[2]&240][u[Gt]],o[ue]===pe||(o[D]=l[D][s[2]&12],o[D]===W)||(o[qe]=s[2]&2&&u[qe],o[Ze]=!!(s[2]&1),o[Se]=Math.floor(125*o[ue]*o[k]/o[D]+o[qe]),!o[Se]))return null;let f=s[3]&192;if(o[me]=za[f][z],o[I]=za[f][I],o[et]=u[et][s[3]&48],o[jr]=!!(s[3]&8),o[Je]=!!(s[3]&4),o[hr]=sd[s[3]&3],o[hr]===W)return null;o[de]=16;{let{length:m,frameLength:p,samples:y,...h}=o;r[Te](a,o,h)}return new t(o)}constructor(e){super(e),this[ue]=e[ue],this[hr]=e[hr],this[qe]=e[qe],this[jr]=e[jr],this[Je]=e[Je],this[Ze]=e[Ze],this[ve]=e[ve],this[et]=e[et],this[tt]=e[tt],this[rt]=e[rt]}};var vn=class t extends Le{static*[Re](e,r,n){return yield*super[Re](Wt,t,e,r,n)}constructor(e,r,n){super(e,r,n)}};var Sn=class extends ye{constructor(e,r,n){super(e,r),this.Frame=vn,this.Header=Wt,n(this[j])}get[j](){return uo}*[Qe](){return yield*this[_t]()}};var ad={0:"MPEG-4",8:"MPEG-2"},cd={0:"valid",2:pe,4:pe,6:pe},ld={0:So,1:hn},dd={0:"AAC Main",64:"AAC LC (Low Complexity)",128:"AAC SSR (Scalable Sample Rate)",192:"AAC LTP (Long Term Prediction)"},ud={0:so,4:ao,8:ga,12:yt,16:ar,20:cr,24:lr,28:dr,32:ur,36:co,40:lo,44:fr,48:xa,52:W,56:W,60:"frequency is written explicitly"},Fa={0:{[I]:0,[z]:"Defined in AOT Specific Config"},64:{[I]:1,[z]:ht},128:{[I]:2,[z]:Z(2,P[0][0])},192:{[I]:3,[z]:Z(3,P[1][3])},256:{[I]:4,[z]:Z(4,P[1][3],P[3][4])},320:{[I]:5,[z]:Z(5,P[1][3],P[3][0])},384:{[I]:6,[z]:Z(6,P[1][3],P[3][0],Xe)},448:{[I]:8,[z]:Z(8,P[1][3],P[2][0],P[3][0],Xe)}},Xt=class t extends Ee{static*[G](e,r,n){let o={},i=yield*e[N](7,n),s=we([i[0],i[1],i[2],i[3]&252|i[6]&3]),a=r[G](s);if(a)Object.assign(o,a);else{if(i[0]!==255||i[1]<240||(o[tt]=ad[i[1]&8],o[ve]=cd[i[1]&6],o[ve]===pe))return null;let l=i[1]&1;o[rt]=ld[l],o[x]=l?7:9,o[fo]=i[2]&192,o[je]=i[2]&60;let d=i[2]&2;if(o[en]=dd[o[fo]],o[D]=ud[o[je]],o[D]===W)return null;o[Ze]=!!d,o[sn]=(i[2]<<8|i[3])&448,o[me]=Fa[o[sn]][z],o[I]=Fa[o[sn]][I],o[Je]=!!(i[3]&32),o[$r]=!!(i[3]&8),o[an]=!!(i[3]&8),o[cn]=!!(i[3]&4),o[de]=16,o[k]=1024,o[Jr]=i[6]&3;{let{length:u,channelModeBits:f,profileBits:m,sampleRateBits:p,frameLength:y,samples:h,numberAACFrames:g,...S}=o;r[Te](s,o,S)}}if(o[Se]=(i[3]<<11|i[4]<<3|i[5]>>5)&8191,!o[Se])return null;let c=(i[5]<<6|i[6]>>2)&2047;return o[Wr]=c===2047?"VBR":c,new t(o)}constructor(e){super(e),this[an]=e[an],this[cn]=e[cn],this[Wr]=e[Wr],this[$r]=e[$r],this[Je]=e[Je],this[Ze]=e[Ze],this[ve]=e[ve],this[x]=e[x],this[tt]=e[tt],this[Jr]=e[Jr],this[en]=e[en],this[rt]=e[rt]}get audioSpecificConfig(){let e=se.get(this),r=e[fo]+64<<5|e[je]<<5|e[sn]>>3,n=new he(2);return new Lt(n[Ke]).setUint16(0,r,!1),n}};var Mn=class t extends Le{static*[Re](e,r,n){return yield*super[Re](Xt,t,e,r,n)}constructor(e,r,n){super(e,r,n)}};var An=class extends ye{constructor(e,r,n){super(e,r),this.Frame=Mn,this.Header=Xt,n(this[j])}get[j](){return"aac"}*[Qe](){return yield*this[_t]()}};var Et=class t extends Le{static _getFrameFooterCrc16(e){return(e[e[x]-2]<<8)+e[e[x]-1]}static[vo](e){let r=t._getFrameFooterCrc16(e),n=Aa(e[O](0,-2));return r===n}constructor(e,r,n){r[fn]=n,r[Kr]=t._getFrameFooterCrc16(e),super(r,e,se.get(r)[k])}};var Ca="get from STREAMINFO metadata block",fd={0:"Fixed",1:"Variable"},Ta={0:W,16:192};for(let t=2;t<16;t++)Ta[t<<4]=t<6?576*2**(t-2):2**t;var md={0:Ca,1:ao,2:ya,3:pa,4:fr,5:ur,6:dr,7:lr,8:cr,9:ar,10:yt,11:so,15:pe},hd={0:{[I]:1,[z]:ht},16:{[I]:2,[z]:Z(2,P[0][0])},32:{[I]:3,[z]:Z(3,P[0][1])},48:{[I]:4,[z]:Z(4,P[1][0],P[3][0])},64:{[I]:5,[z]:Z(5,P[1][1],P[3][0])},80:{[I]:6,[z]:Z(6,P[1][1],Xe,P[3][0])},96:{[I]:7,[z]:Z(7,P[1][1],Xe,P[3][4],P[2][0])},112:{[I]:8,[z]:Z(8,P[1][1],Xe,P[3][0],P[2][0])},128:{[I]:2,[z]:`${pt} (left, diff)`},144:{[I]:2,[z]:`${pt} (diff, right)`},160:{[I]:2,[z]:`${pt} (avg, diff)`},176:W,192:W,208:W,224:W,240:W},pd={0:Ca,2:8,4:12,6:W,8:16,10:20,12:24,14:W},It=class t extends Ee{static _decodeUTF8Int(e){if(e[0]>254)return null;if(e[0]<128)return{value:e[0],length:1};let r=1;for(let s=64;s&e[0];s>>=1)r++;let n=r-1,o=0,i=0;for(;n>0;i+=6,n--){if((e[n]&192)!==128)return null;o|=(e[n]&63)<<i}return o|=(e[n]&127>>r)<<i,{value:o,length:r}}static[Be](e,r){let n={[N]:function*(){return e}};return t[G](n,r,0).next().value}static*[G](e,r,n){let o=yield*e[N](6,n);if(o[0]!==255||!(o[1]===248||o[1]===249))return null;let i={},s=we(o[O](0,4)),a=r[G](s);if(a)Object.assign(i,a);else{if(i[ho]=o[1]&1,i[rn]=fd[i[ho]],i[nn]=o[2]&240,i[je]=o[2]&15,i[nt]=Ta[i[nn]],i[nt]===W||(i[D]=md[i[je]],i[D]===pe)||o[3]&1)return null;let l=hd[o[3]&240];if(l===W||(i[I]=l[I],i[me]=l[z],i[de]=pd[o[3]&14],i[de]===W))return null}i[x]=5,o=yield*e[N](i[x]+8,n);let c=t._decodeUTF8Int(o[O](4));if(!c||(i[ho]?i[dn]=c.value:i[at]=c.value,i[x]+=c[x],i[nn]===96?(o[x]<i[x]&&(o=yield*e[N](i[x],n)),i[nt]=o[i[x]-1]+1,i[x]+=1):i[nn]===112&&(o[x]<i[x]&&(o=yield*e[N](i[x],n)),i[nt]=(o[i[x]-1]<<8)+o[i[x]]+1,i[x]+=2),i[k]=i[nt],i[je]===12?(o[x]<i[x]&&(o=yield*e[N](i[x],n)),i[D]=o[i[x]-1]*1e3,i[x]+=1):i[je]===13?(o[x]<i[x]&&(o=yield*e[N](i[x],n)),i[D]=(o[i[x]-1]<<8)+o[i[x]],i[x]+=2):i[je]===14&&(o[x]<i[x]&&(o=yield*e[N](i[x],n)),i[D]=((o[i[x]-1]<<8)+o[i[x]])*10,i[x]+=2),o[x]<i[x]&&(o=yield*e[N](i[x],n)),i[mr]=o[i[x]-1],i[mr]!==Ma(o[O](0,i[x]-1))))return null;if(!a){let{blockingStrategyBits:l,frameNumber:d,sampleNumber:u,samples:f,sampleRateBits:m,blockSizeBits:p,crc:y,length:h,...g}=i;r[Te](s,i,g)}return new t(i)}constructor(e){super(e),this[Kr]=null,this[rn]=e[rn],this[nt]=e[nt],this[at]=e[at],this[dn]=e[dn],this[fn]=null}};var yd=2,gd=512*1024,Kt=class extends ye{constructor(e,r,n){super(e,r),this.Frame=Et,this.Header=It,n(this[j])}get[j](){return"flac"}*_getNextFrameSyncOffset(e){let r=yield*this._codecParser[N](2,0),n=r[x]-2;for(;e<n;){if(r[e]===255){let i=r[e+1];if(i===248||i===249)break;i!==255&&e++}e++}return e}*[Qe](){do{let e=yield*It[G](this._codecParser,this._headerCache,0);if(e){let r=se.get(e)[x]+yd;for(;r<=gd;){if(this._codecParser._flushing||(yield*It[G](this._codecParser,this._headerCache,r))){let n=yield*this._codecParser[N](r);if(this._codecParser._flushing||(n=n[O](0,r)),Et[vo](n)){let o=new Et(n,e);return this._headerCache[Ge](),this._codecParser[Ce](r),this._codecParser[At](o),o}}r=yield*this._getNextFrameSyncOffset(r+1)}this._codecParser[Ve](`Unable to sync FLAC frame after searching ${r} bytes.`),this._codecParser[Ce](r)}else this._codecParser[Ce](yield*this._getNextFrameSyncOffset(1))}while(!0)}[wt](e){return e[ne]===0?(this._headerCache[Ge](),this._streamInfo=e[Y][O](13)):e[ne]===1||(e[fe]=ce.get(e)[Fe].map(r=>{let n=It[Be](r,this._headerCache);if(n)return new Et(r,n,this._streamInfo);this._codecParser[Ve]("Failed to parse Ogg FLAC frame","Skipping invalid FLAC frame")}).filter(r=>!!r)),e}};var Yt=class t{static*[G](e,r,n){let o={},i=yield*e[N](28,n);if(i[0]!==79||i[1]!==103||i[2]!==103||i[3]!==83||(o[Ri]=i[4],i[5]&248))return null;o[_e]=!!(i[5]&4),o[xt]=!!(i[5]&2),o[gt]=!!(i[5]&1);let a=new Lt(he.from(i[O](0,28))[Ke]);o[Ne]=wa(a,6),o[$e]=a.getInt32(14,!0),o[ne]=a.getInt32(18,!0),o[kt]=a.getInt32(22,!0);let c=i[26];o[x]=c+27,i=yield*e[N](o[x],n),o[Se]=0,o[Mt]=[],o[yr]=he.from(i[O](27,o[x]));for(let l=0,d=0;l<c;l++){let u=o[yr][l];o[Se]+=u,d+=u,(u!==255||l===c-1)&&(o[Mt].push(d),d=0)}return new t(o)}constructor(e){se.set(this,e),this[Ne]=e[Ne],this[gt]=e[gt],this[xt]=e[xt],this[_e]=e[_e],this[Mt]=e[Mt],this[ne]=e[ne],this[kt]=e[kt],this[$e]=e[$e]}};var _n=class t extends Ut{static*[Re](e,r,n){let o=yield*Yt[G](e,r,n);if(o){let i=se.get(o)[Se],s=se.get(o)[x],a=s+i,c=(yield*e[N](a,0))[O](0,a),l=c[O](s,a);return new t(o,l,c)}else return null}constructor(e,r,n){super(e,r),ce.get(this)[x]=n[x],this[fe]=[],this[Fi]=n,this[Ne]=e[Ne],this[Yr]=e[kt],this[Ye]=0,this[gt]=e[gt],this[xt]=e[xt],this[_e]=e[_e],this[ne]=e[ne],this[k]=0,this[$e]=e[$e]}};var xr=class extends Le{constructor(e,r,n){super(r,e,n)}};var Ra={0:Nr.slice(0,2),1:Nr},Oe="SILK-only",le="CELT-only",Fo="Hybrid",zt="narrowband",Co="medium-band",Pt="wideband",br="super-wideband",vr="fullband",xd={0:{[R]:Oe,[B]:zt,[T]:10},8:{[R]:Oe,[B]:zt,[T]:20},16:{[R]:Oe,[B]:zt,[T]:40},24:{[R]:Oe,[B]:zt,[T]:60},32:{[R]:Oe,[B]:Co,[T]:10},40:{[R]:Oe,[B]:Co,[T]:20},48:{[R]:Oe,[B]:Co,[T]:40},56:{[R]:Oe,[B]:Co,[T]:60},64:{[R]:Oe,[B]:Pt,[T]:10},72:{[R]:Oe,[B]:Pt,[T]:20},80:{[R]:Oe,[B]:Pt,[T]:40},88:{[R]:Oe,[B]:Pt,[T]:60},96:{[R]:Fo,[B]:br,[T]:10},104:{[R]:Fo,[B]:br,[T]:20},112:{[R]:Fo,[B]:vr,[T]:10},120:{[R]:Fo,[B]:vr,[T]:20},128:{[R]:le,[B]:zt,[T]:2.5},136:{[R]:le,[B]:zt,[T]:5},144:{[R]:le,[B]:zt,[T]:10},152:{[R]:le,[B]:zt,[T]:20},160:{[R]:le,[B]:Pt,[T]:2.5},168:{[R]:le,[B]:Pt,[T]:5},176:{[R]:le,[B]:Pt,[T]:10},184:{[R]:le,[B]:Pt,[T]:20},192:{[R]:le,[B]:br,[T]:2.5},200:{[R]:le,[B]:br,[T]:5},208:{[R]:le,[B]:br,[T]:10},216:{[R]:le,[B]:br,[T]:20},224:{[R]:le,[B]:vr,[T]:2.5},232:{[R]:le,[B]:vr,[T]:5},240:{[R]:le,[B]:vr,[T]:10},248:{[R]:le,[B]:vr,[T]:20}},Sr=class t extends Ee{static[Be](e,r,n){let o={};if(o[I]=e[9],o[ot]=e[18],o[x]=o[ot]!==0?21+o[I]:19,e[x]<o[x])throw new Error("Out of data while inside an Ogg Page");let i=r[0]&3,s=i===3?2:1,a=we(e[O](0,o[x]))+we(r[O](0,s)),c=n[G](a);if(c)return new t(c);if(a.substr(0,8)!=="OpusHead"||e[8]!==1)return null;o[Y]=he.from(e[O](0,o[x]));let l=new Lt(o[Y][Ke]);if(o[de]=16,o[Ot]=l.getUint16(10,!0),o[ln]=l.getUint32(12,!0),o[D]=yt,o[Zr]=l.getInt16(16,!0),o[ot]in Ra&&(o[me]=Ra[o[ot]][o[I]-1],!o[me]))return null;o[ot]!==0&&(o[un]=e[19],o[Xr]=e[20],o[on]=[...e[O](21,o[I]+21)]);let d=xd[248&r[0]];switch(o[R]=d[R],o[B]=d[B],o[T]=d[T],i){case 0:o[st]=1;break;case 1:case 2:o[st]=2;break;case 3:o[Qr]=!!(128&r[1]),o[qr]=!!(64&r[1]),o[st]=63&r[1];break;default:return null}{let{length:u,data:f,channelMappingFamily:m,...p}=o;n[Te](a,o,p)}return new t(o)}constructor(e){super(e),this[Y]=e[Y],this[B]=e[B],this[ot]=e[ot],this[on]=e[on],this[Xr]=e[Xr],this[st]=e[st],this[T]=e[T],this[qr]=e[qr],this[ln]=e[ln],this[Qr]=e[Qr],this[R]=e[R],this[Zr]=e[Zr],this[Ot]=e[Ot],this[un]=e[un]}};var wn=class extends ye{constructor(e,r,n){super(e,r),this.Frame=xr,this.Header=Sr,n(this[j]),this._identificationHeader=null,this._preSkipRemaining=null}get[j](){return"opus"}[wt](e){return e[ne]===0?(this._headerCache[Ge](),this._identificationHeader=e[Y]):e[ne]===1||(e[fe]=ce.get(e)[Fe].map(r=>{let n=Sr[Be](this._identificationHeader,r,this._headerCache);if(n){this._preSkipRemaining===null&&(this._preSkipRemaining=n[Ot]);let o=n[T]*n[st]/1e3*n[D];return this._preSkipRemaining>0&&(this._preSkipRemaining-=o,o=this._preSkipRemaining<0?-this._preSkipRemaining:0),new xr(r,n,o)}this._codecParser[xo]("Failed to parse Ogg Opus Header","Not a valid Ogg Opus file")})),e}};var Mr=class extends Le{constructor(e,r,n){super(r,e,n)}};var Wi={};for(let t=0;t<8;t++)Wi[t+6]=2**(6+t);var Ln=class t extends Ee{static[Be](e,r,n,o){if(e[x]<30)throw new Error("Out of data while inside an Ogg Page");let i=we(e[O](0,30)),s=r[G](i);if(s)return new t(s);let a={[x]:30};if(i.substr(0,7)!=="vorbis")return null;a[Y]=he.from(e[O](0,30));let c=new Lt(a[Y][Ke]);if(a[bt]=c.getUint32(7,!0),a[bt]!==0||(a[I]=e[11],a[me]=Nr[a[I]-1]||"application defined",a[D]=c.getUint32(12,!0),a[Vr]=c.getInt32(16,!0),a[Gr]=c.getInt32(20,!0),a[Ur]=c.getInt32(24,!0),a[St]=Wi[(e[28]&240)>>4],a[vt]=Wi[e[28]&15],a[vt]>a[St])||e[29]!==1)return null;a[de]=32,a[pr]=o,a[tn]=n;{let{length:l,data:d,version:u,vorbisSetup:f,vorbisComments:m,...p}=a;r[Te](i,a,p)}return new t(a)}constructor(e){super(e),this[Vr]=e[Vr],this[Ur]=e[Ur],this[Gr]=e[Gr],this[vt]=e[vt],this[St]=e[St],this[Y]=e[Y],this[tn]=e[tn],this[pr]=e[pr]}};var En=class extends ye{constructor(e,r,n){super(e,r),this.Frame=Mr,n(this[j]),this._identificationHeader=null,this._setupComplete=!1,this._prevBlockSize=null}get[j](){return Dt}[wt](e){e[fe]=[];for(let r of ce.get(e)[Fe])if(r[0]===1)this._headerCache[Ge](),this._identificationHeader=e[Y],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=Ln[Be](this._identificationHeader,this._headerCache,this._vorbisComments,this._vorbisSetup);n?e[fe].push(new Mr(r,n,this._getSamples(r,n))):this._codecParser[logError]("Failed to parse Ogg Vorbis Header","Not a valid Ogg Vorbis file")}return e}_getSamples(e,r){let o=this._mode.blockFlags[e[0]>>1&this._mode.mask]?r[St]:r[vt],i=this._prevBlockSize===null?0:(this._prevBlockSize+o)/4;return this._prevBlockSize=o,i}_parseSetupHeader(e){let r=new Mo(e),n={count:0,blockFlags:[]};for(;(r.read(1)&1)!==1;);let o;for(;n.count<64&&r.position>0;){pn(r.read(8));let i=0;for(;r.read(8)===0&&i++<3;);if(i===4)o=r.read(7),n.blockFlags.unshift(o&1),r.position+=6,n.count++;else{((pn(o)&126)>>1)+1!==n.count&&this._codecParser[Ve]("vorbis derived mode count did not match actual mode count");break}}return n.mask=(1<<Math.log2(n.count))-1,n}};var Xi=class{constructor(e,r,n){this._codecParser=e,this._headerCache=r,this._onCodec=n,this._continuedPacket=new he,this._codec=null,this._isSupported=null,this._previousAbsoluteGranulePosition=null}get[j](){return this._codec||""}_updateCodec(e,r){this._codec!==e&&(this._headerCache[Ue](),this._parser=new r(this._codecParser,this._headerCache,this._onCodec),this._codec=e)}_checkCodecSupport({data:e}){let r=we(e[O](0,8));switch(r){case"fishead\0":return!1;case"OpusHead":return this._updateCodec("opus",wn),!0;case(/^\x7fFLAC/.test(r)&&r):return this._updateCodec("flac",Kt),!0;case(/^\x01vorbis/.test(r)&&r):return this._updateCodec(Dt,En),!0;default:return!1}}_checkPageSequenceNumber(e){e[ne]!==this._pageSequenceNumber+1&&this._pageSequenceNumber>1&&e[ne]>1&&this._codecParser[Ve]("Unexpected gap in Ogg Page Sequence Number.",`Expected: ${this._pageSequenceNumber+1}, Got: ${e[ne]}`),this._pageSequenceNumber=e[ne]}_parsePage(e){this._isSupported===null&&(this._pageSequenceNumber=e[ne],this._isSupported=this._checkCodecSupport(e)),this._checkPageSequenceNumber(e);let r=ce.get(e),n=se.get(r[Ae]),o=0;if(r[Fe]=n[Mt].map(i=>e[Y][O](o,o+=i)),this._continuedPacket[x]&&(r[Fe][0]=yn(this._continuedPacket,r[Fe][0]),this._continuedPacket=new he),n[yr][n[yr][x]-1]===255&&(this._continuedPacket=yn(this._continuedPacket,r[Fe].pop())),this._previousAbsoluteGranulePosition!==null&&(e[k]=Number(e[Ne]-this._previousAbsoluteGranulePosition)),this._previousAbsoluteGranulePosition=e[Ne],this._isSupported){let i=this._parser[wt](e);return this._codecParser[At](i),i}else return e}},In=class extends ye{constructor(e,r,n){super(e,r),this._onCodec=n,this.Frame=_n,this.Header=Yt,this._streams=new Map,this._currentSerialNumber=null}get[j](){let e=this._streams.get(this._currentSerialNumber);return e?e.codec:""}*[Qe](){let e=yield*this[_t](!0);this._currentSerialNumber=e[$e];let r=this._streams.get(this._currentSerialNumber);return r||(r=new Xi(this._codecParser,this._headerCache,this._onCodec),this._streams.set(this._currentSerialNumber,r)),e[_e]&&this._streams.delete(this._currentSerialNumber),r._parsePage(e)}};var Ki=()=>{},zn=class{constructor(e,{onCodec:r,onCodecHeader:n,onCodecUpdate:o,enableLogging:i=!1,enableFrameCRC32:s=!0}={}){this._inputMimeType=e,this._onCodec=r||Ki,this._onCodecHeader=n||Ki,this._onCodecUpdate=o,this._enableLogging=i,this._crc32=s?_a:Ki,this[Ue]()}get[j](){return this._parser?this._parser[j]:""}[Ue](){this._headerCache=new gn(this._onCodecHeader,this._onCodecUpdate),this._generator=this._getGenerator(),this._generator.next()}*flush(){this._flushing=!0;for(let e=this._generator.next();e.value;e=this._generator.next())yield e.value;this._flushing=!1,this[Ue]()}*parseChunk(e){for(let r=this._generator.next(e);r.value;r=this._generator.next())yield r.value}parseAll(e){return[...this.parseChunk(e),...this.flush()]}*_getGenerator(){if(this._inputMimeType.match(/aac/))this._parser=new An(this,this._headerCache,this._onCodec);else if(this._inputMimeType.match(/mpeg/))this._parser=new Sn(this,this._headerCache,this._onCodec);else if(this._inputMimeType.match(/flac/))this._parser=new Kt(this,this._headerCache,this._onCodec);else if(this._inputMimeType.match(/ogg/))this._parser=new In(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 e=yield*this._parser[Qe]();e&&(yield e)}}*[N](e=0,r=0){let n;for(;this._rawData[x]<=e+r;){if(n=yield,this._flushing)return this._rawData[O](r);n&&(this._totalBytesIn+=n[x],this._rawData=yn(this._rawData,n))}return this._rawData[O](r)}[Ce](e){this._currentReadPosition+=e,this._rawData=this._rawData[O](e)}[mn](e){this._sampleRate=e[Ae][D],e[Ae][ue]=e[Ye]>0?Math.round(e[Y][x]/e[Ye])*8:0,e[at]=this._frameNumber++,e[Ht]=this._totalBytesOut,e[Vt]=this._totalSamples,e[Nt]=this._totalSamples/this._sampleRate*1e3,e[Yr]=this._crc32(e[Y]),this._headerCache[bo](e[Ae][ue],e[Nt]),this._totalBytesOut+=e[Y][x],this._totalSamples+=e[k]}[At](e){if(e[fe]){if(e[_e]){let r=e[k];e[fe].forEach(n=>{let o=n[k];r<o&&(n[k]=r>0?r:0,n[Ye]=n[k]/n[Ae][D]*1e3),r-=o,this[mn](n)})}else e[k]=0,e[fe].forEach(r=>{e[k]+=r[k],this[mn](r)});e[Ye]=e[k]/this._sampleRate*1e3||0,e[Vt]=this._totalSamples,e[Nt]=this._totalSamples/this._sampleRate*1e3||0,e[Ht]=this._totalBytesOut}else this[mn](e)}_log(e,r){if(this._enableLogging){let n=[`${j}: ${this[j]}`,`inputMimeType: ${this._inputMimeType}`,`readPosition: ${this._currentReadPosition}`,`totalBytesIn: ${this._totalBytesIn}`,`${Ht}: ${this._totalBytesOut}`],o=Math.max(...n.map(i=>i[x]));r.push(`--stats--${"-".repeat(o-9)}`,...n,"-".repeat(o)),e("codec-parser",r.reduce((i,s)=>i+`
|
|
4
|
+
`+s,""))}}[Ve](...e){this._log(console.warn,e)}[xo](...e){this._log(console.error,e)}};var Ba=zn;var To=fe;var Ro=Y;var Oa=Ae;var Da=_e;var ka=pr;var Ha=Vt;function ct(t){var e=e;function r(){}e={};function n(E){throw E}var o,i,s,a,c,l,d,u,f,m,p;function y(){var E=p.buffer;o=new Int8Array(E),i=new Int16Array(E),a=new Uint8Array(E),c=new Uint16Array(E),s=new Int32Array(E),l=new Uint32Array(E),d=new Float32Array(E),u=new Float64Array(E),f=new BigInt64Array(E),m=new BigUint64Array(E)}for(var h=E=>{for(var Ie,Fr,Qt=0,Hn=0,Nn=E.length,Vn=new Uint8Array((Nn*3>>2)-(E[Nn-2]=="=")-(E[Nn-1]=="="));Qt<Nn;Qt+=4,Hn+=3)Ie=$[E.charCodeAt(Qt+1)],Fr=$[E.charCodeAt(Qt+2)],Vn[Hn]=$[E.charCodeAt(Qt)]<<2|Ie>>4,Vn[Hn+1]=Ie<<4|Fr>>2,Vn[Hn+2]=Fr<<6|$[E.charCodeAt(Qt+3)];return Vn},g=()=>n(""),S=()=>{},b={},M=E=>E(),v=()=>performance.now(),A=(E,Ie)=>{if(b[E]&&(clearTimeout(b[E].id),delete b[E]),!Ie)return 0;var Fr=setTimeout(()=>{delete b[E],M(()=>zs(E,v()))},Ie);return b[E]={id:Fr,timeout_ms:Ie},0},_=Math.atan,L=Math.cos,F=Math.exp,w=Math.log,H=Math.pow,U=Math.sin,V=E=>{var Ie=a.length;return E>>>=0,!1},C=E=>{throw`exit(${E})`},$=new Uint8Array(123),be=25;be>=0;--be)$[48+be]=52+be,$[65+be]=be,$[97+be]=26+be;$[43]=62,$[47]=63;var Ft={e:g,d:S,f:A,b:_,a:L,i:F,h:w,g:H,c:U,k:V,j:C};function kn(E){Pr=E.n,As=E.o,_s=E.p,ws=E.q,Ls=E.r,Es=E.s,Is=E.t,zs=E.v}var Pr,As,_s,ws,Ls,Es,Is,zs;function Cc(E){E.m()}ct.wasm||Object.defineProperty(ct,"wasm",{get:()=>String.raw`dynEncode012091253f87dì%nä= 4&¿nÝØäÂLÚªã9ÚØ[äº\ ¼¡³R=}L]Èÿ2 ÿù¶J1jj¡é,zäV|i¸Qk¹=
|
|
5
5
|
¨¨%ýv²±»oúâLa:ê±ÊäÌÓ.÷Øý×>àW>z¯°8¯ñ\Ñós9\§ôÊ@Ü (tÃø4° ¢7fqÓg²Jè6x[zç®&4=} p.(°tÍÞã¾>÷CõË"*k?¿~7~H2ÛÜâ.ÏQä;6{ÜãFÑá'DD¤±°HQ>MínÎÏÎöʵÑÓ
ÞÌP¼P¨Þ*X²E=M¦qíxMñ=MÌë4/<gNO/¢ ¢>a~Ï®ììììì0ìa笡çëOÓÇM Q9tùµyuéµµÞÏ/±Óõò}E{òÓJ¹Û|·ôfÒ c¬Wêaûÿlʽp¹|)ÖEL¦ }ypÕSϹI]¢ºãæ°ÿo¶7ÛRq¾ÔÅEߨ]æËwÚ{óçVwó1¾EØpàe"Æùû¡Áª Ààð´LõÎxEÓ¢N¦
9ëùi& Ò§Ø!ÇFçS=MbäO?߷縪7ùa}5ðûÕtsUþ£KïgN¾)ø§\V0uSIö:ÌU4ж¯´Õn9ÔèE£ZƼ{hµmÙ¾6ÆÑ+xñ´«þ¸=Mߤ·å®«ïÆGFÝì|H?äE"þ!9«Æïpæ'][¯ù·£W÷O§&#ax$qf=}ø ô bÏ×W÷LôoÝWQÕÓ)u÷½èV|¥Gà¨Ö¸@ê|ÇK5ò A·Â9CS2¸¼¿,äÝÑÝy!ÑR%ÆÝÎ0Âv§ qTcó±hØÉã=}Z=}Ælüën¯ð(-°ÜwVÏï.th¥íS~SÏ»ZZÔZ
|
|
6
6
|
3BÌÛ¬<éæO)ÎyÚ¯O*®uìÛ$öI¥Ý9ôø³\¤ò³Ù¹ÇP¸J×y@ÔyOÇmô½ü¾|S?2àú¤F?½ûoo3ô;<àáûÜ8ì²7ïë¨RäY¹|ÓºÌF,Ð-¸*\P!FJÒ8= o6HwLrúº¶ÐÛ\Ù¬o¢9IqÝ.ôf¶ÎÈ{Ī×N|Mfs
¤ÉÝàâ§*+ã§ô¯î¬7ç×§ä)!Z¨É,Äp~ý·wsSGóäsE\ýïé§Ö:Ò'Cç(_X$\¦½eÒ8$XF|eíÙÓ¡¤Û<ØÞÛ¸9¿ðÃÎ#b~× 4éîÿÏq
|
|
7
7
|
ód|0wU&®è·vh6¨{ÚçÚ18Ó(ÓY\0¦= çèíß)Ø=}[xü-v?N(Kkg0}âÚ´ð¬ÕQNÍ¢usѳ=}. ëg
û= ÍMBp'²¨ x4è@9t§eݵ¾âð½ z?Z¹FH'̯¿<K,üµ<{ ¶JãývåàÆeù0Ð"F¥ÃÒÞþÔÉvCzl}ðN£ Í^P%²¸FX»WÎêô¶
äÉJ^g×SÃã.Ät*'ªG«ÒB<ÜÓ
¿ºp\àuV¯£ÅݽáÞ ùß=}ÎÚ^ÿí>¥!¨ â=M·?*/¤"å)â·ÿîÿî*(%*2[½"üríÔ4l½»a}¯CwpCÓèìGc-ã6®=M32k?Êg
!So-x>³G+ã@ò, ÁïáåN0þÙè.~È÷¡vTr¶Ã[üB±º»ávëw¹{pܺû"Aæ±9Æ^¹³òïRIAy5GÂwÉf4@Tù|qý7ðªwBL|Ôqv!ª°|]KiÐJVQ5¸åõ§å"H¼0e¬<óBîÚSÏUìHPÙA+çÉ'seÌNf°@ÈM,ð½egÖ¬x©û½2~«Ò1;Ö«
¯°4&90èE»Ó׺çʧJ<Æ¿&~Nu¼ãÙµ¢.UÇä(qQô^ö·%!É
|
|
@@ -138,7 +138,7 @@ KÙ:KµºKí{K]ûK£[KÚKóKÓ½R׿ÿ'P^j9TîçmóþL¿_o©×hÙtÙ
|
|
|
138
138
|
Ái;ªäÀ%n= =M+W= ÓÖc[aS
|
|
139
139
|
FÁð]NôÝ'= qr(¶ù¤nü«òÿ¿d&ÿÈõT4Þ=}z|ö ¿OW×SMtdH.ÏãRX&§o3ØÜXÍ^ÊMí£W´iâ]NüOå£S£Å·ç÷ݧ½GÑUy¹¦ß§/6P0(Cúýb"þ¥°VÙÄá£ÓÙ@¾YýòD{òÃv?EP©=MBé\ĽYäýRò øfâëEEf¼D+gC×úDZGÅÿ±Ç?TzÙ¡±ÏÁÕ¯¦ðvZmT}3xËz×cºrÑM=Mc-É©Ô7½wæc§Î»cû¾yfÙWòÆÝÔc¥³ôØf«Äñ·9ø%g:y^+{U]¤þ
[&fÓÏYë«Gªõ¹¦Öðþ¬moÛø?/ÛS.[S9ÛùC
/û2²Y£ÎÑ%/sy¢×ÌùJW6Oí\g0^JùêßÏ0í[Ü'ÏÔ>À-¿[ÔW?Y]±ØÙÃî<~ÎëR~Ìf¾Z/×¼_á¾Þê+îoÐñ{Þ\e3K%©¹§íB¹§(c=}ËÈ·SzÔnf§èx}o\9öf|%Ýå¥~©IÇüñY8}Ffú@Rú1éþ3÷ËótQøvû|³Îaá,Óé>BG6Òê}ÃJ|¶=}°öf6õk¶ÌºHgNjÒ{æ¾M;9·é§WèO±Ä3ÒËÒyt ;ù´à©a|Ó^!ÝøûÂÄ
|
|
140
140
|
(VV¸ÇÙcÏ>yoçzÃvòG{3Þ£½c×ôíÅé;°OÛGØ<wÜW> rU]q{û'ùÝír{*øï?t-ígùWÿ
&§]m}×ût¥Ë~ß&>&Õv!b#ÅÌq¢µ|jÍüùÉ^Æ&ôþ~sIµ"]d)uâ´ºvk Å\<Íÿöê½Â
|
|
141
|
-
ïBçϧmÙIólÜoëVb¦¯éWÇû3`});var Pc={a:It};this.setModule=E=>{t.setModule(ct,E)},this.getModule=()=>t.getModule(ct),this.instantiate=()=>(this.getModule().then(E=>WebAssembly.instantiate(E,Pc)).then(E=>{let ze=E.exports;Hn(ze),h=ze.l,y(),Fc(ze),r()}),this.ready=new Promise(E=>{r=E}).then(()=>{this.HEAP=h.buffer,this.malloc=As,this.free=zs,this.create_decoder=Tr,this.send_setup=_s,this.init_dsp=ws,this.decode_packets=Ls,this.destroy_decoder=Es}),this)}function Kt(){return this._init=()=>new this._WASMAudioDecoderCommon().instantiate(this._EmscriptenWASM,this._module).then(t=>{this._common=t,this._input=this._common.allocateTypedArray(this._inputSize,Uint8Array),this._firstPage=!0,this._inputLen=this._common.allocateTypedArray(1,Uint32Array),this._outputBufferPtr=this._common.allocateTypedArray(1,Uint32Array),this._channels=this._common.allocateTypedArray(1,Uint32Array),this._sampleRate=this._common.allocateTypedArray(1,Uint32Array),this._samplesDecoded=this._common.allocateTypedArray(1,Uint32Array);let e=256;this._errors=this._common.allocateTypedArray(e,Uint32Array),this._errorsLength=this._common.allocateTypedArray(1,Int32Array),this._frameNumber=0,this._inputBytes=0,this._outputSamples=0,this._decoder=this._common.wasm.create_decoder(this._input.ptr,this._inputLen.ptr,this._outputBufferPtr.ptr,this._channels.ptr,this._sampleRate.ptr,this._samplesDecoded.ptr,this._errors.ptr,this._errorsLength.ptr,e)}),Object.defineProperty(this,"ready",{enumerable:!0,get:()=>this._ready}),this.reset=()=>(this.free(),this._init()),this.free=()=>{this._common.wasm.destroy_decoder(this._decoder),this._common.free()},this.sendSetupHeader=t=>{this._input.buf.set(t),this._inputLen.buf[0]=t.length,this._common.wasm.send_setup(this._decoder,this._firstPage),this._firstPage=!1},this.initDsp=()=>{this._common.wasm.init_dsp(this._decoder)},this.decodePackets=t=>{let e=[],r=0,n=[];for(let o=0;o<t.length;o++){let i=t[o];this._input.buf.set(i),this._inputLen.buf[0]=i.length,this._common.wasm.decode_packets(this._decoder);let s=this._samplesDecoded.buf[0],a=[],c=new Uint32Array(this._common.wasm.HEAP,this._outputBufferPtr.buf[0],this._channels.buf[0]);for(let l=0;l<this._channels.buf[0];l++){let d=new Float32Array(s);s&&d.set(new Float32Array(this._common.wasm.HEAP,c[l],s)),a.push(d)}e.push(a),r+=s,this._frameNumber++,this._inputBytes+=i.length,this._outputSamples+=s;for(let l=0;l<this._errorsLength.buf;l+=2){let d=this._common.codeToString(this._errors.buf[l]),u=this._common.codeToString(this._errors.buf[l+1]);n.push({message:d+" vorbis_synthesis"+u,frameLength:i.length,frameNumber:this._frameNumber,inputBytes:this._inputBytes,outputSamples:this._outputSamples})}this._errorsLength.buf[0]=0}return this._WASMAudioDecoderCommon.getDecodedAudioMultiChannel(n,e,this._channels.buf[0],r,this._sampleRate.buf[0],16)},this._isWebWorker=Kt.isWebWorker,this._WASMAudioDecoderCommon=Kt.WASMAudioDecoderCommon||Q,this._EmscriptenWASM=Kt.EmscriptenWASM||ct,this._module=Kt.module,this._inputSize=128*1024,this._ready=this._init(),this}var Bo=Symbol(),lt=class{constructor(){this._onCodec=e=>{if(e!=="vorbis")throw new Error("@wasm-audio-decoders/ogg-vorbis does not support this codec "+e)},new Q,this._init(),this._ready=this[Bo](Kt)}_init(){this._vorbisSetupInProgress=!0,this._totalSamplesDecoded=0,this._codecParser=new Ba("audio/ogg",{onCodec:this._onCodec,enableFrameCRC32:!1})}async[Bo](e){if(this._decoder){let r=this._decoder;await r.ready.then(()=>r.free())}return this._decoder=new e,this._decoder.ready}get ready(){return this._ready}async reset(){return this._init(),this._decoder.reset()}free(){this._decoder.free()}async decodeOggPages(e){let r=[];for(let i=0;i<e.length;i++){let s=e[i];if(this._vorbisSetupInProgress&&(s[Ro][0]===1&&this._decoder.sendSetupHeader(s[Ro]),s[Po].length)){let a=s[Po][0][ka];this._decoder.sendSetupHeader(a[Ha]),this._decoder.initDsp(),this._vorbisSetupInProgress=!1}r.push(...s[Po].map(a=>a[Ro]))}let n=await this._decoder.decodePackets(r);this._totalSamplesDecoded+=n.samplesDecoded;let o=e[e.length-1];if(o&&o[Da]){let i=this._totalSamplesDecoded-o[Oa];if(i>0){for(let s=0;s<n.channelData.length;s++)n.channelData[s]=n.channelData[s].subarray(0,n.samplesDecoded-i);n.samplesDecoded-=i,this._totalSamplesDecoded-=i}}return n}async decode(e){return this.decodeOggPages([...this._codecParser.parseChunk(e)])}async flush(){let e=await this.decodeOggPages([...this._codecParser.flush()]);return await this.reset(),e}async decodeFile(e){let r=await this.decodeOggPages([...this._codecParser.parseAll(e)]);return await this.reset(),r}};var Yi=class extends sr{constructor(e){super(e,"ogg-vorbis-decoder",Kt,ct)}async sendSetupHeader(e){return this.postToDecoder("sendSetupHeader",e)}async initDsp(){return this.postToDecoder("initDsp")}async decodePackets(e){return this.postToDecoder("decodePackets",e)}},Tn=class extends lt{constructor(){super(),this._ready=super[Bo](Yi)}async free(){await this._decoder.free()}terminate(){this._decoder.terminate()}};io(lt,"OggVorbisDecoder");io(Tn,"OggVorbisDecoderWebWorker");var Ki=class extends Error{constructor(e){super(e),this.name="OggDecodeError"}};async function ko(t,e=new lt){await e.ready;let r=await e.decode(new Uint8Array(t)),n=r.errors;if(n&&n.length>0)throw new Ki(n.map(o=>o.message).join("; "));return{sampleRate:r.sampleRate,channels:r.channelData.length,bitDepth:r.bitDepth,channelData:r.channelData}}var In=class extends Error{constructor(e){super(e),this.name="AudioRegistryError"}},Ar=class{constructor(e,r={}){this.vfs=e;this.refCounts=new Map;this.cache=new mt(r.cacheSize??64)}get size(){return this.cache.size}async load(e){let r=e.toLowerCase(),n=this.cache.get(r);if(n)return this.refCounts.set(r,(this.refCounts.get(r)??0)+1),n;let i=(await this.vfs.readFile(e)).slice().buffer,s=await this.decodeByExtension(e,i);return this.cache.set(r,s),this.refCounts.set(r,1),s}release(e){let r=e.toLowerCase(),n=this.refCounts.get(r)??0;n<=1?(this.cache.delete(r),this.refCounts.delete(r)):this.refCounts.set(r,n-1)}clearAll(){this.cache.clear(),this.refCounts.clear()}async decodeByExtension(e,r){let n=e.toLowerCase();if(n.endsWith(".wav")){let o=oo(r),i=o.channels,s=Array.from({length:i},()=>new Float32Array(o.samples.length/i));for(let a=0;a<o.samples.length;a+=1)s[a%i][Math.floor(a/i)]=o.samples[a];return{sampleRate:o.sampleRate,channels:i,bitDepth:o.bitsPerSample,channelData:s}}if(n.endsWith(".ogg")||n.endsWith(".oga"))return ko(r);throw new In(`Unsupported audio format: ${e}`)}};var vd="quake2ts-pak-indexes",bd="pak-indexes";function Na(){if(typeof indexedDB<"u")return indexedDB;if(typeof window<"u"&&"indexedDB"in window)return window.indexedDB;if(typeof globalThis<"u"&&"indexedDB"in globalThis)return globalThis.indexedDB}function Fn(t,e){let r=Na();return r?new Promise((n,o)=>{let i=r.open(t,1);i.onupgradeneeded=()=>{let{result:s}=i;s.objectStoreNames.contains(e)||s.createObjectStore(e,{keyPath:"key"})},i.onerror=()=>o(i.error??new Error("Unknown IndexedDB error")),i.onsuccess=()=>n(i.result)}):Promise.reject(new Error("IndexedDB is not available in this environment"))}function Pn(t,e,r,n){return new Promise((o,i)=>{let a=t.transaction(e,r).objectStore(e),c=n(a);c.onsuccess=()=>o(c.result),c.onerror=()=>i(c.error??new Error("IndexedDB transaction error"))})}function ji(t,e){return`${re(t)}:${e.toString(16)}`}function Sd(t){return t.map(e=>({...e}))}var Do=class{constructor(e=vd,r=bd){this.dbName=e;this.storeName=r}get isSupported(){return!!Na()}async persist(e){if(!this.isSupported)return;let r=e.validate(),n={...r,key:ji(e.name,r.checksum),name:e.name,size:e.size,persistedAt:Date.now(),entries:Sd(r.entries)},o=await Fn(this.dbName,this.storeName);return await Pn(o,this.storeName,"readwrite",i=>i.put(n)),o.close(),n}async find(e,r){if(!this.isSupported)return;let n=await Fn(this.dbName,this.storeName),o=r!==void 0?ji(e,r):void 0,i=await Pn(n,this.storeName,"readonly",s=>o?s.get(o):s.getAll());if(n.close(),!!i){if(Array.isArray(i)){let s=re(e),a=i.filter(c=>re(c.name)===s);return a.length===0?void 0:a.sort((c,l)=>l.persistedAt-c.persistedAt)[0]}return i}}async remove(e,r){if(!this.isSupported)return!1;let n=await Fn(this.dbName,this.storeName),o=r!==void 0?ji(e,r):void 0,i=await Pn(n,this.storeName,"readwrite",s=>{if(o)return s.delete(o);let a=`${re(e)}:`;return s.delete(IDBKeyRange.bound(a,`${a}\uFFFF`,!1,!0))});return n.close(),typeof i=="number"?i>0:!0}async clear(){if(!this.isSupported)return;let e=await Fn(this.dbName,this.storeName);await Pn(e,this.storeName,"readwrite",r=>r.clear()),e.close()}async list(){if(!this.isSupported)return[];let e=await Fn(this.dbName,this.storeName),r=await Pn(e,this.storeName,"readonly",n=>n.getAll());return e.close(),r.sort((n,o)=>o.persistedAt-n.persistedAt)}};var jt=class extends Error{constructor(r,n){super(n??`Missing dependencies: ${r.join(", ")}`);this.missing=r;this.name="AssetDependencyError"}},Rn=class{constructor(){this.nodes=new Map}register(e,r=[]){let n=this.nodes.get(e)??{dependencies:new Set,loaded:!1};r.forEach(o=>n.dependencies.add(o)),this.nodes.set(e,n),r.forEach(o=>{this.nodes.has(o)||this.nodes.set(o,{dependencies:new Set,loaded:!1})})}markLoaded(e){let r=this.nodes.get(e)??{dependencies:new Set,loaded:!1},n=this.getMissingDependencies(e,r);if(n.length>0)throw new jt(n,`Asset ${e} is missing dependencies: ${n.join(", ")}`);r.loaded=!0,this.nodes.set(e,r)}markUnloaded(e){let r=this.nodes.get(e);r&&(r.loaded=!1)}isLoaded(e){return this.nodes.get(e)?.loaded??!1}missingDependencies(e){let r=this.nodes.get(e);return r?this.getMissingDependencies(e,r):[]}reset(){this.nodes.clear()}getMissingDependencies(e,r){let n=[];for(let o of r.dependencies)this.nodes.get(o)?.loaded||n.push(o);return n}},Ho=class{constructor(e,r={}){this.vfs=e;this.textures=new ir({capacity:r.textureCacheCapacity??128}),this.audio=new Ar(e,{cacheSize:r.audioCacheSize??64}),this.dependencyTracker=r.dependencyTracker??new Rn,this.md2=new rr(e),this.md3=new nr(e),this.sprite=new or(e)}isAssetLoaded(e,r){return this.dependencyTracker.isLoaded(this.makeKey(e,r))}registerTexture(e,r){this.textures.set(e,r);let n=this.makeKey("texture",e);this.dependencyTracker.register(n),this.dependencyTracker.markLoaded(n)}async loadSound(e){let r=await this.audio.load(e),n=this.makeKey("sound",e);return this.dependencyTracker.register(n),this.dependencyTracker.markLoaded(n),r}async loadMd2Model(e,r=[]){let n=this.makeKey("model",e),o=r.map(a=>this.makeKey("texture",a));this.dependencyTracker.register(n,o);let i=this.dependencyTracker.missingDependencies(n);if(i.length>0)throw new jt(i,`Asset ${n} is missing dependencies: ${i.join(", ")}`);let s=await this.md2.load(e);return this.dependencyTracker.markLoaded(n),s}async loadMd3Model(e,r=[]){let n=this.makeKey("model",e),o=r.map(a=>this.makeKey("texture",a));this.dependencyTracker.register(n,o);let i=this.dependencyTracker.missingDependencies(n);if(i.length>0)throw new jt(i,`Asset ${n} is missing dependencies: ${i.join(", ")}`);let s=await this.md3.load(e);return this.dependencyTracker.markLoaded(n),s}async loadSprite(e){let r=this.makeKey("sprite",e);this.dependencyTracker.register(r);let n=await this.sprite.load(e);return this.dependencyTracker.markLoaded(r),n}resetForLevelChange(){this.textures.clear(),this.audio.clearAll(),this.dependencyTracker.reset()}makeKey(e,r){return`${e}:${re(r)}`}};var $i=32,Oo=(u=>(u[u.Auto=0]="Auto",u[u.Weapon=1]="Weapon",u[u.Voice=2]="Voice",u[u.Item=3]="Item",u[u.Body=4]="Body",u[u.Aux=5]="Aux",u[u.Footstep=6]="Footstep",u[u.Aux3=7]="Aux3",u[u.NoPhsAdd=8]="NoPhsAdd",u[u.Reliable=16]="Reliable",u[u.ForcePos=32]="ForcePos",u))(Oo||{}),Va=-1,No=0,Ua=1,Ga=2,Wa=3,_r=80,Xa=.003;function $t(t){return t===3?t*.001:t*5e-4}function Vo(t){let e=$t(t);return e<=0?Number.POSITIVE_INFINITY:80+1/e}var Uo=class{constructor(e){this.factory=e}getContext(){return this.context||(this.context=this.factory()),this.context}async resume(){let e=this.getContext();e.state==="suspended"&&await e.resume()}getState(){return this.context?.state??"suspended"}};function Go(t){let e=t.getContext(),r=e.createGain();r.gain.value=1;let n=e.createDynamicsCompressor(),o=e.createBiquadFilter?.();return o?(o.type="lowpass",o.frequency.value=2e4,o.Q.value=.707,r.connect(o),o.connect(n)):r.connect(n),n.connect(e.destination),{context:e,master:r,compressor:n,filter:o}}var Wo=class{constructor(e=new er){this.configStrings=e;this.buffers=new Map}registerName(e){return this.configStrings.soundIndex(e)}register(e,r){let n=this.registerName(e);return this.buffers.set(n,r),n}find(e){return this.configStrings.findSoundIndex(e)}get(e){return this.buffers.get(e)}has(e){return this.buffers.has(e)}};var Xo=class{constructor(e){this.vfs=e.vfs,this.registry=e.registry,this.contextController=e.context,this.soundRoot=e.soundRoot??"sound/",this.decodeAudio=e.decodeAudio??((r,n)=>{if(!r.decodeAudioData)throw new Error("decodeAudioData is not available on the provided audio context");return r.decodeAudioData(n)})}async precache(e){let r=[...new Set(e.map(i=>this.normalize(i)))],n={loaded:[],skipped:[],missing:[],errors:{}},o=this.contextController.getContext();for(let i of r)try{let s=this.registry.find(i);if(s!==void 0&&this.registry.has(s)){n.skipped.push(i);continue}if(!this.vfs.stat(i)){n.missing.push(i);continue}let l=(await this.vfs.readFile(i)).slice().buffer,d=await this.decodeAudio(o,l);this.registry.register(i,d),n.loaded.push(i)}catch(s){let a=s instanceof Error?s:new Error(String(s));n.errors[i]=a}return n}normalize(e){let r=re(e.replace(/^\//,""));return r.startsWith(this.soundRoot)?r:re(`${this.soundRoot}${r}`)}};var Md=7,Bn=t=>t&Md;function qo(t){return Array.from({length:32},()=>({entnum:0,entchannel:0,endTimeMs:0,isPlayer:!1,active:!1})).map(e=>({...e,isPlayer:e.entnum===t}))}function Yo(t,e,r,n){if(r<0)throw new Error("pickChannel: entchannel must be non-negative");let o=Bn(r),i=-1,s=Number.POSITIVE_INFINITY;for(let a=0;a<t.length;a+=1){let c=t[a],l=Bn(c.entchannel);if(o!==0&&c.entnum===e&&l===o){i=a;break}if(c.active&&c.entnum===n.playerEntity&&e!==n.playerEntity)continue;let d=c.endTimeMs-n.nowMs;(i===-1||d<s)&&(s=d,i=a)}return i===-1?void 0:i}function Ko(t,e,r,n,o){if(o)return{left:r,right:r,distanceComponent:0};let i=Fs(t,e.origin),s=fi(i),a=Oe(i),c=s-80;c<0&&(c=0),c*=$t(n);let l=mi(e.right,a),d=e.mono??!1,u=d||n===0?1:.5*(1+l),m=d||n===0?1:.5*(1-l),f=Math.max(0,Math.floor(r*(1-c)*u));return{left:Math.max(0,Math.floor(r*(1-c)*m)),right:f,distanceComponent:c}}var jo=class{constructor(e){this.activeSources=new Map;this.contextController=e.context,this.registry=e.registry,this.playerEntity=e.playerEntity,this.channels=qo(e.playerEntity),this.listener=e.listener??{origin:Is,right:{x:1,y:0,z:0}},this.sfxVolume=e.sfxVolume??1,this.masterVolume=e.masterVolume??1,this.resolveOcclusion=e.resolveOcclusion,this.graph=Go(this.contextController),this.graph.master.gain.value=this.masterVolume}setListener(e){this.listener=e}setMasterVolume(e){this.masterVolume=e,this.graph.master.gain.value=e}setSfxVolume(e){this.sfxVolume=e}async ensureRunning(){await this.contextController.resume()}play(e){let r=this.registry.get(e.soundIndex);if(!r)return;let n=this.graph.context,o=n.currentTime*1e3,i=Yo(this.channels,e.entity,e.channel,{nowMs:o,playerEntity:this.playerEntity});if(i===void 0)return;let s=this.activeSources.get(i);s&&(s.source.onended=null,s.source.stop(),this.activeSources.delete(i));let a=n.createBufferSource();a.buffer=r,a.loop=e.looping??!1;let c=e.origin??this.listener.origin,l=n.createGain(),d=this.createPanner(n,e.attenuation),u=this.resolveOcclusion?.(this.listener,c,e.attenuation),m=qa(u?.gainScale??1),f=this.resolveOcclusion?this.createOcclusionFilter(n,u?.lowpassHz??2e4):void 0;this.applyOriginToPanner(d,c);let h=e.entity===this.playerEntity,y=Ko(c,this.listener,e.volume,e.attenuation,h),g=(e.volume===0?0:Math.max(y.left,y.right)/Math.max(1,e.volume))*(e.volume/255)*this.masterVolume*this.sfxVolume;l.gain.value=g*m;let S=n.currentTime+(e.timeOffsetMs??0)/1e3,v=(e.looping?Number.POSITIVE_INFINITY:r.duration*1e3)+S*1e3;a.connect(d),f?(d.connect(f),f.connect(l)):d.connect(l),l.connect(this.graph.master),a.start(S),a.onended=()=>{this.channels[i].active=!1,this.activeSources.delete(i)};let M={channelIndex:i,entnum:e.entity,entchannel:Bn(e.channel),endTimeMs:v,source:a,panner:d,gain:l,baseGain:g,origin:c,attenuation:e.attenuation,occlusion:f?{scale:m,lowpassHz:u?.lowpassHz,filter:f}:u?{scale:m,lowpassHz:u.lowpassHz}:void 0};return this.channels[i]={entnum:e.entity,entchannel:Bn(e.channel),endTimeMs:v,isPlayer:e.entity===this.playerEntity,active:!0},this.activeSources.set(i,M),M}stop(e){let r=this.activeSources.get(e);r&&(r.source.stop(),this.channels[e].active=!1,this.activeSources.delete(e))}stopEntitySounds(e){for(let[r,n]of[...this.activeSources.entries()])n.entnum===e&&(n.source.stop(),this.channels[r].active=!1,this.activeSources.delete(r))}updateEntityPosition(e,r){for(let n of this.activeSources.values())if(n.entnum===e&&(this.applyOriginToPanner(n.panner,r),n.origin=r,this.resolveOcclusion)){let o=this.resolveOcclusion(this.listener,r,n.attenuation);this.applyOcclusion(n,o)}}positionedSound(e,r,n,o){return this.play({entity:0,channel:0,soundIndex:r,volume:n,attenuation:o,origin:e})}ambientSound(e,r,n){return this.play({entity:0,channel:0,soundIndex:r,volume:n,attenuation:0,origin:e,looping:!0})}getChannelState(e){return this.channels[e]}getDiagnostics(){return{activeChannels:this.activeSources.size,masterVolume:this.masterVolume,sfxVolume:this.sfxVolume,channels:[...this.channels],activeSounds:[...this.activeSources.values()].map(e=>({entnum:e.entnum,entchannel:e.entchannel,channelIndex:e.channelIndex,origin:e.origin,gain:e.gain.gain.value,baseGain:e.baseGain,attenuation:e.attenuation,maxDistance:e.panner.maxDistance,distanceModel:e.panner.distanceModel,occlusion:e.occlusion?{scale:e.occlusion.scale,lowpassHz:e.occlusion.lowpassHz}:void 0}))}}setUnderwater(e,r=400){let n=this.graph.filter;n&&(n.type="lowpass",n.Q.value=.707,n.frequency.value=e?r:2e4)}createPanner(e,r){let n=e.createPanner?e.createPanner():Object.assign(e.createGain(),{positionX:{value:this.listener.origin.x},positionY:{value:this.listener.origin.y},positionZ:{value:this.listener.origin.z}});return this.configurePanner(n,r)}configurePanner(e,r){let n=$t(r);return e.refDistance=80,e.maxDistance=Vo(r),e.rolloffFactor=n,e.distanceModel=r===0?"linear":"inverse",e.positionX.value=this.listener.origin.x,e.positionY.value=this.listener.origin.y,e.positionZ.value=this.listener.origin.z,e}applyOriginToPanner(e,r){e.positionX.value=r.x,e.positionY.value=r.y,e.positionZ.value=r.z}createOcclusionFilter(e,r){if(!e.createBiquadFilter)return;let n=e.createBiquadFilter();return n.type="lowpass",n.Q.value=.707,n.frequency.value=Qi(r,10,2e4),n}applyOcclusion(e,r){let n=qa(r?.gainScale??1);if(e.gain.gain.value=e.baseGain*n,e.occlusion?.filter){let o=r?.lowpassHz??2e4;e.occlusion.filter.frequency.value=Qi(o,10,2e4)}e.occlusion?(e.occlusion.scale=n,e.occlusion.lowpassHz=r?.lowpassHz):r&&(e.occlusion={scale:n,lowpassHz:r.lowpassHz})}},Qi=(t,e,r)=>Math.min(r,Math.max(e,t)),qa=t=>Qi(t,0,1);var $o=class{constructor(e){this.createElement=e.createElement,this.resolveSource=e.resolveSource??(async r=>r),this.volume=e.volume??1}async play(e,{loop:r=!0,restart:n=!1}={}){if(this.track===e&&this.element){this.element.loop=r,this.element.volume=this.volume,n&&(this.element.currentTime=0),(this.element.paused||n)&&await this.element.play();return}let o=await this.resolveSource(e),i=this.createElement();i.src=o,i.loop=r,i.volume=this.volume,i.currentTime=0,i.load(),await i.play(),this.element=i,this.track=e}pause(){!this.element||this.element.paused||this.element.pause()}async resume(){!this.element||!this.element.paused||await this.element.play()}stop(){this.element&&(this.element.pause(),this.element.currentTime=0,this.element=void 0,this.track=void 0)}setVolume(e){this.volume=e,this.element&&(this.element.volume=e)}getState(){let e=!!(this.element&&!this.element.paused&&!this.element.ended),r=!!this.element?.paused;return{track:this.track,paused:r,playing:e,volume:this.volume}}};var Qo=class{constructor(e){this.registry=e.registry,this.system=e.system,this.music=e.music}soundindex(e){return this.registry.registerName(e)}sound(e,r,n,o,i,s){this.system.play({entity:e,channel:r,soundIndex:n,volume:o,attenuation:i,timeOffsetMs:s})}positioned_sound(e,r,n,o){this.system.positionedSound(e,r,n,o)}loop_sound(e,r,n,o,i){this.system.play({entity:e,channel:r,soundIndex:n,volume:o,attenuation:i,looping:!0})}stop_entity_sounds(e){this.system.stopEntitySounds(e)}set_listener(e){this.system.setListener(e)}play_music(e,r=!0){return this.music?this.music.play(e,{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(e){this.music?.setVolume(e)}play_ambient(e,r,n){this.system.ambientSound(e,r,n)}play_channel(e){this.system.play({...e})}};function Ad(t){t.enable(t.DEPTH_TEST),t.depthFunc(t.LEQUAL),t.enable(t.CULL_FACE),t.cullFace(t.BACK),t.enable(t.BLEND),t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA)}function _d(t,e,r,n){for(let o of e){let i=t.getExtension(o);if(!i)throw new Error(`Missing required WebGL extension: ${o}`);n.set(o,i)}for(let o of r){let i=t.getExtension(o);i&&n.set(o,i)}}function Ya(t,e={}){let{contextAttributes:r,requiredExtensions:n=[],optionalExtensions:o=[]}=e,i=t.getContext("webgl2",r??{antialias:!0});if(!i)throw new Error("WebGL2 not supported or failed to initialize");Ad(i);let s=new Map;_d(i,n,o,s);let a=!1,c=new Set,l=new Set,d=m=>{a=!0,m.preventDefault();for(let f of c)f()},u=()=>{a=!1;for(let m of l)m()};return t.addEventListener("webglcontextlost",d),t.addEventListener("webglcontextrestored",u),{gl:i,extensions:s,isLost:()=>a,onLost(m){return c.add(m),()=>c.delete(m)},onRestored(m){return l.add(m),()=>l.delete(m)},dispose(){t.removeEventListener("webglcontextlost",d),t.removeEventListener("webglcontextrestored",u),c.clear(),l.clear(),s.clear()}}}function Ka(t,e,r){let n=t.createShader(e);if(!n)throw new Error("Failed to allocate shader");if(t.shaderSource(n,r),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS)){let i=t.getShaderInfoLog(n)??"Unknown shader compile failure";throw t.deleteShader(n),new Error(i)}return n}function wd(t,e,r,n){let o=t.createProgram();if(!o)throw new Error("Failed to allocate shader program");if(t.attachShader(o,e),t.attachShader(o,r),n)for(let[s,a]of Object.entries(n))t.bindAttribLocation(o,a,s);if(t.linkProgram(o),!t.getProgramParameter(o,t.LINK_STATUS)){let s=t.getProgramInfoLog(o)??"Unknown shader link failure";throw t.deleteProgram(o),new Error(s)}return o}var ge=class t{constructor(e,r){this.uniformLocations=new Map;this.attributeLocations=new Map;this.gl=e,this.program=r}static create(e,r,n){let o=Ka(e,e.VERTEX_SHADER,r.vertex),i=Ka(e,e.FRAGMENT_SHADER,r.fragment);try{let s=wd(e,o,i,n);return new t(e,s)}finally{e.deleteShader(o),e.deleteShader(i)}}use(){this.gl.useProgram(this.program)}getUniformLocation(e){if(!this.uniformLocations.has(e)){let r=this.gl.getUniformLocation(this.program,e);this.uniformLocations.set(e,r)}return this.uniformLocations.get(e)??null}getAttributeLocation(e){if(!this.attributeLocations.has(e)){let r=this.gl.getAttribLocation(this.program,e);this.attributeLocations.set(e,r)}return this.attributeLocations.get(e)??-1}dispose(){this.gl.deleteProgram(this.program),this.uniformLocations.clear(),this.attributeLocations.clear()}};function ja(t,e,r){return ge.create(t,e,r)}var xe=class{constructor(e,r=e.STATIC_DRAW,n){this.gl=e,this.target=n??e.ARRAY_BUFFER;let o=e.createBuffer();if(!o)throw new Error("Failed to allocate buffer");this.buffer=o,e.bindBuffer(this.target,this.buffer),e.bufferData(this.target,0,r)}bind(){this.gl.bindBuffer(this.target,this.buffer)}upload(e,r=this.gl.STATIC_DRAW){this.bind(),this.gl.bufferData(this.target,e,r)}update(e,r=0){this.bind(),this.gl.bufferSubData(this.target,r,e)}dispose(){this.gl.deleteBuffer(this.buffer)}},De=class extends xe{constructor(e,r=e.STATIC_DRAW){super(e,r,e.ELEMENT_ARRAY_BUFFER)}},Me=class{constructor(e){this.gl=e;let r=e.createVertexArray();if(!r)throw new Error("Failed to allocate vertex array object");this.vao=r}bind(){this.gl.bindVertexArray(this.vao)}configureAttributes(e,r){this.bind(),r&&r.bind();for(let n of e)this.gl.enableVertexAttribArray(n.index),this.gl.vertexAttribPointer(n.index,n.size,n.type,n.normalized??!1,n.stride??0,n.offset??0),n.divisor!==void 0&&this.gl.vertexAttribDivisor(n.index,n.divisor)}dispose(){this.gl.deleteVertexArray(this.vao)}},wr=class{constructor(e,r=e.TEXTURE_2D){this.width=0;this.height=0;this.gl=e,this.target=r;let n=e.createTexture();if(!n)throw new Error("Failed to allocate texture");this.texture=n}bind(e=0){this.gl.activeTexture(this.gl.TEXTURE0+e),this.gl.bindTexture(this.target,this.texture)}setParameters(e){this.bind(),e.wrapS!==void 0&&this.gl.texParameteri(this.target,this.gl.TEXTURE_WRAP_S,e.wrapS),e.wrapT!==void 0&&this.gl.texParameteri(this.target,this.gl.TEXTURE_WRAP_T,e.wrapT),e.minFilter!==void 0&&this.gl.texParameteri(this.target,this.gl.TEXTURE_MIN_FILTER,e.minFilter),e.magFilter!==void 0&&this.gl.texParameteri(this.target,this.gl.TEXTURE_MAG_FILTER,e.magFilter)}upload(e,r,n){this.width=e,this.height=r,this.uploadImage(0,this.gl.RGBA,e,r,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,n)}uploadImage(e,r,n,o,i,s,a,c){this.bind(),this.gl.texImage2D(this.target,e,r,n,o,i,s,a,c)}dispose(){this.gl.deleteTexture(this.texture)}},Lr=class{constructor(e){this.gl=e,this.target=e.TEXTURE_CUBE_MAP;let r=e.createTexture();if(!r)throw new Error("Failed to allocate cubemap texture");this.texture=r}bind(e=0){this.gl.activeTexture(this.gl.TEXTURE0+e),this.gl.bindTexture(this.target,this.texture)}setParameters(e){this.bind(),e.wrapS!==void 0&&this.gl.texParameteri(this.target,this.gl.TEXTURE_WRAP_S,e.wrapS),e.wrapT!==void 0&&this.gl.texParameteri(this.target,this.gl.TEXTURE_WRAP_T,e.wrapT),e.minFilter!==void 0&&this.gl.texParameteri(this.target,this.gl.TEXTURE_MIN_FILTER,e.minFilter),e.magFilter!==void 0&&this.gl.texParameteri(this.target,this.gl.TEXTURE_MAG_FILTER,e.magFilter)}uploadFace(e,r,n,o,i,s,a,c,l){this.bind(),this.gl.texImage2D(e,r,n,o,i,s,a,c,l)}dispose(){this.gl.deleteTexture(this.texture)}},Jo=class{constructor(e){this.gl=e;let r=e.createFramebuffer();if(!r)throw new Error("Failed to allocate framebuffer");this.framebuffer=r}bind(e=this.gl.FRAMEBUFFER){this.gl.bindFramebuffer(e,this.framebuffer)}attachTexture2D(e,r,n=0){this.bind(),this.gl.framebufferTexture2D(this.gl.FRAMEBUFFER,e,r.target,r.texture,n)}dispose(){this.gl.deleteFramebuffer(this.framebuffer)}};var Zi=4,Ji=7*Zi,es=[{index:0,size:3,type:5126,stride:Ji,offset:0},{index:1,size:2,type:5126,stride:Ji,offset:3*Zi},{index:2,size:2,type:5126,stride:Ji,offset:5*Zi}];function Ld(t,e){return{width:t,height:t,padding:e,data:new Uint8Array(t*t*4),cursorX:0,cursorY:0,rowHeight:0}}function Ed(t){let e=t.width*t.height;if(e===0)throw new Error("Invalid lightmap with zero area");let r=t.samples.byteLength/e;if(!Number.isInteger(r)||r<3||r>4)throw new Error("Unsupported lightmap channel count");return r}function zd(t,e,r){let n=Ed(r),o=t.width*4,i=e.x+t.padding,s=e.y+t.padding,a=0;for(let c=0;c<r.height;c++){let l=(s+c)*o+i*4;for(let d=0;d<r.width;d++){let u=l+d*4;t.data[u]=r.samples[a],t.data[u+1]=r.samples[a+1],t.data[u+2]=r.samples[a+2],t.data[u+3]=n===4?r.samples[a+3]:255,a+=n}}}function Cd(t,e,r){let n=e.width+r.lightmapPadding*2,o=e.height+r.lightmapPadding*2;if(n>r.atlasSize||o>r.atlasSize)throw new Error("Lightmap too large for atlas");for(let a of t){if(a.cursorX+n>a.width&&(a.cursorX=0,a.cursorY+=a.rowHeight+r.lightmapPadding,a.rowHeight=0),a.cursorY+o>a.height)continue;let c={atlasIndex:t.indexOf(a),x:a.cursorX,y:a.cursorY,width:e.width,height:e.height};return a.cursorX+=n+r.lightmapPadding,a.rowHeight=Math.max(a.rowHeight,o),{placement:c,atlas:a}}let i=Ld(r.atlasSize,r.lightmapPadding);t.push(i);let s={atlasIndex:t.length-1,x:0,y:0,width:e.width,height:e.height};return i.cursorX=n+r.lightmapPadding,i.rowHeight=o,{placement:s,atlas:i}}function Zo(t){return t instanceof Float32Array?t:new Float32Array(t)}function Td(t,e){if(!t){let n=new Uint16Array(e);for(let o=0;o<e;o++)n[o]=o;return n}return t instanceof Uint16Array?t:new Uint16Array(t)}function Id(t,e){let r=new Float32Array(t.length);for(let n=0;n<t.length;n+=2)r[n]=e.offset[0]+t[n]*e.scale[0],r[n+1]=e.offset[1]+t[n+1]*e.scale[1];return r}function Fd(t,e){let r=Zo(t.vertices),n=Zo(t.textureCoords),o=e?Id(Zo(t.lightmapCoords??t.textureCoords),e):Zo(t.lightmapCoords??new Float32Array(n.length)),i=r.length/3;if(n.length/2!==i)throw new Error("Texture coordinates count mismatch");if(o.length/2!==i)throw new Error("Lightmap coordinates count mismatch");let s=new Float32Array(i*7);for(let a=0;a<i;a++){let c=a*3,l=a*2,d=a*7;s[d]=r[c],s[d+1]=r[c+1],s[d+2]=r[c+2],s[d+3]=n[l],s[d+4]=n[l+1],s[d+5]=o[l],s[d+6]=o[l+1]}return s}function $a(t){let e=[];for(let r=0;r<t.faces.length;r++){let n=t.faces[r];if(n.texInfo<0)continue;let o=t.texInfo[n.texInfo],i=[],s=[],a=[];for(let m=0;m<n.numEdges;m++){let f=t.surfEdges[n.firstEdge+m],h=t.edges[Math.abs(f)],y=f>=0?h.vertices[0]:h.vertices[1],p=t.vertices[y];i.push(p[0],p[1],p[2]);let g=p[0]*o.s[0]+p[1]*o.s[1]+p[2]*o.s[2]+o.sOffset,S=p[0]*o.t[0]+p[1]*o.t[1]+p[2]*o.t[2]+o.tOffset;s.push(g,S),a.push(g,S)}let c=[],l=i.length/3;for(let m=1;m<l-1;m++)c.push(0,m,m+1);let d,u=t.lightMapInfo[r];if(u){let m=1/0,f=-1/0,h=1/0,y=-1/0;for(let b=0;b<s.length;b+=2){let A=s[b],_=s[b+1];A<m&&(m=A),A>f&&(f=A),_<h&&(h=_),_>y&&(y=_)}let p=Math.floor(m/16),g=Math.floor(h/16),S=Math.ceil(f/16)-p+1,v=Math.ceil(y/16)-g+1,M=eo(n,t.lightMaps,u);if(M&&M.length===S*v*3){d={width:S,height:v,samples:M};for(let b=0;b<a.length;b+=2)a[b]=s[b]/16-p+.5,a[b+1]=s[b+1]/16-g+.5}}e.push({vertices:new Float32Array(i),textureCoords:new Float32Array(s),lightmapCoords:new Float32Array(a),indices:new Uint16Array(c),texture:o.texture,surfaceFlags:o.flags,lightmap:d})}return e}function Qa(t,e,r={}){let n={atlasSize:r.atlasSize??1024,lightmapPadding:r.lightmapPadding??1},o=[],i=new Map;e.forEach((c,l)=>{if(!c.lightmap)return;let{placement:d,atlas:u}=Cd(o,c.lightmap,n);zd(u,d,c.lightmap),i.set(l,{atlasIndex:d.atlasIndex,offset:[(d.x+n.lightmapPadding)/n.atlasSize,(d.y+n.lightmapPadding)/n.atlasSize],scale:[d.width/n.atlasSize,d.height/n.atlasSize]})});let s=o.map(c=>{let l=new wr(t);return l.setParameters({wrapS:t.CLAMP_TO_EDGE,wrapT:t.CLAMP_TO_EDGE,minFilter:t.LINEAR,magFilter:t.LINEAR}),l.uploadImage(0,t.RGBA,c.width,c.height,0,t.RGBA,t.UNSIGNED_BYTE,c.data),{texture:l,width:c.width,height:c.height,pixels:c.data}});return{surfaces:e.map((c,l)=>{let d=i.get(l),u=Fd(c,d),m=Td(c.indices,u.length/7),f=new xe(t,t.STATIC_DRAW,t.ARRAY_BUFFER);f.upload(u);let h=new De(t,t.STATIC_DRAW);h.upload(m);let y=new Me(t);return y.configureAttributes(es,f),{vao:y,vertexBuffer:f,indexBuffer:h,indexCount:m.length,vertexCount:u.length/7,texture:c.texture,surfaceFlags:c.surfaceFlags??Pr,lightmap:d,vertexData:u,indexData:m}}),lightmaps:s}}function Er(t){let{normal:e,distance:r}=t,n=Math.sqrt(e.x*e.x+e.y*e.y+e.z*e.z);if(n===0)return t;let o=1/n;return{normal:{x:e.x*o,y:e.y*o,z:e.z*o},distance:r*o}}function Ja(t){if(t.length!==16)throw new Error("View-projection matrix must contain 16 elements");let e=t[0],r=t[4],n=t[8],o=t[12],i=t[1],s=t[5],a=t[9],c=t[13],l=t[2],d=t[6],u=t[10],m=t[14],f=t[3],h=t[7],y=t[11],p=t[15];return[Er({normal:{x:f+e,y:h+r,z:y+n},distance:p+o}),Er({normal:{x:f-e,y:h-r,z:y-n},distance:p-o}),Er({normal:{x:f+i,y:h+s,z:y+a},distance:p+c}),Er({normal:{x:f-i,y:h-s,z:y-a},distance:p-c}),Er({normal:{x:f+l,y:h+d,z:y+u},distance:p+m}),Er({normal:{x:f-l,y:h-d,z:y-u},distance:p-m})]}function Pd(t,e){return t.normal.x*e.x+t.normal.y*e.y+t.normal.z*e.z+t.distance}function kn(t,e,r){for(let n of r){let o=n.normal.x>=0?e.x:t.x,i=n.normal.y>=0?e.y:t.y,s=n.normal.z>=0?e.z:t.z;if(Pd(n,{x:o,y:i,z:s})<0)return!1}return!0}function Za(t){return t<0}function ec(t){return-t-1}function tc(t,e){return t.normal[0]*e.x+t.normal[1]*e.y+t.normal[2]*e.z-t.dist}function Rd(t,e,r){if(!t||e<0||r<0)return!0;let n=Math.ceil(t.numClusters/8),o=t.clusters[e].pvs,i=Math.floor(r/8),s=1<<r%8;return i<0||i>=n?!1:(o[i]&s)!==0}function Bd(t,e){let r={x:t.mins[0],y:t.mins[1],z:t.mins[2]},n={x:t.maxs[0],y:t.maxs[1],z:t.maxs[2]};return kn(r,n,e)}function rs(t,e){let r=0;for(;r>=0;){let n=t.nodes[r],o=t.planes[n.planeIndex],s=tc(o,e)>=0?0:1,a=n.children[s];if(Za(a))return ec(a);r=a}return-1}function kd(t,e){let r=t.leafs[e],n=[];for(let o=0;o<r.numLeafFaces;o+=1)n.push(t.leafLists.leafFaces[e][o]);return n}function ts(t,e,r,n,o,i,s){if(Za(e)){let m=ec(e),f=t.leafs[m];if(!Rd(t.visibility,o,f.cluster)||!Bd(f,n))return;let h={x:(f.mins[0]+f.maxs[0])*.5,y:(f.mins[1]+f.maxs[1])*.5,z:(f.mins[2]+f.maxs[2])*.5},y=h.x-r.x,p=h.y-r.y,g=h.z-r.z,S=-(y*y+p*p+g*g);for(let v of kd(t,m))s.has(v)||(s.add(v),i.push({faceIndex:v,leafIndex:m,sortKey:S}));return}let a=t.nodes[e],c=t.planes[a.planeIndex],l=tc(c,r),d=l>=0?a.children[0]:a.children[1],u=l>=0?a.children[1]:a.children[0];kn({x:a.mins[0],y:a.mins[1],z:a.mins[2]},{x:a.maxs[0],y:a.maxs[1],z:a.maxs[2]},n)&&(ts(t,d,r,n,o,i,s),ts(t,u,r,n,o,i,s))}function rc(t,e,r){let n=rs(t,e),o=n>=0?t.leafs[n].cluster:-1,i=[];return ts(t,0,e,r,o,i,new Set),i}var ns=`#version 300 es
|
|
141
|
+
ïBçϧmÙIólÜoëVb¦¯éWÇû3`});var Tc={a:Ft};this.setModule=E=>{t.setModule(ct,E)},this.getModule=()=>t.getModule(ct),this.instantiate=()=>(this.getModule().then(E=>WebAssembly.instantiate(E,Tc)).then(E=>{let Ie=E.exports;kn(Ie),p=Ie.l,y(),Cc(Ie),r()}),this.ready=new Promise(E=>{r=E}).then(()=>{this.HEAP=p.buffer,this.malloc=As,this.free=Is,this.create_decoder=Pr,this.send_setup=_s,this.init_dsp=ws,this.decode_packets=Ls,this.destroy_decoder=Es}),this)}function qt(){return this._init=()=>new this._WASMAudioDecoderCommon().instantiate(this._EmscriptenWASM,this._module).then(t=>{this._common=t,this._input=this._common.allocateTypedArray(this._inputSize,Uint8Array),this._firstPage=!0,this._inputLen=this._common.allocateTypedArray(1,Uint32Array),this._outputBufferPtr=this._common.allocateTypedArray(1,Uint32Array),this._channels=this._common.allocateTypedArray(1,Uint32Array),this._sampleRate=this._common.allocateTypedArray(1,Uint32Array),this._samplesDecoded=this._common.allocateTypedArray(1,Uint32Array);let e=256;this._errors=this._common.allocateTypedArray(e,Uint32Array),this._errorsLength=this._common.allocateTypedArray(1,Int32Array),this._frameNumber=0,this._inputBytes=0,this._outputSamples=0,this._decoder=this._common.wasm.create_decoder(this._input.ptr,this._inputLen.ptr,this._outputBufferPtr.ptr,this._channels.ptr,this._sampleRate.ptr,this._samplesDecoded.ptr,this._errors.ptr,this._errorsLength.ptr,e)}),Object.defineProperty(this,"ready",{enumerable:!0,get:()=>this._ready}),this.reset=()=>(this.free(),this._init()),this.free=()=>{this._common.wasm.destroy_decoder(this._decoder),this._common.free()},this.sendSetupHeader=t=>{this._input.buf.set(t),this._inputLen.buf[0]=t.length,this._common.wasm.send_setup(this._decoder,this._firstPage),this._firstPage=!1},this.initDsp=()=>{this._common.wasm.init_dsp(this._decoder)},this.decodePackets=t=>{let e=[],r=0,n=[];for(let o=0;o<t.length;o++){let i=t[o];this._input.buf.set(i),this._inputLen.buf[0]=i.length,this._common.wasm.decode_packets(this._decoder);let s=this._samplesDecoded.buf[0],a=[],c=new Uint32Array(this._common.wasm.HEAP,this._outputBufferPtr.buf[0],this._channels.buf[0]);for(let l=0;l<this._channels.buf[0];l++){let d=new Float32Array(s);s&&d.set(new Float32Array(this._common.wasm.HEAP,c[l],s)),a.push(d)}e.push(a),r+=s,this._frameNumber++,this._inputBytes+=i.length,this._outputSamples+=s;for(let l=0;l<this._errorsLength.buf;l+=2){let d=this._common.codeToString(this._errors.buf[l]),u=this._common.codeToString(this._errors.buf[l+1]);n.push({message:d+" vorbis_synthesis"+u,frameLength:i.length,frameNumber:this._frameNumber,inputBytes:this._inputBytes,outputSamples:this._outputSamples})}this._errorsLength.buf[0]=0}return this._WASMAudioDecoderCommon.getDecodedAudioMultiChannel(n,e,this._channels.buf[0],r,this._sampleRate.buf[0],16)},this._isWebWorker=qt.isWebWorker,this._WASMAudioDecoderCommon=qt.WASMAudioDecoderCommon||Q,this._EmscriptenWASM=qt.EmscriptenWASM||ct,this._module=qt.module,this._inputSize=128*1024,this._ready=this._init(),this}var Bo=Symbol(),lt=class{constructor(){this._onCodec=e=>{if(e!=="vorbis")throw new Error("@wasm-audio-decoders/ogg-vorbis does not support this codec "+e)},new Q,this._init(),this._ready=this[Bo](qt)}_init(){this._vorbisSetupInProgress=!0,this._totalSamplesDecoded=0,this._codecParser=new Ba("audio/ogg",{onCodec:this._onCodec,enableFrameCRC32:!1})}async[Bo](e){if(this._decoder){let r=this._decoder;await r.ready.then(()=>r.free())}return this._decoder=new e,this._decoder.ready}get ready(){return this._ready}async reset(){return this._init(),this._decoder.reset()}free(){this._decoder.free()}async decodeOggPages(e){let r=[];for(let i=0;i<e.length;i++){let s=e[i];if(this._vorbisSetupInProgress&&(s[Ro][0]===1&&this._decoder.sendSetupHeader(s[Ro]),s[To].length)){let a=s[To][0][Oa];this._decoder.sendSetupHeader(a[ka]),this._decoder.initDsp(),this._vorbisSetupInProgress=!1}r.push(...s[To].map(a=>a[Ro]))}let n=await this._decoder.decodePackets(r);this._totalSamplesDecoded+=n.samplesDecoded;let o=e[e.length-1];if(o&&o[Da]){let i=this._totalSamplesDecoded-o[Ha];if(i>0){for(let s=0;s<n.channelData.length;s++)n.channelData[s]=n.channelData[s].subarray(0,n.samplesDecoded-i);n.samplesDecoded-=i,this._totalSamplesDecoded-=i}}return n}async decode(e){return this.decodeOggPages([...this._codecParser.parseChunk(e)])}async flush(){let e=await this.decodeOggPages([...this._codecParser.flush()]);return await this.reset(),e}async decodeFile(e){let r=await this.decodeOggPages([...this._codecParser.parseAll(e)]);return await this.reset(),r}};var Yi=class extends sr{constructor(e){super(e,"ogg-vorbis-decoder",qt,ct)}async sendSetupHeader(e){return this.postToDecoder("sendSetupHeader",e)}async initDsp(){return this.postToDecoder("initDsp")}async decodePackets(e){return this.postToDecoder("decodePackets",e)}},Pn=class extends lt{constructor(){super(),this._ready=super[Bo](Yi)}async free(){await this._decoder.free()}terminate(){this._decoder.terminate()}};io(lt,"OggVorbisDecoder");io(Pn,"OggVorbisDecoderWebWorker");var qi=class extends Error{constructor(e){super(e),this.name="OggDecodeError"}};async function Oo(t,e=new lt){await e.ready;let r=await e.decode(new Uint8Array(t)),n=r.errors;if(n&&n.length>0)throw new qi(n.map(o=>o.message).join("; "));return{sampleRate:r.sampleRate,channels:r.channelData.length,bitDepth:r.bitDepth,channelData:r.channelData}}var Fn=class extends Error{constructor(e){super(e),this.name="AudioRegistryError"}},Ar=class{constructor(e,r={}){this.vfs=e;this.refCounts=new Map;this.cache=new ft(r.cacheSize??64)}get size(){return this.cache.size}async load(e){let r=e.toLowerCase(),n=this.cache.get(r);if(n)return this.refCounts.set(r,(this.refCounts.get(r)??0)+1),n;let i=(await this.vfs.readFile(e)).slice().buffer,s=await this.decodeByExtension(e,i);return this.cache.set(r,s),this.refCounts.set(r,1),s}release(e){let r=e.toLowerCase(),n=this.refCounts.get(r)??0;n<=1?(this.cache.delete(r),this.refCounts.delete(r)):this.refCounts.set(r,n-1)}clearAll(){this.cache.clear(),this.refCounts.clear()}async decodeByExtension(e,r){let n=e.toLowerCase();if(n.endsWith(".wav")){let o=oo(r),i=o.channels,s=Array.from({length:i},()=>new Float32Array(o.samples.length/i));for(let a=0;a<o.samples.length;a+=1)s[a%i][Math.floor(a/i)]=o.samples[a];return{sampleRate:o.sampleRate,channels:i,bitDepth:o.bitsPerSample,channelData:s}}if(n.endsWith(".ogg")||n.endsWith(".oga"))return Oo(r);throw new Fn(`Unsupported audio format: ${e}`)}};var bd="quake2ts-pak-indexes",vd="pak-indexes";function Na(){if(typeof indexedDB<"u")return indexedDB;if(typeof window<"u"&&"indexedDB"in window)return window.indexedDB;if(typeof globalThis<"u"&&"indexedDB"in globalThis)return globalThis.indexedDB}function Cn(t,e){let r=Na();return r?new Promise((n,o)=>{let i=r.open(t,1);i.onupgradeneeded=()=>{let{result:s}=i;s.objectStoreNames.contains(e)||s.createObjectStore(e,{keyPath:"key"})},i.onerror=()=>o(i.error??new Error("Unknown IndexedDB error")),i.onsuccess=()=>n(i.result)}):Promise.reject(new Error("IndexedDB is not available in this environment"))}function Tn(t,e,r,n){return new Promise((o,i)=>{let a=t.transaction(e,r).objectStore(e),c=n(a);c.onsuccess=()=>o(c.result),c.onerror=()=>i(c.error??new Error("IndexedDB transaction error"))})}function ji(t,e){return`${re(t)}:${e.toString(16)}`}function Sd(t){return t.map(e=>({...e}))}var Do=class{constructor(e=bd,r=vd){this.dbName=e;this.storeName=r}get isSupported(){return!!Na()}async persist(e){if(!this.isSupported)return;let r=e.validate(),n={...r,key:ji(e.name,r.checksum),name:e.name,size:e.size,persistedAt:Date.now(),entries:Sd(r.entries)},o=await Cn(this.dbName,this.storeName);return await Tn(o,this.storeName,"readwrite",i=>i.put(n)),o.close(),n}async find(e,r){if(!this.isSupported)return;let n=await Cn(this.dbName,this.storeName),o=r!==void 0?ji(e,r):void 0,i=await Tn(n,this.storeName,"readonly",s=>o?s.get(o):s.getAll());if(n.close(),!!i){if(Array.isArray(i)){let s=re(e),a=i.filter(c=>re(c.name)===s);return a.length===0?void 0:a.sort((c,l)=>l.persistedAt-c.persistedAt)[0]}return i}}async remove(e,r){if(!this.isSupported)return!1;let n=await Cn(this.dbName,this.storeName),o=r!==void 0?ji(e,r):void 0,i=await Tn(n,this.storeName,"readwrite",s=>{if(o)return s.delete(o);let a=`${re(e)}:`;return s.delete(IDBKeyRange.bound(a,`${a}\uFFFF`,!1,!0))});return n.close(),typeof i=="number"?i>0:!0}async clear(){if(!this.isSupported)return;let e=await Cn(this.dbName,this.storeName);await Tn(e,this.storeName,"readwrite",r=>r.clear()),e.close()}async list(){if(!this.isSupported)return[];let e=await Cn(this.dbName,this.storeName),r=await Tn(e,this.storeName,"readonly",n=>n.getAll());return e.close(),r.sort((n,o)=>o.persistedAt-n.persistedAt)}};var jt=class extends Error{constructor(r,n){super(n??`Missing dependencies: ${r.join(", ")}`);this.missing=r;this.name="AssetDependencyError"}},Rn=class{constructor(){this.nodes=new Map}register(e,r=[]){let n=this.nodes.get(e)??{dependencies:new Set,loaded:!1};r.forEach(o=>n.dependencies.add(o)),this.nodes.set(e,n),r.forEach(o=>{this.nodes.has(o)||this.nodes.set(o,{dependencies:new Set,loaded:!1})})}markLoaded(e){let r=this.nodes.get(e)??{dependencies:new Set,loaded:!1},n=this.getMissingDependencies(e,r);if(n.length>0)throw new jt(n,`Asset ${e} is missing dependencies: ${n.join(", ")}`);r.loaded=!0,this.nodes.set(e,r)}markUnloaded(e){let r=this.nodes.get(e);r&&(r.loaded=!1)}isLoaded(e){return this.nodes.get(e)?.loaded??!1}missingDependencies(e){let r=this.nodes.get(e);return r?this.getMissingDependencies(e,r):[]}reset(){this.nodes.clear()}getMissingDependencies(e,r){let n=[];for(let o of r.dependencies)this.nodes.get(o)?.loaded||n.push(o);return n}},ko=class{constructor(e,r={}){this.vfs=e;this.textures=new ir({capacity:r.textureCacheCapacity??128}),this.audio=new Ar(e,{cacheSize:r.audioCacheSize??64}),this.dependencyTracker=r.dependencyTracker??new Rn,this.md2=new rr(e),this.md3=new nr(e),this.sprite=new or(e)}isAssetLoaded(e,r){return this.dependencyTracker.isLoaded(this.makeKey(e,r))}registerTexture(e,r){this.textures.set(e,r);let n=this.makeKey("texture",e);this.dependencyTracker.register(n),this.dependencyTracker.markLoaded(n)}async loadSound(e){let r=await this.audio.load(e),n=this.makeKey("sound",e);return this.dependencyTracker.register(n),this.dependencyTracker.markLoaded(n),r}async loadMd2Model(e,r=[]){let n=this.makeKey("model",e),o=r.map(a=>this.makeKey("texture",a));this.dependencyTracker.register(n,o);let i=this.dependencyTracker.missingDependencies(n);if(i.length>0)throw new jt(i,`Asset ${n} is missing dependencies: ${i.join(", ")}`);let s=await this.md2.load(e);return this.dependencyTracker.markLoaded(n),s}async loadMd3Model(e,r=[]){let n=this.makeKey("model",e),o=r.map(a=>this.makeKey("texture",a));this.dependencyTracker.register(n,o);let i=this.dependencyTracker.missingDependencies(n);if(i.length>0)throw new jt(i,`Asset ${n} is missing dependencies: ${i.join(", ")}`);let s=await this.md3.load(e);return this.dependencyTracker.markLoaded(n),s}async loadSprite(e){let r=this.makeKey("sprite",e);this.dependencyTracker.register(r);let n=await this.sprite.load(e);return this.dependencyTracker.markLoaded(r),n}resetForLevelChange(){this.textures.clear(),this.audio.clearAll(),this.dependencyTracker.reset()}makeKey(e,r){return`${e}:${re(r)}`}};var $i=32,Ho=(u=>(u[u.Auto=0]="Auto",u[u.Weapon=1]="Weapon",u[u.Voice=2]="Voice",u[u.Item=3]="Item",u[u.Body=4]="Body",u[u.Aux=5]="Aux",u[u.Footstep=6]="Footstep",u[u.Aux3=7]="Aux3",u[u.NoPhsAdd=8]="NoPhsAdd",u[u.Reliable=16]="Reliable",u[u.ForcePos=32]="ForcePos",u))(Ho||{}),Va=-1,No=0,Ua=1,Ga=2,Wa=3,_r=80,Xa=.003;function $t(t){return t===3?t*.001:t*5e-4}function Vo(t){let e=$t(t);return e<=0?Number.POSITIVE_INFINITY:80+1/e}var Uo=class{constructor(e){this.factory=e}getContext(){return this.context||(this.context=this.factory()),this.context}async resume(){let e=this.getContext();e.state==="suspended"&&await e.resume()}getState(){return this.context?.state??"suspended"}};function Go(t){let e=t.getContext(),r=e.createGain();r.gain.value=1;let n=e.createDynamicsCompressor(),o=e.createBiquadFilter?.();return o?(o.type="lowpass",o.frequency.value=2e4,o.Q.value=.707,r.connect(o),o.connect(n)):r.connect(n),n.connect(e.destination),{context:e,master:r,compressor:n,filter:o}}var Wo=class{constructor(e=new er){this.configStrings=e;this.buffers=new Map}registerName(e){return this.configStrings.soundIndex(e)}register(e,r){let n=this.registerName(e);return this.buffers.set(n,r),n}find(e){return this.configStrings.findSoundIndex(e)}get(e){return this.buffers.get(e)}has(e){return this.buffers.has(e)}};var Xo=class{constructor(e){this.vfs=e.vfs,this.registry=e.registry,this.contextController=e.context,this.soundRoot=e.soundRoot??"sound/",this.decodeAudio=e.decodeAudio??((r,n)=>{if(!r.decodeAudioData)throw new Error("decodeAudioData is not available on the provided audio context");return r.decodeAudioData(n)})}async precache(e){let r=[...new Set(e.map(i=>this.normalize(i)))],n={loaded:[],skipped:[],missing:[],errors:{}},o=this.contextController.getContext();for(let i of r)try{let s=this.registry.find(i);if(s!==void 0&&this.registry.has(s)){n.skipped.push(i);continue}if(!this.vfs.stat(i)){n.missing.push(i);continue}let l=(await this.vfs.readFile(i)).slice().buffer,d=await this.decodeAudio(o,l);this.registry.register(i,d),n.loaded.push(i)}catch(s){let a=s instanceof Error?s:new Error(String(s));n.errors[i]=a}return n}normalize(e){let r=re(e.replace(/^\//,""));return r.startsWith(this.soundRoot)?r:re(`${this.soundRoot}${r}`)}};var Md=7,Bn=t=>t&Md;function Ko(t){return Array.from({length:32},()=>({entnum:0,entchannel:0,endTimeMs:0,isPlayer:!1,active:!1})).map(e=>({...e,isPlayer:e.entnum===t}))}function Yo(t,e,r,n){if(r<0)throw new Error("pickChannel: entchannel must be non-negative");let o=Bn(r),i=-1,s=Number.POSITIVE_INFINITY;for(let a=0;a<t.length;a+=1){let c=t[a],l=Bn(c.entchannel);if(o!==0&&c.entnum===e&&l===o){i=a;break}if(c.active&&c.entnum===n.playerEntity&&e!==n.playerEntity)continue;let d=c.endTimeMs-n.nowMs;(i===-1||d<s)&&(s=d,i=a)}return i===-1?void 0:i}function qo(t,e,r,n,o){if(o)return{left:r,right:r,distanceComponent:0};let i=Cs(t,e.origin),s=mi(i),a=He(i),c=s-80;c<0&&(c=0),c*=$t(n);let l=fi(e.right,a),d=e.mono??!1,u=d||n===0?1:.5*(1+l),f=d||n===0?1:.5*(1-l),m=Math.max(0,Math.floor(r*(1-c)*u));return{left:Math.max(0,Math.floor(r*(1-c)*f)),right:m,distanceComponent:c}}var jo=class{constructor(e){this.activeSources=new Map;this.contextController=e.context,this.registry=e.registry,this.playerEntity=e.playerEntity,this.channels=Ko(e.playerEntity),this.listener=e.listener??{origin:Fs,right:{x:1,y:0,z:0}},this.sfxVolume=e.sfxVolume??1,this.masterVolume=e.masterVolume??1,this.resolveOcclusion=e.resolveOcclusion,this.graph=Go(this.contextController),this.graph.master.gain.value=this.masterVolume}setListener(e){this.listener=e}setMasterVolume(e){this.masterVolume=e,this.graph.master.gain.value=e}setSfxVolume(e){this.sfxVolume=e}async ensureRunning(){await this.contextController.resume()}play(e){let r=this.registry.get(e.soundIndex);if(!r)return;let n=this.graph.context,o=n.currentTime*1e3,i=Yo(this.channels,e.entity,e.channel,{nowMs:o,playerEntity:this.playerEntity});if(i===void 0)return;let s=this.activeSources.get(i);s&&(s.source.onended=null,s.source.stop(),this.activeSources.delete(i));let a=n.createBufferSource();a.buffer=r,a.loop=e.looping??!1;let c=e.origin??this.listener.origin,l=n.createGain(),d=this.createPanner(n,e.attenuation),u=this.resolveOcclusion?.(this.listener,c,e.attenuation),f=Ka(u?.gainScale??1),m=this.resolveOcclusion?this.createOcclusionFilter(n,u?.lowpassHz??2e4):void 0;this.applyOriginToPanner(d,c);let p=e.entity===this.playerEntity,y=qo(c,this.listener,e.volume,e.attenuation,p),g=(e.volume===0?0:Math.max(y.left,y.right)/Math.max(1,e.volume))*(e.volume/255)*this.masterVolume*this.sfxVolume;l.gain.value=g*f;let S=n.currentTime+(e.timeOffsetMs??0)/1e3,b=(e.looping?Number.POSITIVE_INFINITY:r.duration*1e3)+S*1e3;a.connect(d),m?(d.connect(m),m.connect(l)):d.connect(l),l.connect(this.graph.master),a.start(S),a.onended=()=>{this.channels[i].active=!1,this.activeSources.delete(i)};let M={channelIndex:i,entnum:e.entity,entchannel:Bn(e.channel),endTimeMs:b,source:a,panner:d,gain:l,baseGain:g,origin:c,attenuation:e.attenuation,occlusion:m?{scale:f,lowpassHz:u?.lowpassHz,filter:m}:u?{scale:f,lowpassHz:u.lowpassHz}:void 0};return this.channels[i]={entnum:e.entity,entchannel:Bn(e.channel),endTimeMs:b,isPlayer:e.entity===this.playerEntity,active:!0},this.activeSources.set(i,M),M}stop(e){let r=this.activeSources.get(e);r&&(r.source.stop(),this.channels[e].active=!1,this.activeSources.delete(e))}stopEntitySounds(e){for(let[r,n]of[...this.activeSources.entries()])n.entnum===e&&(n.source.stop(),this.channels[r].active=!1,this.activeSources.delete(r))}updateEntityPosition(e,r){for(let n of this.activeSources.values())if(n.entnum===e&&(this.applyOriginToPanner(n.panner,r),n.origin=r,this.resolveOcclusion)){let o=this.resolveOcclusion(this.listener,r,n.attenuation);this.applyOcclusion(n,o)}}positionedSound(e,r,n,o){return this.play({entity:0,channel:0,soundIndex:r,volume:n,attenuation:o,origin:e})}ambientSound(e,r,n){return this.play({entity:0,channel:0,soundIndex:r,volume:n,attenuation:0,origin:e,looping:!0})}getChannelState(e){return this.channels[e]}getDiagnostics(){return{activeChannels:this.activeSources.size,masterVolume:this.masterVolume,sfxVolume:this.sfxVolume,channels:[...this.channels],activeSounds:[...this.activeSources.values()].map(e=>({entnum:e.entnum,entchannel:e.entchannel,channelIndex:e.channelIndex,origin:e.origin,gain:e.gain.gain.value,baseGain:e.baseGain,attenuation:e.attenuation,maxDistance:e.panner.maxDistance,distanceModel:e.panner.distanceModel,occlusion:e.occlusion?{scale:e.occlusion.scale,lowpassHz:e.occlusion.lowpassHz}:void 0}))}}setUnderwater(e,r=400){let n=this.graph.filter;n&&(n.type="lowpass",n.Q.value=.707,n.frequency.value=e?r:2e4)}createPanner(e,r){let n=e.createPanner?e.createPanner():Object.assign(e.createGain(),{positionX:{value:this.listener.origin.x},positionY:{value:this.listener.origin.y},positionZ:{value:this.listener.origin.z}});return this.configurePanner(n,r)}configurePanner(e,r){let n=$t(r);return e.refDistance=80,e.maxDistance=Vo(r),e.rolloffFactor=n,e.distanceModel=r===0?"linear":"inverse",e.positionX.value=this.listener.origin.x,e.positionY.value=this.listener.origin.y,e.positionZ.value=this.listener.origin.z,e}applyOriginToPanner(e,r){e.positionX.value=r.x,e.positionY.value=r.y,e.positionZ.value=r.z}createOcclusionFilter(e,r){if(!e.createBiquadFilter)return;let n=e.createBiquadFilter();return n.type="lowpass",n.Q.value=.707,n.frequency.value=Qi(r,10,2e4),n}applyOcclusion(e,r){let n=Ka(r?.gainScale??1);if(e.gain.gain.value=e.baseGain*n,e.occlusion?.filter){let o=r?.lowpassHz??2e4;e.occlusion.filter.frequency.value=Qi(o,10,2e4)}e.occlusion?(e.occlusion.scale=n,e.occlusion.lowpassHz=r?.lowpassHz):r&&(e.occlusion={scale:n,lowpassHz:r.lowpassHz})}},Qi=(t,e,r)=>Math.min(r,Math.max(e,t)),Ka=t=>Qi(t,0,1);var $o=class{constructor(e){this.createElement=e.createElement,this.resolveSource=e.resolveSource??(async r=>r),this.volume=e.volume??1}async play(e,{loop:r=!0,restart:n=!1}={}){if(this.track===e&&this.element){this.element.loop=r,this.element.volume=this.volume,n&&(this.element.currentTime=0),(this.element.paused||n)&&await this.element.play();return}let o=await this.resolveSource(e),i=this.createElement();i.src=o,i.loop=r,i.volume=this.volume,i.currentTime=0,i.load(),await i.play(),this.element=i,this.track=e}pause(){!this.element||this.element.paused||this.element.pause()}async resume(){!this.element||!this.element.paused||await this.element.play()}stop(){this.element&&(this.element.pause(),this.element.currentTime=0,this.element=void 0,this.track=void 0)}setVolume(e){this.volume=e,this.element&&(this.element.volume=e)}getState(){let e=!!(this.element&&!this.element.paused&&!this.element.ended),r=!!this.element?.paused;return{track:this.track,paused:r,playing:e,volume:this.volume}}};var Qo=class{constructor(e){this.registry=e.registry,this.system=e.system,this.music=e.music}soundindex(e){return this.registry.registerName(e)}sound(e,r,n,o,i,s){this.system.play({entity:e,channel:r,soundIndex:n,volume:o,attenuation:i,timeOffsetMs:s})}positioned_sound(e,r,n,o){this.system.positionedSound(e,r,n,o)}loop_sound(e,r,n,o,i){this.system.play({entity:e,channel:r,soundIndex:n,volume:o,attenuation:i,looping:!0})}stop_entity_sounds(e){this.system.stopEntitySounds(e)}set_listener(e){this.system.setListener(e)}play_music(e,r=!0){return this.music?this.music.play(e,{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(e){this.music?.setVolume(e)}play_ambient(e,r,n){this.system.ambientSound(e,r,n)}play_channel(e){this.system.play({...e})}};function Ad(t){t.enable(t.DEPTH_TEST),t.depthFunc(t.LEQUAL),t.enable(t.CULL_FACE),t.cullFace(t.BACK),t.enable(t.BLEND),t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA)}function _d(t,e,r,n){for(let o of e){let i=t.getExtension(o);if(!i)throw new Error(`Missing required WebGL extension: ${o}`);n.set(o,i)}for(let o of r){let i=t.getExtension(o);i&&n.set(o,i)}}function Ya(t,e={}){let{contextAttributes:r,requiredExtensions:n=[],optionalExtensions:o=[]}=e,i=t.getContext("webgl2",r??{antialias:!0});if(!i)throw new Error("WebGL2 not supported or failed to initialize");Ad(i);let s=new Map;_d(i,n,o,s);let a=!1,c=new Set,l=new Set,d=f=>{a=!0,f.preventDefault();for(let m of c)m()},u=()=>{a=!1;for(let f of l)f()};return t.addEventListener("webglcontextlost",d),t.addEventListener("webglcontextrestored",u),{gl:i,extensions:s,isLost:()=>a,onLost(f){return c.add(f),()=>c.delete(f)},onRestored(f){return l.add(f),()=>l.delete(f)},dispose(){t.removeEventListener("webglcontextlost",d),t.removeEventListener("webglcontextrestored",u),c.clear(),l.clear(),s.clear()}}}function qa(t,e,r){let n=t.createShader(e);if(!n)throw new Error("Failed to allocate shader");if(t.shaderSource(n,r),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS)){let i=t.getShaderInfoLog(n)??"Unknown shader compile failure";throw t.deleteShader(n),new Error(i)}return n}function wd(t,e,r,n){let o=t.createProgram();if(!o)throw new Error("Failed to allocate shader program");if(t.attachShader(o,e),t.attachShader(o,r),n)for(let[s,a]of Object.entries(n))t.bindAttribLocation(o,a,s);if(t.linkProgram(o),!t.getProgramParameter(o,t.LINK_STATUS)){let s=t.getProgramInfoLog(o)??"Unknown shader link failure";throw t.deleteProgram(o),new Error(s)}return o}var ge=class t{constructor(e,r){this.uniformLocations=new Map;this.attributeLocations=new Map;this.gl=e,this.program=r}static create(e,r,n){let o=qa(e,e.VERTEX_SHADER,r.vertex),i=qa(e,e.FRAGMENT_SHADER,r.fragment);try{let s=wd(e,o,i,n);return new t(e,s)}finally{e.deleteShader(o),e.deleteShader(i)}}use(){this.gl.useProgram(this.program)}getUniformLocation(e){if(!this.uniformLocations.has(e)){let r=this.gl.getUniformLocation(this.program,e);this.uniformLocations.set(e,r)}return this.uniformLocations.get(e)??null}getAttributeLocation(e){if(!this.attributeLocations.has(e)){let r=this.gl.getAttribLocation(this.program,e);this.attributeLocations.set(e,r)}return this.attributeLocations.get(e)??-1}dispose(){this.gl.deleteProgram(this.program),this.uniformLocations.clear(),this.attributeLocations.clear()}};function ja(t,e,r){return ge.create(t,e,r)}var xe=class{constructor(e,r=e.STATIC_DRAW,n){this.gl=e,this.target=n??e.ARRAY_BUFFER;let o=e.createBuffer();if(!o)throw new Error("Failed to allocate buffer");this.buffer=o,e.bindBuffer(this.target,this.buffer),e.bufferData(this.target,0,r)}bind(){this.gl.bindBuffer(this.target,this.buffer)}upload(e,r=this.gl.STATIC_DRAW){this.bind(),this.gl.bufferData(this.target,e,r)}update(e,r=0){this.bind(),this.gl.bufferSubData(this.target,r,e)}dispose(){this.gl.deleteBuffer(this.buffer)}},De=class extends xe{constructor(e,r=e.STATIC_DRAW){super(e,r,e.ELEMENT_ARRAY_BUFFER)}},Me=class{constructor(e){this.gl=e;let r=e.createVertexArray();if(!r)throw new Error("Failed to allocate vertex array object");this.vao=r}bind(){this.gl.bindVertexArray(this.vao)}configureAttributes(e,r){this.bind(),r&&r.bind();for(let n of e)this.gl.enableVertexAttribArray(n.index),this.gl.vertexAttribPointer(n.index,n.size,n.type,n.normalized??!1,n.stride??0,n.offset??0),n.divisor!==void 0&&this.gl.vertexAttribDivisor(n.index,n.divisor)}dispose(){this.gl.deleteVertexArray(this.vao)}},wr=class{constructor(e,r=e.TEXTURE_2D){this.width=0;this.height=0;this.gl=e,this.target=r;let n=e.createTexture();if(!n)throw new Error("Failed to allocate texture");this.texture=n}bind(e=0){this.gl.activeTexture(this.gl.TEXTURE0+e),this.gl.bindTexture(this.target,this.texture)}setParameters(e){this.bind(),e.wrapS!==void 0&&this.gl.texParameteri(this.target,this.gl.TEXTURE_WRAP_S,e.wrapS),e.wrapT!==void 0&&this.gl.texParameteri(this.target,this.gl.TEXTURE_WRAP_T,e.wrapT),e.minFilter!==void 0&&this.gl.texParameteri(this.target,this.gl.TEXTURE_MIN_FILTER,e.minFilter),e.magFilter!==void 0&&this.gl.texParameteri(this.target,this.gl.TEXTURE_MAG_FILTER,e.magFilter)}upload(e,r,n){this.width=e,this.height=r,this.uploadImage(0,this.gl.RGBA,e,r,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,n)}uploadImage(e,r,n,o,i,s,a,c){this.bind(),this.gl.texImage2D(this.target,e,r,n,o,i,s,a,c)}dispose(){this.gl.deleteTexture(this.texture)}},Lr=class{constructor(e){this.gl=e,this.target=e.TEXTURE_CUBE_MAP;let r=e.createTexture();if(!r)throw new Error("Failed to allocate cubemap texture");this.texture=r}bind(e=0){this.gl.activeTexture(this.gl.TEXTURE0+e),this.gl.bindTexture(this.target,this.texture)}setParameters(e){this.bind(),e.wrapS!==void 0&&this.gl.texParameteri(this.target,this.gl.TEXTURE_WRAP_S,e.wrapS),e.wrapT!==void 0&&this.gl.texParameteri(this.target,this.gl.TEXTURE_WRAP_T,e.wrapT),e.minFilter!==void 0&&this.gl.texParameteri(this.target,this.gl.TEXTURE_MIN_FILTER,e.minFilter),e.magFilter!==void 0&&this.gl.texParameteri(this.target,this.gl.TEXTURE_MAG_FILTER,e.magFilter)}uploadFace(e,r,n,o,i,s,a,c,l){this.bind(),this.gl.texImage2D(e,r,n,o,i,s,a,c,l)}dispose(){this.gl.deleteTexture(this.texture)}},Jo=class{constructor(e){this.gl=e;let r=e.createFramebuffer();if(!r)throw new Error("Failed to allocate framebuffer");this.framebuffer=r}bind(e=this.gl.FRAMEBUFFER){this.gl.bindFramebuffer(e,this.framebuffer)}attachTexture2D(e,r,n=0){this.bind(),this.gl.framebufferTexture2D(this.gl.FRAMEBUFFER,e,r.target,r.texture,n)}dispose(){this.gl.deleteFramebuffer(this.framebuffer)}};var Zi=4,Ji=7*Zi,es=[{index:0,size:3,type:5126,stride:Ji,offset:0},{index:1,size:2,type:5126,stride:Ji,offset:3*Zi},{index:2,size:2,type:5126,stride:Ji,offset:5*Zi}];function Ld(t,e){return{width:t,height:t,padding:e,data:new Uint8Array(t*t*4),cursorX:0,cursorY:0,rowHeight:0}}function Ed(t){let e=t.width*t.height;if(e===0)throw new Error("Invalid lightmap with zero area");let r=t.samples.byteLength/e;if(!Number.isInteger(r)||r<3||r>4)throw new Error("Unsupported lightmap channel count");return r}function Id(t,e,r){let n=Ed(r),o=t.width*4,i=e.x+t.padding,s=e.y+t.padding,a=0;for(let c=0;c<r.height;c++){let l=(s+c)*o+i*4;for(let d=0;d<r.width;d++){let u=l+d*4;t.data[u]=r.samples[a],t.data[u+1]=r.samples[a+1],t.data[u+2]=r.samples[a+2],t.data[u+3]=n===4?r.samples[a+3]:255,a+=n}}}function zd(t,e,r){let n=e.width+r.lightmapPadding*2,o=e.height+r.lightmapPadding*2;if(n>r.atlasSize||o>r.atlasSize)throw new Error("Lightmap too large for atlas");for(let a of t){if(a.cursorX+n>a.width&&(a.cursorX=0,a.cursorY+=a.rowHeight+r.lightmapPadding,a.rowHeight=0),a.cursorY+o>a.height)continue;let c={atlasIndex:t.indexOf(a),x:a.cursorX,y:a.cursorY,width:e.width,height:e.height};return a.cursorX+=n+r.lightmapPadding,a.rowHeight=Math.max(a.rowHeight,o),{placement:c,atlas:a}}let i=Ld(r.atlasSize,r.lightmapPadding);t.push(i);let s={atlasIndex:t.length-1,x:0,y:0,width:e.width,height:e.height};return i.cursorX=n+r.lightmapPadding,i.rowHeight=o,{placement:s,atlas:i}}function Zo(t){return t instanceof Float32Array?t:new Float32Array(t)}function Pd(t,e){if(!t){let n=new Uint16Array(e);for(let o=0;o<e;o++)n[o]=o;return n}return t instanceof Uint16Array?t:new Uint16Array(t)}function Fd(t,e){let r=new Float32Array(t.length);for(let n=0;n<t.length;n+=2)r[n]=e.offset[0]+t[n]*e.scale[0],r[n+1]=e.offset[1]+t[n+1]*e.scale[1];return r}function Cd(t,e){let r=Zo(t.vertices),n=Zo(t.textureCoords),o=e?Fd(Zo(t.lightmapCoords??t.textureCoords),e):Zo(t.lightmapCoords??new Float32Array(n.length)),i=r.length/3;if(n.length/2!==i)throw new Error("Texture coordinates count mismatch");if(o.length/2!==i)throw new Error("Lightmap coordinates count mismatch");let s=new Float32Array(i*7);for(let a=0;a<i;a++){let c=a*3,l=a*2,d=a*7;s[d]=r[c],s[d+1]=r[c+1],s[d+2]=r[c+2],s[d+3]=n[l],s[d+4]=n[l+1],s[d+5]=o[l],s[d+6]=o[l+1]}return s}function $a(t){let e=[];for(let r=0;r<t.faces.length;r++){let n=t.faces[r];if(n.texInfo<0)continue;let o=t.texInfo[n.texInfo],i=[],s=[],a=[];for(let f=0;f<n.numEdges;f++){let m=t.surfEdges[n.firstEdge+f],p=t.edges[Math.abs(m)],y=m>=0?p.vertices[0]:p.vertices[1],h=t.vertices[y];i.push(h[0],h[1],h[2]);let g=h[0]*o.s[0]+h[1]*o.s[1]+h[2]*o.s[2]+o.sOffset,S=h[0]*o.t[0]+h[1]*o.t[1]+h[2]*o.t[2]+o.tOffset;s.push(g,S),a.push(g,S)}let c=[],l=i.length/3;for(let f=1;f<l-1;f++)c.push(0,f,f+1);let d,u=t.lightMapInfo[r];if(u){let f=1/0,m=-1/0,p=1/0,y=-1/0;for(let v=0;v<s.length;v+=2){let A=s[v],_=s[v+1];A<f&&(f=A),A>m&&(m=A),_<p&&(p=_),_>y&&(y=_)}let h=Math.floor(f/16),g=Math.floor(p/16),S=Math.ceil(m/16)-h+1,b=Math.ceil(y/16)-g+1,M=eo(n,t.lightMaps,u);if(M&&M.length===S*b*3){d={width:S,height:b,samples:M};for(let v=0;v<a.length;v+=2)a[v]=s[v]/16-h+.5,a[v+1]=s[v+1]/16-g+.5}}e.push({vertices:new Float32Array(i),textureCoords:new Float32Array(s),lightmapCoords:new Float32Array(a),indices:new Uint16Array(c),texture:o.texture,surfaceFlags:o.flags,lightmap:d})}return e}function Qa(t,e,r={}){let n={atlasSize:r.atlasSize??1024,lightmapPadding:r.lightmapPadding??1},o=[],i=new Map;e.forEach((c,l)=>{if(!c.lightmap)return;let{placement:d,atlas:u}=zd(o,c.lightmap,n);Id(u,d,c.lightmap),i.set(l,{atlasIndex:d.atlasIndex,offset:[(d.x+n.lightmapPadding)/n.atlasSize,(d.y+n.lightmapPadding)/n.atlasSize],scale:[d.width/n.atlasSize,d.height/n.atlasSize]})});let s=o.map(c=>{let l=new wr(t);return l.setParameters({wrapS:t.CLAMP_TO_EDGE,wrapT:t.CLAMP_TO_EDGE,minFilter:t.LINEAR,magFilter:t.LINEAR}),l.uploadImage(0,t.RGBA,c.width,c.height,0,t.RGBA,t.UNSIGNED_BYTE,c.data),{texture:l,width:c.width,height:c.height,pixels:c.data}});return{surfaces:e.map((c,l)=>{let d=i.get(l),u=Cd(c,d),f=Pd(c.indices,u.length/7),m=new xe(t,t.STATIC_DRAW,t.ARRAY_BUFFER);m.upload(u);let p=new De(t,t.STATIC_DRAW);p.upload(f);let y=new Me(t);return y.configureAttributes(es,m),{vao:y,vertexBuffer:m,indexBuffer:p,indexCount:f.length,vertexCount:u.length/7,texture:c.texture,surfaceFlags:c.surfaceFlags??Tr,lightmap:d,vertexData:u,indexData:f}}),lightmaps:s}}function Er(t){let{normal:e,distance:r}=t,n=Math.sqrt(e.x*e.x+e.y*e.y+e.z*e.z);if(n===0)return t;let o=1/n;return{normal:{x:e.x*o,y:e.y*o,z:e.z*o},distance:r*o}}function Ja(t){if(t.length!==16)throw new Error("View-projection matrix must contain 16 elements");let e=t[0],r=t[4],n=t[8],o=t[12],i=t[1],s=t[5],a=t[9],c=t[13],l=t[2],d=t[6],u=t[10],f=t[14],m=t[3],p=t[7],y=t[11],h=t[15];return[Er({normal:{x:m+e,y:p+r,z:y+n},distance:h+o}),Er({normal:{x:m-e,y:p-r,z:y-n},distance:h-o}),Er({normal:{x:m+i,y:p+s,z:y+a},distance:h+c}),Er({normal:{x:m-i,y:p-s,z:y-a},distance:h-c}),Er({normal:{x:m+l,y:p+d,z:y+u},distance:h+f}),Er({normal:{x:m-l,y:p-d,z:y-u},distance:h-f})]}function Td(t,e){return t.normal.x*e.x+t.normal.y*e.y+t.normal.z*e.z+t.distance}function On(t,e,r){for(let n of r){let o=n.normal.x>=0?e.x:t.x,i=n.normal.y>=0?e.y:t.y,s=n.normal.z>=0?e.z:t.z;if(Td(n,{x:o,y:i,z:s})<0)return!1}return!0}function Za(t){return t<0}function ec(t){return-t-1}function tc(t,e){return t.normal[0]*e.x+t.normal[1]*e.y+t.normal[2]*e.z-t.dist}function Rd(t,e,r){if(!t||e<0||r<0)return!0;let n=Math.ceil(t.numClusters/8),o=t.clusters[e].pvs,i=Math.floor(r/8),s=1<<r%8;return i<0||i>=n?!1:(o[i]&s)!==0}function Bd(t,e){let r={x:t.mins[0],y:t.mins[1],z:t.mins[2]},n={x:t.maxs[0],y:t.maxs[1],z:t.maxs[2]};return On(r,n,e)}function rs(t,e){let r=0;for(;r>=0;){let n=t.nodes[r],o=t.planes[n.planeIndex],s=tc(o,e)>=0?0:1,a=n.children[s];if(Za(a))return ec(a);r=a}return-1}function Od(t,e){let r=t.leafs[e],n=[];for(let o=0;o<r.numLeafFaces;o+=1)n.push(t.leafLists.leafFaces[e][o]);return n}function ts(t,e,r,n,o,i,s){if(Za(e)){let f=ec(e),m=t.leafs[f];if(!Rd(t.visibility,o,m.cluster)||!Bd(m,n))return;let p={x:(m.mins[0]+m.maxs[0])*.5,y:(m.mins[1]+m.maxs[1])*.5,z:(m.mins[2]+m.maxs[2])*.5},y=p.x-r.x,h=p.y-r.y,g=p.z-r.z,S=-(y*y+h*h+g*g);for(let b of Od(t,f))s.has(b)||(s.add(b),i.push({faceIndex:b,leafIndex:f,sortKey:S}));return}let a=t.nodes[e],c=t.planes[a.planeIndex],l=tc(c,r),d=l>=0?a.children[0]:a.children[1],u=l>=0?a.children[1]:a.children[0];On({x:a.mins[0],y:a.mins[1],z:a.mins[2]},{x:a.maxs[0],y:a.maxs[1],z:a.maxs[2]},n)&&(ts(t,d,r,n,o,i,s),ts(t,u,r,n,o,i,s))}function rc(t,e,r){let n=rs(t,e),o=n>=0?t.leafs[n].cluster:-1,i=[];return ts(t,0,e,r,o,i,new Set),i}var ns=`#version 300 es
|
|
142
142
|
precision highp float;
|
|
143
143
|
|
|
144
144
|
layout(location = 0) in vec3 a_position;
|
|
@@ -197,7 +197,7 @@ void main() {
|
|
|
197
197
|
}
|
|
198
198
|
|
|
199
199
|
o_color = vec4(base.rgb, base.a * u_alpha);
|
|
200
|
-
}`,nc=[0,255,255,255];function is(t=nc,e=[]){let r=new Float32Array(4);for(let n=0;n<4;n+=1){let o=t[n]??255;if(o===255){r[n]=0;continue}let i=e[o];r[n]=i!==void 0?i:1}return r}function Dd(t){return[-(t*.25%1),0]}function ss(t=
|
|
200
|
+
}`,nc=[0,255,255,255];function is(t=nc,e=[]){let r=new Float32Array(4);for(let n=0;n<4;n+=1){let o=t[n]??255;if(o===255){r[n]=0;continue}let i=e[o];r[n]=i!==void 0?i:1}return r}function Dd(t){return[-(t*.25%1),0]}function ss(t=Tr,e=0){let r=(t&Ns)!==0,n=(t&Ds)!==0,o=(t&Os)!==0,i=(t&ks)!==0,s=(t&Hs)!==0,a=i?.33:s?.66:1,c=i||s,l=!c&&!o,d=r?Dd(e):[0,0];return{alpha:a,blend:c,depthWrite:l,warp:n,flowOffset:d,sky:o}}var ei=class{constructor(e){this.gl=e,this.program=ge.create(e,{vertex:ns,fragment:os},{a_position:0,a_texCoord:1,a_lightmapCoord:2}),this.uniformMvp=this.program.getUniformLocation("u_modelViewProjection"),this.uniformTexScroll=this.program.getUniformLocation("u_texScroll"),this.uniformLmScroll=this.program.getUniformLocation("u_lightmapScroll"),this.uniformLightStyles=this.program.getUniformLocation("u_lightStyleFactors"),this.uniformAlpha=this.program.getUniformLocation("u_alpha"),this.uniformApplyLightmap=this.program.getUniformLocation("u_applyLightmap"),this.uniformWarp=this.program.getUniformLocation("u_warp"),this.uniformDiffuse=this.program.getUniformLocation("u_diffuseMap"),this.uniformLightmap=this.program.getUniformLocation("u_lightmapAtlas"),this.uniformTime=this.program.getUniformLocation("u_time")}bind(e){let{modelViewProjection:r,styleIndices:n=nc,styleValues:o=[],diffuseSampler:i=0,lightmapSampler:s,surfaceFlags:a=Tr,timeSeconds:c=0}=e,l=ss(a,c),d=is(n,o);this.program.use(),this.gl.uniformMatrix4fv(this.uniformMvp,!1,r),this.gl.uniform2f(this.uniformTexScroll,l.flowOffset[0],l.flowOffset[1]),this.gl.uniform2f(this.uniformLmScroll,l.flowOffset[0],l.flowOffset[1]),this.gl.uniform4fv(this.uniformLightStyles,d),this.gl.uniform1f(this.uniformAlpha,l.alpha);let u=!l.sky&&s!==void 0;return this.gl.uniform1i(this.uniformApplyLightmap,u?1:0),this.gl.uniform1i(this.uniformWarp,l.warp?1:0),this.gl.uniform1f(this.uniformTime,c),this.gl.uniform1i(this.uniformDiffuse,i),this.gl.uniform1i(this.uniformLightmap,s??0),l}dispose(){this.program.dispose()}};function oc(t,e){t.depthMask(e.depthWrite),e.blend?(t.enable(t.BLEND),t.blendFunc(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA)):t.disable(t.BLEND)}var ic=new Float32Array([-1,-1,1,1,-1,1,1,1,1,-1,-1,1,1,1,1,-1,1,1,-1,-1,-1,-1,1,-1,1,1,-1,-1,-1,-1,1,1,-1,1,-1,-1,-1,-1,-1,-1,-1,1,-1,1,1,-1,-1,-1,-1,1,1,-1,1,-1,1,-1,-1,1,1,-1,1,1,1,1,-1,-1,1,1,1,1,-1,1,-1,1,-1,-1,1,1,1,1,1,-1,1,-1,1,1,1,1,1,-1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,-1,1,-1,1,-1,-1,1]),as=`#version 300 es
|
|
201
201
|
precision highp float;
|
|
202
202
|
|
|
203
203
|
layout(location = 0) in vec3 a_position;
|
|
@@ -254,7 +254,7 @@ out vec4 o_color;
|
|
|
254
254
|
void main() {
|
|
255
255
|
vec4 albedo = texture(u_diffuseMap, v_texCoord) * u_tint;
|
|
256
256
|
o_color = vec4(albedo.rgb * v_light, albedo.a);
|
|
257
|
-
}`;function Hd(t){let e=t.x*t.x+t.y*t.y+t.z*t.z;if(e<=0)return{x:0,y:0,z:1};let r=1/Math.sqrt(e);return{x:t.x*r,y:t.y*r,z:t.z*r}}function ls(t,e,r){return t+(e-t)*r}function cc(t,e,r){return{x:ls(t.x,e.x,r),y:ls(t.y,e.y,r),z:ls(t.z,e.z,r)}}function Od(t,e,r){return[t/r.skinWidth,1-e/r.skinHeight]}function ms(t){if(t.glCommands.length===0){let n=[],o=[];return t.triangles.forEach(i=>{let s=n.length;for(let a=0;a<3;a+=1){let c=i.vertexIndices[a],l=i.texCoordIndices[a],d=t.texCoords[l];n.push({vertexIndex:c,texCoord:Od(d.s,d.t,t.header)})}o.push(s,s+1,s+2)}),{vertices:n,indices:new Uint16Array(o)}}let e=[],r=[];for(let n of t.glCommands){let o=e.length;if(e.push(...n.vertices.map(i=>({vertexIndex:i.vertexIndex,texCoord:[i.s,1-i.t]}))),n.mode==="strip")for(let i=0;i<n.vertices.length-2;i+=1){let s=i%2===0,a=o+i+(s?0:1),c=o+i+(s?1:0),l=o+i+2;r.push(a,c,l)}else for(let i=1;i<n.vertices.length-1;i+=1)r.push(o,o+i,o+i+1)}return{vertices:e,indices:new Uint16Array(r)}}function fs(t,e,r){let{currentFrame:n,nextFrame:o,lerp:i}=r,s=t.frames[n],a=t.frames[o];if(!s||!a)throw new Error("Requested MD2 frames are out of range");let c=new Float32Array(e.vertices.length*8);return e.vertices.forEach((l,d)=>{let u=s.vertices[l.vertexIndex],m=a.vertices[l.vertexIndex];if(!u||!m)throw new Error("MD2 vertex index out of range for frame");let f=cc(u.position,m.position,i),h=Hd(cc(u.normal,m.normal,i)),y=d*8;c[y]=f.x,c[y+1]=f.y,c[y+2]=f.z,c[y+3]=h.x,c[y+4]=h.y,c[y+5]=h.z,c[y+6]=l.texCoord[0],c[y+7]=l.texCoord[1]}),c}var ri=class{constructor(e,r,n){this.gl=e,this.geometry=ms(r),this.vertexBuffer=new xe(e,e.STATIC_DRAW),this.indexBuffer=new De(e,e.STATIC_DRAW),this.vertexArray=new Me(e),this.indexCount=this.geometry.indices.length,this.vertexArray.configureAttributes([{index:0,size:3,type:e.FLOAT,stride:32,offset:0},{index:1,size:3,type:e.FLOAT,stride:32,offset:12},{index:2,size:2,type:e.FLOAT,stride:32,offset:24}],this.vertexBuffer),this.vertexArray.bind(),this.indexBuffer.bind(),this.indexBuffer.upload(this.geometry.indices,e.STATIC_DRAW),this.update(r,n)}update(e,r){let n=fs(e,this.geometry,r);this.vertexBuffer.upload(n,this.gl.STATIC_DRAW)}bind(){this.vertexArray.bind(),this.indexBuffer.bind()}dispose(){this.vertexBuffer.dispose(),this.indexBuffer.dispose(),this.vertexArray.dispose()}},ni=class{constructor(e){this.gl=e,this.program=ge.create(e,{vertex:ds,fragment:us},{a_position:0,a_normal:1,a_texCoord:2}),this.uniformMvp=this.program.getUniformLocation("u_modelViewProjection"),this.uniformLightDir=this.program.getUniformLocation("u_lightDir"),this.uniformTint=this.program.getUniformLocation("u_tint"),this.uniformDiffuse=this.program.getUniformLocation("u_diffuseMap")}bind(e){let{modelViewProjection:r,lightDirection:n=[0,0,1],tint:o=[1,1,1,1],diffuseSampler:i=0}=e,s=new Float32Array(n),a=new Float32Array(o);this.program.use(),this.gl.uniformMatrix4fv(this.uniformMvp,!1,r),this.gl.uniform3fv(this.uniformLightDir,s),this.gl.uniform4fv(this.uniformTint,a),this.gl.uniform1i(this.uniformDiffuse,i)}draw(e){e.bind(),this.gl.drawElements(this.gl.TRIANGLES,e.indexCount,this.gl.UNSIGNED_SHORT,0)}dispose(){this.program.dispose()}};var K=1e-6,He=typeof Float32Array<"u"?Float32Array:Array,ps=Math.random;function oi(t){return t>=0?Math.round(t):t%.5===0?Math.floor(t):Math.round(t)}var g1=Math.PI/180,x1=180/Math.PI;var ie={};di(ie,{add:()=>_0,adjoint:()=>Yd,clone:()=>Vd,copy:()=>Ud,create:()=>Nd,decompose:()=>d0,determinant:()=>Kd,equals:()=>z0,exactEquals:()=>E0,frob:()=>A0,fromQuat:()=>f0,fromQuat2:()=>a0,fromRotation:()=>n0,fromRotationTranslation:()=>mc,fromRotationTranslationScale:()=>u0,fromRotationTranslationScaleOrigin:()=>m0,fromScaling:()=>r0,fromTranslation:()=>t0,fromValues:()=>Gd,fromXRotation:()=>o0,fromYRotation:()=>i0,fromZRotation:()=>s0,frustum:()=>p0,getRotation:()=>l0,getScaling:()=>fc,getTranslation:()=>c0,identity:()=>dc,invert:()=>qd,lookAt:()=>b0,mul:()=>C0,multiply:()=>uc,multiplyScalar:()=>w0,multiplyScalarAndAdd:()=>L0,ortho:()=>x0,orthoNO:()=>hc,orthoZO:()=>v0,perspective:()=>h0,perspectiveFromFieldOfView:()=>g0,perspectiveNO:()=>pc,perspectiveZO:()=>y0,rotate:()=>Qd,rotateX:()=>Jd,rotateY:()=>Zd,rotateZ:()=>e0,scale:()=>$d,set:()=>Wd,str:()=>M0,sub:()=>T0,subtract:()=>yc,targetTo:()=>S0,translate:()=>jd,transpose:()=>Xd});function Nd(){var t=new He(16);return He!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function Vd(t){var e=new He(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function Ud(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function Gd(t,e,r,n,o,i,s,a,c,l,d,u,m,f,h,y){var p=new He(16);return p[0]=t,p[1]=e,p[2]=r,p[3]=n,p[4]=o,p[5]=i,p[6]=s,p[7]=a,p[8]=c,p[9]=l,p[10]=d,p[11]=u,p[12]=m,p[13]=f,p[14]=h,p[15]=y,p}function Wd(t,e,r,n,o,i,s,a,c,l,d,u,m,f,h,y,p){return t[0]=e,t[1]=r,t[2]=n,t[3]=o,t[4]=i,t[5]=s,t[6]=a,t[7]=c,t[8]=l,t[9]=d,t[10]=u,t[11]=m,t[12]=f,t[13]=h,t[14]=y,t[15]=p,t}function dc(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Xd(t,e){if(t===e){var r=e[1],n=e[2],o=e[3],i=e[6],s=e[7],a=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=n,t[9]=i,t[11]=e[14],t[12]=o,t[13]=s,t[14]=a}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function qd(t,e){var r=e[0],n=e[1],o=e[2],i=e[3],s=e[4],a=e[5],c=e[6],l=e[7],d=e[8],u=e[9],m=e[10],f=e[11],h=e[12],y=e[13],p=e[14],g=e[15],S=r*a-n*s,v=r*c-o*s,M=r*l-i*s,b=n*c-o*a,A=n*l-i*a,_=o*l-i*c,L=d*y-u*h,I=d*p-m*h,w=d*g-f*h,O=u*p-m*y,U=u*g-f*y,V=m*g-f*p,F=S*V-v*U+M*O+b*w-A*I+_*L;return F?(F=1/F,t[0]=(a*V-c*U+l*O)*F,t[1]=(o*U-n*V-i*O)*F,t[2]=(y*_-p*A+g*b)*F,t[3]=(m*A-u*_-f*b)*F,t[4]=(c*w-s*V-l*I)*F,t[5]=(r*V-o*w+i*I)*F,t[6]=(p*M-h*_-g*v)*F,t[7]=(d*_-m*M+f*v)*F,t[8]=(s*U-a*w+l*L)*F,t[9]=(n*w-r*U-i*L)*F,t[10]=(h*A-y*M+g*S)*F,t[11]=(u*M-d*A-f*S)*F,t[12]=(a*I-s*O-c*L)*F,t[13]=(r*O-n*I+o*L)*F,t[14]=(y*v-h*b-p*S)*F,t[15]=(d*b-u*v+m*S)*F,t):null}function Yd(t,e){var r=e[0],n=e[1],o=e[2],i=e[3],s=e[4],a=e[5],c=e[6],l=e[7],d=e[8],u=e[9],m=e[10],f=e[11],h=e[12],y=e[13],p=e[14],g=e[15],S=r*a-n*s,v=r*c-o*s,M=r*l-i*s,b=n*c-o*a,A=n*l-i*a,_=o*l-i*c,L=d*y-u*h,I=d*p-m*h,w=d*g-f*h,O=u*p-m*y,U=u*g-f*y,V=m*g-f*p;return t[0]=a*V-c*U+l*O,t[1]=o*U-n*V-i*O,t[2]=y*_-p*A+g*b,t[3]=m*A-u*_-f*b,t[4]=c*w-s*V-l*I,t[5]=r*V-o*w+i*I,t[6]=p*M-h*_-g*v,t[7]=d*_-m*M+f*v,t[8]=s*U-a*w+l*L,t[9]=n*w-r*U-i*L,t[10]=h*A-y*M+g*S,t[11]=u*M-d*A-f*S,t[12]=a*I-s*O-c*L,t[13]=r*O-n*I+o*L,t[14]=y*v-h*b-p*S,t[15]=d*b-u*v+m*S,t}function Kd(t){var e=t[0],r=t[1],n=t[2],o=t[3],i=t[4],s=t[5],a=t[6],c=t[7],l=t[8],d=t[9],u=t[10],m=t[11],f=t[12],h=t[13],y=t[14],p=t[15],g=e*s-r*i,S=e*a-n*i,v=r*a-n*s,M=l*h-d*f,b=l*y-u*f,A=d*y-u*h,_=e*A-r*b+n*M,L=i*A-s*b+a*M,I=l*v-d*S+u*g,w=f*v-h*S+y*g;return c*_-o*L+p*I-m*w}function uc(t,e,r){var n=e[0],o=e[1],i=e[2],s=e[3],a=e[4],c=e[5],l=e[6],d=e[7],u=e[8],m=e[9],f=e[10],h=e[11],y=e[12],p=e[13],g=e[14],S=e[15],v=r[0],M=r[1],b=r[2],A=r[3];return t[0]=v*n+M*a+b*u+A*y,t[1]=v*o+M*c+b*m+A*p,t[2]=v*i+M*l+b*f+A*g,t[3]=v*s+M*d+b*h+A*S,v=r[4],M=r[5],b=r[6],A=r[7],t[4]=v*n+M*a+b*u+A*y,t[5]=v*o+M*c+b*m+A*p,t[6]=v*i+M*l+b*f+A*g,t[7]=v*s+M*d+b*h+A*S,v=r[8],M=r[9],b=r[10],A=r[11],t[8]=v*n+M*a+b*u+A*y,t[9]=v*o+M*c+b*m+A*p,t[10]=v*i+M*l+b*f+A*g,t[11]=v*s+M*d+b*h+A*S,v=r[12],M=r[13],b=r[14],A=r[15],t[12]=v*n+M*a+b*u+A*y,t[13]=v*o+M*c+b*m+A*p,t[14]=v*i+M*l+b*f+A*g,t[15]=v*s+M*d+b*h+A*S,t}function jd(t,e,r){var n=r[0],o=r[1],i=r[2],s,a,c,l,d,u,m,f,h,y,p,g;return e===t?(t[12]=e[0]*n+e[4]*o+e[8]*i+e[12],t[13]=e[1]*n+e[5]*o+e[9]*i+e[13],t[14]=e[2]*n+e[6]*o+e[10]*i+e[14],t[15]=e[3]*n+e[7]*o+e[11]*i+e[15]):(s=e[0],a=e[1],c=e[2],l=e[3],d=e[4],u=e[5],m=e[6],f=e[7],h=e[8],y=e[9],p=e[10],g=e[11],t[0]=s,t[1]=a,t[2]=c,t[3]=l,t[4]=d,t[5]=u,t[6]=m,t[7]=f,t[8]=h,t[9]=y,t[10]=p,t[11]=g,t[12]=s*n+d*o+h*i+e[12],t[13]=a*n+u*o+y*i+e[13],t[14]=c*n+m*o+p*i+e[14],t[15]=l*n+f*o+g*i+e[15]),t}function $d(t,e,r){var n=r[0],o=r[1],i=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*o,t[5]=e[5]*o,t[6]=e[6]*o,t[7]=e[7]*o,t[8]=e[8]*i,t[9]=e[9]*i,t[10]=e[10]*i,t[11]=e[11]*i,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function Qd(t,e,r,n){var o=n[0],i=n[1],s=n[2],a=Math.sqrt(o*o+i*i+s*s),c,l,d,u,m,f,h,y,p,g,S,v,M,b,A,_,L,I,w,O,U,V,F,$;return a<K?null:(a=1/a,o*=a,i*=a,s*=a,c=Math.sin(r),l=Math.cos(r),d=1-l,u=e[0],m=e[1],f=e[2],h=e[3],y=e[4],p=e[5],g=e[6],S=e[7],v=e[8],M=e[9],b=e[10],A=e[11],_=o*o*d+l,L=i*o*d+s*c,I=s*o*d-i*c,w=o*i*d-s*c,O=i*i*d+l,U=s*i*d+o*c,V=o*s*d+i*c,F=i*s*d-o*c,$=s*s*d+l,t[0]=u*_+y*L+v*I,t[1]=m*_+p*L+M*I,t[2]=f*_+g*L+b*I,t[3]=h*_+S*L+A*I,t[4]=u*w+y*O+v*U,t[5]=m*w+p*O+M*U,t[6]=f*w+g*O+b*U,t[7]=h*w+S*O+A*U,t[8]=u*V+y*F+v*$,t[9]=m*V+p*F+M*$,t[10]=f*V+g*F+b*$,t[11]=h*V+S*F+A*$,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)}function Jd(t,e,r){var n=Math.sin(r),o=Math.cos(r),i=e[4],s=e[5],a=e[6],c=e[7],l=e[8],d=e[9],u=e[10],m=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=i*o+l*n,t[5]=s*o+d*n,t[6]=a*o+u*n,t[7]=c*o+m*n,t[8]=l*o-i*n,t[9]=d*o-s*n,t[10]=u*o-a*n,t[11]=m*o-c*n,t}function Zd(t,e,r){var n=Math.sin(r),o=Math.cos(r),i=e[0],s=e[1],a=e[2],c=e[3],l=e[8],d=e[9],u=e[10],m=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=i*o-l*n,t[1]=s*o-d*n,t[2]=a*o-u*n,t[3]=c*o-m*n,t[8]=i*n+l*o,t[9]=s*n+d*o,t[10]=a*n+u*o,t[11]=c*n+m*o,t}function e0(t,e,r){var n=Math.sin(r),o=Math.cos(r),i=e[0],s=e[1],a=e[2],c=e[3],l=e[4],d=e[5],u=e[6],m=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=i*o+l*n,t[1]=s*o+d*n,t[2]=a*o+u*n,t[3]=c*o+m*n,t[4]=l*o-i*n,t[5]=d*o-s*n,t[6]=u*o-a*n,t[7]=m*o-c*n,t}function t0(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}function r0(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function n0(t,e,r){var n=r[0],o=r[1],i=r[2],s=Math.sqrt(n*n+o*o+i*i),a,c,l;return s<K?null:(s=1/s,n*=s,o*=s,i*=s,a=Math.sin(e),c=Math.cos(e),l=1-c,t[0]=n*n*l+c,t[1]=o*n*l+i*a,t[2]=i*n*l-o*a,t[3]=0,t[4]=n*o*l-i*a,t[5]=o*o*l+c,t[6]=i*o*l+n*a,t[7]=0,t[8]=n*i*l+o*a,t[9]=o*i*l-n*a,t[10]=i*i*l+c,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t)}function o0(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=n,t[6]=r,t[7]=0,t[8]=0,t[9]=-r,t[10]=n,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function i0(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=0,t[2]=-r,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=r,t[9]=0,t[10]=n,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function s0(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=r,t[2]=0,t[3]=0,t[4]=-r,t[5]=n,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function mc(t,e,r){var n=e[0],o=e[1],i=e[2],s=e[3],a=n+n,c=o+o,l=i+i,d=n*a,u=n*c,m=n*l,f=o*c,h=o*l,y=i*l,p=s*a,g=s*c,S=s*l;return t[0]=1-(f+y),t[1]=u+S,t[2]=m-g,t[3]=0,t[4]=u-S,t[5]=1-(d+y),t[6]=h+p,t[7]=0,t[8]=m+g,t[9]=h-p,t[10]=1-(d+f),t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function a0(t,e){var r=new He(3),n=-e[0],o=-e[1],i=-e[2],s=e[3],a=e[4],c=e[5],l=e[6],d=e[7],u=n*n+o*o+i*i+s*s;return u>0?(r[0]=(a*s+d*n+c*i-l*o)*2/u,r[1]=(c*s+d*o+l*n-a*i)*2/u,r[2]=(l*s+d*i+a*o-c*n)*2/u):(r[0]=(a*s+d*n+c*i-l*o)*2,r[1]=(c*s+d*o+l*n-a*i)*2,r[2]=(l*s+d*i+a*o-c*n)*2),mc(t,e,r),t}function c0(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}function fc(t,e){var r=e[0],n=e[1],o=e[2],i=e[4],s=e[5],a=e[6],c=e[8],l=e[9],d=e[10];return t[0]=Math.sqrt(r*r+n*n+o*o),t[1]=Math.sqrt(i*i+s*s+a*a),t[2]=Math.sqrt(c*c+l*l+d*d),t}function l0(t,e){var r=new He(3);fc(r,e);var n=1/r[0],o=1/r[1],i=1/r[2],s=e[0]*n,a=e[1]*o,c=e[2]*i,l=e[4]*n,d=e[5]*o,u=e[6]*i,m=e[8]*n,f=e[9]*o,h=e[10]*i,y=s+d+h,p=0;return y>0?(p=Math.sqrt(y+1)*2,t[3]=.25*p,t[0]=(u-f)/p,t[1]=(m-c)/p,t[2]=(a-l)/p):s>d&&s>h?(p=Math.sqrt(1+s-d-h)*2,t[3]=(u-f)/p,t[0]=.25*p,t[1]=(a+l)/p,t[2]=(m+c)/p):d>h?(p=Math.sqrt(1+d-s-h)*2,t[3]=(m-c)/p,t[0]=(a+l)/p,t[1]=.25*p,t[2]=(u+f)/p):(p=Math.sqrt(1+h-s-d)*2,t[3]=(a-l)/p,t[0]=(m+c)/p,t[1]=(u+f)/p,t[2]=.25*p),t}function d0(t,e,r,n){e[0]=n[12],e[1]=n[13],e[2]=n[14];var o=n[0],i=n[1],s=n[2],a=n[4],c=n[5],l=n[6],d=n[8],u=n[9],m=n[10];r[0]=Math.sqrt(o*o+i*i+s*s),r[1]=Math.sqrt(a*a+c*c+l*l),r[2]=Math.sqrt(d*d+u*u+m*m);var f=1/r[0],h=1/r[1],y=1/r[2],p=o*f,g=i*h,S=s*y,v=a*f,M=c*h,b=l*y,A=d*f,_=u*h,L=m*y,I=p+M+L,w=0;return I>0?(w=Math.sqrt(I+1)*2,t[3]=.25*w,t[0]=(b-_)/w,t[1]=(A-S)/w,t[2]=(g-v)/w):p>M&&p>L?(w=Math.sqrt(1+p-M-L)*2,t[3]=(b-_)/w,t[0]=.25*w,t[1]=(g+v)/w,t[2]=(A+S)/w):M>L?(w=Math.sqrt(1+M-p-L)*2,t[3]=(A-S)/w,t[0]=(g+v)/w,t[1]=.25*w,t[2]=(b+_)/w):(w=Math.sqrt(1+L-p-M)*2,t[3]=(g-v)/w,t[0]=(A+S)/w,t[1]=(b+_)/w,t[2]=.25*w),t}function u0(t,e,r,n){var o=e[0],i=e[1],s=e[2],a=e[3],c=o+o,l=i+i,d=s+s,u=o*c,m=o*l,f=o*d,h=i*l,y=i*d,p=s*d,g=a*c,S=a*l,v=a*d,M=n[0],b=n[1],A=n[2];return t[0]=(1-(h+p))*M,t[1]=(m+v)*M,t[2]=(f-S)*M,t[3]=0,t[4]=(m-v)*b,t[5]=(1-(u+p))*b,t[6]=(y+g)*b,t[7]=0,t[8]=(f+S)*A,t[9]=(y-g)*A,t[10]=(1-(u+h))*A,t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function m0(t,e,r,n,o){var i=e[0],s=e[1],a=e[2],c=e[3],l=i+i,d=s+s,u=a+a,m=i*l,f=i*d,h=i*u,y=s*d,p=s*u,g=a*u,S=c*l,v=c*d,M=c*u,b=n[0],A=n[1],_=n[2],L=o[0],I=o[1],w=o[2],O=(1-(y+g))*b,U=(f+M)*b,V=(h-v)*b,F=(f-M)*A,$=(1-(m+g))*A,ve=(p+S)*A,It=(h+v)*_,Hn=(p-S)*_,Tr=(1-(m+y))*_;return t[0]=O,t[1]=U,t[2]=V,t[3]=0,t[4]=F,t[5]=$,t[6]=ve,t[7]=0,t[8]=It,t[9]=Hn,t[10]=Tr,t[11]=0,t[12]=r[0]+L-(O*L+F*I+It*w),t[13]=r[1]+I-(U*L+$*I+Hn*w),t[14]=r[2]+w-(V*L+ve*I+Tr*w),t[15]=1,t}function f0(t,e){var r=e[0],n=e[1],o=e[2],i=e[3],s=r+r,a=n+n,c=o+o,l=r*s,d=n*s,u=n*a,m=o*s,f=o*a,h=o*c,y=i*s,p=i*a,g=i*c;return t[0]=1-u-h,t[1]=d+g,t[2]=m-p,t[3]=0,t[4]=d-g,t[5]=1-l-h,t[6]=f+y,t[7]=0,t[8]=m+p,t[9]=f-y,t[10]=1-l-u,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function p0(t,e,r,n,o,i,s){var a=1/(r-e),c=1/(o-n),l=1/(i-s);return t[0]=i*2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=i*2*c,t[6]=0,t[7]=0,t[8]=(r+e)*a,t[9]=(o+n)*c,t[10]=(s+i)*l,t[11]=-1,t[12]=0,t[13]=0,t[14]=s*i*2*l,t[15]=0,t}function pc(t,e,r,n,o){var i=1/Math.tan(e/2);if(t[0]=i/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=i,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,o!=null&&o!==1/0){var s=1/(n-o);t[10]=(o+n)*s,t[14]=2*o*n*s}else t[10]=-1,t[14]=-2*n;return t}var h0=pc;function y0(t,e,r,n,o){var i=1/Math.tan(e/2);if(t[0]=i/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=i,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,o!=null&&o!==1/0){var s=1/(n-o);t[10]=o*s,t[14]=o*n*s}else t[10]=-1,t[14]=-n;return t}function g0(t,e,r,n){var o=Math.tan(e.upDegrees*Math.PI/180),i=Math.tan(e.downDegrees*Math.PI/180),s=Math.tan(e.leftDegrees*Math.PI/180),a=Math.tan(e.rightDegrees*Math.PI/180),c=2/(s+a),l=2/(o+i);return t[0]=c,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=l,t[6]=0,t[7]=0,t[8]=-((s-a)*c*.5),t[9]=(o-i)*l*.5,t[10]=n/(r-n),t[11]=-1,t[12]=0,t[13]=0,t[14]=n*r/(r-n),t[15]=0,t}function hc(t,e,r,n,o,i,s){var a=1/(e-r),c=1/(n-o),l=1/(i-s);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*l,t[11]=0,t[12]=(e+r)*a,t[13]=(o+n)*c,t[14]=(s+i)*l,t[15]=1,t}var x0=hc;function v0(t,e,r,n,o,i,s){var a=1/(e-r),c=1/(n-o),l=1/(i-s);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=l,t[11]=0,t[12]=(e+r)*a,t[13]=(o+n)*c,t[14]=i*l,t[15]=1,t}function b0(t,e,r,n){var o,i,s,a,c,l,d,u,m,f,h=e[0],y=e[1],p=e[2],g=n[0],S=n[1],v=n[2],M=r[0],b=r[1],A=r[2];return Math.abs(h-M)<K&&Math.abs(y-b)<K&&Math.abs(p-A)<K?dc(t):(d=h-M,u=y-b,m=p-A,f=1/Math.sqrt(d*d+u*u+m*m),d*=f,u*=f,m*=f,o=S*m-v*u,i=v*d-g*m,s=g*u-S*d,f=Math.sqrt(o*o+i*i+s*s),f?(f=1/f,o*=f,i*=f,s*=f):(o=0,i=0,s=0),a=u*s-m*i,c=m*o-d*s,l=d*i-u*o,f=Math.sqrt(a*a+c*c+l*l),f?(f=1/f,a*=f,c*=f,l*=f):(a=0,c=0,l=0),t[0]=o,t[1]=a,t[2]=d,t[3]=0,t[4]=i,t[5]=c,t[6]=u,t[7]=0,t[8]=s,t[9]=l,t[10]=m,t[11]=0,t[12]=-(o*h+i*y+s*p),t[13]=-(a*h+c*y+l*p),t[14]=-(d*h+u*y+m*p),t[15]=1,t)}function S0(t,e,r,n){var o=e[0],i=e[1],s=e[2],a=n[0],c=n[1],l=n[2],d=o-r[0],u=i-r[1],m=s-r[2],f=d*d+u*u+m*m;f>0&&(f=1/Math.sqrt(f),d*=f,u*=f,m*=f);var h=c*m-l*u,y=l*d-a*m,p=a*u-c*d;return f=h*h+y*y+p*p,f>0&&(f=1/Math.sqrt(f),h*=f,y*=f,p*=f),t[0]=h,t[1]=y,t[2]=p,t[3]=0,t[4]=u*p-m*y,t[5]=m*h-d*p,t[6]=d*y-u*h,t[7]=0,t[8]=d,t[9]=u,t[10]=m,t[11]=0,t[12]=o,t[13]=i,t[14]=s,t[15]=1,t}function M0(t){return"mat4("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+", "+t[9]+", "+t[10]+", "+t[11]+", "+t[12]+", "+t[13]+", "+t[14]+", "+t[15]+")"}function A0(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]+t[3]*t[3]+t[4]*t[4]+t[5]*t[5]+t[6]*t[6]+t[7]*t[7]+t[8]*t[8]+t[9]*t[9]+t[10]*t[10]+t[11]*t[11]+t[12]*t[12]+t[13]*t[13]+t[14]*t[14]+t[15]*t[15])}function _0(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t[6]=e[6]+r[6],t[7]=e[7]+r[7],t[8]=e[8]+r[8],t[9]=e[9]+r[9],t[10]=e[10]+r[10],t[11]=e[11]+r[11],t[12]=e[12]+r[12],t[13]=e[13]+r[13],t[14]=e[14]+r[14],t[15]=e[15]+r[15],t}function yc(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t[4]=e[4]-r[4],t[5]=e[5]-r[5],t[6]=e[6]-r[6],t[7]=e[7]-r[7],t[8]=e[8]-r[8],t[9]=e[9]-r[9],t[10]=e[10]-r[10],t[11]=e[11]-r[11],t[12]=e[12]-r[12],t[13]=e[13]-r[13],t[14]=e[14]-r[14],t[15]=e[15]-r[15],t}function w0(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*r,t[9]=e[9]*r,t[10]=e[10]*r,t[11]=e[11]*r,t[12]=e[12]*r,t[13]=e[13]*r,t[14]=e[14]*r,t[15]=e[15]*r,t}function L0(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t[4]=e[4]+r[4]*n,t[5]=e[5]+r[5]*n,t[6]=e[6]+r[6]*n,t[7]=e[7]+r[7]*n,t[8]=e[8]+r[8]*n,t[9]=e[9]+r[9]*n,t[10]=e[10]+r[10]*n,t[11]=e[11]+r[11]*n,t[12]=e[12]+r[12]*n,t[13]=e[13]+r[13]*n,t[14]=e[14]+r[14]*n,t[15]=e[15]+r[15]*n,t}function E0(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]}function z0(t,e){var r=t[0],n=t[1],o=t[2],i=t[3],s=t[4],a=t[5],c=t[6],l=t[7],d=t[8],u=t[9],m=t[10],f=t[11],h=t[12],y=t[13],p=t[14],g=t[15],S=e[0],v=e[1],M=e[2],b=e[3],A=e[4],_=e[5],L=e[6],I=e[7],w=e[8],O=e[9],U=e[10],V=e[11],F=e[12],$=e[13],ve=e[14],It=e[15];return Math.abs(r-S)<=K*Math.max(1,Math.abs(r),Math.abs(S))&&Math.abs(n-v)<=K*Math.max(1,Math.abs(n),Math.abs(v))&&Math.abs(o-M)<=K*Math.max(1,Math.abs(o),Math.abs(M))&&Math.abs(i-b)<=K*Math.max(1,Math.abs(i),Math.abs(b))&&Math.abs(s-A)<=K*Math.max(1,Math.abs(s),Math.abs(A))&&Math.abs(a-_)<=K*Math.max(1,Math.abs(a),Math.abs(_))&&Math.abs(c-L)<=K*Math.max(1,Math.abs(c),Math.abs(L))&&Math.abs(l-I)<=K*Math.max(1,Math.abs(l),Math.abs(I))&&Math.abs(d-w)<=K*Math.max(1,Math.abs(d),Math.abs(w))&&Math.abs(u-O)<=K*Math.max(1,Math.abs(u),Math.abs(O))&&Math.abs(m-U)<=K*Math.max(1,Math.abs(m),Math.abs(U))&&Math.abs(f-V)<=K*Math.max(1,Math.abs(f),Math.abs(V))&&Math.abs(h-F)<=K*Math.max(1,Math.abs(h),Math.abs(F))&&Math.abs(y-$)<=K*Math.max(1,Math.abs(y),Math.abs($))&&Math.abs(p-ve)<=K*Math.max(1,Math.abs(p),Math.abs(ve))&&Math.abs(g-It)<=K*Math.max(1,Math.abs(g),Math.abs(It))}var C0=uc,T0=yc;var oe={};di(oe,{add:()=>B0,angle:()=>ou,bezier:()=>$0,ceil:()=>k0,clone:()=>I0,copy:()=>P0,create:()=>gc,cross:()=>q0,dist:()=>mu,distance:()=>Mc,div:()=>uu,divide:()=>Sc,dot:()=>hs,equals:()=>cu,exactEquals:()=>au,floor:()=>D0,forEach:()=>yu,fromValues:()=>F0,hermite:()=>j0,inverse:()=>W0,len:()=>pu,length:()=>xc,lerp:()=>Y0,max:()=>O0,min:()=>H0,mul:()=>du,multiply:()=>bc,negate:()=>G0,normalize:()=>X0,random:()=>Q0,rotateX:()=>tu,rotateY:()=>ru,rotateZ:()=>nu,round:()=>N0,scale:()=>V0,scaleAndAdd:()=>U0,set:()=>R0,slerp:()=>K0,sqrDist:()=>fu,sqrLen:()=>hu,squaredDistance:()=>Ac,squaredLength:()=>_c,str:()=>su,sub:()=>lu,subtract:()=>vc,transformMat3:()=>Z0,transformMat4:()=>J0,transformQuat:()=>eu,zero:()=>iu});function gc(){var t=new He(3);return He!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function I0(t){var e=new He(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function xc(t){var e=t[0],r=t[1],n=t[2];return Math.sqrt(e*e+r*r+n*n)}function F0(t,e,r){var n=new He(3);return n[0]=t,n[1]=e,n[2]=r,n}function P0(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function R0(t,e,r,n){return t[0]=e,t[1]=r,t[2]=n,t}function B0(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t}function vc(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function bc(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t}function Sc(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t}function k0(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t}function D0(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t}function H0(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t}function O0(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t}function N0(t,e){return t[0]=oi(e[0]),t[1]=oi(e[1]),t[2]=oi(e[2]),t}function V0(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function U0(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t}function Mc(t,e){var r=e[0]-t[0],n=e[1]-t[1],o=e[2]-t[2];return Math.sqrt(r*r+n*n+o*o)}function Ac(t,e){var r=e[0]-t[0],n=e[1]-t[1],o=e[2]-t[2];return r*r+n*n+o*o}function _c(t){var e=t[0],r=t[1],n=t[2];return e*e+r*r+n*n}function G0(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t}function W0(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t}function X0(t,e){var r=e[0],n=e[1],o=e[2],i=r*r+n*n+o*o;return i>0&&(i=1/Math.sqrt(i)),t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t}function hs(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function q0(t,e,r){var n=e[0],o=e[1],i=e[2],s=r[0],a=r[1],c=r[2];return t[0]=o*c-i*a,t[1]=i*s-n*c,t[2]=n*a-o*s,t}function Y0(t,e,r,n){var o=e[0],i=e[1],s=e[2];return t[0]=o+n*(r[0]-o),t[1]=i+n*(r[1]-i),t[2]=s+n*(r[2]-s),t}function K0(t,e,r,n){var o=Math.acos(Math.min(Math.max(hs(e,r),-1),1)),i=Math.sin(o),s=Math.sin((1-n)*o)/i,a=Math.sin(n*o)/i;return t[0]=s*e[0]+a*r[0],t[1]=s*e[1]+a*r[1],t[2]=s*e[2]+a*r[2],t}function j0(t,e,r,n,o,i){var s=i*i,a=s*(2*i-3)+1,c=s*(i-2)+i,l=s*(i-1),d=s*(3-2*i);return t[0]=e[0]*a+r[0]*c+n[0]*l+o[0]*d,t[1]=e[1]*a+r[1]*c+n[1]*l+o[1]*d,t[2]=e[2]*a+r[2]*c+n[2]*l+o[2]*d,t}function $0(t,e,r,n,o,i){var s=1-i,a=s*s,c=i*i,l=a*s,d=3*i*a,u=3*c*s,m=c*i;return t[0]=e[0]*l+r[0]*d+n[0]*u+o[0]*m,t[1]=e[1]*l+r[1]*d+n[1]*u+o[1]*m,t[2]=e[2]*l+r[2]*d+n[2]*u+o[2]*m,t}function Q0(t,e){e=e===void 0?1:e;var r=ps()*2*Math.PI,n=ps()*2-1,o=Math.sqrt(1-n*n)*e;return t[0]=Math.cos(r)*o,t[1]=Math.sin(r)*o,t[2]=n*e,t}function J0(t,e,r){var n=e[0],o=e[1],i=e[2],s=r[3]*n+r[7]*o+r[11]*i+r[15];return s=s||1,t[0]=(r[0]*n+r[4]*o+r[8]*i+r[12])/s,t[1]=(r[1]*n+r[5]*o+r[9]*i+r[13])/s,t[2]=(r[2]*n+r[6]*o+r[10]*i+r[14])/s,t}function Z0(t,e,r){var n=e[0],o=e[1],i=e[2];return t[0]=n*r[0]+o*r[3]+i*r[6],t[1]=n*r[1]+o*r[4]+i*r[7],t[2]=n*r[2]+o*r[5]+i*r[8],t}function eu(t,e,r){var n=r[0],o=r[1],i=r[2],s=r[3],a=e[0],c=e[1],l=e[2],d=o*l-i*c,u=i*a-n*l,m=n*c-o*a;return d=d+d,u=u+u,m=m+m,t[0]=a+s*d+o*m-i*u,t[1]=c+s*u+i*d-n*m,t[2]=l+s*m+n*u-o*d,t}function tu(t,e,r,n){var o=[],i=[];return o[0]=e[0]-r[0],o[1]=e[1]-r[1],o[2]=e[2]-r[2],i[0]=o[0],i[1]=o[1]*Math.cos(n)-o[2]*Math.sin(n),i[2]=o[1]*Math.sin(n)+o[2]*Math.cos(n),t[0]=i[0]+r[0],t[1]=i[1]+r[1],t[2]=i[2]+r[2],t}function ru(t,e,r,n){var o=[],i=[];return o[0]=e[0]-r[0],o[1]=e[1]-r[1],o[2]=e[2]-r[2],i[0]=o[2]*Math.sin(n)+o[0]*Math.cos(n),i[1]=o[1],i[2]=o[2]*Math.cos(n)-o[0]*Math.sin(n),t[0]=i[0]+r[0],t[1]=i[1]+r[1],t[2]=i[2]+r[2],t}function nu(t,e,r,n){var o=[],i=[];return o[0]=e[0]-r[0],o[1]=e[1]-r[1],o[2]=e[2]-r[2],i[0]=o[0]*Math.cos(n)-o[1]*Math.sin(n),i[1]=o[0]*Math.sin(n)+o[1]*Math.cos(n),i[2]=o[2],t[0]=i[0]+r[0],t[1]=i[1]+r[1],t[2]=i[2]+r[2],t}function ou(t,e){var r=t[0],n=t[1],o=t[2],i=e[0],s=e[1],a=e[2],c=Math.sqrt((r*r+n*n+o*o)*(i*i+s*s+a*a)),l=c&&hs(t,e)/c;return Math.acos(Math.min(Math.max(l,-1),1))}function iu(t){return t[0]=0,t[1]=0,t[2]=0,t}function su(t){return"vec3("+t[0]+", "+t[1]+", "+t[2]+")"}function au(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]}function cu(t,e){var r=t[0],n=t[1],o=t[2],i=e[0],s=e[1],a=e[2];return Math.abs(r-i)<=K*Math.max(1,Math.abs(r),Math.abs(i))&&Math.abs(n-s)<=K*Math.max(1,Math.abs(n),Math.abs(s))&&Math.abs(o-a)<=K*Math.max(1,Math.abs(o),Math.abs(a))}var lu=vc,du=bc,uu=Sc,mu=Mc,fu=Ac,pu=xc,hu=_c,yu=(function(){var t=gc();return function(e,r,n,o,i,s){var a,c;for(r||(r=3),n||(n=0),o?c=Math.min(o*r+n,e.length):c=e.length,a=n;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],i(t,t,s),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2];return e}})();var ii=class{constructor(){this._position=oe.create();this._angles=oe.create();this._bobAngles=oe.create();this._bobOffset=oe.create();this._kickAngles=oe.create();this._rollAngle=0;this._fov=90;this._aspect=1;this._near=.1;this._far=1e3;this._viewMatrix=ie.create();this._projectionMatrix=ie.create();this._viewProjectionMatrix=ie.create();this._dirty=!0}get position(){return this._position}set position(e){oe.copy(this._position,e),this._dirty=!0}get angles(){return this._angles}set angles(e){oe.copy(this._angles,e),this._dirty=!0}get bobAngles(){return this._bobAngles}set bobAngles(e){oe.copy(this._bobAngles,e),this._dirty=!0}get kickAngles(){return this._kickAngles}set kickAngles(e){oe.copy(this._kickAngles,e),this._dirty=!0}get bobOffset(){return this._bobOffset}set bobOffset(e){oe.copy(this._bobOffset,e),this._dirty=!0}get rollAngle(){return this._rollAngle}set rollAngle(e){this._rollAngle=e,this._dirty=!0}get fov(){return this._fov}set fov(e){this._fov=e,this._dirty=!0}get aspect(){return this._aspect}set aspect(e){this._aspect=e,this._dirty=!0}get viewMatrix(){return this.updateMatrices(),this._viewMatrix}get projectionMatrix(){return this.updateMatrices(),this._projectionMatrix}get viewProjectionMatrix(){return this.updateMatrices(),this._viewProjectionMatrix}getViewmodelProjectionMatrix(e){let r=ie.create();return ie.perspective(r,e*Zt,this._aspect,this._near,this._far),r}updateMatrices(){if(!this._dirty)return;ie.perspective(this._projectionMatrix,this._fov*Zt,this._aspect,this._near,this._far);let e=ie.fromValues(0,-1,0,0,0,0,1,0,-1,0,0,0,0,0,0,1),r=this._angles[0]+this._bobAngles[0]+this._kickAngles[0],n=this._angles[1]+this._bobAngles[1]+this._kickAngles[1],o=this._angles[2]+this._bobAngles[2]+this._kickAngles[2]+this._rollAngle,i=r*Zt,s=n*Zt,a=o*Zt,c=ie.create();ie.identity(c),ie.rotateZ(c,c,-s),ie.rotateY(c,c,-i),ie.rotateX(c,c,-a);let l=ie.create();ie.multiply(l,e,c);let d=oe.add(oe.create(),this._position,this._bobOffset),u=oe.negate(oe.create(),d),m=oe.create();oe.transformMat4(m,u,c);let f=oe.fromValues(m[1]||0,m[2]||0,m[0]||0);ie.copy(this._viewMatrix,l),this._viewMatrix[12]=f[0],this._viewMatrix[13]=f[1],this._viewMatrix[14]=f[2],ie.multiply(this._viewProjectionMatrix,this._projectionMatrix,this._viewMatrix),this._dirty=!1}};var gu=[.2,.2,.2],xu={x:0,y:0,z:1},vu=[.8,.8,.8];function ys(t,e,r){return t+(e-t)*r}function Cr(t,e,r){return{x:ys(t.x,e.x,r),y:ys(t.y,e.y,r),z:ys(t.z,e.z,r)}}function zr(t){return t<0?0:t>1?1:t}function gs(t){let e=[],r=[];for(let n of t.triangles){let o=e.length,[i,s,a]=n.indices,c=t.texCoords[i],l=t.texCoords[s],d=t.texCoords[a];if(!c||!l||!d)throw new Error(`Missing texCoord for triangle in surface ${t.name}`);e.push({vertexIndex:i,texCoord:[c.s,1-c.t]},{vertexIndex:s,texCoord:[l.s,1-l.t]},{vertexIndex:a,texCoord:[d.s,1-d.t]}),r.push(o,o+1,o+2)}return{vertices:e,indices:new Uint16Array(r)}}function bu(t,e,r){let n=r?.ambient??gu,o=r?.directional??{direction:xu,color:vu},i=Oe(t),s=Oe(o.direction),a=zr(i.x*s.x+i.y*s.y+i.z*s.z),c=n[0]+o.color[0]*a,l=n[1]+o.color[1]*a,d=n[2]+o.color[2]*a;if(r?.dynamicLights){let u=r.modelMatrix?Ps(r.modelMatrix,e):e;for(let m of r.dynamicLights){let f=u.x-m.origin.x,h=u.y-m.origin.y,y=u.z-m.origin.z,p=f*f+h*h+y*y,g=m.radius*m.radius;if(p<g&&g>0){let S=1-Math.sqrt(p)/m.radius,v=Math.sqrt(p),M=v>0?zr(-(f*i.x+h*i.y+y*i.z)/v):0,b=zr(S*M);c+=m.color[0]*b,l+=m.color[1]*b,d+=m.color[2]*b}}}return[zr(c),zr(l),zr(d)]}function xs(t,e,r,n){let o=t.vertices[r.currentFrame],i=t.vertices[r.nextFrame];if(!o||!i)throw new Error("Requested MD3 frames are out of range");let s=new Float32Array(e.vertices.length*12);return e.vertices.forEach((a,c)=>{let l=o[a.vertexIndex],d=i[a.vertexIndex];if(!l||!d)throw new Error(`Vertex index ${a.vertexIndex} missing for frame`);let u=Cr(l.position,d.position,r.lerp),m=Oe(Cr(l.normal,d.normal,r.lerp)),f=bu(m,u,n),h=c*12;s[h]=u.x,s[h+1]=u.y,s[h+2]=u.z,s[h+3]=m.x,s[h+4]=m.y,s[h+5]=m.z,s[h+6]=a.texCoord[0],s[h+7]=a.texCoord[1],s[h+8]=f[0],s[h+9]=f[1],s[h+10]=f[2],s[h+11]=1}),s}function wc(t,e,r){let n=t.tags[0];if(!n)return null;let o=n.findIndex(y=>y.name===r);if(o===-1)return null;let i=t.tags[e.currentFrame]?.[o],s=t.tags[e.nextFrame]?.[o];if(!i||!s)throw new Error(`Tag ${r} is missing for one of the interpolated frames`);let a=Cr(i.origin,s.origin,e.lerp),c=Oe(Cr(i.axis[0],s.axis[0],e.lerp)),l=Oe(Cr(i.axis[1],s.axis[1],e.lerp)),d=Oe(Cr(i.axis[2],s.axis[2],e.lerp)),u=c,m=Oe({x:l.x-u.x*(u.x*l.x+u.y*l.y+u.z*l.z),y:l.y-u.y*(u.x*l.x+u.y*l.y+u.z*l.z),z:l.z-u.z*(u.x*l.x+u.y*l.y+u.z*l.z)}),f=Oe({x:u.y*m.z-u.z*m.y,y:u.z*m.x-u.x*m.z,z:u.x*m.y-u.y*m.x}),h=[u,m,f];return{origin:a,axis:h,matrix:Rs(a,h)}}var vs=`#version 300 es
|
|
257
|
+
}`;function kd(t){let e=t.x*t.x+t.y*t.y+t.z*t.z;if(e<=0)return{x:0,y:0,z:1};let r=1/Math.sqrt(e);return{x:t.x*r,y:t.y*r,z:t.z*r}}function ls(t,e,r){return t+(e-t)*r}function cc(t,e,r){return{x:ls(t.x,e.x,r),y:ls(t.y,e.y,r),z:ls(t.z,e.z,r)}}function Hd(t,e,r){return[t/r.skinWidth,1-e/r.skinHeight]}function fs(t){if(t.glCommands.length===0){let n=[],o=[];return t.triangles.forEach(i=>{let s=n.length;for(let a=0;a<3;a+=1){let c=i.vertexIndices[a],l=i.texCoordIndices[a],d=t.texCoords[l];n.push({vertexIndex:c,texCoord:Hd(d.s,d.t,t.header)})}o.push(s,s+1,s+2)}),{vertices:n,indices:new Uint16Array(o)}}let e=[],r=[];for(let n of t.glCommands){let o=e.length;if(e.push(...n.vertices.map(i=>({vertexIndex:i.vertexIndex,texCoord:[i.s,1-i.t]}))),n.mode==="strip")for(let i=0;i<n.vertices.length-2;i+=1){let s=i%2===0,a=o+i+(s?0:1),c=o+i+(s?1:0),l=o+i+2;r.push(a,c,l)}else for(let i=1;i<n.vertices.length-1;i+=1)r.push(o,o+i,o+i+1)}return{vertices:e,indices:new Uint16Array(r)}}function ms(t,e,r){let{currentFrame:n,nextFrame:o,lerp:i}=r,s=t.frames[n],a=t.frames[o];if(!s||!a)throw new Error("Requested MD2 frames are out of range");let c=new Float32Array(e.vertices.length*8);return e.vertices.forEach((l,d)=>{let u=s.vertices[l.vertexIndex],f=a.vertices[l.vertexIndex];if(!u||!f)throw new Error("MD2 vertex index out of range for frame");let m=cc(u.position,f.position,i),p=kd(cc(u.normal,f.normal,i)),y=d*8;c[y]=m.x,c[y+1]=m.y,c[y+2]=m.z,c[y+3]=p.x,c[y+4]=p.y,c[y+5]=p.z,c[y+6]=l.texCoord[0],c[y+7]=l.texCoord[1]}),c}var ri=class{constructor(e,r,n){this.gl=e,this.geometry=fs(r),this.vertexBuffer=new xe(e,e.STATIC_DRAW),this.indexBuffer=new De(e,e.STATIC_DRAW),this.vertexArray=new Me(e),this.indexCount=this.geometry.indices.length,this.vertexArray.configureAttributes([{index:0,size:3,type:e.FLOAT,stride:32,offset:0},{index:1,size:3,type:e.FLOAT,stride:32,offset:12},{index:2,size:2,type:e.FLOAT,stride:32,offset:24}],this.vertexBuffer),this.vertexArray.bind(),this.indexBuffer.bind(),this.indexBuffer.upload(this.geometry.indices,e.STATIC_DRAW),this.update(r,n)}update(e,r){let n=ms(e,this.geometry,r);this.vertexBuffer.upload(n,this.gl.STATIC_DRAW)}bind(){this.vertexArray.bind(),this.indexBuffer.bind()}dispose(){this.vertexBuffer.dispose(),this.indexBuffer.dispose(),this.vertexArray.dispose()}},ni=class{constructor(e){this.gl=e,this.program=ge.create(e,{vertex:ds,fragment:us},{a_position:0,a_normal:1,a_texCoord:2}),this.uniformMvp=this.program.getUniformLocation("u_modelViewProjection"),this.uniformLightDir=this.program.getUniformLocation("u_lightDir"),this.uniformTint=this.program.getUniformLocation("u_tint"),this.uniformDiffuse=this.program.getUniformLocation("u_diffuseMap")}bind(e){let{modelViewProjection:r,lightDirection:n=[0,0,1],tint:o=[1,1,1,1],diffuseSampler:i=0}=e,s=new Float32Array(n),a=new Float32Array(o);this.program.use(),this.gl.uniformMatrix4fv(this.uniformMvp,!1,r),this.gl.uniform3fv(this.uniformLightDir,s),this.gl.uniform4fv(this.uniformTint,a),this.gl.uniform1i(this.uniformDiffuse,i)}draw(e){e.bind(),this.gl.drawElements(this.gl.TRIANGLES,e.indexCount,this.gl.UNSIGNED_SHORT,0)}dispose(){this.program.dispose()}};var q=1e-6,ke=typeof Float32Array<"u"?Float32Array:Array,hs=Math.random;function oi(t){return t>=0?Math.round(t):t%.5===0?Math.floor(t):Math.round(t)}var g1=Math.PI/180,x1=180/Math.PI;var ie={};di(ie,{add:()=>_u,adjoint:()=>Yd,clone:()=>Vd,copy:()=>Ud,create:()=>Nd,decompose:()=>du,determinant:()=>qd,equals:()=>Iu,exactEquals:()=>Eu,frob:()=>Au,fromQuat:()=>mu,fromQuat2:()=>au,fromRotation:()=>nu,fromRotationTranslation:()=>fc,fromRotationTranslationScale:()=>uu,fromRotationTranslationScaleOrigin:()=>fu,fromScaling:()=>ru,fromTranslation:()=>tu,fromValues:()=>Gd,fromXRotation:()=>ou,fromYRotation:()=>iu,fromZRotation:()=>su,frustum:()=>hu,getRotation:()=>lu,getScaling:()=>mc,getTranslation:()=>cu,identity:()=>dc,invert:()=>Kd,lookAt:()=>vu,mul:()=>zu,multiply:()=>uc,multiplyScalar:()=>wu,multiplyScalarAndAdd:()=>Lu,ortho:()=>xu,orthoNO:()=>pc,orthoZO:()=>bu,perspective:()=>pu,perspectiveFromFieldOfView:()=>gu,perspectiveNO:()=>hc,perspectiveZO:()=>yu,rotate:()=>Qd,rotateX:()=>Jd,rotateY:()=>Zd,rotateZ:()=>eu,scale:()=>$d,set:()=>Wd,str:()=>Mu,sub:()=>Pu,subtract:()=>yc,targetTo:()=>Su,translate:()=>jd,transpose:()=>Xd});function Nd(){var t=new ke(16);return ke!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function Vd(t){var e=new ke(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function Ud(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function Gd(t,e,r,n,o,i,s,a,c,l,d,u,f,m,p,y){var h=new ke(16);return h[0]=t,h[1]=e,h[2]=r,h[3]=n,h[4]=o,h[5]=i,h[6]=s,h[7]=a,h[8]=c,h[9]=l,h[10]=d,h[11]=u,h[12]=f,h[13]=m,h[14]=p,h[15]=y,h}function Wd(t,e,r,n,o,i,s,a,c,l,d,u,f,m,p,y,h){return t[0]=e,t[1]=r,t[2]=n,t[3]=o,t[4]=i,t[5]=s,t[6]=a,t[7]=c,t[8]=l,t[9]=d,t[10]=u,t[11]=f,t[12]=m,t[13]=p,t[14]=y,t[15]=h,t}function dc(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Xd(t,e){if(t===e){var r=e[1],n=e[2],o=e[3],i=e[6],s=e[7],a=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=n,t[9]=i,t[11]=e[14],t[12]=o,t[13]=s,t[14]=a}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function Kd(t,e){var r=e[0],n=e[1],o=e[2],i=e[3],s=e[4],a=e[5],c=e[6],l=e[7],d=e[8],u=e[9],f=e[10],m=e[11],p=e[12],y=e[13],h=e[14],g=e[15],S=r*a-n*s,b=r*c-o*s,M=r*l-i*s,v=n*c-o*a,A=n*l-i*a,_=o*l-i*c,L=d*y-u*p,F=d*h-f*p,w=d*g-m*p,H=u*h-f*y,U=u*g-m*y,V=f*g-m*h,C=S*V-b*U+M*H+v*w-A*F+_*L;return C?(C=1/C,t[0]=(a*V-c*U+l*H)*C,t[1]=(o*U-n*V-i*H)*C,t[2]=(y*_-h*A+g*v)*C,t[3]=(f*A-u*_-m*v)*C,t[4]=(c*w-s*V-l*F)*C,t[5]=(r*V-o*w+i*F)*C,t[6]=(h*M-p*_-g*b)*C,t[7]=(d*_-f*M+m*b)*C,t[8]=(s*U-a*w+l*L)*C,t[9]=(n*w-r*U-i*L)*C,t[10]=(p*A-y*M+g*S)*C,t[11]=(u*M-d*A-m*S)*C,t[12]=(a*F-s*H-c*L)*C,t[13]=(r*H-n*F+o*L)*C,t[14]=(y*b-p*v-h*S)*C,t[15]=(d*v-u*b+f*S)*C,t):null}function Yd(t,e){var r=e[0],n=e[1],o=e[2],i=e[3],s=e[4],a=e[5],c=e[6],l=e[7],d=e[8],u=e[9],f=e[10],m=e[11],p=e[12],y=e[13],h=e[14],g=e[15],S=r*a-n*s,b=r*c-o*s,M=r*l-i*s,v=n*c-o*a,A=n*l-i*a,_=o*l-i*c,L=d*y-u*p,F=d*h-f*p,w=d*g-m*p,H=u*h-f*y,U=u*g-m*y,V=f*g-m*h;return t[0]=a*V-c*U+l*H,t[1]=o*U-n*V-i*H,t[2]=y*_-h*A+g*v,t[3]=f*A-u*_-m*v,t[4]=c*w-s*V-l*F,t[5]=r*V-o*w+i*F,t[6]=h*M-p*_-g*b,t[7]=d*_-f*M+m*b,t[8]=s*U-a*w+l*L,t[9]=n*w-r*U-i*L,t[10]=p*A-y*M+g*S,t[11]=u*M-d*A-m*S,t[12]=a*F-s*H-c*L,t[13]=r*H-n*F+o*L,t[14]=y*b-p*v-h*S,t[15]=d*v-u*b+f*S,t}function qd(t){var e=t[0],r=t[1],n=t[2],o=t[3],i=t[4],s=t[5],a=t[6],c=t[7],l=t[8],d=t[9],u=t[10],f=t[11],m=t[12],p=t[13],y=t[14],h=t[15],g=e*s-r*i,S=e*a-n*i,b=r*a-n*s,M=l*p-d*m,v=l*y-u*m,A=d*y-u*p,_=e*A-r*v+n*M,L=i*A-s*v+a*M,F=l*b-d*S+u*g,w=m*b-p*S+y*g;return c*_-o*L+h*F-f*w}function uc(t,e,r){var n=e[0],o=e[1],i=e[2],s=e[3],a=e[4],c=e[5],l=e[6],d=e[7],u=e[8],f=e[9],m=e[10],p=e[11],y=e[12],h=e[13],g=e[14],S=e[15],b=r[0],M=r[1],v=r[2],A=r[3];return t[0]=b*n+M*a+v*u+A*y,t[1]=b*o+M*c+v*f+A*h,t[2]=b*i+M*l+v*m+A*g,t[3]=b*s+M*d+v*p+A*S,b=r[4],M=r[5],v=r[6],A=r[7],t[4]=b*n+M*a+v*u+A*y,t[5]=b*o+M*c+v*f+A*h,t[6]=b*i+M*l+v*m+A*g,t[7]=b*s+M*d+v*p+A*S,b=r[8],M=r[9],v=r[10],A=r[11],t[8]=b*n+M*a+v*u+A*y,t[9]=b*o+M*c+v*f+A*h,t[10]=b*i+M*l+v*m+A*g,t[11]=b*s+M*d+v*p+A*S,b=r[12],M=r[13],v=r[14],A=r[15],t[12]=b*n+M*a+v*u+A*y,t[13]=b*o+M*c+v*f+A*h,t[14]=b*i+M*l+v*m+A*g,t[15]=b*s+M*d+v*p+A*S,t}function jd(t,e,r){var n=r[0],o=r[1],i=r[2],s,a,c,l,d,u,f,m,p,y,h,g;return e===t?(t[12]=e[0]*n+e[4]*o+e[8]*i+e[12],t[13]=e[1]*n+e[5]*o+e[9]*i+e[13],t[14]=e[2]*n+e[6]*o+e[10]*i+e[14],t[15]=e[3]*n+e[7]*o+e[11]*i+e[15]):(s=e[0],a=e[1],c=e[2],l=e[3],d=e[4],u=e[5],f=e[6],m=e[7],p=e[8],y=e[9],h=e[10],g=e[11],t[0]=s,t[1]=a,t[2]=c,t[3]=l,t[4]=d,t[5]=u,t[6]=f,t[7]=m,t[8]=p,t[9]=y,t[10]=h,t[11]=g,t[12]=s*n+d*o+p*i+e[12],t[13]=a*n+u*o+y*i+e[13],t[14]=c*n+f*o+h*i+e[14],t[15]=l*n+m*o+g*i+e[15]),t}function $d(t,e,r){var n=r[0],o=r[1],i=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*o,t[5]=e[5]*o,t[6]=e[6]*o,t[7]=e[7]*o,t[8]=e[8]*i,t[9]=e[9]*i,t[10]=e[10]*i,t[11]=e[11]*i,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function Qd(t,e,r,n){var o=n[0],i=n[1],s=n[2],a=Math.sqrt(o*o+i*i+s*s),c,l,d,u,f,m,p,y,h,g,S,b,M,v,A,_,L,F,w,H,U,V,C,$;return a<q?null:(a=1/a,o*=a,i*=a,s*=a,c=Math.sin(r),l=Math.cos(r),d=1-l,u=e[0],f=e[1],m=e[2],p=e[3],y=e[4],h=e[5],g=e[6],S=e[7],b=e[8],M=e[9],v=e[10],A=e[11],_=o*o*d+l,L=i*o*d+s*c,F=s*o*d-i*c,w=o*i*d-s*c,H=i*i*d+l,U=s*i*d+o*c,V=o*s*d+i*c,C=i*s*d-o*c,$=s*s*d+l,t[0]=u*_+y*L+b*F,t[1]=f*_+h*L+M*F,t[2]=m*_+g*L+v*F,t[3]=p*_+S*L+A*F,t[4]=u*w+y*H+b*U,t[5]=f*w+h*H+M*U,t[6]=m*w+g*H+v*U,t[7]=p*w+S*H+A*U,t[8]=u*V+y*C+b*$,t[9]=f*V+h*C+M*$,t[10]=m*V+g*C+v*$,t[11]=p*V+S*C+A*$,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)}function Jd(t,e,r){var n=Math.sin(r),o=Math.cos(r),i=e[4],s=e[5],a=e[6],c=e[7],l=e[8],d=e[9],u=e[10],f=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=i*o+l*n,t[5]=s*o+d*n,t[6]=a*o+u*n,t[7]=c*o+f*n,t[8]=l*o-i*n,t[9]=d*o-s*n,t[10]=u*o-a*n,t[11]=f*o-c*n,t}function Zd(t,e,r){var n=Math.sin(r),o=Math.cos(r),i=e[0],s=e[1],a=e[2],c=e[3],l=e[8],d=e[9],u=e[10],f=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=i*o-l*n,t[1]=s*o-d*n,t[2]=a*o-u*n,t[3]=c*o-f*n,t[8]=i*n+l*o,t[9]=s*n+d*o,t[10]=a*n+u*o,t[11]=c*n+f*o,t}function eu(t,e,r){var n=Math.sin(r),o=Math.cos(r),i=e[0],s=e[1],a=e[2],c=e[3],l=e[4],d=e[5],u=e[6],f=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=i*o+l*n,t[1]=s*o+d*n,t[2]=a*o+u*n,t[3]=c*o+f*n,t[4]=l*o-i*n,t[5]=d*o-s*n,t[6]=u*o-a*n,t[7]=f*o-c*n,t}function tu(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}function ru(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function nu(t,e,r){var n=r[0],o=r[1],i=r[2],s=Math.sqrt(n*n+o*o+i*i),a,c,l;return s<q?null:(s=1/s,n*=s,o*=s,i*=s,a=Math.sin(e),c=Math.cos(e),l=1-c,t[0]=n*n*l+c,t[1]=o*n*l+i*a,t[2]=i*n*l-o*a,t[3]=0,t[4]=n*o*l-i*a,t[5]=o*o*l+c,t[6]=i*o*l+n*a,t[7]=0,t[8]=n*i*l+o*a,t[9]=o*i*l-n*a,t[10]=i*i*l+c,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t)}function ou(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=n,t[6]=r,t[7]=0,t[8]=0,t[9]=-r,t[10]=n,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function iu(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=0,t[2]=-r,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=r,t[9]=0,t[10]=n,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function su(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=r,t[2]=0,t[3]=0,t[4]=-r,t[5]=n,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function fc(t,e,r){var n=e[0],o=e[1],i=e[2],s=e[3],a=n+n,c=o+o,l=i+i,d=n*a,u=n*c,f=n*l,m=o*c,p=o*l,y=i*l,h=s*a,g=s*c,S=s*l;return t[0]=1-(m+y),t[1]=u+S,t[2]=f-g,t[3]=0,t[4]=u-S,t[5]=1-(d+y),t[6]=p+h,t[7]=0,t[8]=f+g,t[9]=p-h,t[10]=1-(d+m),t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function au(t,e){var r=new ke(3),n=-e[0],o=-e[1],i=-e[2],s=e[3],a=e[4],c=e[5],l=e[6],d=e[7],u=n*n+o*o+i*i+s*s;return u>0?(r[0]=(a*s+d*n+c*i-l*o)*2/u,r[1]=(c*s+d*o+l*n-a*i)*2/u,r[2]=(l*s+d*i+a*o-c*n)*2/u):(r[0]=(a*s+d*n+c*i-l*o)*2,r[1]=(c*s+d*o+l*n-a*i)*2,r[2]=(l*s+d*i+a*o-c*n)*2),fc(t,e,r),t}function cu(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}function mc(t,e){var r=e[0],n=e[1],o=e[2],i=e[4],s=e[5],a=e[6],c=e[8],l=e[9],d=e[10];return t[0]=Math.sqrt(r*r+n*n+o*o),t[1]=Math.sqrt(i*i+s*s+a*a),t[2]=Math.sqrt(c*c+l*l+d*d),t}function lu(t,e){var r=new ke(3);mc(r,e);var n=1/r[0],o=1/r[1],i=1/r[2],s=e[0]*n,a=e[1]*o,c=e[2]*i,l=e[4]*n,d=e[5]*o,u=e[6]*i,f=e[8]*n,m=e[9]*o,p=e[10]*i,y=s+d+p,h=0;return y>0?(h=Math.sqrt(y+1)*2,t[3]=.25*h,t[0]=(u-m)/h,t[1]=(f-c)/h,t[2]=(a-l)/h):s>d&&s>p?(h=Math.sqrt(1+s-d-p)*2,t[3]=(u-m)/h,t[0]=.25*h,t[1]=(a+l)/h,t[2]=(f+c)/h):d>p?(h=Math.sqrt(1+d-s-p)*2,t[3]=(f-c)/h,t[0]=(a+l)/h,t[1]=.25*h,t[2]=(u+m)/h):(h=Math.sqrt(1+p-s-d)*2,t[3]=(a-l)/h,t[0]=(f+c)/h,t[1]=(u+m)/h,t[2]=.25*h),t}function du(t,e,r,n){e[0]=n[12],e[1]=n[13],e[2]=n[14];var o=n[0],i=n[1],s=n[2],a=n[4],c=n[5],l=n[6],d=n[8],u=n[9],f=n[10];r[0]=Math.sqrt(o*o+i*i+s*s),r[1]=Math.sqrt(a*a+c*c+l*l),r[2]=Math.sqrt(d*d+u*u+f*f);var m=1/r[0],p=1/r[1],y=1/r[2],h=o*m,g=i*p,S=s*y,b=a*m,M=c*p,v=l*y,A=d*m,_=u*p,L=f*y,F=h+M+L,w=0;return F>0?(w=Math.sqrt(F+1)*2,t[3]=.25*w,t[0]=(v-_)/w,t[1]=(A-S)/w,t[2]=(g-b)/w):h>M&&h>L?(w=Math.sqrt(1+h-M-L)*2,t[3]=(v-_)/w,t[0]=.25*w,t[1]=(g+b)/w,t[2]=(A+S)/w):M>L?(w=Math.sqrt(1+M-h-L)*2,t[3]=(A-S)/w,t[0]=(g+b)/w,t[1]=.25*w,t[2]=(v+_)/w):(w=Math.sqrt(1+L-h-M)*2,t[3]=(g-b)/w,t[0]=(A+S)/w,t[1]=(v+_)/w,t[2]=.25*w),t}function uu(t,e,r,n){var o=e[0],i=e[1],s=e[2],a=e[3],c=o+o,l=i+i,d=s+s,u=o*c,f=o*l,m=o*d,p=i*l,y=i*d,h=s*d,g=a*c,S=a*l,b=a*d,M=n[0],v=n[1],A=n[2];return t[0]=(1-(p+h))*M,t[1]=(f+b)*M,t[2]=(m-S)*M,t[3]=0,t[4]=(f-b)*v,t[5]=(1-(u+h))*v,t[6]=(y+g)*v,t[7]=0,t[8]=(m+S)*A,t[9]=(y-g)*A,t[10]=(1-(u+p))*A,t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function fu(t,e,r,n,o){var i=e[0],s=e[1],a=e[2],c=e[3],l=i+i,d=s+s,u=a+a,f=i*l,m=i*d,p=i*u,y=s*d,h=s*u,g=a*u,S=c*l,b=c*d,M=c*u,v=n[0],A=n[1],_=n[2],L=o[0],F=o[1],w=o[2],H=(1-(y+g))*v,U=(m+M)*v,V=(p-b)*v,C=(m-M)*A,$=(1-(f+g))*A,be=(h+S)*A,Ft=(p+b)*_,kn=(h-S)*_,Pr=(1-(f+y))*_;return t[0]=H,t[1]=U,t[2]=V,t[3]=0,t[4]=C,t[5]=$,t[6]=be,t[7]=0,t[8]=Ft,t[9]=kn,t[10]=Pr,t[11]=0,t[12]=r[0]+L-(H*L+C*F+Ft*w),t[13]=r[1]+F-(U*L+$*F+kn*w),t[14]=r[2]+w-(V*L+be*F+Pr*w),t[15]=1,t}function mu(t,e){var r=e[0],n=e[1],o=e[2],i=e[3],s=r+r,a=n+n,c=o+o,l=r*s,d=n*s,u=n*a,f=o*s,m=o*a,p=o*c,y=i*s,h=i*a,g=i*c;return t[0]=1-u-p,t[1]=d+g,t[2]=f-h,t[3]=0,t[4]=d-g,t[5]=1-l-p,t[6]=m+y,t[7]=0,t[8]=f+h,t[9]=m-y,t[10]=1-l-u,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function hu(t,e,r,n,o,i,s){var a=1/(r-e),c=1/(o-n),l=1/(i-s);return t[0]=i*2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=i*2*c,t[6]=0,t[7]=0,t[8]=(r+e)*a,t[9]=(o+n)*c,t[10]=(s+i)*l,t[11]=-1,t[12]=0,t[13]=0,t[14]=s*i*2*l,t[15]=0,t}function hc(t,e,r,n,o){var i=1/Math.tan(e/2);if(t[0]=i/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=i,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,o!=null&&o!==1/0){var s=1/(n-o);t[10]=(o+n)*s,t[14]=2*o*n*s}else t[10]=-1,t[14]=-2*n;return t}var pu=hc;function yu(t,e,r,n,o){var i=1/Math.tan(e/2);if(t[0]=i/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=i,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,o!=null&&o!==1/0){var s=1/(n-o);t[10]=o*s,t[14]=o*n*s}else t[10]=-1,t[14]=-n;return t}function gu(t,e,r,n){var o=Math.tan(e.upDegrees*Math.PI/180),i=Math.tan(e.downDegrees*Math.PI/180),s=Math.tan(e.leftDegrees*Math.PI/180),a=Math.tan(e.rightDegrees*Math.PI/180),c=2/(s+a),l=2/(o+i);return t[0]=c,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=l,t[6]=0,t[7]=0,t[8]=-((s-a)*c*.5),t[9]=(o-i)*l*.5,t[10]=n/(r-n),t[11]=-1,t[12]=0,t[13]=0,t[14]=n*r/(r-n),t[15]=0,t}function pc(t,e,r,n,o,i,s){var a=1/(e-r),c=1/(n-o),l=1/(i-s);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*l,t[11]=0,t[12]=(e+r)*a,t[13]=(o+n)*c,t[14]=(s+i)*l,t[15]=1,t}var xu=pc;function bu(t,e,r,n,o,i,s){var a=1/(e-r),c=1/(n-o),l=1/(i-s);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=l,t[11]=0,t[12]=(e+r)*a,t[13]=(o+n)*c,t[14]=i*l,t[15]=1,t}function vu(t,e,r,n){var o,i,s,a,c,l,d,u,f,m,p=e[0],y=e[1],h=e[2],g=n[0],S=n[1],b=n[2],M=r[0],v=r[1],A=r[2];return Math.abs(p-M)<q&&Math.abs(y-v)<q&&Math.abs(h-A)<q?dc(t):(d=p-M,u=y-v,f=h-A,m=1/Math.sqrt(d*d+u*u+f*f),d*=m,u*=m,f*=m,o=S*f-b*u,i=b*d-g*f,s=g*u-S*d,m=Math.sqrt(o*o+i*i+s*s),m?(m=1/m,o*=m,i*=m,s*=m):(o=0,i=0,s=0),a=u*s-f*i,c=f*o-d*s,l=d*i-u*o,m=Math.sqrt(a*a+c*c+l*l),m?(m=1/m,a*=m,c*=m,l*=m):(a=0,c=0,l=0),t[0]=o,t[1]=a,t[2]=d,t[3]=0,t[4]=i,t[5]=c,t[6]=u,t[7]=0,t[8]=s,t[9]=l,t[10]=f,t[11]=0,t[12]=-(o*p+i*y+s*h),t[13]=-(a*p+c*y+l*h),t[14]=-(d*p+u*y+f*h),t[15]=1,t)}function Su(t,e,r,n){var o=e[0],i=e[1],s=e[2],a=n[0],c=n[1],l=n[2],d=o-r[0],u=i-r[1],f=s-r[2],m=d*d+u*u+f*f;m>0&&(m=1/Math.sqrt(m),d*=m,u*=m,f*=m);var p=c*f-l*u,y=l*d-a*f,h=a*u-c*d;return m=p*p+y*y+h*h,m>0&&(m=1/Math.sqrt(m),p*=m,y*=m,h*=m),t[0]=p,t[1]=y,t[2]=h,t[3]=0,t[4]=u*h-f*y,t[5]=f*p-d*h,t[6]=d*y-u*p,t[7]=0,t[8]=d,t[9]=u,t[10]=f,t[11]=0,t[12]=o,t[13]=i,t[14]=s,t[15]=1,t}function Mu(t){return"mat4("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+", "+t[9]+", "+t[10]+", "+t[11]+", "+t[12]+", "+t[13]+", "+t[14]+", "+t[15]+")"}function Au(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]+t[3]*t[3]+t[4]*t[4]+t[5]*t[5]+t[6]*t[6]+t[7]*t[7]+t[8]*t[8]+t[9]*t[9]+t[10]*t[10]+t[11]*t[11]+t[12]*t[12]+t[13]*t[13]+t[14]*t[14]+t[15]*t[15])}function _u(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t[6]=e[6]+r[6],t[7]=e[7]+r[7],t[8]=e[8]+r[8],t[9]=e[9]+r[9],t[10]=e[10]+r[10],t[11]=e[11]+r[11],t[12]=e[12]+r[12],t[13]=e[13]+r[13],t[14]=e[14]+r[14],t[15]=e[15]+r[15],t}function yc(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t[4]=e[4]-r[4],t[5]=e[5]-r[5],t[6]=e[6]-r[6],t[7]=e[7]-r[7],t[8]=e[8]-r[8],t[9]=e[9]-r[9],t[10]=e[10]-r[10],t[11]=e[11]-r[11],t[12]=e[12]-r[12],t[13]=e[13]-r[13],t[14]=e[14]-r[14],t[15]=e[15]-r[15],t}function wu(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*r,t[9]=e[9]*r,t[10]=e[10]*r,t[11]=e[11]*r,t[12]=e[12]*r,t[13]=e[13]*r,t[14]=e[14]*r,t[15]=e[15]*r,t}function Lu(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t[4]=e[4]+r[4]*n,t[5]=e[5]+r[5]*n,t[6]=e[6]+r[6]*n,t[7]=e[7]+r[7]*n,t[8]=e[8]+r[8]*n,t[9]=e[9]+r[9]*n,t[10]=e[10]+r[10]*n,t[11]=e[11]+r[11]*n,t[12]=e[12]+r[12]*n,t[13]=e[13]+r[13]*n,t[14]=e[14]+r[14]*n,t[15]=e[15]+r[15]*n,t}function Eu(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]}function Iu(t,e){var r=t[0],n=t[1],o=t[2],i=t[3],s=t[4],a=t[5],c=t[6],l=t[7],d=t[8],u=t[9],f=t[10],m=t[11],p=t[12],y=t[13],h=t[14],g=t[15],S=e[0],b=e[1],M=e[2],v=e[3],A=e[4],_=e[5],L=e[6],F=e[7],w=e[8],H=e[9],U=e[10],V=e[11],C=e[12],$=e[13],be=e[14],Ft=e[15];return Math.abs(r-S)<=q*Math.max(1,Math.abs(r),Math.abs(S))&&Math.abs(n-b)<=q*Math.max(1,Math.abs(n),Math.abs(b))&&Math.abs(o-M)<=q*Math.max(1,Math.abs(o),Math.abs(M))&&Math.abs(i-v)<=q*Math.max(1,Math.abs(i),Math.abs(v))&&Math.abs(s-A)<=q*Math.max(1,Math.abs(s),Math.abs(A))&&Math.abs(a-_)<=q*Math.max(1,Math.abs(a),Math.abs(_))&&Math.abs(c-L)<=q*Math.max(1,Math.abs(c),Math.abs(L))&&Math.abs(l-F)<=q*Math.max(1,Math.abs(l),Math.abs(F))&&Math.abs(d-w)<=q*Math.max(1,Math.abs(d),Math.abs(w))&&Math.abs(u-H)<=q*Math.max(1,Math.abs(u),Math.abs(H))&&Math.abs(f-U)<=q*Math.max(1,Math.abs(f),Math.abs(U))&&Math.abs(m-V)<=q*Math.max(1,Math.abs(m),Math.abs(V))&&Math.abs(p-C)<=q*Math.max(1,Math.abs(p),Math.abs(C))&&Math.abs(y-$)<=q*Math.max(1,Math.abs(y),Math.abs($))&&Math.abs(h-be)<=q*Math.max(1,Math.abs(h),Math.abs(be))&&Math.abs(g-Ft)<=q*Math.max(1,Math.abs(g),Math.abs(Ft))}var zu=uc,Pu=yc;var oe={};di(oe,{add:()=>Bu,angle:()=>o0,bezier:()=>$u,ceil:()=>Ou,clone:()=>Fu,copy:()=>Tu,create:()=>gc,cross:()=>Ku,dist:()=>f0,distance:()=>Mc,div:()=>u0,divide:()=>Sc,dot:()=>ps,equals:()=>c0,exactEquals:()=>a0,floor:()=>Du,forEach:()=>y0,fromValues:()=>Cu,hermite:()=>ju,inverse:()=>Wu,len:()=>h0,length:()=>xc,lerp:()=>Yu,max:()=>Hu,min:()=>ku,mul:()=>d0,multiply:()=>vc,negate:()=>Gu,normalize:()=>Xu,random:()=>Qu,rotateX:()=>t0,rotateY:()=>r0,rotateZ:()=>n0,round:()=>Nu,scale:()=>Vu,scaleAndAdd:()=>Uu,set:()=>Ru,slerp:()=>qu,sqrDist:()=>m0,sqrLen:()=>p0,squaredDistance:()=>Ac,squaredLength:()=>_c,str:()=>s0,sub:()=>l0,subtract:()=>bc,transformMat3:()=>Zu,transformMat4:()=>Ju,transformQuat:()=>e0,zero:()=>i0});function gc(){var t=new ke(3);return ke!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function Fu(t){var e=new ke(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function xc(t){var e=t[0],r=t[1],n=t[2];return Math.sqrt(e*e+r*r+n*n)}function Cu(t,e,r){var n=new ke(3);return n[0]=t,n[1]=e,n[2]=r,n}function Tu(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function Ru(t,e,r,n){return t[0]=e,t[1]=r,t[2]=n,t}function Bu(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t}function bc(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function vc(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t}function Sc(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t}function Ou(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t}function Du(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t}function ku(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t}function Hu(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t}function Nu(t,e){return t[0]=oi(e[0]),t[1]=oi(e[1]),t[2]=oi(e[2]),t}function Vu(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function Uu(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t}function Mc(t,e){var r=e[0]-t[0],n=e[1]-t[1],o=e[2]-t[2];return Math.sqrt(r*r+n*n+o*o)}function Ac(t,e){var r=e[0]-t[0],n=e[1]-t[1],o=e[2]-t[2];return r*r+n*n+o*o}function _c(t){var e=t[0],r=t[1],n=t[2];return e*e+r*r+n*n}function Gu(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t}function Wu(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t}function Xu(t,e){var r=e[0],n=e[1],o=e[2],i=r*r+n*n+o*o;return i>0&&(i=1/Math.sqrt(i)),t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t}function ps(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Ku(t,e,r){var n=e[0],o=e[1],i=e[2],s=r[0],a=r[1],c=r[2];return t[0]=o*c-i*a,t[1]=i*s-n*c,t[2]=n*a-o*s,t}function Yu(t,e,r,n){var o=e[0],i=e[1],s=e[2];return t[0]=o+n*(r[0]-o),t[1]=i+n*(r[1]-i),t[2]=s+n*(r[2]-s),t}function qu(t,e,r,n){var o=Math.acos(Math.min(Math.max(ps(e,r),-1),1)),i=Math.sin(o),s=Math.sin((1-n)*o)/i,a=Math.sin(n*o)/i;return t[0]=s*e[0]+a*r[0],t[1]=s*e[1]+a*r[1],t[2]=s*e[2]+a*r[2],t}function ju(t,e,r,n,o,i){var s=i*i,a=s*(2*i-3)+1,c=s*(i-2)+i,l=s*(i-1),d=s*(3-2*i);return t[0]=e[0]*a+r[0]*c+n[0]*l+o[0]*d,t[1]=e[1]*a+r[1]*c+n[1]*l+o[1]*d,t[2]=e[2]*a+r[2]*c+n[2]*l+o[2]*d,t}function $u(t,e,r,n,o,i){var s=1-i,a=s*s,c=i*i,l=a*s,d=3*i*a,u=3*c*s,f=c*i;return t[0]=e[0]*l+r[0]*d+n[0]*u+o[0]*f,t[1]=e[1]*l+r[1]*d+n[1]*u+o[1]*f,t[2]=e[2]*l+r[2]*d+n[2]*u+o[2]*f,t}function Qu(t,e){e=e===void 0?1:e;var r=hs()*2*Math.PI,n=hs()*2-1,o=Math.sqrt(1-n*n)*e;return t[0]=Math.cos(r)*o,t[1]=Math.sin(r)*o,t[2]=n*e,t}function Ju(t,e,r){var n=e[0],o=e[1],i=e[2],s=r[3]*n+r[7]*o+r[11]*i+r[15];return s=s||1,t[0]=(r[0]*n+r[4]*o+r[8]*i+r[12])/s,t[1]=(r[1]*n+r[5]*o+r[9]*i+r[13])/s,t[2]=(r[2]*n+r[6]*o+r[10]*i+r[14])/s,t}function Zu(t,e,r){var n=e[0],o=e[1],i=e[2];return t[0]=n*r[0]+o*r[3]+i*r[6],t[1]=n*r[1]+o*r[4]+i*r[7],t[2]=n*r[2]+o*r[5]+i*r[8],t}function e0(t,e,r){var n=r[0],o=r[1],i=r[2],s=r[3],a=e[0],c=e[1],l=e[2],d=o*l-i*c,u=i*a-n*l,f=n*c-o*a;return d=d+d,u=u+u,f=f+f,t[0]=a+s*d+o*f-i*u,t[1]=c+s*u+i*d-n*f,t[2]=l+s*f+n*u-o*d,t}function t0(t,e,r,n){var o=[],i=[];return o[0]=e[0]-r[0],o[1]=e[1]-r[1],o[2]=e[2]-r[2],i[0]=o[0],i[1]=o[1]*Math.cos(n)-o[2]*Math.sin(n),i[2]=o[1]*Math.sin(n)+o[2]*Math.cos(n),t[0]=i[0]+r[0],t[1]=i[1]+r[1],t[2]=i[2]+r[2],t}function r0(t,e,r,n){var o=[],i=[];return o[0]=e[0]-r[0],o[1]=e[1]-r[1],o[2]=e[2]-r[2],i[0]=o[2]*Math.sin(n)+o[0]*Math.cos(n),i[1]=o[1],i[2]=o[2]*Math.cos(n)-o[0]*Math.sin(n),t[0]=i[0]+r[0],t[1]=i[1]+r[1],t[2]=i[2]+r[2],t}function n0(t,e,r,n){var o=[],i=[];return o[0]=e[0]-r[0],o[1]=e[1]-r[1],o[2]=e[2]-r[2],i[0]=o[0]*Math.cos(n)-o[1]*Math.sin(n),i[1]=o[0]*Math.sin(n)+o[1]*Math.cos(n),i[2]=o[2],t[0]=i[0]+r[0],t[1]=i[1]+r[1],t[2]=i[2]+r[2],t}function o0(t,e){var r=t[0],n=t[1],o=t[2],i=e[0],s=e[1],a=e[2],c=Math.sqrt((r*r+n*n+o*o)*(i*i+s*s+a*a)),l=c&&ps(t,e)/c;return Math.acos(Math.min(Math.max(l,-1),1))}function i0(t){return t[0]=0,t[1]=0,t[2]=0,t}function s0(t){return"vec3("+t[0]+", "+t[1]+", "+t[2]+")"}function a0(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]}function c0(t,e){var r=t[0],n=t[1],o=t[2],i=e[0],s=e[1],a=e[2];return Math.abs(r-i)<=q*Math.max(1,Math.abs(r),Math.abs(i))&&Math.abs(n-s)<=q*Math.max(1,Math.abs(n),Math.abs(s))&&Math.abs(o-a)<=q*Math.max(1,Math.abs(o),Math.abs(a))}var l0=bc,d0=vc,u0=Sc,f0=Mc,m0=Ac,h0=xc,p0=_c,y0=(function(){var t=gc();return function(e,r,n,o,i,s){var a,c;for(r||(r=3),n||(n=0),o?c=Math.min(o*r+n,e.length):c=e.length,a=n;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],i(t,t,s),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2];return e}})();var ii=class{constructor(){this._position=oe.create();this._angles=oe.create();this._bobAngles=oe.create();this._bobOffset=oe.create();this._kickAngles=oe.create();this._rollAngle=0;this._fov=90;this._aspect=1;this._near=.1;this._far=1e3;this._viewMatrix=ie.create();this._projectionMatrix=ie.create();this._viewProjectionMatrix=ie.create();this._dirty=!0}get position(){return this._position}set position(e){oe.copy(this._position,e),this._dirty=!0}get angles(){return this._angles}set angles(e){oe.copy(this._angles,e),this._dirty=!0}get bobAngles(){return this._bobAngles}set bobAngles(e){oe.copy(this._bobAngles,e),this._dirty=!0}get kickAngles(){return this._kickAngles}set kickAngles(e){oe.copy(this._kickAngles,e),this._dirty=!0}get bobOffset(){return this._bobOffset}set bobOffset(e){oe.copy(this._bobOffset,e),this._dirty=!0}get rollAngle(){return this._rollAngle}set rollAngle(e){this._rollAngle=e,this._dirty=!0}get fov(){return this._fov}set fov(e){this._fov=e,this._dirty=!0}get aspect(){return this._aspect}set aspect(e){this._aspect=e,this._dirty=!0}get viewMatrix(){return this.updateMatrices(),this._viewMatrix}get projectionMatrix(){return this.updateMatrices(),this._projectionMatrix}get viewProjectionMatrix(){return this.updateMatrices(),this._viewProjectionMatrix}getViewmodelProjectionMatrix(e){let r=ie.create();return ie.perspective(r,e*Zt,this._aspect,this._near,this._far),r}updateMatrices(){if(!this._dirty)return;ie.perspective(this._projectionMatrix,this._fov*Zt,this._aspect,this._near,this._far);let e=ie.fromValues(0,-1,0,0,0,0,1,0,-1,0,0,0,0,0,0,1),r=this._angles[0]+this._bobAngles[0]+this._kickAngles[0],n=this._angles[1]+this._bobAngles[1]+this._kickAngles[1],o=this._angles[2]+this._bobAngles[2]+this._kickAngles[2]+this._rollAngle,i=r*Zt,s=n*Zt,a=o*Zt,c=ie.create();ie.identity(c),ie.rotateZ(c,c,-s),ie.rotateY(c,c,-i),ie.rotateX(c,c,-a);let l=ie.create();ie.multiply(l,e,c);let d=oe.add(oe.create(),this._position,this._bobOffset),u=oe.negate(oe.create(),d),f=oe.create();oe.transformMat4(f,u,c);let m=oe.fromValues(f[1]||0,f[2]||0,f[0]||0);ie.copy(this._viewMatrix,l),this._viewMatrix[12]=m[0],this._viewMatrix[13]=m[1],this._viewMatrix[14]=m[2],ie.multiply(this._viewProjectionMatrix,this._projectionMatrix,this._viewMatrix),this._dirty=!1}};var g0=[.2,.2,.2],x0={x:0,y:0,z:1},b0=[.8,.8,.8];function ys(t,e,r){return t+(e-t)*r}function zr(t,e,r){return{x:ys(t.x,e.x,r),y:ys(t.y,e.y,r),z:ys(t.z,e.z,r)}}function Ir(t){return t<0?0:t>1?1:t}function gs(t){let e=[],r=[];for(let n of t.triangles){let o=e.length,[i,s,a]=n.indices,c=t.texCoords[i],l=t.texCoords[s],d=t.texCoords[a];if(!c||!l||!d)throw new Error(`Missing texCoord for triangle in surface ${t.name}`);e.push({vertexIndex:i,texCoord:[c.s,1-c.t]},{vertexIndex:s,texCoord:[l.s,1-l.t]},{vertexIndex:a,texCoord:[d.s,1-d.t]}),r.push(o,o+1,o+2)}return{vertices:e,indices:new Uint16Array(r)}}function v0(t,e,r){let n=r?.ambient??g0,o=r?.directional??{direction:x0,color:b0},i=He(t),s=He(o.direction),a=Ir(i.x*s.x+i.y*s.y+i.z*s.z),c=n[0]+o.color[0]*a,l=n[1]+o.color[1]*a,d=n[2]+o.color[2]*a;if(r?.dynamicLights){let u=r.modelMatrix?Ts(r.modelMatrix,e):e;for(let f of r.dynamicLights){let m=u.x-f.origin.x,p=u.y-f.origin.y,y=u.z-f.origin.z,h=m*m+p*p+y*y,g=f.radius*f.radius;if(h<g&&g>0){let S=1-Math.sqrt(h)/f.radius,b=Math.sqrt(h),M=b>0?Ir(-(m*i.x+p*i.y+y*i.z)/b):0,v=Ir(S*M);c+=f.color[0]*v,l+=f.color[1]*v,d+=f.color[2]*v}}}return[Ir(c),Ir(l),Ir(d)]}function xs(t,e,r,n){let o=t.vertices[r.currentFrame],i=t.vertices[r.nextFrame];if(!o||!i)throw new Error("Requested MD3 frames are out of range");let s=new Float32Array(e.vertices.length*12);return e.vertices.forEach((a,c)=>{let l=o[a.vertexIndex],d=i[a.vertexIndex];if(!l||!d)throw new Error(`Vertex index ${a.vertexIndex} missing for frame`);let u=zr(l.position,d.position,r.lerp),f=He(zr(l.normal,d.normal,r.lerp)),m=v0(f,u,n),p=c*12;s[p]=u.x,s[p+1]=u.y,s[p+2]=u.z,s[p+3]=f.x,s[p+4]=f.y,s[p+5]=f.z,s[p+6]=a.texCoord[0],s[p+7]=a.texCoord[1],s[p+8]=m[0],s[p+9]=m[1],s[p+10]=m[2],s[p+11]=1}),s}function wc(t,e,r){let n=t.tags[0];if(!n)return null;let o=n.findIndex(y=>y.name===r);if(o===-1)return null;let i=t.tags[e.currentFrame]?.[o],s=t.tags[e.nextFrame]?.[o];if(!i||!s)throw new Error(`Tag ${r} is missing for one of the interpolated frames`);let a=zr(i.origin,s.origin,e.lerp),c=He(zr(i.axis[0],s.axis[0],e.lerp)),l=He(zr(i.axis[1],s.axis[1],e.lerp)),d=He(zr(i.axis[2],s.axis[2],e.lerp)),u=c,f=He({x:l.x-u.x*(u.x*l.x+u.y*l.y+u.z*l.z),y:l.y-u.y*(u.x*l.x+u.y*l.y+u.z*l.z),z:l.z-u.z*(u.x*l.x+u.y*l.y+u.z*l.z)}),m=He({x:u.y*f.z-u.z*f.y,y:u.z*f.x-u.x*f.z,z:u.x*f.y-u.y*f.x}),p=[u,f,m];return{origin:a,axis:p,matrix:Rs(a,p)}}var bs=`#version 300 es
|
|
258
258
|
precision highp float;
|
|
259
259
|
|
|
260
260
|
layout(location = 0) in vec3 a_position;
|
|
@@ -271,7 +271,7 @@ void main() {
|
|
|
271
271
|
v_texCoord = a_texCoord;
|
|
272
272
|
v_color = a_color;
|
|
273
273
|
gl_Position = u_modelViewProjection * vec4(a_position, 1.0);
|
|
274
|
-
}`,
|
|
274
|
+
}`,vs=`#version 300 es
|
|
275
275
|
precision highp float;
|
|
276
276
|
|
|
277
277
|
in vec2 v_texCoord;
|
|
@@ -285,7 +285,7 @@ out vec4 o_color;
|
|
|
285
285
|
void main() {
|
|
286
286
|
vec4 albedo = texture(u_diffuseMap, v_texCoord) * u_tint;
|
|
287
287
|
o_color = vec4(albedo.rgb * v_color.rgb, albedo.a * v_color.a);
|
|
288
|
-
}`,Dn=class{constructor(e,r,n,o){this.gl=e,this.geometry=gs(r),this.vertexBuffer=new xe(e,e.STATIC_DRAW),this.indexBuffer=new De(e,e.STATIC_DRAW),this.vertexArray=new Me(e),this.indexCount=this.geometry.indices.length,this.vertexArray.configureAttributes([{index:0,size:3,type:e.FLOAT,stride:48,offset:0},{index:1,size:3,type:e.FLOAT,stride:48,offset:12},{index:2,size:2,type:e.FLOAT,stride:48,offset:24},{index:3,size:4,type:e.FLOAT,stride:48,offset:32}],this.vertexBuffer),this.vertexArray.bind(),this.indexBuffer.bind(),this.indexBuffer.upload(this.geometry.indices,e.STATIC_DRAW),this.update(r,n,o)}update(e,r,n){let o=xs(e,this.geometry,r,n);this.vertexBuffer.upload(o,this.gl.STATIC_DRAW)}bind(){this.vertexArray.bind(),this.indexBuffer.bind()}dispose(){this.vertexBuffer.dispose(),this.indexBuffer.dispose(),this.vertexArray.dispose()}},si=class{constructor(e,r,n,o){this.surfaces=new Map;this.gl=e,this.model=r,this.blend=n,this.lighting=o,r.surfaces.forEach(i=>{this.surfaces.set(i.name,new Dn(e,i,n,o))})}update(e,r){this.blend=e,this.lighting=r??this.lighting;for(let n of this.model.surfaces)this.surfaces.get(n.name)?.update(n,e,this.lighting)}dispose(){for(let e of this.surfaces.values())e.dispose();this.surfaces.clear()}},ai=class{constructor(e){this.gl=e,this.program=ge.create(e,{vertex:
|
|
288
|
+
}`,Dn=class{constructor(e,r,n,o){this.gl=e,this.geometry=gs(r),this.vertexBuffer=new xe(e,e.STATIC_DRAW),this.indexBuffer=new De(e,e.STATIC_DRAW),this.vertexArray=new Me(e),this.indexCount=this.geometry.indices.length,this.vertexArray.configureAttributes([{index:0,size:3,type:e.FLOAT,stride:48,offset:0},{index:1,size:3,type:e.FLOAT,stride:48,offset:12},{index:2,size:2,type:e.FLOAT,stride:48,offset:24},{index:3,size:4,type:e.FLOAT,stride:48,offset:32}],this.vertexBuffer),this.vertexArray.bind(),this.indexBuffer.bind(),this.indexBuffer.upload(this.geometry.indices,e.STATIC_DRAW),this.update(r,n,o)}update(e,r,n){let o=xs(e,this.geometry,r,n);this.vertexBuffer.upload(o,this.gl.STATIC_DRAW)}bind(){this.vertexArray.bind(),this.indexBuffer.bind()}dispose(){this.vertexBuffer.dispose(),this.indexBuffer.dispose(),this.vertexArray.dispose()}},si=class{constructor(e,r,n,o){this.surfaces=new Map;this.gl=e,this.model=r,this.blend=n,this.lighting=o,r.surfaces.forEach(i=>{this.surfaces.set(i.name,new Dn(e,i,n,o))})}update(e,r){this.blend=e,this.lighting=r??this.lighting;for(let n of this.model.surfaces)this.surfaces.get(n.name)?.update(n,e,this.lighting)}dispose(){for(let e of this.surfaces.values())e.dispose();this.surfaces.clear()}},ai=class{constructor(e){this.gl=e,this.program=ge.create(e,{vertex:bs,fragment:vs},{a_position:0,a_normal:1,a_texCoord:2,a_color:3}),this.uniformMvp=this.program.getUniformLocation("u_modelViewProjection"),this.uniformTint=this.program.getUniformLocation("u_tint"),this.uniformDiffuse=this.program.getUniformLocation("u_diffuseMap")}bind(e,r=[1,1,1,1],n=0){this.program.use(),this.gl.uniformMatrix4fv(this.uniformMvp,!1,e),this.gl.uniform4fv(this.uniformTint,new Float32Array(r)),this.gl.uniform1i(this.uniformDiffuse,n)}drawSurface(e,r){let n=r?.diffuseSampler??0,o=r?.tint??[1,1,1,1];this.gl.uniform4fv(this.uniformTint,new Float32Array(o)),this.gl.uniform1i(this.uniformDiffuse,n),e.bind(),this.gl.drawElements(this.gl.TRIANGLES,e.indexCount,this.gl.UNSIGNED_SHORT,0)}dispose(){this.program.dispose()}};var S0=[1,1,1,1],ci=class{constructor(e,r=Math.random){this.maxParticles=e,this.random=r,this.alive=new Uint8Array(e),this.positionX=new Float32Array(e),this.positionY=new Float32Array(e),this.positionZ=new Float32Array(e),this.velocityX=new Float32Array(e),this.velocityY=new Float32Array(e),this.velocityZ=new Float32Array(e),this.colorR=new Float32Array(e),this.colorG=new Float32Array(e),this.colorB=new Float32Array(e),this.colorA=new Float32Array(e),this.size=new Float32Array(e),this.lifetime=new Float32Array(e),this.remaining=new Float32Array(e),this.gravity=new Float32Array(e),this.damping=new Float32Array(e),this.bounce=new Float32Array(e),this.fade=new Uint8Array(e),this.blendMode=new Uint8Array(e)}spawn(e){let r=this.findFreeSlot();if(r===-1)return null;let n=e.color??S0,o=e.velocity??{x:0,y:0,z:0};return this.alive[r]=1,this.positionX[r]=e.position.x,this.positionY[r]=e.position.y,this.positionZ[r]=e.position.z,this.velocityX[r]=o.x,this.velocityY[r]=o.y,this.velocityZ[r]=o.z,this.colorR[r]=n[0],this.colorG[r]=n[1],this.colorB[r]=n[2],this.colorA[r]=n[3],this.size[r]=e.size??2.5,this.lifetime[r]=e.lifetime,this.remaining[r]=e.lifetime,this.gravity[r]=e.gravity??800,this.damping[r]=e.damping??0,this.bounce[r]=e.bounce??.25,this.fade[r]=e.fade?1:0,this.blendMode[r]=e.blendMode==="additive"?1:0,r}update(e,r={}){let n=r.floorZ??-1/0;for(let o=0;o<this.maxParticles;o+=1){if(!this.alive[o])continue;if(this.remaining[o]-=e,this.remaining[o]<=0){this.alive[o]=0;continue}let i=Math.max(0,1-this.damping[o]*e);this.velocityX[o]*=i,this.velocityY[o]*=i,this.velocityZ[o]=this.velocityZ[o]*i-this.gravity[o]*e,this.positionX[o]+=this.velocityX[o]*e,this.positionY[o]+=this.velocityY[o]*e,this.positionZ[o]+=this.velocityZ[o]*e,this.positionZ[o]<n&&(this.positionZ[o]=n,this.velocityZ[o]=-this.velocityZ[o]*this.bounce[o],this.velocityX[o]*=.7,this.velocityY[o]*=.7)}}killAll(){this.alive.fill(0)}aliveCount(){let e=0;for(let r=0;r<this.maxParticles;r+=1)this.alive[r]&&(e+=1);return e}getState(e){return{alive:this.alive[e]===1,position:{x:this.positionX[e],y:this.positionY[e],z:this.positionZ[e]},velocity:{x:this.velocityX[e],y:this.velocityY[e],z:this.velocityZ[e]},remaining:this.remaining[e],color:[this.colorR[e],this.colorG[e],this.colorB[e],this.colorA[e]],size:this.size[e],blendMode:this.blendMode[e]===1?"additive":"alpha"}}buildMesh(e,r){let n=[],o=[],i=[],s=a=>{let c=o.length,l=0;for(let d=0;d<this.maxParticles;d+=1){if(!this.alive[d]||(a==="additive"?1:0)!==this.blendMode[d])continue;l+=1;let u=n.length/9,f=this.size[d]*.5,m=this.fade[d]?Math.max(this.remaining[d]/this.lifetime[d],0):1,p=this.blendMode[d]===1?1.2:1,y=this.colorR[d]*p,h=this.colorG[d]*p,g=this.colorB[d]*p,S=this.colorA[d]*m,b=this.positionX[d],M=this.positionY[d],v=this.positionZ[d],A=e.x*f,_=e.y*f,L=e.z*f,F=r.x*f,w=r.y*f,H=r.z*f,U=[{x:b-A-F,y:M-_-w,z:v-L-H},{x:b+A-F,y:M+_-w,z:v+L-H},{x:b-A+F,y:M-_+w,z:v-L+H},{x:b+A+F,y:M+_+w,z:v+L+H}],V=[[0,1],[1,1],[0,0],[1,0]];U.forEach((C,$)=>{n.push(C.x,C.y,C.z,V[$]?.[0]??0,V[$]?.[1]??0,y,h,g,S)}),o.push(u,u+1,u+2,u+2,u+1,u+3)}l>0&&i.push({blendMode:a,start:c,count:o.length-c})};return s("alpha"),s("additive"),{vertices:new Float32Array(n),indices:new Uint16Array(o),batches:i}}findFreeSlot(){for(let e=0;e<this.maxParticles;e+=1)if(!this.alive[e])return e;return-1}},Ss=`#version 300 es
|
|
289
289
|
precision highp float;
|
|
290
290
|
|
|
291
291
|
layout(location = 0) in vec3 a_position;
|
|
@@ -313,5 +313,5 @@ void main() {
|
|
|
313
313
|
float dist = distance(v_uv, vec2(0.5));
|
|
314
314
|
float alpha = v_color.a * (1.0 - smoothstep(0.35, 0.5, dist));
|
|
315
315
|
o_color = vec4(v_color.rgb, alpha);
|
|
316
|
-
}`,li=class{constructor(e,r){this.vertexCapacity=0;this.indexCapacity=0;this.gl=e,this.system=r,this.program=ge.create(e,{vertex:Ss,fragment:Ms}),this.vertexBuffer=new xe(e,e.DYNAMIC_DRAW),this.indexBuffer=new De(e,e.DYNAMIC_DRAW),this.vertexArray=new Me(e),this.vertexArray.configureAttributes([{index:0,size:3,type:e.FLOAT,stride:36,offset:0},{index:1,size:2,type:e.FLOAT,stride:36,offset:12},{index:2,size:4,type:e.FLOAT,stride:36,offset:20}],this.vertexBuffer)}render(e){let r=this.system.buildMesh(e.viewRight,e.viewUp);if(r.indices.length===0)return;let n=r.vertices;r.vertices.byteLength>this.vertexCapacity?(this.vertexCapacity=r.vertices.byteLength,this.vertexBuffer.upload(n,this.gl.DYNAMIC_DRAW)):this.vertexBuffer.update(n);let o=r.indices;r.indices.byteLength>this.indexCapacity?(this.indexCapacity=r.indices.byteLength,this.indexBuffer.upload(o,this.gl.DYNAMIC_DRAW)):this.indexBuffer.update(o),this.gl.depthMask(!1),this.program.use();let i=this.program.getUniformLocation("u_viewProjection");this.gl.uniformMatrix4fv(i,!1,e.viewProjection),this.vertexArray.bind();for(let s of r.batches)s.blendMode==="additive"?this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE):this.gl.blendFuncSeparate(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA,this.gl.ONE,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.drawElements(this.gl.TRIANGLES,s.count,this.gl.UNSIGNED_SHORT,s.start*2);this.gl.depthMask(!0)}dispose(){this.program.dispose(),this.vertexBuffer.dispose(),this.indexBuffer.dispose(),this.vertexArray.dispose()}};function Lc(t){let{system:e,origin:r,normal:n={x:0,y:0,z:1}}=t;for(let o=0;o<12;o+=1){let i=200+e.random()*180,s=e.random()*.35;e.spawn({position:r,velocity:{x:n.x*i+(e.random()-.5)*80,y:n.y*i+(e.random()-.5)*80,z:Math.max(n.z*i,120)+s*80},color:[1,.8,.4,1],size:2.5,lifetime:.45+e.random()*.1,gravity:600,damping:2,bounce:.45,blendMode:"additive",fade:!0})}for(let o=0;o<8;o+=1)e.spawn({position:r,velocity:{x:(e.random()-.5)*40,y:(e.random()-.5)*40,z:80+e.random()*40},color:[.45,.45,.45,.75],size:6,lifetime:.6,gravity:200,damping:4,bounce:.15,blendMode:"alpha",fade:!0})}function Ec(t){let{system:e,origin:r}=t;for(let n=0;n<40;n+=1){let o=e.random()*Math.PI*2,i=Math.acos(2*e.random()-1),s=220+e.random()*260,a={x:Math.sin(i)*Math.cos(o),y:Math.sin(i)*Math.sin(o),z:Math.cos(i)};e.spawn({position:r,velocity:{x:a.x*s,y:a.y*s,z:a.z*s},color:[1,.6,.2,1],size:5,lifetime:.9,gravity:700,damping:1,bounce:.35,blendMode:"additive",fade:!0})}for(let n=0;n<16;n+=1)e.spawn({position:r,velocity:{x:(e.random()-.5)*30,y:(e.random()-.5)*30,z:120+e.random()*120},color:[.25,.25,.25,.9],size:12,lifetime:1.2,gravity:300,damping:3,blendMode:"alpha",fade:!0})}function
|
|
316
|
+
}`,li=class{constructor(e,r){this.vertexCapacity=0;this.indexCapacity=0;this.gl=e,this.system=r,this.program=ge.create(e,{vertex:Ss,fragment:Ms}),this.vertexBuffer=new xe(e,e.DYNAMIC_DRAW),this.indexBuffer=new De(e,e.DYNAMIC_DRAW),this.vertexArray=new Me(e),this.vertexArray.configureAttributes([{index:0,size:3,type:e.FLOAT,stride:36,offset:0},{index:1,size:2,type:e.FLOAT,stride:36,offset:12},{index:2,size:4,type:e.FLOAT,stride:36,offset:20}],this.vertexBuffer)}render(e){let r=this.system.buildMesh(e.viewRight,e.viewUp);if(r.indices.length===0)return;let n=r.vertices;r.vertices.byteLength>this.vertexCapacity?(this.vertexCapacity=r.vertices.byteLength,this.vertexBuffer.upload(n,this.gl.DYNAMIC_DRAW)):this.vertexBuffer.update(n);let o=r.indices;r.indices.byteLength>this.indexCapacity?(this.indexCapacity=r.indices.byteLength,this.indexBuffer.upload(o,this.gl.DYNAMIC_DRAW)):this.indexBuffer.update(o),this.gl.depthMask(!1),this.program.use();let i=this.program.getUniformLocation("u_viewProjection");this.gl.uniformMatrix4fv(i,!1,e.viewProjection),this.vertexArray.bind();for(let s of r.batches)s.blendMode==="additive"?this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE):this.gl.blendFuncSeparate(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA,this.gl.ONE,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.drawElements(this.gl.TRIANGLES,s.count,this.gl.UNSIGNED_SHORT,s.start*2);this.gl.depthMask(!0)}dispose(){this.program.dispose(),this.vertexBuffer.dispose(),this.indexBuffer.dispose(),this.vertexArray.dispose()}};function Lc(t){let{system:e,origin:r,normal:n={x:0,y:0,z:1}}=t;for(let o=0;o<12;o+=1){let i=200+e.random()*180,s=e.random()*.35;e.spawn({position:r,velocity:{x:n.x*i+(e.random()-.5)*80,y:n.y*i+(e.random()-.5)*80,z:Math.max(n.z*i,120)+s*80},color:[1,.8,.4,1],size:2.5,lifetime:.45+e.random()*.1,gravity:600,damping:2,bounce:.45,blendMode:"additive",fade:!0})}for(let o=0;o<8;o+=1)e.spawn({position:r,velocity:{x:(e.random()-.5)*40,y:(e.random()-.5)*40,z:80+e.random()*40},color:[.45,.45,.45,.75],size:6,lifetime:.6,gravity:200,damping:4,bounce:.15,blendMode:"alpha",fade:!0})}function Ec(t){let{system:e,origin:r}=t;for(let n=0;n<40;n+=1){let o=e.random()*Math.PI*2,i=Math.acos(2*e.random()-1),s=220+e.random()*260,a={x:Math.sin(i)*Math.cos(o),y:Math.sin(i)*Math.sin(o),z:Math.cos(i)};e.spawn({position:r,velocity:{x:a.x*s,y:a.y*s,z:a.z*s},color:[1,.6,.2,1],size:5,lifetime:.9,gravity:700,damping:1,bounce:.35,blendMode:"additive",fade:!0})}for(let n=0;n<16;n+=1)e.spawn({position:r,velocity:{x:(e.random()-.5)*30,y:(e.random()-.5)*30,z:120+e.random()*120},color:[.25,.25,.25,.9],size:12,lifetime:1.2,gravity:300,damping:3,blendMode:"alpha",fade:!0})}function Ic(t){let{system:e,origin:r,direction:n={x:0,y:0,z:1}}=t;for(let o=0;o<24;o+=1){let i=120+e.random()*180;e.spawn({position:r,velocity:{x:n.x*i+(e.random()-.5)*70,y:n.y*i+(e.random()-.5)*70,z:n.z*i+e.random()*80},color:[.6,0,0,.95],size:3,lifetime:.8,gravity:900,damping:1,bounce:.2,blendMode:"alpha",fade:!0})}}function zc(t){let{system:e,origin:r}=t;for(let n=0;n<30;n+=1){let o=e.random()*Math.PI*2,i=8+e.random()*8;e.spawn({position:r,velocity:{x:Math.cos(o)*i,y:Math.sin(o)*i,z:100+e.random()*80},color:[.4,.6,1,.9],size:4,lifetime:.5,gravity:300,damping:2,blendMode:"additive",fade:!0})}}function Pc(t){let{system:e,origin:r,direction:n={x:1,y:0,z:0}}=t;for(let o=0;o<10;o+=1){let i=350+e.random()*100;e.spawn({position:r,velocity:{x:n.x*i+(e.random()-.5)*30,y:n.y*i+(e.random()-.5)*30,z:n.z*i+(e.random()-.5)*30},color:[1,.8,.3,1],size:3,lifetime:.25,gravity:200,damping:1,blendMode:"additive",fade:!0})}}function Fc(t){let{system:e,origin:r,direction:n={x:0,y:0,z:0}}=t;for(let o=0;o<6;o+=1)e.spawn({position:{x:r.x+n.x*o*2,y:r.y+n.y*o*2,z:r.z+n.z*o*2},velocity:{x:(e.random()-.5)*15,y:(e.random()-.5)*15,z:20+e.random()*15},color:[.6,.6,.6,.8],size:2.2,lifetime:.6,gravity:200,damping:1.5,blendMode:"alpha",fade:!0})}function M0(t){return{init(){t.trace({x:0,y:0,z:0},{x:0,y:0,z:0})},shutdown(){},createMainLoop(e,r){return new Ct(e,r)}}}return Vc(A0);})();
|
|
317
317
|
//# sourceMappingURL=index.global.js.map
|