quake2ts 0.0.89 → 0.0.90

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.
Files changed (45) hide show
  1. package/package.json +1 -1
  2. package/packages/client/dist/browser/index.global.js +1 -1
  3. package/packages/client/dist/browser/index.global.js.map +1 -1
  4. package/packages/client/dist/cjs/index.cjs +121 -10
  5. package/packages/client/dist/cjs/index.cjs.map +1 -1
  6. package/packages/client/dist/esm/index.js +121 -10
  7. package/packages/client/dist/esm/index.js.map +1 -1
  8. package/packages/client/dist/tsconfig.tsbuildinfo +1 -1
  9. package/packages/client/dist/types/hud/icons.d.ts +3 -2
  10. package/packages/client/dist/types/hud/icons.d.ts.map +1 -1
  11. package/packages/client/dist/types/hud/messages.d.ts +10 -0
  12. package/packages/client/dist/types/hud/messages.d.ts.map +1 -0
  13. package/packages/client/dist/types/hud/numbers.d.ts +1 -1
  14. package/packages/client/dist/types/hud/numbers.d.ts.map +1 -1
  15. package/packages/client/dist/types/hud.d.ts +2 -1
  16. package/packages/client/dist/types/hud.d.ts.map +1 -1
  17. package/packages/client/dist/types/index.d.ts +2 -0
  18. package/packages/client/dist/types/index.d.ts.map +1 -1
  19. package/packages/engine/dist/browser/index.global.js +8 -8
  20. package/packages/engine/dist/browser/index.global.js.map +1 -1
  21. package/packages/engine/dist/cjs/index.cjs.map +1 -1
  22. package/packages/engine/dist/esm/index.js.map +1 -1
  23. package/packages/engine/dist/tsconfig.tsbuildinfo +1 -1
  24. package/packages/engine/dist/types/render/renderer.d.ts +1 -1
  25. package/packages/engine/dist/types/render/renderer.d.ts.map +1 -1
  26. package/packages/game/dist/browser/index.global.js +1 -1
  27. package/packages/game/dist/browser/index.global.js.map +1 -1
  28. package/packages/game/dist/cjs/index.cjs +2687 -2640
  29. package/packages/game/dist/cjs/index.cjs.map +1 -1
  30. package/packages/game/dist/esm/index.js +2687 -2640
  31. package/packages/game/dist/esm/index.js.map +1 -1
  32. package/packages/game/dist/tsconfig.tsbuildinfo +1 -1
  33. package/packages/game/dist/types/entities/system.d.ts.map +1 -1
  34. package/packages/game/dist/types/physics/movement.d.ts +1 -0
  35. package/packages/game/dist/types/physics/movement.d.ts.map +1 -1
  36. package/packages/shared/dist/browser/index.global.js +1 -1
  37. package/packages/shared/dist/browser/index.global.js.map +1 -1
  38. package/packages/shared/dist/cjs/index.cjs +22 -0
  39. package/packages/shared/dist/cjs/index.cjs.map +1 -1
  40. package/packages/shared/dist/esm/index.js +19 -0
  41. package/packages/shared/dist/esm/index.js.map +1 -1
  42. package/packages/shared/dist/tsconfig.tsbuildinfo +1 -1
  43. package/packages/shared/dist/types/bsp/collision.d.ts +8 -0
  44. package/packages/shared/dist/types/bsp/collision.d.ts.map +1 -1
  45. package/packages/tools/dist/tsconfig.tsbuildinfo +1 -1
@@ -1,2 +1,2 @@
1
- "use strict";var Quake2Shared=(()=>{var Fe=Object.defineProperty;var Xt=Object.getOwnPropertyDescriptor;var jt=Object.getOwnPropertyNames;var Yt=Object.prototype.hasOwnProperty;var it=(t,e)=>{for(var o in e)Fe(t,o,{get:e[o],enumerable:!0})},Zt=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of jt(e))!Yt.call(t,r)&&r!==o&&Fe(t,r,{get:()=>e[r],enumerable:!(n=Xt(e,r))||n.enumerable});return t};var qt=t=>Zt(Fe({},"__esModule",{value:!0}),t);var Hr={};it(Hr,{BinaryStream:()=>at,CGAME_EXPORT_KEYS:()=>Tn,CGAME_IMPORT_KEYS:()=>Vn,CONTENTS_AREAPORTAL:()=>ss,CONTENTS_AUX:()=>Qr,CONTENTS_CURRENT_0:()=>go,CONTENTS_CURRENT_180:()=>Ro,CONTENTS_CURRENT_270:()=>Oo,CONTENTS_CURRENT_90:()=>Eo,CONTENTS_CURRENT_DOWN:()=>zo,CONTENTS_CURRENT_UP:()=>vo,CONTENTS_DEADMONSTER:()=>us,CONTENTS_DETAIL:()=>ds,CONTENTS_LADDER:()=>ft,CONTENTS_LAVA:()=>es,CONTENTS_MIST:()=>ns,CONTENTS_MONSTER:()=>ls,CONTENTS_MONSTERCLIP:()=>is,CONTENTS_NONE:()=>Te,CONTENTS_NO_WATERJUMP:()=>No,CONTENTS_ORIGIN:()=>cs,CONTENTS_PLAYER:()=>fs,CONTENTS_PLAYERCLIP:()=>as,CONTENTS_PROJECTILE:()=>ps,CONTENTS_PROJECTILECLIP:()=>rs,CONTENTS_SLIME:()=>ts,CONTENTS_SOLID:()=>qr,CONTENTS_TRANSLUCENT:()=>ms,CONTENTS_TRIGGER:()=>Ao,CONTENTS_WATER:()=>os,CONTENTS_WINDOW:()=>$r,CS_MAX_STRING_LENGTH:()=>qs,CS_MAX_STRING_LENGTH_OLD:()=>$s,ClientCommand:()=>Ht,CollisionEntityIndex:()=>Be,ConfigStringIndex:()=>re,CvarFlags:()=>Tt,DEFAULT_FORWARD_SPEED:()=>zr,DEFAULT_MOUSE_SENSITIVITY:()=>Dr,DEFAULT_PITCH_SPEED:()=>wr,DEFAULT_SIDE_SPEED:()=>Fr,DEFAULT_UP_SPEED:()=>Mr,DEFAULT_YAW_SPEED:()=>Lr,DEG2RAD:()=>yo,DIST_EPSILON:()=>J,GAME_EXPORT_KEYS:()=>bn,GAME_IMPORT_KEYS:()=>hn,LAST_VISIBLE_CONTENTS:()=>ys,MASK_ALL:()=>Os,MASK_BLOCK_SIGHT:()=>ws,MASK_CURRENT:()=>Fo,MASK_DEADSOLID:()=>zs,MASK_LADDER_NAV_SOLID:()=>Is,MASK_MONSTERSOLID:()=>Fs,MASK_NAV_SOLID:()=>Ds,MASK_OPAQUE:()=>Ms,MASK_PLAYERSOLID:()=>vs,MASK_PROJECTILE:()=>Bs,MASK_SHOT:()=>Ls,MASK_SOLID:()=>De,MASK_WALK_NAV_SOLID:()=>Ws,MASK_WATER:()=>Pe,MAX_CLIENTS:()=>tn,MAX_CONFIGSTRINGS:()=>un,MAX_EDICTS:()=>Zs,MAX_GENERAL:()=>cn,MAX_IMAGES:()=>sn,MAX_ITEMS:()=>an,MAX_LIGHTSTYLES:()=>on,MAX_MODELS:()=>nn,MAX_OSPATH:()=>Ys,MAX_QPATH:()=>js,MAX_SHADOW_LIGHTS:()=>ln,MAX_SOUNDS:()=>rn,MAX_STRING_CHARS:()=>Ks,MAX_STRING_TOKENS:()=>Js,MAX_TOKEN_CHARS:()=>Xs,MAX_WHEEL_ITEMS:()=>Ke,MersenneTwister19937:()=>be,PITCH:()=>Se,PlaneSide:()=>pt,PlayerButton:()=>ee,PmFlag:()=>Q,PmType:()=>ae,RAD2DEG:()=>xo,ROLL:()=>Le,RandomGenerator:()=>Ve,Replay:()=>Je,SLIDEMOVE_BLOCKED_FLOOR:()=>_t,SLIDEMOVE_BLOCKED_WALL:()=>At,STOP_EPSILON:()=>j,SURF_ALPHATEST:()=>As,SURF_FLOWING:()=>Cs,SURF_LIGHT:()=>Ss,SURF_N64_SCROLL_FLIP:()=>Rs,SURF_N64_SCROLL_X:()=>gs,SURF_N64_SCROLL_Y:()=>Es,SURF_N64_UV:()=>Ns,SURF_NODRAW:()=>_s,SURF_NONE:()=>xs,SURF_SKY:()=>bs,SURF_SLICK:()=>hs,SURF_TRANS33:()=>Ts,SURF_TRANS66:()=>Ps,SURF_WARP:()=>Vs,ServerCommand:()=>Ut,TempEntity:()=>Kt,WaterLevel:()=>se,YAW:()=>he,ZERO_VEC3:()=>R,addBlendColor:()=>Vo,addContents:()=>wo,addPmFlag:()=>W,addPointToBounds:()=>ao,addVec3:()=>N,addViewAngles:()=>Wr,angleMod:()=>ue,angleVectors:()=>we,applyPmove:()=>Ur,applyPmoveAccelerate:()=>H,applyPmoveAddCurrents:()=>Ee,applyPmoveAirAccelerate:()=>Ye,applyPmoveAirMove:()=>dr,applyPmoveFlyMove:()=>Wn,applyPmoveFriction:()=>je,applyPmoveWaterMove:()=>mr,assertContract:()=>Sn,boxContents:()=>jo,boxOnPlaneSide:()=>Uo,boxesIntersect:()=>io,buildAirGroundWish:()=>Ze,buildCollisionModel:()=>ko,buildWaterWish:()=>qe,categorizePosition:()=>lr,checkDuckState:()=>Yn,checkJump:()=>Hn,checkSpecialMovement:()=>Ar,clampViewAngles:()=>vr,clipBoxToBrush:()=>Ge,clipVelocityAgainstPlanes:()=>co,clipVelocityVec3:()=>q,closestPointToBox:()=>no,combineSurfaceFlags:()=>Wo,computePlaneSignBits:()=>ke,computePlayerDimensions:()=>Oe,concatRotationMatrices:()=>Me,configStringSize:()=>dn,createDefaultTrace:()=>_e,createEmptyBounds3:()=>so,createMat4Identity:()=>mt,createRandomGenerator:()=>To,crossVec3:()=>Z,currentVectorFromContents:()=>ot,degToRad:()=>ye,distance:()=>to,distanceBetweenBoxesSquared:()=>ro,dotVec3:()=>F,fixStuckObjectGeneric:()=>et,getWaterLevel:()=>fe,goodPosition:()=>st,groundCurrentVelocity:()=>Lt,hasAllContents:()=>Mo,hasAnyContents:()=>Lo,hasPmFlag:()=>M,hasSurfaceFlags:()=>Io,inPHS:()=>Zo,inPVS:()=>Yo,initialSnapPosition:()=>Er,isAtLeastWaistDeep:()=>Xe,isUnderwater:()=>Pn,lengthSquaredVec3:()=>oe,lengthVec3:()=>D,lerpAngle:()=>So,mat4FromBasis:()=>_o,mouseDeltaToViewDelta:()=>Br,multiplyMat4:()=>Po,multiplyVec3:()=>Qt,negateVec3:()=>eo,normalizeVec3:()=>v,perpendicularVec3:()=>lt,planeDistanceToPoint:()=>$,pmoveCmdScale:()=>Cn,pointContents:()=>Jo,pointContentsMany:()=>Xo,pointInsideBrush:()=>yt,pointOnPlaneSide:()=>Go,projectPointOnPlane:()=>ct,projectSourceVec3:()=>uo,projectSourceVec3WithUp:()=>mo,radToDeg:()=>xe,removeContents:()=>Do,removePmFlag:()=>U,resolveSlideMove:()=>Nt,rotatePointAroundVector:()=>po,scaleVec3:()=>g,slerpVec3:()=>fo,slideClipVelocityVec3:()=>lo,slideMove:()=>$e,snapPosition:()=>gr,stepSlideMove:()=>te,subtractVec3:()=>Y,testBoxInBrush:()=>xt,traceBox:()=>Vt,transformPointMat4:()=>Co,validateContract:()=>Pt,vec3Equals:()=>oo,vectorToAngles:()=>bo,vectorToYaw:()=>ho,waterCurrentVelocity:()=>Mt});var R={x:0,y:0,z:0},j=.1,$t=Math.PI/180;function N(t,e){return{x:t.x+e.x,y:t.y+e.y,z:t.z+e.z}}function Y(t,e){return{x:t.x-e.x,y:t.y-e.y,z:t.z-e.z}}function Qt(t,e){return{x:t.x*e.x,y:t.y*e.y,z:t.z*e.z}}function g(t,e){return{x:t.x*e,y:t.y*e,z:t.z*e}}function eo(t){return g(t,-1)}function F(t,e){return t.x*e.x+t.y*e.y+t.z*e.z}function Z(t,e){return{x:t.y*e.z-t.z*e.y,y:t.z*e.x-t.x*e.z,z:t.x*e.y-t.y*e.x}}function oe(t){return F(t,t)}function D(t){return Math.sqrt(oe(t))}function to(t,e){return D(Y(t,e))}function oo(t,e){return t.x===e.x&&t.y===e.y&&t.z===e.z}function v(t){let e=D(t);return e===0?t:g(t,1/e)}function ct(t,e){let o=1/F(e,e),n=F(e,t)*o;return Y(t,g(e,o*n))}function lt(t){let e=0,o=Math.abs(t.x);return Math.abs(t.y)<o&&(e=1,o=Math.abs(t.y)),Math.abs(t.z)<o&&(e=2),v(ct(e===0?{x:1,y:0,z:0}:e===1?{x:0,y:1,z:0}:{x:0,y:0,z:1},t))}function no(t,e,o){return{x:t.x<e.x?e.x:t.x>o.x?o.x:t.x,y:t.y<e.y?e.y:t.y>o.y?o.y:t.y,z:t.z<e.z?e.z:t.z>o.z?o.z:t.z}}function ro(t,e,o,n){let r=0;if(e.x<o.x){let s=e.x-o.x;r+=s*s}else if(t.x>n.x){let s=t.x-n.x;r+=s*s}if(e.y<o.y){let s=e.y-o.y;r+=s*s}else if(t.y>n.y){let s=t.y-n.y;r+=s*s}if(e.z<o.z){let s=e.z-o.z;r+=s*s}else if(t.z>n.z){let s=t.z-n.z;r+=s*s}return r}function so(){return{mins:{x:Number.POSITIVE_INFINITY,y:Number.POSITIVE_INFINITY,z:Number.POSITIVE_INFINITY},maxs:{x:Number.NEGATIVE_INFINITY,y:Number.NEGATIVE_INFINITY,z:Number.NEGATIVE_INFINITY}}}function ao(t,e){return{mins:{x:Math.min(e.mins.x,t.x),y:Math.min(e.mins.y,t.y),z:Math.min(e.mins.z,t.z)},maxs:{x:Math.max(e.maxs.x,t.x),y:Math.max(e.maxs.y,t.y),z:Math.max(e.maxs.z,t.z)}}}function io(t,e){return t.mins.x<=e.maxs.x&&t.maxs.x>=e.mins.x&&t.mins.y<=e.maxs.y&&t.maxs.y>=e.mins.y&&t.mins.z<=e.maxs.z&&t.maxs.z>=e.mins.z}function q(t,e,o){let n=F(t,e)*o,r=t.x-e.x*n,s=t.y-e.y*n,a=t.z-e.z*n;return r>-j&&r<j&&(r=0),s>-j&&s<j&&(s=0),a>-j&&a<j&&(a=0),{x:r,y:s,z:a}}function co(t,e,o,n){if(e.length===0)return t;let r=t;for(let s=0;s<e.length;s++){r=q(r,e[s],o);let a=0;for(;a<e.length&&!(a!==s&&F(r,e[a])<0);a++);if(a===e.length)return n&&F(r,n)<=0?R:r}if(e.length===2){let s=Z(e[0],e[1]),a=F(s,t),i=g(s,a);return n&&F(i,n)<=0?R:i}return n&&F(r,n)<=0,R}function lo(t,e,o){return q(t,e,o)}function uo(t,e,o,n){return{x:t.x+o.x*e.x+n.x*e.y,y:t.y+o.y*e.x+n.y*e.y,z:t.z+o.z*e.x+n.z*e.y+e.z}}function mo(t,e,o,n,r){return{x:t.x+o.x*e.x+n.x*e.y+r.x*e.z,y:t.y+o.y*e.x+n.y*e.y+r.y*e.z,z:t.z+o.z*e.x+n.z*e.y+r.z*e.z}}function fo(t,e,o){let n=F(t,e),r,s;if(Math.abs(n)>.9995)r=1-o,s=o;else{let a=Math.acos(n),i=Math.sin(a),u=Math.sin((1-o)*a),l=Math.sin(o*a);r=u/i,s=l/i}return{x:t.x*r+e.x*s,y:t.y*r+e.y*s,z:t.z*r+e.z*s}}function Me(t,e){let o=r=>[t[r][0]*e[0][0]+t[r][1]*e[1][0]+t[r][2]*e[2][0],t[r][0]*e[0][1]+t[r][1]*e[1][1]+t[r][2]*e[2][1],t[r][0]*e[0][2]+t[r][1]*e[1][2]+t[r][2]*e[2][2]];return[o(0),o(1),o(2)]}function po(t,e,o){if(D(t)===0)return e;let r=v(t),s=lt(r),a=Z(s,r),i=[[s.x,a.x,r.x],[s.y,a.y,r.y],[s.z,a.z,r.z]],u=[[i[0][0],i[1][0],i[2][0]],[i[0][1],i[1][1],i[2][1]],[i[0][2],i[1][2],i[2][2]]],l=o*$t,m=Math.cos(l),c=Math.sin(l),f=[[m,c,0],[-c,m,0],[0,0,1]],p=Me(Me(i,f),u);return{x:p[0][0]*e.x+p[0][1]*e.y+p[0][2]*e.z,y:p[1][0]*e.x+p[1][1]*e.y+p[1][2]*e.z,z:p[2][0]*e.x+p[2][1]*e.y+p[2][2]*e.z}}var Se=0,he=1,Le=2,ut=Math.PI/180,dt=180/Math.PI,yo=ut,xo=dt;function le(t,e){switch(e){case Se:return t.x;case he:return t.y;case Le:default:return t.z}}function ye(t){return t*ut}function xe(t){return t*dt}function So(t,e,o){let n=e;return n-t>180?n-=360:n-t<-180&&(n+=360),t+o*(n-t)}function ue(t){let e=t%360;return e<0?360+e:e}function we(t){let e=ye(le(t,he)),o=ye(le(t,Se)),n=ye(le(t,Le)),r=Math.sin(e),s=Math.cos(e),a=Math.sin(o),i=Math.cos(o),u=Math.sin(n),l=Math.cos(n),m={x:i*s,y:i*r,z:-a},c={x:-u*a*s-l*-r,y:-u*a*r-l*s,z:-u*i},f={x:l*a*s-u*-r,y:l*a*r-u*s,z:l*i};return{forward:m,right:c,up:f}}function ho(t){let e=le(t,Se),o=le(t,he);if(e===0)return o===0?0:o>0?90:270;let n=xe(Math.atan2(o,e));return n<0?n+360:n}function bo(t){let e=t.x,o=t.y,n=t.z;if(o===0&&e===0)return{x:n>0?-90:-270,y:0,z:0};let r;e?r=xe(Math.atan2(o,e)):o>0?r=90:r=270,r<0&&(r+=360);let s=Math.sqrt(e*e+o*o),a=xe(Math.atan2(n,s));return a<0&&(a+=360),{x:-a,y:r,z:0}}function Vo(t,e,o,n,r){if(n<=0)return r;let s=r[0],a=r[1],i=r[2],u=r[3],l=u+(1-u)*n;if(l<=0)return[0,0,0,0];let m=u/l,c=s*m+t*(1-m),f=a*m+e*(1-m),p=i*m+o*(1-m);return[c,f,p,l]}var be=class{constructor(e=5489){this.state=new Uint32Array(624);this.index=624;this.seed(e)}seed(e){this.state[0]=e>>>0;for(let o=1;o<624;o++){let n=this.state[o-1]^this.state[o-1]>>>30,r=Math.imul(n>>>0,1812433253)+o;this.state[o]=r>>>0}this.index=624}nextUint32(){this.index>=624&&this.twist();let e=this.state[this.index++];return e^=e>>>11,e^=e<<7&2636928640,e^=e<<15&4022730752,e^=e>>>18,e>>>0}twist(){for(let e=0;e<624;e++){let o=this.state[e]&2147483648|this.state[(e+1)%624]&2147483647,n=this.state[(e+397)%624]^o>>>1;(o&1)!==0&&(n^=2567483615),this.state[e]=n>>>0}this.index=0}getState(){return{index:this.index,state:Array.from(this.state)}}setState(e){if(e.state.length!==624)throw new Error(`Expected 624 MT state values, received ${e.state.length}`);this.index=e.index,this.state=Uint32Array.from(e.state,o=>o>>>0)}},Ve=class{constructor(e={}){this.mt=new be(e.seed)}frandom(){return this.mt.nextUint32()/4294967296}frandomRange(e,o){return e+(o-e)*this.frandom()}frandomMax(e){return this.frandomRange(0,e)}crandom(){return this.frandomRange(-1,1)}crandomOpen(){let e=Number.EPSILON;return this.frandomRange(-1+e,1)}irandomUint32(){return this.mt.nextUint32()}irandomRange(e,o){if(o-e<=1)return e;let n=o-e,r=4294967296-4294967296%n,s;do s=this.mt.nextUint32();while(s>=r);return e+s%n}irandom(e){return e<=0?0:this.irandomRange(0,e)}randomTimeRange(e,o){return o<=e?e:this.irandomRange(e,o)}randomTime(e){return this.irandom(e)}randomIndex(e){return this.irandom(e.length)}getState(){return{mt:this.mt.getState()}}setState(e){this.mt.setState(e.mt)}};function To(t){return new Ve(t)}function mt(){return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function Po(t,e){let o=new Float32Array(16);for(let n=0;n<4;n+=1)for(let r=0;r<4;r+=1)o[r*4+n]=t[0+n]*e[r*4+0]+t[4+n]*e[r*4+1]+t[8+n]*e[r*4+2]+t[12+n]*e[r*4+3];return o}function Co(t,e){let o=e.x,n=e.y,r=e.z;return{x:t[0]*o+t[4]*n+t[8]*r+t[12],y:t[1]*o+t[5]*n+t[9]*r+t[13],z:t[2]*o+t[6]*n+t[10]*r+t[14]}}function _o(t,e){let o=mt();return o[0]=e[0].x,o[1]=e[0].y,o[2]=e[0].z,o[4]=e[1].x,o[5]=e[1].y,o[6]=e[1].z,o[8]=e[2].x,o[9]=e[2].y,o[10]=e[2].z,o[12]=t.x,o[13]=t.y,o[14]=t.z,o}var Te=0,qr=1,$r=2,Qr=4,es=8,ts=16,os=32,ns=64,Ao=1073741824,No=8192,rs=16384,ss=32768,as=65536,is=131072,go=262144,Eo=524288,Ro=1048576,Oo=2097152,vo=4194304,zo=8388608,cs=16777216,ls=33554432,us=67108864,ds=134217728,ms=268435456,ft=536870912,fs=1073741824,ps=-2147483648,ys=64,xs=0,Ss=1,hs=2,bs=4,Vs=8,Ts=16,Ps=32,Cs=64,_s=128,As=33554432,Ns=268435456,gs=536870912,Es=1073741824,Rs=-2147483648,Os=4294967295,De=3,vs=1107361795,zs=65539,Fs=1107427331,Pe=56,Ms=25,Ls=1174405123,Fo=16515072,ws=1107296281,Ds=65539,Is=3,Ws=196611,Bs=1174421507;function Mo(t,e){return(t&e)===e}function Lo(t,e){return(t&e)!==0}function wo(t,e){return t|e}function Do(t,e){return t&~e}function Io(t,e){return(t&e)===e}function Wo(...t){let e=0;for(let o of t)e|=o;return e}var pt=(n=>(n[n.FRONT=1]="FRONT",n[n.BACK=2]="BACK",n[n.CROSS=3]="CROSS",n))(pt||{}),J=.03125,Bo=Number.MAX_SAFE_INTEGER-1,Ce=1;function ko(t){let e=t.planes.map(a=>({...a,signbits:ke(a.normal)})),o=t.nodes.map(a=>({plane:e[a.planenum],children:a.children})),n=t.brushes.map(a=>{let i=t.brushSides.slice(a.firstSide,a.firstSide+a.numSides).map(u=>({plane:e[u.planenum],surfaceFlags:u.surfaceFlags}));return{contents:a.contents,sides:i,checkcount:0}}),r=t.leaves.map(a=>({contents:a.contents,cluster:a.cluster,area:a.area,firstLeafBrush:a.firstLeafBrush,numLeafBrushes:a.numLeafBrushes})),s=t.bmodels.map(a=>({mins:a.mins,maxs:a.maxs,origin:a.origin,headnode:a.headnode}));return{planes:e,nodes:o,leaves:r,brushes:n,leafBrushes:t.leafBrushes,bmodels:s,visibility:t.visibility}}function ke(t){let e=0;return t.x<0&&(e|=1),t.y<0&&(e|=2),t.z<0&&(e|=4),e}function $(t,e){return t.normal.x*e.x+t.normal.y*e.y+t.normal.z*e.z-t.dist}function Go(t,e,o=0){let n=$(t,e);return n>o?1:n<-o?2:3}function Uo(t,e,o,n=0){let r,s;switch(o.signbits){case 0:r=o.normal.x*e.x+o.normal.y*e.y+o.normal.z*e.z,s=o.normal.x*t.x+o.normal.y*t.y+o.normal.z*t.z;break;case 1:r=o.normal.x*t.x+o.normal.y*e.y+o.normal.z*e.z,s=o.normal.x*e.x+o.normal.y*t.y+o.normal.z*t.z;break;case 2:r=o.normal.x*e.x+o.normal.y*t.y+o.normal.z*e.z,s=o.normal.x*t.x+o.normal.y*e.y+o.normal.z*t.z;break;case 3:r=o.normal.x*t.x+o.normal.y*t.y+o.normal.z*e.z,s=o.normal.x*e.x+o.normal.y*e.y+o.normal.z*t.z;break;case 4:r=o.normal.x*e.x+o.normal.y*e.y+o.normal.z*t.z,s=o.normal.x*t.x+o.normal.y*t.y+o.normal.z*e.z;break;case 5:r=o.normal.x*t.x+o.normal.y*e.y+o.normal.z*t.z,s=o.normal.x*e.x+o.normal.y*t.y+o.normal.z*e.z;break;case 6:r=o.normal.x*e.x+o.normal.y*t.y+o.normal.z*t.z,s=o.normal.x*t.x+o.normal.y*e.y+o.normal.z*e.z;break;default:r=o.normal.x*t.x+o.normal.y*t.y+o.normal.z*t.z,s=o.normal.x*e.x+o.normal.y*e.y+o.normal.z*e.z;break}let a=0;return r-o.dist>=-n&&(a=1),s-o.dist<=n&&(a|=2),a}function yt(t,e,o=J){for(let n of e.sides)if($(n.plane,t)>o)return!1;return!0}function xt(t,e,o,n){for(let r of n.sides){let s=r.plane.normal.x*(r.plane.normal.x<0?o.x:e.x)+r.plane.normal.y*(r.plane.normal.y<0?o.y:e.y)+r.plane.normal.z*(r.plane.normal.z<0?o.z:e.z),a=r.plane.dist-s;if(t.x*r.plane.normal.x+t.y*r.plane.normal.y+t.z*r.plane.normal.z-a>0)return{startsolid:!1,allsolid:!1,contents:0}}return{startsolid:!0,allsolid:!0,contents:n.contents}}function Ge({start:t,end:e,mins:o,maxs:n,brush:r,trace:s}){if(r.sides.length===0)return;let a=o.x===0&&o.y===0&&o.z===0&&n.x===0&&n.y===0&&n.z===0,i=-1,u=1,l=null,m=null,c=!1,f=!1;for(let p of r.sides){let{plane:y}=p,T=y.dist;if(!a){let A=y.normal.x<0?n.x:o.x,C=y.normal.y<0?n.y:o.y,b=y.normal.z<0?n.z:o.z;T-=y.normal.x*A+y.normal.y*C+y.normal.z*b}let h=t.x*y.normal.x+t.y*y.normal.y+t.z*y.normal.z-T,V=e.x*y.normal.x+e.y*y.normal.y+e.z*y.normal.z-T;if(V>0&&(c=!0),h>0&&(f=!0),h>0&&V>=h)return;if(!(h<=0&&V<=0))if(h>V){let A=(h-J)/(h-V);A>i&&(i=A,l=y,m=p)}else{let A=(h+J)/(h-V);A<u&&(u=A)}}if(!f){s.startsolid=!0,c||(s.allsolid=!0),s.fraction=0;return}i<u&&i>-1&&i<s.fraction&&(s.fraction=i<0?0:i,s.plane=l,s.contents=r.contents,s.surfaceFlags=m?.surfaceFlags??0)}function _e(){return{fraction:1,plane:null,contents:0,surfaceFlags:0,startsolid:!1,allsolid:!1}}function Ue(t,e,o){let n=o;for(;n>=0;){let r=e.nodes[n];n=$(r.plane,t)>=0?r.children[0]:r.children[1]}return-1-n}function St(t,e,o){let n=t.leaves[e],r=n.contents,s=He(),a=n.firstLeafBrush,i=a+n.numLeafBrushes;for(let u=a;u<i;u+=1){let l=t.leafBrushes[u],m=t.brushes[l];m.checkcount!==s&&(m.checkcount=s,m.sides.length!==0&&yt(o,m)&&(r|=m.contents))}return r}function He(){let t=Ce;return Ce+=1,Ce>=Bo&&(Ce=1),t}function Ho(t,e){return t.x===0&&t.y===0&&t.z===0&&e.x===0&&e.y===0&&e.z===0}function Ko(t,e,o){return Ho(e,o)?0:t.normal.x*(t.normal.x<0?o.x:e.x)+t.normal.y*(t.normal.y<0?o.y:e.y)+t.normal.z*(t.normal.z<0?o.z:e.z)}function ht(t,e,o){return Math.abs(Ko(t,e,o))}function Ie(t,e,o){return N(t,g(Y(e,t),o))}function We(t,e,o){let n=t.allsolid?0:t.fraction,r=Ie(e,o,n);return{fraction:n,endpos:r,plane:t.plane,planeNormal:t.startsolid?void 0:t.plane?.normal,contents:t.contents,surfaceFlags:t.surfaceFlags,startsolid:t.startsolid,allsolid:t.allsolid}}function Ae(t,e,o){let n=Ue(t,e,o);return e.leaves[n]?.cluster??-1}function bt(t,e,o,n){if(!t||t.numClusters===0)return!0;if(e<0||o<0||e>=t.clusters.length||o>=t.numClusters)return!1;let r=t.clusters[e],a=(n?r.phs:r.pvs)[o>>3];return a===void 0?!1:(a&1<<(o&7))!==0}function de(t){let{model:e,nodeIndex:o,startFraction:n,endFraction:r,start:s,end:a,traceStart:i,traceEnd:u,mins:l,maxs:m,contentMask:c,trace:f,brushCheckCount:p}=t;if(f.fraction<=n)return;if(o<0){let L=-1-o,_=e.leaves[L],I=_.firstLeafBrush,K=I+_.numLeafBrushes;for(let w=I;w<K;w+=1){let G=e.leafBrushes[w],z=e.brushes[G];if((z.contents&c)!==0&&z.sides.length&&z.checkcount!==p&&(z.checkcount=p,Ge({start:i,end:u,mins:l,maxs:m,brush:z,trace:f}),f.allsolid))return}return}let y=e.nodes[o],T=y.plane,h=ht(T,l,m),V=$(T,s),A=$(T,a);if(V>=h&&A>=h){de({model:e,nodeIndex:y.children[0],startFraction:n,endFraction:r,start:s,end:a,traceStart:i,traceEnd:u,mins:l,maxs:m,contentMask:c,trace:f,brushCheckCount:p});return}if(V<-h&&A<-h){de({model:e,nodeIndex:y.children[1],startFraction:n,endFraction:r,start:s,end:a,traceStart:i,traceEnd:u,mins:l,maxs:m,contentMask:c,trace:f,brushCheckCount:p});return}let C=0,b=1/(V-A),x,P;V<A?(C=1,P=(V+h+J)*b,x=(V-h+J)*b):(C=0,P=(V-h-J)*b,x=(V+h+J)*b),x<0?x=0:x>1&&(x=1),P<0?P=0:P>1&&(P=1);let S=n+(r-n)*x,O=Ie(s,a,x);if(de({model:e,nodeIndex:y.children[C],startFraction:n,endFraction:S,start:s,end:O,traceStart:i,traceEnd:u,mins:l,maxs:m,contentMask:c,trace:f,brushCheckCount:p}),f.fraction<=S)return;let k=n+(r-n)*P,E=Ie(s,a,P);de({model:e,nodeIndex:y.children[1-C],startFraction:k,endFraction:r,start:E,end:a,traceStart:i,traceEnd:u,mins:l,maxs:m,contentMask:c,trace:f,brushCheckCount:p})}function Vt(t){let{model:e,start:o,end:n}=t,r=t.mins??R,s=t.maxs??R,a=t.contentMask??4294967295,i=t.headnode??0,u=_e(),l=He();return de({model:e,nodeIndex:i,startFraction:0,endFraction:1,start:o,end:n,traceStart:o,traceEnd:n,mins:r,maxs:s,contentMask:a,trace:u,brushCheckCount:l}),We(u,o,n)}function Jo(t,e,o=0){let n=Ue(t,e,o);return St(e,n,t)}function Xo(t,e,o=0){let n=new Map;return t.map(r=>{let s=Ue(r,e,o),a=e.leaves[s];if(a.numLeafBrushes===0){let i=n.get(s);return i!==void 0?i:(n.set(s,a.contents),a.contents)}return St(e,s,r)})}function jo(t,e,o,n,r=0){let s=He(),a=0;function i(u){if(u<0){let p=-1-u,y=n.leaves[p];a|=y.contents;let T=y.firstLeafBrush,h=T+y.numLeafBrushes;for(let V=T;V<h;V+=1){let A=n.leafBrushes[V],C=n.brushes[A];if(C.checkcount===s||(C.checkcount=s,C.sides.length===0))continue;let b=xt(t,e,o,C);b.startsolid&&(a|=b.contents)}return}let l=n.nodes[u],m=l.plane,c=ht(m,e,o),f=$(m,t);if(c===0){i(f>=0?l.children[0]:l.children[1]);return}if(f>c){i(l.children[0]);return}if(f<-c){i(l.children[1]);return}i(l.children[0]),i(l.children[1])}return i(r),a}function Yo(t,e,o,n=0){let{visibility:r}=o;if(!r)return!0;let s=Ae(t,o,n),a=Ae(e,o,n);return bt(r,s,a,!1)}function Zo(t,e,o,n=0){let{visibility:r}=o;if(!r)return!0;let s=Ae(t,o,n),a=Ae(e,o,n);return bt(r,s,a,!0)}function ne(t,e,o){return{normal:t,dist:e,type:o,signbits:ke(t)}}function qo(t){let e=t.surfaceFlags??0,o=t.origin.x+t.maxs.x,n=t.origin.x+t.mins.x,r=t.origin.y+t.maxs.y,s=t.origin.y+t.mins.y,a=t.origin.z+t.maxs.z,i=t.origin.z+t.mins.z,l=[ne({x:1,y:0,z:0},o,0),ne({x:-1,y:0,z:0},-n,0),ne({x:0,y:1,z:0},r,1),ne({x:0,y:-1,z:0},-s,1),ne({x:0,y:0,z:1},a,2),ne({x:0,y:0,z:-1},-i,2)].map(m=>({plane:m,surfaceFlags:e}));return{contents:t.contents,sides:l,checkcount:0}}function $o(t){let e=qo(t);return{...t,brush:e,bounds:{mins:{x:t.origin.x+t.mins.x,y:t.origin.y+t.mins.y,z:t.origin.z+t.mins.z},maxs:{x:t.origin.x+t.maxs.x,y:t.origin.y+t.maxs.y,z:t.origin.z+t.maxs.z}}}}function Qo(t,e){return!(t.mins.x>e.maxs.x||t.maxs.x<e.mins.x||t.mins.y>e.maxs.y||t.maxs.y<e.mins.y||t.mins.z>e.maxs.z||t.maxs.z<e.mins.z)}function en(t,e){return e.allsolid&&!t.allsolid||e.startsolid&&!t.startsolid?!0:e.fraction<t.fraction}var Be=class{constructor(){this.entities=new Map}link(e){this.entities.set(e.id,$o(e))}unlink(e){this.entities.delete(e)}trace(e){let{passId:o}=e,n=e.mins??R,r=e.maxs??R,s=e.contentMask??4294967295,a,i=null;e.model?a=Vt(e):a=We(_e(),e.start,e.end);for(let u of this.entities.values()){if(u.id===o||(u.contents&s)===0)continue;let l=_e();Ge({start:e.start,end:e.end,mins:n,maxs:r,brush:u.brush,trace:l}),l.contents===0&&(l.contents=u.contents);let m=We(l,e.start,e.end);en(a,m)&&(a=m,i=u.id)}return{...a,entityId:i}}gatherTriggerTouches(e,o,n,r=1073741824){let s=[],a={mins:N(e,o),maxs:N(e,n)};for(let i of this.entities.values())(i.contents&r)!==0&&Qo(a,i.bounds)&&s.push(i.id);return s}};var Tt=(a=>(a[a.None=0]="None",a[a.Archive=1]="Archive",a[a.UserInfo=2]="UserInfo",a[a.ServerInfo=4]="ServerInfo",a[a.Latch=8]="Latch",a[a.Cheat=16]="Cheat",a))(Tt||{});var Ks=1024,Js=80,Xs=512,js=64,Ys=128,tn=256,Zs=8192,on=256,nn=8192,rn=2048,sn=512,an=256,cn=512,ln=256,Ke=32,qs=96,$s=64,re=(S=>(S[S.Name=0]="Name",S[S.CdTrack=1]="CdTrack",S[S.Sky=2]="Sky",S[S.SkyAxis=3]="SkyAxis",S[S.SkyRotate=4]="SkyRotate",S[S.StatusBar=5]="StatusBar",S[S.AirAccel=59]="AirAccel",S[S.MaxClients=60]="MaxClients",S[S.MapChecksum=61]="MapChecksum",S[S.Models=62]="Models",S[S.Sounds=62+nn]="Sounds",S[S.Images=S.Sounds+rn]="Images",S[S.Lights=S.Images+sn]="Lights",S[S.ShadowLights=S.Lights+on]="ShadowLights",S[S.Items=S.ShadowLights+ln]="Items",S[S.PlayerSkins=S.Items+an]="PlayerSkins",S[S.General=S.PlayerSkins+tn]="General",S[S.WheelWeapons=S.General+cn]="WheelWeapons",S[S.WheelAmmo=S.WheelWeapons+Ke]="WheelAmmo",S[S.WheelPowerups=S.WheelAmmo+Ke]="WheelPowerups",S[S.CdLoopCount=S.WheelPowerups+Ke]="CdLoopCount",S[S.GameStyle=S.CdLoopCount+1]="GameStyle",S[S.MaxConfigStrings=S.GameStyle+1]="MaxConfigStrings",S))(re||{}),un=re.MaxConfigStrings;function dn(t){return t>=5&&t<59?96*(59-t):t>=re.General&&t<re.WheelWeapons?96*(re.MaxConfigStrings-t):96}var Je={};it(Je,{addReplayFrame:()=>yn,createReplaySession:()=>pn,deserializeReplay:()=>fn,serializeReplay:()=>mn});function mn(t){return JSON.stringify(t,null,2)}function fn(t){let e=JSON.parse(t);if(!e.metadata||!Array.isArray(e.frames))throw new Error("Invalid replay format: missing metadata or frames");return e}function pn(t,e){return{metadata:{map:t,date:new Date().toISOString(),version:"1.0",seed:e},frames:[]}}function yn(t,e,o,n){t.frames.push({serverFrame:o,cmd:e,timestamp:Date.now()-n})}function xn(t){return t??{}}function Pt(t,e,o={}){let n=xn(t),r=[],s=[];for(let i of e){if(!(i in n)){r.push(i);continue}typeof n[i]!="function"&&s.push(i)}let a=o.allowExtra===!1?Object.keys(n).filter(i=>!e.includes(i)):[];return{missing:r,nonFunctions:s,extras:a}}function Sn(t,e,o={}){let{missing:n,nonFunctions:r,extras:s}=Pt(t,e,o);if(n.length===0&&r.length===0&&s.length===0)return;let a=[];n.length>0&&a.push(`missing: ${n.join(", ")}`),r.length>0&&a.push(`non-functions: ${r.join(", ")}`),s.length>0&&a.push(`extras: ${s.join(", ")}`);let i=o.name??"contract";throw new Error(`${i} validation failed (${a.join("; ")})`)}var hn=["Broadcast_Print","Com_Print","Client_Print","Center_Print","sound","positioned_sound","local_sound","configstring","get_configstring","Com_Error","modelindex","soundindex","imageindex","setmodel","trace","clip","pointcontents","inPVS","inPHS","SetAreaPortalState","AreasConnected","linkentity","unlinkentity","BoxEdicts","multicast","unicast"],bn=["PreInit","Init","Shutdown","SpawnEntities","WriteGameJson","ReadGameJson","WriteLevelJson","ReadLevelJson","CanSave","ClientConnect","ClientThink","RunFrame","Pmove"],Vn=["Com_Print","get_configstring","Com_Error","TagMalloc","TagFree","AddCommandString","CL_FrameValid","CL_FrameTime","CL_ClientTime","CL_ServerFrame","Draw_RegisterPic","Draw_GetPicSize","SCR_DrawChar","SCR_DrawPic","SCR_DrawColorPic"],Tn=["Init","Shutdown","DrawHUD","TouchPics","LayoutFlags","GetActiveWeaponWheelWeapon","GetOwnedWeaponWheelWeapons","GetWeaponWheelAmmoCount","GetPowerupWheelCount","GetHitMarkerDamage","Pmove","ParseConfigString","ParseCenterPrint","ClearNotify","ClearCenterprint","NotifyMessage","GetMonsterFlashOffset"];var se=(r=>(r[r.None=0]="None",r[r.Feet=1]="Feet",r[r.Waist=2]="Waist",r[r.Under=3]="Under",r))(se||{});function Xe(t){return t>=2}function Pn(t){return t===3}var Q=(c=>(c[c.Ducked=1]="Ducked",c[c.JumpHeld=2]="JumpHeld",c[c.OnGround=4]="OnGround",c[c.TimeWaterJump=8]="TimeWaterJump",c[c.TimeLand=16]="TimeLand",c[c.TimeTeleport=32]="TimeTeleport",c[c.NoPositionalPrediction=64]="NoPositionalPrediction",c[c.OnLadder=128]="OnLadder",c[c.NoAngularPrediction=256]="NoAngularPrediction",c[c.IgnorePlayerCollision=512]="IgnorePlayerCollision",c[c.TimeTrick=1024]="TimeTrick",c))(Q||{});function M(t,e){return(t&e)!==0}function W(t,e){return t|e}function U(t,e){return t&~e}var ae=(i=>(i[i.Normal=0]="Normal",i[i.Grapple=1]="Grapple",i[i.NoClip=2]="NoClip",i[i.Spectator=3]="Spectator",i[i.Dead=4]="Dead",i[i.Gib=5]="Gib",i[i.Freeze=6]="Freeze",i))(ae||{}),ee=(i=>(i[i.None=0]="None",i[i.Attack=1]="Attack",i[i.Use=2]="Use",i[i.Holster=4]="Holster",i[i.Jump=8]="Jump",i[i.Crouch=16]="Crouch",i[i.Any=128]="Any",i))(ee||{});function je(t){let{velocity:e,frametime:o,onGround:n,groundIsSlick:r,onLadder:s,waterlevel:a,pmFriction:i,pmStopSpeed:u,pmWaterFriction:l}=t,m=D(e);if(m<1)return{x:0,y:0,z:e.z};let c=0;if(n&&!r||s){let y=m<u?u:m;c+=y*i*o}a>0&&!s&&(c+=m*l*a*o);let f=m-c;if(f<0&&(f=0),f===m)return e;let p=f/m;return g(e,p)}function H(t){let{velocity:e,wishdir:o,wishspeed:n,accel:r,frametime:s}=t,a=F(e,o),i=n-a;if(i<=0)return e;let u=r*s*n;return u>i&&(u=i),{x:e.x+o.x*u,y:e.y+o.y*u,z:e.z+o.z*u}}function Ye(t){let{velocity:e,wishdir:o,wishspeed:n,accel:r,frametime:s}=t,a=Math.min(n,30),i=F(e,o),u=a-i;if(u<=0)return e;let l=r*n*s;return l>u&&(l=u),{x:e.x+o.x*l,y:e.y+o.y*l,z:e.z+o.z*l}}function Cn(t,e){let o=Math.abs(t.forwardmove),n=Math.abs(t.sidemove),r=Math.abs(t.upmove),s=Math.max(o,n,r);if(s===0)return 0;let a=Math.sqrt(t.forwardmove*t.forwardmove+t.sidemove*t.sidemove+t.upmove*t.upmove);return e*s/(127*a)}function Ze(t){let{forward:e,right:o,cmd:n,maxSpeed:r}=t,s={x:e.x*n.forwardmove+o.x*n.sidemove,y:e.y*n.forwardmove+o.y*n.sidemove,z:0},a=D(s);if(a>r){let i=r/a;s=g(s,i),a=r}return{wishdir:a===0?s:v(s),wishspeed:a}}function qe(t){let{forward:e,right:o,cmd:n,maxSpeed:r}=t,s={x:e.x*n.forwardmove+o.x*n.sidemove,y:e.y*n.forwardmove+o.y*n.sidemove,z:0};n.upmove>10?s=N(s,{x:0,y:0,z:n.upmove}):n.upmove<-10?s=N(s,{x:0,y:0,z:n.upmove}):s=N(s,{x:0,y:0,z:10});let a=D(s);if(a>r){let i=r/a;s=g(s,i),a=r}return a*=.5,{wishdir:a===0?s:v(s),wishspeed:a}}var Ct=5,_n=4,An=18,Nn=.7,_t=1,At=2;function Nt(t,e,o,n=Ct,r=t){if(e.length===0)return{velocity:t,planes:[],stopped:!1};let s=[],a=t;for(let u of e){if(s.length>=n)return{velocity:R,planes:s,stopped:!0};if(s.find(f=>F(f,u)>.99))continue;s.push(u);let m,c=0;for(;c<s.length;c++){let f=q(a,s[c],o),p=0;for(;p<s.length&&!(p!==c&&F(f,s[p])<0);p++);if(p===s.length){m=f;break}}if(m)a=m;else{if(s.length!==2)return{velocity:R,planes:s,stopped:!0};let f=Z(s[0],s[1]),p=F(f,a);a=g(f,p)}if(F(a,r)<=0)return{velocity:R,planes:s,stopped:!0}}let i=a.x===0&&a.y===0&&a.z===0;return{velocity:a,planes:s,stopped:i}}function $e(t){let{origin:e,velocity:o,frametime:n,overbounce:r,trace:s,maxBumps:a=_n,maxClipPlanes:i=Ct,mins:u,maxs:l,hasTime:m=!1}=t,c=e,f=o,p=[],y=o,T=n,h=0;for(let A=0;A<a&&!(f.x===0&&f.y===0&&f.z===0);A++){let C=N(c,g(f,T)),b=s(c,C,u,l);if(b.allsolid){let P=m?y:R;return{origin:b.endpos,velocity:P,planes:p,stopped:!0,blocked:h}}if(b.startsolid){let P=m?y:R;return{origin:b.endpos,velocity:P,planes:p,stopped:!0,blocked:h}}if(b.fraction>0&&(c=b.endpos),b.fraction===1)break;if(!b.planeNormal)return{origin:c,velocity:m?y:R,planes:p,stopped:!0,blocked:h};b.planeNormal.z>.7&&(h|=_t),b.planeNormal.z===0&&(h|=At),p.push(b.planeNormal),T-=T*b.fraction;let x=Nt(f,p,r,i,y);if(f=x.velocity,p.splice(0,p.length,...x.planes),y.z>0&&f.z<0&&(f={...f,z:0}),x.stopped)return{origin:c,velocity:m?y:f,planes:p,stopped:!0,blocked:h}}let V=m?y:f;return{origin:c,velocity:V,planes:p,stopped:V.x===0&&V.y===0&&V.z===0,blocked:h}}function te(t){let{mins:e,maxs:o,stepSize:n=An,...r}=t,s=t.origin,a=t.velocity,i=$e({...r,mins:e,maxs:o}),u=N(s,{x:0,y:0,z:n}),l=r.trace(s,u,e,o);if(l.allsolid)return{...i,stepped:!1,stepHeight:0};let m=l.endpos.z-s.z,c=$e({...r,origin:l.endpos,velocity:a,mins:e,maxs:o}),f=N(c.origin,{x:0,y:0,z:-m}),p=r.trace(c.origin,f,e,o),y=c.origin,T=p.planeNormal;p.allsolid||(y=p.endpos);let h=(P,S)=>(P.x-S.x)**2+(P.y-S.y)**2,V=h(i.origin,s),A=h(y,s);if(V>A||T&&T.z<Nn)return{...i,stepped:!1,stepHeight:0};let C={...c.velocity,z:i.velocity.z},b=c.blocked,x=C.x===0&&C.y===0&&C.z===0;return{origin:y,velocity:C,planes:c.planes,blocked:b,stopped:x,stepped:!0,stepHeight:m,stepNormal:T}}var ie=["x","y","z"],Qe=[{normal:[0,0,1],mins:[-1,-1,0],maxs:[1,1,0]},{normal:[0,0,-1],mins:[-1,-1,0],maxs:[1,1,0]},{normal:[1,0,0],mins:[0,-1,-1],maxs:[0,1,1]},{normal:[-1,0,0],mins:[0,-1,-1],maxs:[0,1,1]},{normal:[0,1,0],mins:[-1,0,-1],maxs:[1,0,1]},{normal:[0,-1,0],mins:[-1,0,-1],maxs:[1,0,1]}],gt={x:0,y:0,z:0};function ce(t){return{x:t.x,y:t.y,z:t.z}}function gn(t){return{x:t[0],y:t[1],z:t[2]}}function me(t,e,o){if(o!==0)switch(e){case"x":t.x+=o;break;case"y":t.y+=o;break;case"z":t.z+=o;break}}function Et(t,e,o){switch(e){case"x":t.x=o;break;case"y":t.y=o;break;case"z":t.z=o;break}}function Ne(t,e){switch(e){case"x":return t.x;case"y":return t.y;case"z":default:return t.z}}function Rt(t,e,o,n){return t===-1?Ne(o,e):t===1?Ne(n,e):0}function Ot(t,e,o,n){let r=ce(t);for(let s=0;s<ie.length;s++){let a=ie[s],i=e.normal[s];i<0?me(r,a,Ne(o,a)):i>0&&me(r,a,Ne(n,a))}return r}function En(t,e,o){let n=ce(gt),r=ce(gt);for(let s=0;s<ie.length;s++){let a=ie[s];Et(n,a,Rt(t.mins[s],a,e,o)),Et(r,a,Rt(t.maxs[s],a,e,o))}return{mins:n,maxs:r}}function Rn(t,e,o){if(!e||o===0)return t;let n=ce(t);return me(n,e,o),n}function On(t,e,o){if(!e||o===0)return t;switch(e){case"x":return{...t,x:t.x+o};case"y":return{...t,y:t.y+o};case"z":default:return{...t,z:t.z+o}}}function et(t){let{origin:e,mins:o,maxs:n,trace:r}=t;if(!r(e,o,n,e).startsolid)return{result:"good-position",origin:{...e}};let a=[];for(let i=0;i<Qe.length;i++){let u=Qe[i],{mins:l,maxs:m}=En(u,o,n),c=Ot(e,u,o,n),f=r(c,l,m,c),p,y=0;if(f.startsolid)for(let P=0;P<ie.length;P++){if(u.normal[P]!==0)continue;let S=ie[P],O=ce(c);if(me(O,S,1),f=r(O,l,m,O),!f.startsolid){c=O,p=S,y=1;break}if(O=ce(c),me(O,S,-1),f=r(O,l,m,O),!f.startsolid){c=O,p=S,y=-1;break}}if(f.startsolid)continue;let T=Qe[i^1],h=Ot(e,T,o,n);if(h=Rn(h,p,y),f=r(c,l,m,h),f.startsolid)continue;let V=gn(u.normal),A=N(f.endpos??h,g(V,.125)),C=Y(A,h),b=N(e,C);b=On(b,p,y),!r(b,o,n,b).startsolid&&a.push({origin:b,distance:oe(C)})}return a.length===0?{result:"no-good-position",origin:{...e}}:(a.sort((i,u)=>i.distance-u.distance),{result:"fixed",origin:{...a[0].origin}})}var vn=100,tt=200,vt=150,ge=25,zn=15,Fn=1,Mn={x:0,y:0,z:1},Ln=(t,e)=>({fraction:1,endpos:e,allsolid:!1,startsolid:!1});function ot(t){let e=0,o=0,n=0;return t&262144&&(e+=1),t&524288&&(o+=1),t&1048576&&(e-=1),t&2097152&&(o-=1),t&4194304&&(n+=1),t&8388608&&(n-=1),e===0&&o===0&&n===0?R:{x:e,y:o,z:n}}function Mt(t){let{watertype:e,waterlevel:o,onGround:n,waterSpeed:r}=t;if((e&16515072)===0)return R;let s=ot(e);if(s===R)return R;let a=r;return o===1&&n&&(a*=.5),g(s,a)}function Lt(t){let{groundContents:e,scale:o=vn}=t,n=ot(e);return n===R?R:g(n,o)}function Ee(t){let{wishVelocity:e,onLadder:o,onGround:n,waterlevel:r,watertype:s,groundContents:a,cmd:i,viewPitch:u,maxSpeed:l,ladderMod:m,waterSpeed:c,forward:f,origin:p,mins:y,maxs:T,trace:h=Ln}=t,V=e;o&&(V=wn({wishVelocity:V,cmd:i,waterlevel:r,viewPitch:u,maxSpeed:l,ladderMod:m,onGround:n,forward:f,origin:p,mins:y,maxs:T,trace:h}));let A=Mt({watertype:s,waterlevel:r,onGround:n,waterSpeed:c});if(A!==R&&(V=N(V,A)),n){let C=Lt({groundContents:a});C!==R&&(V=N(V,C))}return V}function wn(t){let{wishVelocity:e,cmd:o,waterlevel:n,viewPitch:r,maxSpeed:s,ladderMod:a,onGround:i,forward:u,origin:l,mins:m,maxs:c,trace:f}=t,p=o.buttons??0,y={...e};if((p&24)!==0){let T=Xe(n)?s:tt;y={...y,z:p&8?T:-T}}else if(o.forwardmove){let T=zt(o.forwardmove,-tt,tt);if(o.forwardmove>0){let h=r<zn?T:-T;y={...y,z:h}}else i||(y={...y,x:0,y:0}),y={...y,z:T}}else y={...y,z:0};if(!i)if(o.sidemove){let T=zt(o.sidemove,-vt,vt);n<2&&(T*=a);let h=v({x:u.x,y:u.y,z:0});if(h.x!==0||h.y!==0){let V=N(l,g(h,Fn)),A=f(l,V,m,c);if(A.fraction!==1&&!A.allsolid&&A.contents!==void 0&&(A.contents&536870912)!==0&&A.planeNormal){let C=Z(A.planeNormal,Mn);y={...y,x:0,y:0},y=N(y,g(C,-T))}}}else y={...y,x:Ft(y.x),y:Ft(y.y)};return y}function zt(t,e,o){return Math.max(e,Math.min(o,t))}function Ft(t){return t<-ge?-ge:t>ge?ge:t}var Dn=1.5,wt=.5,In=1.01;function Wn(t){let{origin:e,cmd:o,frametime:n,pmFriction:r,pmStopSpeed:s,pmMaxSpeed:a,pmAccelerate:i,pmWaterSpeed:u,doclip:l,forward:m,right:c,mins:f,maxs:p,trace:y,overbounce:T=In,stepSize:h,maxBumps:V,maxClipPlanes:A}=t,C=Bn({velocity:t.velocity,pmFriction:r,pmStopSpeed:s,frametime:n}),b=kn({cmd:o,forward:m,right:c,pmMaxSpeed:a,pmWaterSpeed:u});if(b.wishspeed>0&&(C=H({velocity:C,wishdir:b.wishdir,wishspeed:b.accelSpeed,accel:i,frametime:n})),!l){let x=g(C,n);return{origin:N(e,x),velocity:C,planes:[],blocked:0,stopped:C.x===0&&C.y===0&&C.z===0,stepped:!1,stepHeight:0}}if(!y||!f||!p)throw new Error("applyPmoveFlyMove: doclip=true requires trace/mins/maxs");return te({origin:e,velocity:C,frametime:n,overbounce:T,trace:y,mins:f,maxs:p,stepSize:h,maxBumps:V,maxClipPlanes:A})}function Bn(t){let{velocity:e,pmFriction:o,pmStopSpeed:n,frametime:r}=t,s=D(e);if(s<1)return{x:0,y:0,z:0};let a=o*Dn,u=(s<n?n:s)*a*r,l=s-u;return l<0&&(l=0),l===s?e:g(e,l/s)}function kn(t){let{cmd:e,forward:o,right:n,pmMaxSpeed:r,pmWaterSpeed:s}=t,a=v(o),i=v(n),l={x:a.x*e.forwardmove+i.x*e.sidemove,y:a.y*e.forwardmove+i.y*e.sidemove,z:a.z*e.forwardmove+i.z*e.sidemove},m=e.buttons??0;m&8&&(l=N(l,{x:0,y:0,z:s*wt})),m&16&&(l=N(l,{x:0,y:0,z:-s*wt}));let c=D(l),f=c===0?{x:0,y:0,z:0}:v(l);if(c>r){let y=r/c;l=g(l,y),c=r,f=c===0?{x:0,y:0,z:0}:v(l)}let p=c*2;return{wishdir:f,wishspeed:c,accelSpeed:p}}function fe(t){let{origin:e,mins:o,viewheight:n,pointContents:r}=t,s=n-o.z,a=s/2,i={x:e.x,y:e.y,z:e.z+o.z+1},u=r(i);if((u&56)===0)return{waterlevel:0,watertype:0};let l=u,m=1,c={x:i.x,y:i.y,z:e.z+o.z+a};if(u=r(c),(u&56)!==0){m=2;let f={x:i.x,y:i.y,z:e.z+o.z+s};u=r(f),(u&56)!==0&&(m=3)}return{waterlevel:m,watertype:l}}var Gn=270;function Un(t,e){return(t&e)!==0}function Hn(t){let{pmFlags:e,pmType:o,buttons:n,waterlevel:r,onGround:s,velocity:a,jumpHeight:i=Gn}=t;if(e&16)return{pmFlags:e,onGround:s,velocity:a,jumpSound:!1,jumped:!1};let u=Un(n,8),l=e,m=s,c=!1,f=!1,p=a;if(!u)return l=U(l,2),{pmFlags:l,onGround:m,velocity:p,jumpSound:c,jumped:f};if(Kn(l))return{pmFlags:l,onGround:m,velocity:p,jumpSound:c,jumped:f};if(o===4)return{pmFlags:l,onGround:m,velocity:p,jumpSound:c,jumped:f};if(r>=2)return m=!1,{pmFlags:l,onGround:m,velocity:p,jumpSound:c,jumped:f};if(!m)return{pmFlags:l,onGround:m,velocity:p,jumpSound:c,jumped:f};l=W(l,2),l=U(l,4),m=!1,c=!0,f=!0;let y=a.z+i,T=y<i?i:y;return p={...a,z:T},{pmFlags:l,onGround:m,velocity:p,jumpSound:c,jumped:f}}function Kn(t){return(t&2)!==0}function Re(t,e,o){return{x:t,y:e,z:o}}function Oe(t,e){let o=Re(-16,-16,0),n=Re(16,16,16);if(t===5)return{mins:o,maxs:n,viewheight:8};let r=t===4||(e&1)!==0,s=Re(o.x,o.y,-24),a=Re(n.x,n.y,r?4:32);return{mins:s,maxs:a,viewheight:r?-2:22}}var Jn=4,Xn=32,jn=8;function Yn(t){let{pmType:e}=t;if(e===5){let a=Oe(e,t.pmFlags);return{pmFlags:t.pmFlags,ducked:M(t.pmFlags,1),changed:!1,...a}}let o=t.pmFlags,n=!1;e===4?M(o,1)||(o=W(o,1),n=!0):Zn(t)?!M(o,1)&&!qn(t)&&(o=W(o,1),n=!0):M(o,1)&&!$n(t)&&(o=U(o,1),n=!0);let r=Oe(e,o),s=e===4||M(o,1);return{pmFlags:o,ducked:s,changed:n,...r}}function Zn(t){return(t.buttons&16)===0||t.onLadder||t.n64Physics?!1:!!(t.hasGroundEntity||t.waterlevel<=1&&!Qn(t))}function qn(t){return t.trace({start:t.origin,end:t.origin,mins:t.mins,maxs:Dt(t.maxs,Jn),mask:3}).allsolid}function $n(t){return t.trace({start:t.origin,end:t.origin,mins:t.mins,maxs:Dt(t.maxs,Xn),mask:3}).allsolid}function Qn(t){let e={x:t.origin.x,y:t.origin.y,z:t.origin.z-jn};return t.trace({start:t.origin,end:e,mins:t.mins,maxs:t.maxs,mask:3}).fraction<1?!1:t.trace({start:t.origin,end:e,mins:t.mins,maxs:t.maxs,mask:56}).fraction<1}function Dt(t,e){return{x:t.x,y:t.y,z:e}}var er=.25,tr=180,or=100,nr=.7,rr=.9,sr=64,ar=128,ir=1.01,cr=1080;function lr(t){let{pmType:e,n64Physics:o,velocity:n,startVelocity:r,origin:s,mins:a,maxs:i,viewheight:u,trace:l,pointContents:m}=t,c=t.pmFlags,f=t.pmTime,p,y=M(c,4),T,h=0;if(n.z>tr||e===1)c=U(c,4),y=!1;else{let b={x:s.x,y:s.y,z:s.z-er},x=l(s,b,a,i);T=x,h=x.contents??0;let P=x.planeNormal,S=x.fraction<1&&!!P&&P.z<nr;if(S&&P){let O=N(s,P),B=l(s,O,a,i);B.fraction<1&&!B.startsolid&&(S=!1)}if(x.fraction===1||!P||S&&!x.startsolid)c=U(c,4),y=!1;else{y=!0,M(c,8)&&(c&=~cr,f=0);let O=M(c,4);if(!O){!o&&n.z>=or&&P.z>=rr&&!M(c,1)&&(c=W(c,1024),f=sr);let B=q(n,P,ir);p=r.z-B.z}c=W(c,4),!O&&(o||M(c,1))&&(c=W(c,16),f=ar)}}let{waterlevel:A,watertype:C}=fe({origin:s,mins:a,viewheight:u,pointContents:m});return{pmFlags:c,pmTime:f,onGround:M(c,4),groundTrace:T,groundContents:h,waterlevel:A,watertype:C,impactDelta:p}}var It=1,ur=60,nt=1.01;function dr(t){let{origin:e,frametime:o,mins:n,maxs:r,trace:s,overbounce:a=nt,stepSize:i,maxBumps:u,maxClipPlanes:l,hasTime:m,forward:c,right:f,cmd:p,pmFlags:y,onGround:T,gravity:h,pmType:V,pmAccelerate:A,pmAirAccelerate:C=It,pmMaxSpeed:b,pmDuckSpeed:x,onLadder:P,waterlevel:S,watertype:O,groundContents:B,viewPitch:k,ladderMod:E,pmWaterSpeed:L}=t,_={...t.velocity},I=fr(c,f,p);I=Ee({wishVelocity:I,onLadder:P,onGround:T,waterlevel:S,watertype:O,groundContents:B,cmd:p,viewPitch:k,maxSpeed:M(y,1)?x:b,ladderMod:E,waterSpeed:L,forward:c,origin:e,mins:n,maxs:r,trace:s});let w=M(y,1)?x:b,G=I,z=D(G);if(z!==0&&(G=v(G)),z>w){let X=w/z;I=g(I,X),z=w,z!==0&&(G=v(I))}return P?(_=H({velocity:_,wishdir:G,wishspeed:z,accel:A,frametime:o}),Math.abs(I.z)<Number.EPSILON&&(_=xr(_,h,o)),ve({origin:e,velocity:_,frametime:o,mins:n,maxs:r,trace:s,overbounce:a,stepSize:i,maxBumps:u,maxClipPlanes:l,hasTime:m})):T?(_={..._,z:0},_=H({velocity:_,wishdir:G,wishspeed:z,accel:A,frametime:o}),h>0?_={..._,z:0}:_={..._,z:_.z-h*o},_.x===0&&_.y===0?{origin:e,velocity:_,planes:[],blocked:0,stopped:!0,stepped:!1,stepHeight:0}:ve({origin:e,velocity:_,frametime:o,mins:n,maxs:r,trace:s,overbounce:a,stepSize:i,maxBumps:u,maxClipPlanes:l,hasTime:m})):(C>0?_=Ye({velocity:_,wishdir:G,wishspeed:z,accel:C,frametime:o}):_=H({velocity:_,wishdir:G,wishspeed:z,accel:It,frametime:o}),V!==1&&(_={..._,z:_.z-h*o}),ve({origin:e,velocity:_,frametime:o,mins:n,maxs:r,trace:s,overbounce:a,stepSize:i,maxBumps:u,maxClipPlanes:l,hasTime:m}))}function mr(t){let{origin:e,frametime:o,mins:n,maxs:r,trace:s,overbounce:a=nt,stepSize:i,maxBumps:u,maxClipPlanes:l,hasTime:m,forward:c,right:f,cmd:p,pmFlags:y,onGround:T,pmMaxSpeed:h,pmDuckSpeed:V,pmWaterAccelerate:A,pmWaterSpeed:C,onLadder:b,watertype:x,groundContents:P,waterlevel:S,viewPitch:O,ladderMod:B}=t,k={...t.velocity},E=pr(c,f,p);yr(p,T)?E={...E,z:E.z-ur}:Wt(p,16)?E=N(E,{x:0,y:0,z:-C*.5}):Wt(p,8)&&(E=N(E,{x:0,y:0,z:C*.5})),E=Ee({wishVelocity:E,onLadder:b,onGround:T,waterlevel:S,watertype:x,groundContents:P,cmd:p,viewPitch:O,maxSpeed:M(y,1)?V:h,ladderMod:B,waterSpeed:C,forward:c,origin:e,mins:n,maxs:r,trace:s});let L=E,_=D(L);if(_!==0&&(L=v(L)),_>h){let K=h/_;E=g(E,K),_=h,_!==0&&(L=v(E))}if(_*=.5,M(y,1)&&_>V){let K=V/_;E=g(E,K),_=V,_!==0&&(L=v(E))}return k=H({velocity:k,wishdir:L,wishspeed:_,accel:A,frametime:o}),ve({origin:e,velocity:k,frametime:o,mins:n,maxs:r,trace:s,overbounce:a,stepSize:i,maxBumps:u,maxClipPlanes:l,hasTime:m})}function fr(t,e,o){return{x:t.x*o.forwardmove+e.x*o.sidemove,y:t.y*o.forwardmove+e.y*o.sidemove,z:0}}function pr(t,e,o){return{x:t.x*o.forwardmove+e.x*o.sidemove,y:t.y*o.forwardmove+e.y*o.sidemove,z:t.z*o.forwardmove+e.z*o.sidemove}}function Wt(t,e){return!!((t.buttons??0)&e)}function yr(t,e){let o=t.forwardmove===0&&t.sidemove===0,n=!((t.buttons??0)&24);return o&&n&&!e}function xr(t,e,o){let n=t.z,r=e*o;return n>0?(n-=r,n<0&&(n=0)):(n+=r,n>0&&(n=0)),{...t,z:n}}function ve(t){let{origin:e,velocity:o,frametime:n,mins:r,maxs:s,trace:a,overbounce:i=nt,stepSize:u,maxBumps:l,maxClipPlanes:m,hasTime:c}=t;return te({origin:e,velocity:o,frametime:n,trace:a,mins:r,maxs:s,overbounce:i,stepSize:u,maxBumps:l,maxClipPlanes:m,hasTime:c})}var Sr=1,hr=40,ze=50,Bt=350,br=2048,kt=.1,Vr=800,Tr=50,Gt=.7,Pr=18,Cr=1.01,_r=2;function Ar(t){let{pmFlags:e,pmTime:o,waterlevel:n,watertype:r,gravity:s,cmd:a,forward:i,origin:u,velocity:l,mins:m,maxs:c,viewheight:f,trace:p,pointContents:y,onGround:T,overbounce:h=Cr,stepSize:V=Pr,maxBumps:A,maxClipPlanes:C}=t;if(o>0)return{pmFlags:e,pmTime:o,velocity:l,performedWaterJump:!1};let b=U(e,128),x=o,P=l,S=v({x:i.x,y:i.y,z:0}),O=oe(S)>0;if(n<2&&O){let z=N(u,g(S,Sr)),X=p(u,z,m,c),Jt=X.contents??0;X.fraction<1&&(Jt&536870912)!==0&&(b=W(b,128))}if(s===0)return{pmFlags:b,pmTime:x,velocity:P,performedWaterJump:!1};if(((a.buttons??0)&8)===0&&a.forwardmove<=0)return{pmFlags:b,pmTime:x,velocity:P,performedWaterJump:!1};if(n!==2)return{pmFlags:b,pmTime:x,velocity:P,performedWaterJump:!1};if((r&8192)!==0)return{pmFlags:b,pmTime:x,velocity:P,performedWaterJump:!1};if(!O)return{pmFlags:b,pmTime:x,velocity:P,performedWaterJump:!1};let B=N(u,g(S,hr)),k=p(u,B,m,c);if(k.fraction===1||!k.planeNormal||k.planeNormal.z>=Gt)return{pmFlags:b,pmTime:x,velocity:P,performedWaterJump:!1};let E={x:S.x*ze,y:S.y*ze,z:Bt},L=u,_=!0,I=Nr(s);for(let z=0;z<I;z++){E={x:E.x,y:E.y,z:E.z-s*kt},E.z<0&&(_=!1);let X=te({origin:L,velocity:E,frametime:kt,trace:p,mins:m,maxs:c,overbounce:h,stepSize:V,maxBumps:A,maxClipPlanes:C,hasTime:_});L=X.origin,E=X.velocity}let K=N(L,{x:0,y:0,z:-_r}),w=p(L,K,m,c);return w.fraction===1||!w.planeNormal||w.planeNormal.z<Gt||w.endpos.z<u.z?{pmFlags:b,pmTime:x,velocity:P,performedWaterJump:!1}:T&&Math.abs(u.z-w.endpos.z)<=V?{pmFlags:b,pmTime:x,velocity:P,performedWaterJump:!1}:fe({origin:w.endpos,mins:m,viewheight:f,pointContents:y}).waterlevel>=2?{pmFlags:b,pmTime:x,velocity:P,performedWaterJump:!1}:(b=W(b,8),x=br,P={x:S.x*ze,y:S.y*ze,z:Bt},{pmFlags:b,pmTime:x,velocity:P,performedWaterJump:!0})}function Nr(t){if(t===0)return 0;let e=Math.floor(10*(Vr/t));return e<=0?0:Math.min(Tr,e)}var rt=[0,-1,1];function st(t){let{origin:e,mins:o,maxs:n,trace:r}=t;return!r(e,e,o,n).allsolid}function gr(t){let{origin:e,velocity:o,mins:n,maxs:r,previousOrigin:s,trace:a}=t;if(st({origin:e,mins:n,maxs:r,trace:a}))return{origin:{...e},velocity:{...o},resolution:"unchanged"};let i=et({origin:e,mins:n,maxs:r,trace:(u,l,m,c)=>a(u,c,l,m)});return i.result==="fixed"||i.result==="good-position"?{origin:i.origin,velocity:{...o},resolution:"fixed"}:{origin:{...s},velocity:{...o},resolution:"reverted"}}function Er(t){let{origin:e,mins:o,maxs:n,trace:r}=t;for(let s of rt)for(let a of rt)for(let i of rt){let u={x:e.x+i,y:e.y+a,z:e.z+s};if(st({origin:u,mins:o,maxs:n,trace:r}))return{origin:u,snapped:i!==0||a!==0||s!==0}}return{origin:{...e},snapped:!1}}function Rr(t,e){return{x:t.x+e.x,y:t.y+e.y,z:t.z+e.z}}function Or(t){return t>89&&t<180?89:t<271&&t>=180?271:t}function vr(t){let{pmFlags:e,cmdAngles:o,deltaAngles:n}=t,r;(e&32)!==0?r={x:0,y:o.y+n.y,z:0}:(r=Rr(o,n),r={...r,x:Or(r.x)});let s=we(r);return{viewangles:r,...s}}var zr=200,Fr=200,Mr=200,Lr=140,wr=150,Dr=3;function Ir(t){let e=ue(t);return e>89&&e<180?89:e<271&&e>=180?271:e}function Wr(t,e){return{x:Ir(t.x+e.x),y:ue(t.y+e.y),z:ue(t.z+e.z)}}function Br(t,e){let o=e.sensitivityX??e.sensitivity,n=(e.sensitivityY??e.sensitivity)*(e.invertY?-1:1);return{x:t.deltaY*n,y:t.deltaX*o,z:0}}var Ut=(x=>(x[x.bad=0]="bad",x[x.muzzleflash=1]="muzzleflash",x[x.muzzleflash2=2]="muzzleflash2",x[x.temp_entity=3]="temp_entity",x[x.layout=4]="layout",x[x.inventory=5]="inventory",x[x.nop=6]="nop",x[x.disconnect=7]="disconnect",x[x.reconnect=8]="reconnect",x[x.sound=9]="sound",x[x.print=10]="print",x[x.stufftext=11]="stufftext",x[x.serverdata=12]="serverdata",x[x.configstring=13]="configstring",x[x.spawnbaseline=14]="spawnbaseline",x[x.centerprint=15]="centerprint",x[x.download=16]="download",x[x.playerinfo=17]="playerinfo",x[x.packetentities=18]="packetentities",x[x.deltapacketentities=19]="deltapacketentities",x[x.frame=20]="frame",x))(Ut||{}),Ht=(s=>(s[s.bad=0]="bad",s[s.nop=1]="nop",s[s.move=2]="move",s[s.userinfo=3]="userinfo",s[s.stringcmd=4]="stringcmd",s))(Ht||{});var Kt=(d=>(d[d.GUNSHOT=0]="GUNSHOT",d[d.BLOOD=1]="BLOOD",d[d.BLASTER=2]="BLASTER",d[d.RAILTRAIL=3]="RAILTRAIL",d[d.SHOTGUN=4]="SHOTGUN",d[d.EXPLOSION1=5]="EXPLOSION1",d[d.EXPLOSION2=6]="EXPLOSION2",d[d.ROCKET_EXPLOSION=7]="ROCKET_EXPLOSION",d[d.GRENADE_EXPLOSION=8]="GRENADE_EXPLOSION",d[d.SPARKS=9]="SPARKS",d[d.SPLASH=10]="SPLASH",d[d.BUBBLETRAIL=11]="BUBBLETRAIL",d[d.SCREEN_SPARKS=12]="SCREEN_SPARKS",d[d.SHIELD_SPARKS=13]="SHIELD_SPARKS",d[d.BULLET_SPARKS=14]="BULLET_SPARKS",d[d.LASER_SPARKS=15]="LASER_SPARKS",d[d.PARASITE_ATTACK=16]="PARASITE_ATTACK",d[d.ROCKET_EXPLOSION_WATER=17]="ROCKET_EXPLOSION_WATER",d[d.GRENADE_EXPLOSION_WATER=18]="GRENADE_EXPLOSION_WATER",d[d.MEDIC_CABLE_ATTACK=19]="MEDIC_CABLE_ATTACK",d[d.BFG_EXPLOSION=20]="BFG_EXPLOSION",d[d.BFG_BIGEXPLOSION=21]="BFG_BIGEXPLOSION",d[d.BOSSTPORT=22]="BOSSTPORT",d[d.BFG_LASER=23]="BFG_LASER",d[d.GRAPPLE_CABLE=24]="GRAPPLE_CABLE",d[d.WELDING_SPARKS=25]="WELDING_SPARKS",d[d.GREENBLOOD=26]="GREENBLOOD",d[d.BLUEHYPERBLASTER=27]="BLUEHYPERBLASTER",d[d.PLASMA_EXPLOSION=28]="PLASMA_EXPLOSION",d[d.TUNNEL_SPARKS=29]="TUNNEL_SPARKS",d[d.BLASTER2=30]="BLASTER2",d[d.RAILTRAIL2=31]="RAILTRAIL2",d[d.FLAME=32]="FLAME",d[d.LIGHTNING=33]="LIGHTNING",d[d.DEBUGTRAIL=34]="DEBUGTRAIL",d[d.PLAIN_EXPLOSION=35]="PLAIN_EXPLOSION",d[d.FLASHLIGHT=36]="FLASHLIGHT",d[d.FORCEWALL=37]="FORCEWALL",d[d.HEATBEAM=38]="HEATBEAM",d[d.MONSTER_HEATBEAM=39]="MONSTER_HEATBEAM",d[d.STEAM=40]="STEAM",d[d.BUBBLETRAIL2=41]="BUBBLETRAIL2",d[d.MOREBLOOD=42]="MOREBLOOD",d[d.HEATBEAM_SPARKS=43]="HEATBEAM_SPARKS",d[d.HEATBEAM_STEAM=44]="HEATBEAM_STEAM",d[d.CHAINFIST_SMOKE=45]="CHAINFIST_SMOKE",d[d.ELECTRIC_SPARKS=46]="ELECTRIC_SPARKS",d[d.TRACKER_EXPLOSION=47]="TRACKER_EXPLOSION",d[d.TELEPORT_EFFECT=48]="TELEPORT_EFFECT",d[d.DBALL_GOAL=49]="DBALL_GOAL",d[d.WIDOWBEAMOUT=50]="WIDOWBEAMOUT",d[d.NUKEBLAST=51]="NUKEBLAST",d[d.WIDOWSPLASH=52]="WIDOWSPLASH",d[d.EXPLOSION1_BIG=53]="EXPLOSION1_BIG",d[d.EXPLOSION1_NP=54]="EXPLOSION1_NP",d[d.FLECHETTE=55]="FLECHETTE",d))(Kt||{});var pe=.025,kr=(t,e)=>{let o={...t.origin};o.z-=.25;let n=e(t.origin,o);return{...t,onGround:n.fraction<1}},Gr=(t,e)=>{let o={...t.origin};return o.z+=t.mins.z+1,e(o)&33554432?{...t,waterLevel:1}:{...t,waterLevel:0}},Ur=(t,e,o,n)=>{let r={...t};r=kr(r,o),r=Gr(r,n);let{origin:s,velocity:a,onGround:i,waterLevel:u}=r,l=je({velocity:a,frametime:pe,onGround:i,groundIsSlick:!1,onLadder:!1,waterlevel:u,pmFriction:6,pmStopSpeed:100,pmWaterFriction:1}),m=u>=2?qe({forward:{x:1,y:0,z:0},right:{x:0,y:1,z:0},cmd:e,maxSpeed:320}):Ze({forward:{x:1,y:0,z:0},right:{x:0,y:1,z:0},cmd:e,maxSpeed:320}),c=H({velocity:l,wishdir:m.wishdir,wishspeed:m.wishspeed,accel:i?10:1,frametime:pe}),f=o(s,{x:s.x+c.x*pe,y:s.y+c.y*pe,z:s.z+c.z*pe});return{...r,origin:f.endpos,velocity:c}};var at=class{constructor(e){e instanceof Uint8Array?this.view=new DataView(e.buffer,e.byteOffset,e.byteLength):this.view=new DataView(e),this.offset=0,this.length=this.view.byteLength}getPosition(){return this.offset}seek(e){if(e<0||e>this.length)throw new Error(`Seek out of bounds: ${e} (length: ${this.length})`);this.offset=e}hasMore(){return this.offset<this.length}readChar(){let e=this.view.getInt8(this.offset);return this.offset+=1,e}readByte(){let e=this.view.getUint8(this.offset);return this.offset+=1,e}readShort(){let e=this.view.getInt16(this.offset,!0);return this.offset+=2,e}readLong(){let e=this.view.getInt32(this.offset,!0);return this.offset+=4,e}readFloat(){let e=this.view.getFloat32(this.offset,!0);return this.offset+=4,e}readString(){let e="";for(;this.offset<this.length;){let o=this.readChar();if(o===-1||o===0)break;e+=String.fromCharCode(o)}return e}readStringLine(){let e="";for(;this.offset<this.length;){let o=this.readChar();if(o===-1||o===0||o===10)break;e+=String.fromCharCode(o)}return e}readCoord(){return this.readShort()*(1/8)}readAngle(){return this.readChar()*(360/256)}readAngle16(){return this.readShort()*360/65536}readData(e){if(this.offset+e>this.length)throw new Error(`Read out of bounds: ${this.offset+e} (length: ${this.length})`);let o=new Uint8Array(this.view.buffer,this.view.byteOffset+this.offset,e);return this.offset+=e,new Uint8Array(o)}readPos(e){e.x=this.readCoord(),e.y=this.readCoord(),e.z=this.readCoord()}readDir(e){if(this.readByte()>=162){e.x=0,e.y=0,e.z=0;return}e.x=0,e.y=0,e.z=0}};return qt(Hr);})();
1
+ "use strict";var Quake2Shared=(()=>{var Me=Object.defineProperty;var jt=Object.getOwnPropertyDescriptor;var Yt=Object.getOwnPropertyNames;var Zt=Object.prototype.hasOwnProperty;var ct=(t,e)=>{for(var o in e)Me(t,o,{get:e[o],enumerable:!0})},qt=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Yt(e))!Zt.call(t,r)&&r!==o&&Me(t,r,{get:()=>e[r],enumerable:!(n=jt(e,r))||n.enumerable});return t};var $t=t=>qt(Me({},"__esModule",{value:!0}),t);var Xr={};ct(Xr,{BinaryStream:()=>it,CGAME_EXPORT_KEYS:()=>_n,CGAME_IMPORT_KEYS:()=>Cn,CONTENTS_AREAPORTAL:()=>cs,CONTENTS_AUX:()=>os,CONTENTS_CURRENT_0:()=>Eo,CONTENTS_CURRENT_180:()=>vo,CONTENTS_CURRENT_270:()=>Oo,CONTENTS_CURRENT_90:()=>Ro,CONTENTS_CURRENT_DOWN:()=>Fo,CONTENTS_CURRENT_UP:()=>zo,CONTENTS_DEADMONSTER:()=>fs,CONTENTS_DETAIL:()=>ps,CONTENTS_LADDER:()=>pt,CONTENTS_LAVA:()=>ns,CONTENTS_MIST:()=>as,CONTENTS_MONSTER:()=>ms,CONTENTS_MONSTERCLIP:()=>us,CONTENTS_NONE:()=>Pe,CONTENTS_NO_WATERJUMP:()=>go,CONTENTS_ORIGIN:()=>ds,CONTENTS_PLAYER:()=>xs,CONTENTS_PLAYERCLIP:()=>ls,CONTENTS_PROJECTILE:()=>Ss,CONTENTS_PROJECTILECLIP:()=>is,CONTENTS_SLIME:()=>rs,CONTENTS_SOLID:()=>es,CONTENTS_TRANSLUCENT:()=>ys,CONTENTS_TRIGGER:()=>No,CONTENTS_WATER:()=>ss,CONTENTS_WINDOW:()=>ts,CS_MAX_STRING_LENGTH:()=>ea,CS_MAX_STRING_LENGTH_OLD:()=>ta,ClientCommand:()=>Kt,CollisionEntityIndex:()=>ke,ConfigStringIndex:()=>se,CvarFlags:()=>Pt,DEFAULT_FORWARD_SPEED:()=>Lr,DEFAULT_MOUSE_SENSITIVITY:()=>Br,DEFAULT_PITCH_SPEED:()=>Wr,DEFAULT_SIDE_SPEED:()=>wr,DEFAULT_UP_SPEED:()=>Dr,DEFAULT_YAW_SPEED:()=>Ir,DEG2RAD:()=>xo,DIST_EPSILON:()=>X,GAME_EXPORT_KEYS:()=>Pn,GAME_IMPORT_KEYS:()=>Tn,LAST_VISIBLE_CONTENTS:()=>hs,MASK_ALL:()=>Fs,MASK_BLOCK_SIGHT:()=>Ws,MASK_CURRENT:()=>Mo,MASK_DEADSOLID:()=>Ls,MASK_LADDER_NAV_SOLID:()=>ks,MASK_MONSTERSOLID:()=>ws,MASK_NAV_SOLID:()=>Bs,MASK_OPAQUE:()=>Ds,MASK_PLAYERSOLID:()=>Ms,MASK_PROJECTILE:()=>Us,MASK_SHOT:()=>Is,MASK_SOLID:()=>Ie,MASK_WALK_NAV_SOLID:()=>Gs,MASK_WATER:()=>Ce,MAX_CLIENTS:()=>rn,MAX_CONFIGSTRINGS:()=>fn,MAX_EDICTS:()=>Qs,MAX_GENERAL:()=>dn,MAX_IMAGES:()=>ln,MAX_ITEMS:()=>un,MAX_LIGHTSTYLES:()=>sn,MAX_MODELS:()=>an,MAX_OSPATH:()=>$s,MAX_QPATH:()=>qs,MAX_SHADOW_LIGHTS:()=>mn,MAX_SOUNDS:()=>cn,MAX_STRING_CHARS:()=>js,MAX_STRING_TOKENS:()=>Ys,MAX_TOKEN_CHARS:()=>Zs,MAX_WHEEL_ITEMS:()=>Je,MersenneTwister19937:()=>Ve,PITCH:()=>he,PlaneSide:()=>yt,PlayerButton:()=>te,PmFlag:()=>ee,PmType:()=>ie,RAD2DEG:()=>So,ROLL:()=>we,RandomGenerator:()=>Te,Replay:()=>Xe,SLIDEMOVE_BLOCKED_FLOOR:()=>At,SLIDEMOVE_BLOCKED_WALL:()=>Nt,STOP_EPSILON:()=>Y,SURF_ALPHATEST:()=>Es,SURF_FLOWING:()=>Ns,SURF_LIGHT:()=>Vs,SURF_N64_SCROLL_FLIP:()=>zs,SURF_N64_SCROLL_X:()=>vs,SURF_N64_SCROLL_Y:()=>Os,SURF_N64_UV:()=>Rs,SURF_NODRAW:()=>gs,SURF_NONE:()=>bs,SURF_SKY:()=>Ps,SURF_SLICK:()=>Ts,SURF_TRANS33:()=>_s,SURF_TRANS66:()=>As,SURF_WARP:()=>Cs,ServerCommand:()=>Ht,TempEntity:()=>Jt,WaterLevel:()=>ae,YAW:()=>be,ZERO_VEC3:()=>R,addBlendColor:()=>To,addContents:()=>Do,addPmFlag:()=>W,addPointToBounds:()=>io,addVec3:()=>N,addViewAngles:()=>Gr,angleMod:()=>de,angleVectors:()=>De,applyPmove:()=>Jr,applyPmoveAccelerate:()=>H,applyPmoveAddCurrents:()=>Re,applyPmoveAirAccelerate:()=>Ze,applyPmoveAirMove:()=>pr,applyPmoveFlyMove:()=>Gn,applyPmoveFriction:()=>Ye,applyPmoveWaterMove:()=>yr,assertContract:()=>Vn,boxContents:()=>qo,boxOnPlaneSide:()=>Jo,boxesIntersect:()=>co,buildAirGroundWish:()=>qe,buildCollisionModel:()=>Ho,buildWaterWish:()=>$e,categorizePosition:()=>mr,checkDuckState:()=>$n,checkJump:()=>Xn,checkSpecialMovement:()=>Er,clampViewAngles:()=>Mr,clipBoxToBrush:()=>Ue,clipVelocityAgainstPlanes:()=>lo,clipVelocityVec3:()=>$,closestPointToBox:()=>ro,combineSurfaceFlags:()=>Bo,computePlaneSignBits:()=>Ge,computePlayerDimensions:()=>Oe,concatRotationMatrices:()=>Le,configStringSize:()=>pn,createDefaultTrace:()=>Ae,createEmptyBounds3:()=>ao,createMat4Identity:()=>ft,createRandomGenerator:()=>Po,crossVec3:()=>q,currentVectorFromContents:()=>nt,degToRad:()=>xe,disableTraceDebug:()=>Go,distance:()=>oo,distanceBetweenBoxesSquared:()=>so,dotVec3:()=>F,enableTraceDebug:()=>ko,fixStuckObjectGeneric:()=>tt,getWaterLevel:()=>pe,goodPosition:()=>at,groundCurrentVelocity:()=>wt,hasAllContents:()=>Lo,hasAnyContents:()=>wo,hasPmFlag:()=>M,hasSurfaceFlags:()=>Wo,inPHS:()=>Qo,inPVS:()=>$o,initialSnapPosition:()=>Or,isAtLeastWaistDeep:()=>je,isUnderwater:()=>An,lengthSquaredVec3:()=>ne,lengthVec3:()=>D,lerpAngle:()=>ho,mat4FromBasis:()=>Ao,mouseDeltaToViewDelta:()=>Ur,multiplyMat4:()=>Co,multiplyVec3:()=>eo,negateVec3:()=>to,normalizeVec3:()=>O,perpendicularVec3:()=>ut,planeDistanceToPoint:()=>Q,pmoveCmdScale:()=>Nn,pointContents:()=>Yo,pointContentsMany:()=>Zo,pointInsideBrush:()=>xt,pointOnPlaneSide:()=>Ko,projectPointOnPlane:()=>lt,projectSourceVec3:()=>mo,projectSourceVec3WithUp:()=>fo,radToDeg:()=>Se,removeContents:()=>Io,removePmFlag:()=>U,resolveSlideMove:()=>gt,rotatePointAroundVector:()=>yo,scaleVec3:()=>g,slerpVec3:()=>po,slideClipVelocityVec3:()=>uo,slideMove:()=>Qe,snapPosition:()=>vr,stepSlideMove:()=>oe,subtractVec3:()=>Z,testBoxInBrush:()=>St,traceBox:()=>Tt,traceDebugInfo:()=>K,transformPointMat4:()=>_o,validateContract:()=>Ct,vec3Equals:()=>no,vectorToAngles:()=>Vo,vectorToYaw:()=>bo,waterCurrentVelocity:()=>Lt});var R={x:0,y:0,z:0},Y=.1,Qt=Math.PI/180;function N(t,e){return{x:t.x+e.x,y:t.y+e.y,z:t.z+e.z}}function Z(t,e){return{x:t.x-e.x,y:t.y-e.y,z:t.z-e.z}}function eo(t,e){return{x:t.x*e.x,y:t.y*e.y,z:t.z*e.z}}function g(t,e){return{x:t.x*e,y:t.y*e,z:t.z*e}}function to(t){return g(t,-1)}function F(t,e){return t.x*e.x+t.y*e.y+t.z*e.z}function q(t,e){return{x:t.y*e.z-t.z*e.y,y:t.z*e.x-t.x*e.z,z:t.x*e.y-t.y*e.x}}function ne(t){return F(t,t)}function D(t){return Math.sqrt(ne(t))}function oo(t,e){return D(Z(t,e))}function no(t,e){return t.x===e.x&&t.y===e.y&&t.z===e.z}function O(t){let e=D(t);return e===0?t:g(t,1/e)}function lt(t,e){let o=1/F(e,e),n=F(e,t)*o;return Z(t,g(e,o*n))}function ut(t){let e=0,o=Math.abs(t.x);return Math.abs(t.y)<o&&(e=1,o=Math.abs(t.y)),Math.abs(t.z)<o&&(e=2),O(lt(e===0?{x:1,y:0,z:0}:e===1?{x:0,y:1,z:0}:{x:0,y:0,z:1},t))}function ro(t,e,o){return{x:t.x<e.x?e.x:t.x>o.x?o.x:t.x,y:t.y<e.y?e.y:t.y>o.y?o.y:t.y,z:t.z<e.z?e.z:t.z>o.z?o.z:t.z}}function so(t,e,o,n){let r=0;if(e.x<o.x){let s=e.x-o.x;r+=s*s}else if(t.x>n.x){let s=t.x-n.x;r+=s*s}if(e.y<o.y){let s=e.y-o.y;r+=s*s}else if(t.y>n.y){let s=t.y-n.y;r+=s*s}if(e.z<o.z){let s=e.z-o.z;r+=s*s}else if(t.z>n.z){let s=t.z-n.z;r+=s*s}return r}function ao(){return{mins:{x:Number.POSITIVE_INFINITY,y:Number.POSITIVE_INFINITY,z:Number.POSITIVE_INFINITY},maxs:{x:Number.NEGATIVE_INFINITY,y:Number.NEGATIVE_INFINITY,z:Number.NEGATIVE_INFINITY}}}function io(t,e){return{mins:{x:Math.min(e.mins.x,t.x),y:Math.min(e.mins.y,t.y),z:Math.min(e.mins.z,t.z)},maxs:{x:Math.max(e.maxs.x,t.x),y:Math.max(e.maxs.y,t.y),z:Math.max(e.maxs.z,t.z)}}}function co(t,e){return t.mins.x<=e.maxs.x&&t.maxs.x>=e.mins.x&&t.mins.y<=e.maxs.y&&t.maxs.y>=e.mins.y&&t.mins.z<=e.maxs.z&&t.maxs.z>=e.mins.z}function $(t,e,o){let n=F(t,e)*o,r=t.x-e.x*n,s=t.y-e.y*n,a=t.z-e.z*n;return r>-Y&&r<Y&&(r=0),s>-Y&&s<Y&&(s=0),a>-Y&&a<Y&&(a=0),{x:r,y:s,z:a}}function lo(t,e,o,n){if(e.length===0)return t;let r=t;for(let s=0;s<e.length;s++){r=$(r,e[s],o);let a=0;for(;a<e.length&&!(a!==s&&F(r,e[a])<0);a++);if(a===e.length)return n&&F(r,n)<=0?R:r}if(e.length===2){let s=q(e[0],e[1]),a=F(s,t),i=g(s,a);return n&&F(i,n)<=0?R:i}return n&&F(r,n)<=0,R}function uo(t,e,o){return $(t,e,o)}function mo(t,e,o,n){return{x:t.x+o.x*e.x+n.x*e.y,y:t.y+o.y*e.x+n.y*e.y,z:t.z+o.z*e.x+n.z*e.y+e.z}}function fo(t,e,o,n,r){return{x:t.x+o.x*e.x+n.x*e.y+r.x*e.z,y:t.y+o.y*e.x+n.y*e.y+r.y*e.z,z:t.z+o.z*e.x+n.z*e.y+r.z*e.z}}function po(t,e,o){let n=F(t,e),r,s;if(Math.abs(n)>.9995)r=1-o,s=o;else{let a=Math.acos(n),i=Math.sin(a),u=Math.sin((1-o)*a),l=Math.sin(o*a);r=u/i,s=l/i}return{x:t.x*r+e.x*s,y:t.y*r+e.y*s,z:t.z*r+e.z*s}}function Le(t,e){let o=r=>[t[r][0]*e[0][0]+t[r][1]*e[1][0]+t[r][2]*e[2][0],t[r][0]*e[0][1]+t[r][1]*e[1][1]+t[r][2]*e[2][1],t[r][0]*e[0][2]+t[r][1]*e[1][2]+t[r][2]*e[2][2]];return[o(0),o(1),o(2)]}function yo(t,e,o){if(D(t)===0)return e;let r=O(t),s=ut(r),a=q(s,r),i=[[s.x,a.x,r.x],[s.y,a.y,r.y],[s.z,a.z,r.z]],u=[[i[0][0],i[1][0],i[2][0]],[i[0][1],i[1][1],i[2][1]],[i[0][2],i[1][2],i[2][2]]],l=o*Qt,m=Math.cos(l),c=Math.sin(l),f=[[m,c,0],[-c,m,0],[0,0,1]],p=Le(Le(i,f),u);return{x:p[0][0]*e.x+p[0][1]*e.y+p[0][2]*e.z,y:p[1][0]*e.x+p[1][1]*e.y+p[1][2]*e.z,z:p[2][0]*e.x+p[2][1]*e.y+p[2][2]*e.z}}var he=0,be=1,we=2,dt=Math.PI/180,mt=180/Math.PI,xo=dt,So=mt;function ue(t,e){switch(e){case he:return t.x;case be:return t.y;case we:default:return t.z}}function xe(t){return t*dt}function Se(t){return t*mt}function ho(t,e,o){let n=e;return n-t>180?n-=360:n-t<-180&&(n+=360),t+o*(n-t)}function de(t){let e=t%360;return e<0?360+e:e}function De(t){let e=xe(ue(t,be)),o=xe(ue(t,he)),n=xe(ue(t,we)),r=Math.sin(e),s=Math.cos(e),a=Math.sin(o),i=Math.cos(o),u=Math.sin(n),l=Math.cos(n),m={x:i*s,y:i*r,z:-a},c={x:-u*a*s-l*-r,y:-u*a*r-l*s,z:-u*i},f={x:l*a*s-u*-r,y:l*a*r-u*s,z:l*i};return{forward:m,right:c,up:f}}function bo(t){let e=ue(t,he),o=ue(t,be);if(e===0)return o===0?0:o>0?90:270;let n=Se(Math.atan2(o,e));return n<0?n+360:n}function Vo(t){let e=t.x,o=t.y,n=t.z;if(o===0&&e===0)return{x:n>0?-90:-270,y:0,z:0};let r;e?r=Se(Math.atan2(o,e)):o>0?r=90:r=270,r<0&&(r+=360);let s=Math.sqrt(e*e+o*o),a=Se(Math.atan2(n,s));return a<0&&(a+=360),{x:-a,y:r,z:0}}function To(t,e,o,n,r){if(n<=0)return r;let s=r[0],a=r[1],i=r[2],u=r[3],l=u+(1-u)*n;if(l<=0)return[0,0,0,0];let m=u/l,c=s*m+t*(1-m),f=a*m+e*(1-m),p=i*m+o*(1-m);return[c,f,p,l]}var Ve=class{constructor(e=5489){this.state=new Uint32Array(624);this.index=624;this.seed(e)}seed(e){this.state[0]=e>>>0;for(let o=1;o<624;o++){let n=this.state[o-1]^this.state[o-1]>>>30,r=Math.imul(n>>>0,1812433253)+o;this.state[o]=r>>>0}this.index=624}nextUint32(){this.index>=624&&this.twist();let e=this.state[this.index++];return e^=e>>>11,e^=e<<7&2636928640,e^=e<<15&4022730752,e^=e>>>18,e>>>0}twist(){for(let e=0;e<624;e++){let o=this.state[e]&2147483648|this.state[(e+1)%624]&2147483647,n=this.state[(e+397)%624]^o>>>1;(o&1)!==0&&(n^=2567483615),this.state[e]=n>>>0}this.index=0}getState(){return{index:this.index,state:Array.from(this.state)}}setState(e){if(e.state.length!==624)throw new Error(`Expected 624 MT state values, received ${e.state.length}`);this.index=e.index,this.state=Uint32Array.from(e.state,o=>o>>>0)}},Te=class{constructor(e={}){this.mt=new Ve(e.seed)}frandom(){return this.mt.nextUint32()/4294967296}frandomRange(e,o){return e+(o-e)*this.frandom()}frandomMax(e){return this.frandomRange(0,e)}crandom(){return this.frandomRange(-1,1)}crandomOpen(){let e=Number.EPSILON;return this.frandomRange(-1+e,1)}irandomUint32(){return this.mt.nextUint32()}irandomRange(e,o){if(o-e<=1)return e;let n=o-e,r=4294967296-4294967296%n,s;do s=this.mt.nextUint32();while(s>=r);return e+s%n}irandom(e){return e<=0?0:this.irandomRange(0,e)}randomTimeRange(e,o){return o<=e?e:this.irandomRange(e,o)}randomTime(e){return this.irandom(e)}randomIndex(e){return this.irandom(e.length)}getState(){return{mt:this.mt.getState()}}setState(e){this.mt.setState(e.mt)}};function Po(t){return new Te(t)}function ft(){return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function Co(t,e){let o=new Float32Array(16);for(let n=0;n<4;n+=1)for(let r=0;r<4;r+=1)o[r*4+n]=t[0+n]*e[r*4+0]+t[4+n]*e[r*4+1]+t[8+n]*e[r*4+2]+t[12+n]*e[r*4+3];return o}function _o(t,e){let o=e.x,n=e.y,r=e.z;return{x:t[0]*o+t[4]*n+t[8]*r+t[12],y:t[1]*o+t[5]*n+t[9]*r+t[13],z:t[2]*o+t[6]*n+t[10]*r+t[14]}}function Ao(t,e){let o=ft();return o[0]=e[0].x,o[1]=e[0].y,o[2]=e[0].z,o[4]=e[1].x,o[5]=e[1].y,o[6]=e[1].z,o[8]=e[2].x,o[9]=e[2].y,o[10]=e[2].z,o[12]=t.x,o[13]=t.y,o[14]=t.z,o}var Pe=0,es=1,ts=2,os=4,ns=8,rs=16,ss=32,as=64,No=1073741824,go=8192,is=16384,cs=32768,ls=65536,us=131072,Eo=262144,Ro=524288,vo=1048576,Oo=2097152,zo=4194304,Fo=8388608,ds=16777216,ms=33554432,fs=67108864,ps=134217728,ys=268435456,pt=536870912,xs=1073741824,Ss=-2147483648,hs=64,bs=0,Vs=1,Ts=2,Ps=4,Cs=8,_s=16,As=32,Ns=64,gs=128,Es=33554432,Rs=268435456,vs=536870912,Os=1073741824,zs=-2147483648,Fs=4294967295,Ie=3,Ms=1107361795,Ls=65539,ws=1107427331,Ce=56,Ds=25,Is=1174405123,Mo=16515072,Ws=1107296281,Bs=65539,ks=3,Gs=196611,Us=1174421507;function Lo(t,e){return(t&e)===e}function wo(t,e){return(t&e)!==0}function Do(t,e){return t|e}function Io(t,e){return t&~e}function Wo(t,e){return(t&e)===e}function Bo(...t){let e=0;for(let o of t)e|=o;return e}var yt=(n=>(n[n.FRONT=1]="FRONT",n[n.BACK=2]="BACK",n[n.CROSS=3]="CROSS",n))(yt||{}),K=null;function ko(){K={nodesTraversed:0,leafsReached:0,brushesTested:0}}function Go(){K=null}var X=.03125,Uo=Number.MAX_SAFE_INTEGER-1,_e=1;function Ho(t){let e=t.planes.map(a=>({...a,signbits:Ge(a.normal)})),o=t.nodes.map(a=>({plane:e[a.planenum],children:a.children})),n=t.brushes.map(a=>{let i=t.brushSides.slice(a.firstSide,a.firstSide+a.numSides).map(u=>({plane:e[u.planenum],surfaceFlags:u.surfaceFlags}));return{contents:a.contents,sides:i,checkcount:0}}),r=t.leaves.map(a=>({contents:a.contents,cluster:a.cluster,area:a.area,firstLeafBrush:a.firstLeafBrush,numLeafBrushes:a.numLeafBrushes})),s=t.bmodels.map(a=>({mins:a.mins,maxs:a.maxs,origin:a.origin,headnode:a.headnode}));return{planes:e,nodes:o,leaves:r,brushes:n,leafBrushes:t.leafBrushes,bmodels:s,visibility:t.visibility}}function Ge(t){let e=0;return t.x<0&&(e|=1),t.y<0&&(e|=2),t.z<0&&(e|=4),e}function Q(t,e){return t.normal.x*e.x+t.normal.y*e.y+t.normal.z*e.z-t.dist}function Ko(t,e,o=0){let n=Q(t,e);return n>o?1:n<-o?2:3}function Jo(t,e,o,n=0){let r,s;switch(o.signbits){case 0:r=o.normal.x*e.x+o.normal.y*e.y+o.normal.z*e.z,s=o.normal.x*t.x+o.normal.y*t.y+o.normal.z*t.z;break;case 1:r=o.normal.x*t.x+o.normal.y*e.y+o.normal.z*e.z,s=o.normal.x*e.x+o.normal.y*t.y+o.normal.z*t.z;break;case 2:r=o.normal.x*e.x+o.normal.y*t.y+o.normal.z*e.z,s=o.normal.x*t.x+o.normal.y*e.y+o.normal.z*t.z;break;case 3:r=o.normal.x*t.x+o.normal.y*t.y+o.normal.z*e.z,s=o.normal.x*e.x+o.normal.y*e.y+o.normal.z*t.z;break;case 4:r=o.normal.x*e.x+o.normal.y*e.y+o.normal.z*t.z,s=o.normal.x*t.x+o.normal.y*t.y+o.normal.z*e.z;break;case 5:r=o.normal.x*t.x+o.normal.y*e.y+o.normal.z*t.z,s=o.normal.x*e.x+o.normal.y*t.y+o.normal.z*e.z;break;case 6:r=o.normal.x*e.x+o.normal.y*t.y+o.normal.z*t.z,s=o.normal.x*t.x+o.normal.y*e.y+o.normal.z*e.z;break;default:r=o.normal.x*t.x+o.normal.y*t.y+o.normal.z*t.z,s=o.normal.x*e.x+o.normal.y*e.y+o.normal.z*e.z;break}let a=0;return r-o.dist>=-n&&(a=1),s-o.dist<=n&&(a|=2),a}function xt(t,e,o=X){for(let n of e.sides)if(Q(n.plane,t)>o)return!1;return!0}function St(t,e,o,n){for(let r of n.sides){let s=r.plane.normal.x*(r.plane.normal.x<0?o.x:e.x)+r.plane.normal.y*(r.plane.normal.y<0?o.y:e.y)+r.plane.normal.z*(r.plane.normal.z<0?o.z:e.z),a=r.plane.dist-s;if(t.x*r.plane.normal.x+t.y*r.plane.normal.y+t.z*r.plane.normal.z-a>0)return{startsolid:!1,allsolid:!1,contents:0}}return{startsolid:!0,allsolid:!0,contents:n.contents}}function Ue({start:t,end:e,mins:o,maxs:n,brush:r,trace:s}){if(r.sides.length===0)return;let a=o.x===0&&o.y===0&&o.z===0&&n.x===0&&n.y===0&&n.z===0,i=-1,u=1,l=null,m=null,c=!1,f=!1;for(let p of r.sides){let{plane:y}=p,T=y.dist;if(!a){let A=y.normal.x<0?n.x:o.x,C=y.normal.y<0?n.y:o.y,b=y.normal.z<0?n.z:o.z;T-=y.normal.x*A+y.normal.y*C+y.normal.z*b}let h=t.x*y.normal.x+t.y*y.normal.y+t.z*y.normal.z-T,V=e.x*y.normal.x+e.y*y.normal.y+e.z*y.normal.z-T;if(V>0&&(c=!0),h>0&&(f=!0),h>0&&V>=h)return;if(!(h<=0&&V<=0))if(h>V){let A=(h-X)/(h-V);A>i&&(i=A,l=y,m=p)}else{let A=(h+X)/(h-V);A<u&&(u=A)}}if(!f){s.startsolid=!0,c||(s.allsolid=!0),s.fraction=0;return}i<u&&i>-1&&i<s.fraction&&(s.fraction=i<0?0:i,s.plane=l,s.contents=r.contents,s.surfaceFlags=m?.surfaceFlags??0)}function Ae(){return{fraction:1,plane:null,contents:0,surfaceFlags:0,startsolid:!1,allsolid:!1}}function He(t,e,o){let n=o;for(;n>=0;){let r=e.nodes[n];n=Q(r.plane,t)>=0?r.children[0]:r.children[1]}return-1-n}function ht(t,e,o){let n=t.leaves[e],r=n.contents,s=Ke(),a=n.firstLeafBrush,i=a+n.numLeafBrushes;for(let u=a;u<i;u+=1){let l=t.leafBrushes[u],m=t.brushes[l];m.checkcount!==s&&(m.checkcount=s,m.sides.length!==0&&xt(o,m)&&(r|=m.contents))}return r}function Ke(){let t=_e;return _e+=1,_e>=Uo&&(_e=1),t}function Xo(t,e){return t.x===0&&t.y===0&&t.z===0&&e.x===0&&e.y===0&&e.z===0}function jo(t,e,o){return Xo(e,o)?0:t.normal.x*(t.normal.x<0?o.x:e.x)+t.normal.y*(t.normal.y<0?o.y:e.y)+t.normal.z*(t.normal.z<0?o.z:e.z)}function bt(t,e,o){return Math.abs(jo(t,e,o))}function We(t,e,o){return N(t,g(Z(e,t),o))}function Be(t,e,o){let n=t.allsolid?0:t.fraction,r=We(e,o,n);return{fraction:n,endpos:r,plane:t.plane,planeNormal:t.startsolid?void 0:t.plane?.normal,contents:t.contents,surfaceFlags:t.surfaceFlags,startsolid:t.startsolid,allsolid:t.allsolid}}function Ne(t,e,o){let n=He(t,e,o);return e.leaves[n]?.cluster??-1}function Vt(t,e,o,n){if(!t||t.numClusters===0)return!0;if(e<0||o<0||e>=t.clusters.length||o>=t.numClusters)return!1;let r=t.clusters[e],a=(n?r.phs:r.pvs)[o>>3];return a===void 0?!1:(a&1<<(o&7))!==0}function me(t){let{model:e,nodeIndex:o,startFraction:n,endFraction:r,start:s,end:a,traceStart:i,traceEnd:u,mins:l,maxs:m,contentMask:c,trace:f,brushCheckCount:p}=t;if(f.fraction<=n)return;if(o<0){let L=-1-o,_=e.leaves[L],I=_.firstLeafBrush,J=I+_.numLeafBrushes;for(let w=I;w<J;w+=1){let G=e.leafBrushes[w],z=e.brushes[G];if((z.contents&c)!==0&&z.sides.length&&z.checkcount!==p&&(z.checkcount=p,K&&K.brushesTested++,Ue({start:i,end:u,mins:l,maxs:m,brush:z,trace:f}),f.allsolid))return}return}K&&K.nodesTraversed++;let y=e.nodes[o],T=y.plane,h=bt(T,l,m),V=Q(T,s),A=Q(T,a);if(V>=h&&A>=h){me({model:e,nodeIndex:y.children[0],startFraction:n,endFraction:r,start:s,end:a,traceStart:i,traceEnd:u,mins:l,maxs:m,contentMask:c,trace:f,brushCheckCount:p});return}if(V<-h&&A<-h){me({model:e,nodeIndex:y.children[1],startFraction:n,endFraction:r,start:s,end:a,traceStart:i,traceEnd:u,mins:l,maxs:m,contentMask:c,trace:f,brushCheckCount:p});return}let C=0,b=1/(V-A),x,P;V<A?(C=1,P=(V+h+X)*b,x=(V-h+X)*b):(C=0,P=(V-h-X)*b,x=(V+h+X)*b),x<0?x=0:x>1&&(x=1),P<0?P=0:P>1&&(P=1);let S=n+(r-n)*x,v=We(s,a,x);if(me({model:e,nodeIndex:y.children[C],startFraction:n,endFraction:S,start:s,end:v,traceStart:i,traceEnd:u,mins:l,maxs:m,contentMask:c,trace:f,brushCheckCount:p}),f.fraction<=S)return;let k=n+(r-n)*P,E=We(s,a,P);me({model:e,nodeIndex:y.children[1-C],startFraction:k,endFraction:r,start:E,end:a,traceStart:i,traceEnd:u,mins:l,maxs:m,contentMask:c,trace:f,brushCheckCount:p})}function Tt(t){let{model:e,start:o,end:n}=t,r=t.mins??R,s=t.maxs??R,a=t.contentMask??4294967295,i=t.headnode??0,u=Ae(),l=Ke();return me({model:e,nodeIndex:i,startFraction:0,endFraction:1,start:o,end:n,traceStart:o,traceEnd:n,mins:r,maxs:s,contentMask:a,trace:u,brushCheckCount:l}),Be(u,o,n)}function Yo(t,e,o=0){let n=He(t,e,o);return ht(e,n,t)}function Zo(t,e,o=0){let n=new Map;return t.map(r=>{let s=He(r,e,o),a=e.leaves[s];if(a.numLeafBrushes===0){let i=n.get(s);return i!==void 0?i:(n.set(s,a.contents),a.contents)}return ht(e,s,r)})}function qo(t,e,o,n,r=0){let s=Ke(),a=0;function i(u){if(u<0){K&&K.leafsReached++;let p=-1-u,y=n.leaves[p];a|=y.contents;let T=y.firstLeafBrush,h=T+y.numLeafBrushes;for(let V=T;V<h;V+=1){let A=n.leafBrushes[V],C=n.brushes[A];if(C.checkcount===s||(C.checkcount=s,C.sides.length===0))continue;let b=St(t,e,o,C);b.startsolid&&(a|=b.contents)}return}let l=n.nodes[u],m=l.plane,c=bt(m,e,o),f=Q(m,t);if(c===0){i(f>=0?l.children[0]:l.children[1]);return}if(f>c){i(l.children[0]);return}if(f<-c){i(l.children[1]);return}i(l.children[0]),i(l.children[1])}return i(r),a}function $o(t,e,o,n=0){let{visibility:r}=o;if(!r)return!0;let s=Ne(t,o,n),a=Ne(e,o,n);return Vt(r,s,a,!1)}function Qo(t,e,o,n=0){let{visibility:r}=o;if(!r)return!0;let s=Ne(t,o,n),a=Ne(e,o,n);return Vt(r,s,a,!0)}function re(t,e,o){return{normal:t,dist:e,type:o,signbits:Ge(t)}}function en(t){let e=t.surfaceFlags??0,o=t.origin.x+t.maxs.x,n=t.origin.x+t.mins.x,r=t.origin.y+t.maxs.y,s=t.origin.y+t.mins.y,a=t.origin.z+t.maxs.z,i=t.origin.z+t.mins.z,l=[re({x:1,y:0,z:0},o,0),re({x:-1,y:0,z:0},-n,0),re({x:0,y:1,z:0},r,1),re({x:0,y:-1,z:0},-s,1),re({x:0,y:0,z:1},a,2),re({x:0,y:0,z:-1},-i,2)].map(m=>({plane:m,surfaceFlags:e}));return{contents:t.contents,sides:l,checkcount:0}}function tn(t){let e=en(t);return{...t,brush:e,bounds:{mins:{x:t.origin.x+t.mins.x,y:t.origin.y+t.mins.y,z:t.origin.z+t.mins.z},maxs:{x:t.origin.x+t.maxs.x,y:t.origin.y+t.maxs.y,z:t.origin.z+t.maxs.z}}}}function on(t,e){return!(t.mins.x>e.maxs.x||t.maxs.x<e.mins.x||t.mins.y>e.maxs.y||t.maxs.y<e.mins.y||t.mins.z>e.maxs.z||t.maxs.z<e.mins.z)}function nn(t,e){return e.allsolid&&!t.allsolid||e.startsolid&&!t.startsolid?!0:e.fraction<t.fraction}var ke=class{constructor(){this.entities=new Map}link(e){this.entities.set(e.id,tn(e))}unlink(e){this.entities.delete(e)}trace(e){let{passId:o}=e,n=e.mins??R,r=e.maxs??R,s=e.contentMask??4294967295,a,i=null;e.model?a=Tt(e):a=Be(Ae(),e.start,e.end);for(let u of this.entities.values()){if(u.id===o||(u.contents&s)===0)continue;let l=Ae();Ue({start:e.start,end:e.end,mins:n,maxs:r,brush:u.brush,trace:l}),l.contents===0&&(l.contents=u.contents);let m=Be(l,e.start,e.end);nn(a,m)&&(a=m,i=u.id)}return{...a,entityId:i}}gatherTriggerTouches(e,o,n,r=1073741824){let s=[],a={mins:N(e,o),maxs:N(e,n)};for(let i of this.entities.values())(i.contents&r)!==0&&on(a,i.bounds)&&s.push(i.id);return s}};var Pt=(a=>(a[a.None=0]="None",a[a.Archive=1]="Archive",a[a.UserInfo=2]="UserInfo",a[a.ServerInfo=4]="ServerInfo",a[a.Latch=8]="Latch",a[a.Cheat=16]="Cheat",a))(Pt||{});var js=1024,Ys=80,Zs=512,qs=64,$s=128,rn=256,Qs=8192,sn=256,an=8192,cn=2048,ln=512,un=256,dn=512,mn=256,Je=32,ea=96,ta=64,se=(S=>(S[S.Name=0]="Name",S[S.CdTrack=1]="CdTrack",S[S.Sky=2]="Sky",S[S.SkyAxis=3]="SkyAxis",S[S.SkyRotate=4]="SkyRotate",S[S.StatusBar=5]="StatusBar",S[S.AirAccel=59]="AirAccel",S[S.MaxClients=60]="MaxClients",S[S.MapChecksum=61]="MapChecksum",S[S.Models=62]="Models",S[S.Sounds=62+an]="Sounds",S[S.Images=S.Sounds+cn]="Images",S[S.Lights=S.Images+ln]="Lights",S[S.ShadowLights=S.Lights+sn]="ShadowLights",S[S.Items=S.ShadowLights+mn]="Items",S[S.PlayerSkins=S.Items+un]="PlayerSkins",S[S.General=S.PlayerSkins+rn]="General",S[S.WheelWeapons=S.General+dn]="WheelWeapons",S[S.WheelAmmo=S.WheelWeapons+Je]="WheelAmmo",S[S.WheelPowerups=S.WheelAmmo+Je]="WheelPowerups",S[S.CdLoopCount=S.WheelPowerups+Je]="CdLoopCount",S[S.GameStyle=S.CdLoopCount+1]="GameStyle",S[S.MaxConfigStrings=S.GameStyle+1]="MaxConfigStrings",S))(se||{}),fn=se.MaxConfigStrings;function pn(t){return t>=5&&t<59?96*(59-t):t>=se.General&&t<se.WheelWeapons?96*(se.MaxConfigStrings-t):96}var Xe={};ct(Xe,{addReplayFrame:()=>hn,createReplaySession:()=>Sn,deserializeReplay:()=>xn,serializeReplay:()=>yn});function yn(t){return JSON.stringify(t,null,2)}function xn(t){let e=JSON.parse(t);if(!e.metadata||!Array.isArray(e.frames))throw new Error("Invalid replay format: missing metadata or frames");return e}function Sn(t,e){return{metadata:{map:t,date:new Date().toISOString(),version:"1.0",seed:e},frames:[]}}function hn(t,e,o,n){t.frames.push({serverFrame:o,cmd:e,timestamp:Date.now()-n})}function bn(t){return t??{}}function Ct(t,e,o={}){let n=bn(t),r=[],s=[];for(let i of e){if(!(i in n)){r.push(i);continue}typeof n[i]!="function"&&s.push(i)}let a=o.allowExtra===!1?Object.keys(n).filter(i=>!e.includes(i)):[];return{missing:r,nonFunctions:s,extras:a}}function Vn(t,e,o={}){let{missing:n,nonFunctions:r,extras:s}=Ct(t,e,o);if(n.length===0&&r.length===0&&s.length===0)return;let a=[];n.length>0&&a.push(`missing: ${n.join(", ")}`),r.length>0&&a.push(`non-functions: ${r.join(", ")}`),s.length>0&&a.push(`extras: ${s.join(", ")}`);let i=o.name??"contract";throw new Error(`${i} validation failed (${a.join("; ")})`)}var Tn=["Broadcast_Print","Com_Print","Client_Print","Center_Print","sound","positioned_sound","local_sound","configstring","get_configstring","Com_Error","modelindex","soundindex","imageindex","setmodel","trace","clip","pointcontents","inPVS","inPHS","SetAreaPortalState","AreasConnected","linkentity","unlinkentity","BoxEdicts","multicast","unicast"],Pn=["PreInit","Init","Shutdown","SpawnEntities","WriteGameJson","ReadGameJson","WriteLevelJson","ReadLevelJson","CanSave","ClientConnect","ClientThink","RunFrame","Pmove"],Cn=["Com_Print","get_configstring","Com_Error","TagMalloc","TagFree","AddCommandString","CL_FrameValid","CL_FrameTime","CL_ClientTime","CL_ServerFrame","Draw_RegisterPic","Draw_GetPicSize","SCR_DrawChar","SCR_DrawPic","SCR_DrawColorPic"],_n=["Init","Shutdown","DrawHUD","TouchPics","LayoutFlags","GetActiveWeaponWheelWeapon","GetOwnedWeaponWheelWeapons","GetWeaponWheelAmmoCount","GetPowerupWheelCount","GetHitMarkerDamage","Pmove","ParseConfigString","ParseCenterPrint","ClearNotify","ClearCenterprint","NotifyMessage","GetMonsterFlashOffset"];var ae=(r=>(r[r.None=0]="None",r[r.Feet=1]="Feet",r[r.Waist=2]="Waist",r[r.Under=3]="Under",r))(ae||{});function je(t){return t>=2}function An(t){return t===3}var ee=(c=>(c[c.Ducked=1]="Ducked",c[c.JumpHeld=2]="JumpHeld",c[c.OnGround=4]="OnGround",c[c.TimeWaterJump=8]="TimeWaterJump",c[c.TimeLand=16]="TimeLand",c[c.TimeTeleport=32]="TimeTeleport",c[c.NoPositionalPrediction=64]="NoPositionalPrediction",c[c.OnLadder=128]="OnLadder",c[c.NoAngularPrediction=256]="NoAngularPrediction",c[c.IgnorePlayerCollision=512]="IgnorePlayerCollision",c[c.TimeTrick=1024]="TimeTrick",c))(ee||{});function M(t,e){return(t&e)!==0}function W(t,e){return t|e}function U(t,e){return t&~e}var ie=(i=>(i[i.Normal=0]="Normal",i[i.Grapple=1]="Grapple",i[i.NoClip=2]="NoClip",i[i.Spectator=3]="Spectator",i[i.Dead=4]="Dead",i[i.Gib=5]="Gib",i[i.Freeze=6]="Freeze",i))(ie||{}),te=(i=>(i[i.None=0]="None",i[i.Attack=1]="Attack",i[i.Use=2]="Use",i[i.Holster=4]="Holster",i[i.Jump=8]="Jump",i[i.Crouch=16]="Crouch",i[i.Any=128]="Any",i))(te||{});function Ye(t){let{velocity:e,frametime:o,onGround:n,groundIsSlick:r,onLadder:s,waterlevel:a,pmFriction:i,pmStopSpeed:u,pmWaterFriction:l}=t,m=D(e);if(m<1)return{x:0,y:0,z:e.z};let c=0;if(n&&!r||s){let y=m<u?u:m;c+=y*i*o}a>0&&!s&&(c+=m*l*a*o);let f=m-c;if(f<0&&(f=0),f===m)return e;let p=f/m;return g(e,p)}function H(t){let{velocity:e,wishdir:o,wishspeed:n,accel:r,frametime:s}=t,a=F(e,o),i=n-a;if(i<=0)return e;let u=r*s*n;return u>i&&(u=i),{x:e.x+o.x*u,y:e.y+o.y*u,z:e.z+o.z*u}}function Ze(t){let{velocity:e,wishdir:o,wishspeed:n,accel:r,frametime:s}=t,a=Math.min(n,30),i=F(e,o),u=a-i;if(u<=0)return e;let l=r*n*s;return l>u&&(l=u),{x:e.x+o.x*l,y:e.y+o.y*l,z:e.z+o.z*l}}function Nn(t,e){let o=Math.abs(t.forwardmove),n=Math.abs(t.sidemove),r=Math.abs(t.upmove),s=Math.max(o,n,r);if(s===0)return 0;let a=Math.sqrt(t.forwardmove*t.forwardmove+t.sidemove*t.sidemove+t.upmove*t.upmove);return e*s/(127*a)}function qe(t){let{forward:e,right:o,cmd:n,maxSpeed:r}=t,s={x:e.x*n.forwardmove+o.x*n.sidemove,y:e.y*n.forwardmove+o.y*n.sidemove,z:0},a=D(s);if(a>r){let i=r/a;s=g(s,i),a=r}return{wishdir:a===0?s:O(s),wishspeed:a}}function $e(t){let{forward:e,right:o,cmd:n,maxSpeed:r}=t,s={x:e.x*n.forwardmove+o.x*n.sidemove,y:e.y*n.forwardmove+o.y*n.sidemove,z:0};n.upmove>10?s=N(s,{x:0,y:0,z:n.upmove}):n.upmove<-10?s=N(s,{x:0,y:0,z:n.upmove}):s=N(s,{x:0,y:0,z:10});let a=D(s);if(a>r){let i=r/a;s=g(s,i),a=r}return a*=.5,{wishdir:a===0?s:O(s),wishspeed:a}}var _t=5,gn=4,En=18,Rn=.7,At=1,Nt=2;function gt(t,e,o,n=_t,r=t){if(e.length===0)return{velocity:t,planes:[],stopped:!1};let s=[],a=t;for(let u of e){if(s.length>=n)return{velocity:R,planes:s,stopped:!0};if(s.find(f=>F(f,u)>.99))continue;s.push(u);let m,c=0;for(;c<s.length;c++){let f=$(a,s[c],o),p=0;for(;p<s.length&&!(p!==c&&F(f,s[p])<0);p++);if(p===s.length){m=f;break}}if(m)a=m;else{if(s.length!==2)return{velocity:R,planes:s,stopped:!0};let f=q(s[0],s[1]),p=F(f,a);a=g(f,p)}if(F(a,r)<=0)return{velocity:R,planes:s,stopped:!0}}let i=a.x===0&&a.y===0&&a.z===0;return{velocity:a,planes:s,stopped:i}}function Qe(t){let{origin:e,velocity:o,frametime:n,overbounce:r,trace:s,maxBumps:a=gn,maxClipPlanes:i=_t,mins:u,maxs:l,hasTime:m=!1}=t,c=e,f=o,p=[],y=o,T=n,h=0;for(let A=0;A<a&&!(f.x===0&&f.y===0&&f.z===0);A++){let C=N(c,g(f,T)),b=s(c,C,u,l);if(b.allsolid){let P=m?y:R;return{origin:b.endpos,velocity:P,planes:p,stopped:!0,blocked:h}}if(b.startsolid){let P=m?y:R;return{origin:b.endpos,velocity:P,planes:p,stopped:!0,blocked:h}}if(b.fraction>0&&(c=b.endpos),b.fraction===1)break;if(!b.planeNormal)return{origin:c,velocity:m?y:R,planes:p,stopped:!0,blocked:h};b.planeNormal.z>.7&&(h|=At),b.planeNormal.z===0&&(h|=Nt),p.push(b.planeNormal),T-=T*b.fraction;let x=gt(f,p,r,i,y);if(f=x.velocity,p.splice(0,p.length,...x.planes),y.z>0&&f.z<0&&(f={...f,z:0}),x.stopped)return{origin:c,velocity:m?y:f,planes:p,stopped:!0,blocked:h}}let V=m?y:f;return{origin:c,velocity:V,planes:p,stopped:V.x===0&&V.y===0&&V.z===0,blocked:h}}function oe(t){let{mins:e,maxs:o,stepSize:n=En,...r}=t,s=t.origin,a=t.velocity,i=Qe({...r,mins:e,maxs:o}),u=N(s,{x:0,y:0,z:n}),l=r.trace(s,u,e,o);if(l.allsolid)return{...i,stepped:!1,stepHeight:0};let m=l.endpos.z-s.z,c=Qe({...r,origin:l.endpos,velocity:a,mins:e,maxs:o}),f=N(c.origin,{x:0,y:0,z:-m}),p=r.trace(c.origin,f,e,o),y=c.origin,T=p.planeNormal;p.allsolid||(y=p.endpos);let h=(P,S)=>(P.x-S.x)**2+(P.y-S.y)**2,V=h(i.origin,s),A=h(y,s);if(V>A||T&&T.z<Rn)return{...i,stepped:!1,stepHeight:0};let C={...c.velocity,z:i.velocity.z},b=c.blocked,x=C.x===0&&C.y===0&&C.z===0;return{origin:y,velocity:C,planes:c.planes,blocked:b,stopped:x,stepped:!0,stepHeight:m,stepNormal:T}}var ce=["x","y","z"],et=[{normal:[0,0,1],mins:[-1,-1,0],maxs:[1,1,0]},{normal:[0,0,-1],mins:[-1,-1,0],maxs:[1,1,0]},{normal:[1,0,0],mins:[0,-1,-1],maxs:[0,1,1]},{normal:[-1,0,0],mins:[0,-1,-1],maxs:[0,1,1]},{normal:[0,1,0],mins:[-1,0,-1],maxs:[1,0,1]},{normal:[0,-1,0],mins:[-1,0,-1],maxs:[1,0,1]}],Et={x:0,y:0,z:0};function le(t){return{x:t.x,y:t.y,z:t.z}}function vn(t){return{x:t[0],y:t[1],z:t[2]}}function fe(t,e,o){if(o!==0)switch(e){case"x":t.x+=o;break;case"y":t.y+=o;break;case"z":t.z+=o;break}}function Rt(t,e,o){switch(e){case"x":t.x=o;break;case"y":t.y=o;break;case"z":t.z=o;break}}function ge(t,e){switch(e){case"x":return t.x;case"y":return t.y;case"z":default:return t.z}}function vt(t,e,o,n){return t===-1?ge(o,e):t===1?ge(n,e):0}function Ot(t,e,o,n){let r=le(t);for(let s=0;s<ce.length;s++){let a=ce[s],i=e.normal[s];i<0?fe(r,a,ge(o,a)):i>0&&fe(r,a,ge(n,a))}return r}function On(t,e,o){let n=le(Et),r=le(Et);for(let s=0;s<ce.length;s++){let a=ce[s];Rt(n,a,vt(t.mins[s],a,e,o)),Rt(r,a,vt(t.maxs[s],a,e,o))}return{mins:n,maxs:r}}function zn(t,e,o){if(!e||o===0)return t;let n=le(t);return fe(n,e,o),n}function Fn(t,e,o){if(!e||o===0)return t;switch(e){case"x":return{...t,x:t.x+o};case"y":return{...t,y:t.y+o};case"z":default:return{...t,z:t.z+o}}}function tt(t){let{origin:e,mins:o,maxs:n,trace:r}=t;if(!r(e,o,n,e).startsolid)return{result:"good-position",origin:{...e}};let a=[];for(let i=0;i<et.length;i++){let u=et[i],{mins:l,maxs:m}=On(u,o,n),c=Ot(e,u,o,n),f=r(c,l,m,c),p,y=0;if(f.startsolid)for(let P=0;P<ce.length;P++){if(u.normal[P]!==0)continue;let S=ce[P],v=le(c);if(fe(v,S,1),f=r(v,l,m,v),!f.startsolid){c=v,p=S,y=1;break}if(v=le(c),fe(v,S,-1),f=r(v,l,m,v),!f.startsolid){c=v,p=S,y=-1;break}}if(f.startsolid)continue;let T=et[i^1],h=Ot(e,T,o,n);if(h=zn(h,p,y),f=r(c,l,m,h),f.startsolid)continue;let V=vn(u.normal),A=N(f.endpos??h,g(V,.125)),C=Z(A,h),b=N(e,C);b=Fn(b,p,y),!r(b,o,n,b).startsolid&&a.push({origin:b,distance:ne(C)})}return a.length===0?{result:"no-good-position",origin:{...e}}:(a.sort((i,u)=>i.distance-u.distance),{result:"fixed",origin:{...a[0].origin}})}var Mn=100,ot=200,zt=150,Ee=25,Ln=15,wn=1,Dn={x:0,y:0,z:1},In=(t,e)=>({fraction:1,endpos:e,allsolid:!1,startsolid:!1});function nt(t){let e=0,o=0,n=0;return t&262144&&(e+=1),t&524288&&(o+=1),t&1048576&&(e-=1),t&2097152&&(o-=1),t&4194304&&(n+=1),t&8388608&&(n-=1),e===0&&o===0&&n===0?R:{x:e,y:o,z:n}}function Lt(t){let{watertype:e,waterlevel:o,onGround:n,waterSpeed:r}=t;if((e&16515072)===0)return R;let s=nt(e);if(s===R)return R;let a=r;return o===1&&n&&(a*=.5),g(s,a)}function wt(t){let{groundContents:e,scale:o=Mn}=t,n=nt(e);return n===R?R:g(n,o)}function Re(t){let{wishVelocity:e,onLadder:o,onGround:n,waterlevel:r,watertype:s,groundContents:a,cmd:i,viewPitch:u,maxSpeed:l,ladderMod:m,waterSpeed:c,forward:f,origin:p,mins:y,maxs:T,trace:h=In}=t,V=e;o&&(V=Wn({wishVelocity:V,cmd:i,waterlevel:r,viewPitch:u,maxSpeed:l,ladderMod:m,onGround:n,forward:f,origin:p,mins:y,maxs:T,trace:h}));let A=Lt({watertype:s,waterlevel:r,onGround:n,waterSpeed:c});if(A!==R&&(V=N(V,A)),n){let C=wt({groundContents:a});C!==R&&(V=N(V,C))}return V}function Wn(t){let{wishVelocity:e,cmd:o,waterlevel:n,viewPitch:r,maxSpeed:s,ladderMod:a,onGround:i,forward:u,origin:l,mins:m,maxs:c,trace:f}=t,p=o.buttons??0,y={...e};if((p&24)!==0){let T=je(n)?s:ot;y={...y,z:p&8?T:-T}}else if(o.forwardmove){let T=Ft(o.forwardmove,-ot,ot);if(o.forwardmove>0){let h=r<Ln?T:-T;y={...y,z:h}}else i||(y={...y,x:0,y:0}),y={...y,z:T}}else y={...y,z:0};if(!i)if(o.sidemove){let T=Ft(o.sidemove,-zt,zt);n<2&&(T*=a);let h=O({x:u.x,y:u.y,z:0});if(h.x!==0||h.y!==0){let V=N(l,g(h,wn)),A=f(l,V,m,c);if(A.fraction!==1&&!A.allsolid&&A.contents!==void 0&&(A.contents&536870912)!==0&&A.planeNormal){let C=q(A.planeNormal,Dn);y={...y,x:0,y:0},y=N(y,g(C,-T))}}}else y={...y,x:Mt(y.x),y:Mt(y.y)};return y}function Ft(t,e,o){return Math.max(e,Math.min(o,t))}function Mt(t){return t<-Ee?-Ee:t>Ee?Ee:t}var Bn=1.5,Dt=.5,kn=1.01;function Gn(t){let{origin:e,cmd:o,frametime:n,pmFriction:r,pmStopSpeed:s,pmMaxSpeed:a,pmAccelerate:i,pmWaterSpeed:u,doclip:l,forward:m,right:c,mins:f,maxs:p,trace:y,overbounce:T=kn,stepSize:h,maxBumps:V,maxClipPlanes:A}=t,C=Un({velocity:t.velocity,pmFriction:r,pmStopSpeed:s,frametime:n}),b=Hn({cmd:o,forward:m,right:c,pmMaxSpeed:a,pmWaterSpeed:u});if(b.wishspeed>0&&(C=H({velocity:C,wishdir:b.wishdir,wishspeed:b.accelSpeed,accel:i,frametime:n})),!l){let x=g(C,n);return{origin:N(e,x),velocity:C,planes:[],blocked:0,stopped:C.x===0&&C.y===0&&C.z===0,stepped:!1,stepHeight:0}}if(!y||!f||!p)throw new Error("applyPmoveFlyMove: doclip=true requires trace/mins/maxs");return oe({origin:e,velocity:C,frametime:n,overbounce:T,trace:y,mins:f,maxs:p,stepSize:h,maxBumps:V,maxClipPlanes:A})}function Un(t){let{velocity:e,pmFriction:o,pmStopSpeed:n,frametime:r}=t,s=D(e);if(s<1)return{x:0,y:0,z:0};let a=o*Bn,u=(s<n?n:s)*a*r,l=s-u;return l<0&&(l=0),l===s?e:g(e,l/s)}function Hn(t){let{cmd:e,forward:o,right:n,pmMaxSpeed:r,pmWaterSpeed:s}=t,a=O(o),i=O(n),l={x:a.x*e.forwardmove+i.x*e.sidemove,y:a.y*e.forwardmove+i.y*e.sidemove,z:a.z*e.forwardmove+i.z*e.sidemove},m=e.buttons??0;m&8&&(l=N(l,{x:0,y:0,z:s*Dt})),m&16&&(l=N(l,{x:0,y:0,z:-s*Dt}));let c=D(l),f=c===0?{x:0,y:0,z:0}:O(l);if(c>r){let y=r/c;l=g(l,y),c=r,f=c===0?{x:0,y:0,z:0}:O(l)}let p=c*2;return{wishdir:f,wishspeed:c,accelSpeed:p}}function pe(t){let{origin:e,mins:o,viewheight:n,pointContents:r}=t,s=n-o.z,a=s/2,i={x:e.x,y:e.y,z:e.z+o.z+1},u=r(i);if((u&56)===0)return{waterlevel:0,watertype:0};let l=u,m=1,c={x:i.x,y:i.y,z:e.z+o.z+a};if(u=r(c),(u&56)!==0){m=2;let f={x:i.x,y:i.y,z:e.z+o.z+s};u=r(f),(u&56)!==0&&(m=3)}return{waterlevel:m,watertype:l}}var Kn=270;function Jn(t,e){return(t&e)!==0}function Xn(t){let{pmFlags:e,pmType:o,buttons:n,waterlevel:r,onGround:s,velocity:a,jumpHeight:i=Kn}=t;if(e&16)return{pmFlags:e,onGround:s,velocity:a,jumpSound:!1,jumped:!1};let u=Jn(n,8),l=e,m=s,c=!1,f=!1,p=a;if(!u)return l=U(l,2),{pmFlags:l,onGround:m,velocity:p,jumpSound:c,jumped:f};if(jn(l))return{pmFlags:l,onGround:m,velocity:p,jumpSound:c,jumped:f};if(o===4)return{pmFlags:l,onGround:m,velocity:p,jumpSound:c,jumped:f};if(r>=2)return m=!1,{pmFlags:l,onGround:m,velocity:p,jumpSound:c,jumped:f};if(!m)return{pmFlags:l,onGround:m,velocity:p,jumpSound:c,jumped:f};l=W(l,2),l=U(l,4),m=!1,c=!0,f=!0;let y=a.z+i,T=y<i?i:y;return p={...a,z:T},{pmFlags:l,onGround:m,velocity:p,jumpSound:c,jumped:f}}function jn(t){return(t&2)!==0}function ve(t,e,o){return{x:t,y:e,z:o}}function Oe(t,e){let o=ve(-16,-16,0),n=ve(16,16,16);if(t===5)return{mins:o,maxs:n,viewheight:8};let r=t===4||(e&1)!==0,s=ve(o.x,o.y,-24),a=ve(n.x,n.y,r?4:32);return{mins:s,maxs:a,viewheight:r?-2:22}}var Yn=4,Zn=32,qn=8;function $n(t){let{pmType:e}=t;if(e===5){let a=Oe(e,t.pmFlags);return{pmFlags:t.pmFlags,ducked:M(t.pmFlags,1),changed:!1,...a}}let o=t.pmFlags,n=!1;e===4?M(o,1)||(o=W(o,1),n=!0):Qn(t)?!M(o,1)&&!er(t)&&(o=W(o,1),n=!0):M(o,1)&&!tr(t)&&(o=U(o,1),n=!0);let r=Oe(e,o),s=e===4||M(o,1);return{pmFlags:o,ducked:s,changed:n,...r}}function Qn(t){return(t.buttons&16)===0||t.onLadder||t.n64Physics?!1:!!(t.hasGroundEntity||t.waterlevel<=1&&!or(t))}function er(t){return t.trace({start:t.origin,end:t.origin,mins:t.mins,maxs:It(t.maxs,Yn),mask:3}).allsolid}function tr(t){return t.trace({start:t.origin,end:t.origin,mins:t.mins,maxs:It(t.maxs,Zn),mask:3}).allsolid}function or(t){let e={x:t.origin.x,y:t.origin.y,z:t.origin.z-qn};return t.trace({start:t.origin,end:e,mins:t.mins,maxs:t.maxs,mask:3}).fraction<1?!1:t.trace({start:t.origin,end:e,mins:t.mins,maxs:t.maxs,mask:56}).fraction<1}function It(t,e){return{x:t.x,y:t.y,z:e}}var nr=.25,rr=180,sr=100,ar=.7,ir=.9,cr=64,lr=128,ur=1.01,dr=1080;function mr(t){let{pmType:e,n64Physics:o,velocity:n,startVelocity:r,origin:s,mins:a,maxs:i,viewheight:u,trace:l,pointContents:m}=t,c=t.pmFlags,f=t.pmTime,p,y=M(c,4),T,h=0;if(n.z>rr||e===1)c=U(c,4),y=!1;else{let b={x:s.x,y:s.y,z:s.z-nr},x=l(s,b,a,i);T=x,h=x.contents??0;let P=x.planeNormal,S=x.fraction<1&&!!P&&P.z<ar;if(S&&P){let v=N(s,P),B=l(s,v,a,i);B.fraction<1&&!B.startsolid&&(S=!1)}if(x.fraction===1||!P||S&&!x.startsolid)c=U(c,4),y=!1;else{y=!0,M(c,8)&&(c&=~dr,f=0);let v=M(c,4);if(!v){!o&&n.z>=sr&&P.z>=ir&&!M(c,1)&&(c=W(c,1024),f=cr);let B=$(n,P,ur);p=r.z-B.z}c=W(c,4),!v&&(o||M(c,1))&&(c=W(c,16),f=lr)}}let{waterlevel:A,watertype:C}=pe({origin:s,mins:a,viewheight:u,pointContents:m});return{pmFlags:c,pmTime:f,onGround:M(c,4),groundTrace:T,groundContents:h,waterlevel:A,watertype:C,impactDelta:p}}var Wt=1,fr=60,rt=1.01;function pr(t){let{origin:e,frametime:o,mins:n,maxs:r,trace:s,overbounce:a=rt,stepSize:i,maxBumps:u,maxClipPlanes:l,hasTime:m,forward:c,right:f,cmd:p,pmFlags:y,onGround:T,gravity:h,pmType:V,pmAccelerate:A,pmAirAccelerate:C=Wt,pmMaxSpeed:b,pmDuckSpeed:x,onLadder:P,waterlevel:S,watertype:v,groundContents:B,viewPitch:k,ladderMod:E,pmWaterSpeed:L}=t,_={...t.velocity},I=xr(c,f,p);I=Re({wishVelocity:I,onLadder:P,onGround:T,waterlevel:S,watertype:v,groundContents:B,cmd:p,viewPitch:k,maxSpeed:M(y,1)?x:b,ladderMod:E,waterSpeed:L,forward:c,origin:e,mins:n,maxs:r,trace:s});let w=M(y,1)?x:b,G=I,z=D(G);if(z!==0&&(G=O(G)),z>w){let j=w/z;I=g(I,j),z=w,z!==0&&(G=O(I))}return P?(_=H({velocity:_,wishdir:G,wishspeed:z,accel:A,frametime:o}),Math.abs(I.z)<Number.EPSILON&&(_=br(_,h,o)),ze({origin:e,velocity:_,frametime:o,mins:n,maxs:r,trace:s,overbounce:a,stepSize:i,maxBumps:u,maxClipPlanes:l,hasTime:m})):T?(_={..._,z:0},_=H({velocity:_,wishdir:G,wishspeed:z,accel:A,frametime:o}),h>0?_={..._,z:0}:_={..._,z:_.z-h*o},_.x===0&&_.y===0?{origin:e,velocity:_,planes:[],blocked:0,stopped:!0,stepped:!1,stepHeight:0}:ze({origin:e,velocity:_,frametime:o,mins:n,maxs:r,trace:s,overbounce:a,stepSize:i,maxBumps:u,maxClipPlanes:l,hasTime:m})):(C>0?_=Ze({velocity:_,wishdir:G,wishspeed:z,accel:C,frametime:o}):_=H({velocity:_,wishdir:G,wishspeed:z,accel:Wt,frametime:o}),V!==1&&(_={..._,z:_.z-h*o}),ze({origin:e,velocity:_,frametime:o,mins:n,maxs:r,trace:s,overbounce:a,stepSize:i,maxBumps:u,maxClipPlanes:l,hasTime:m}))}function yr(t){let{origin:e,frametime:o,mins:n,maxs:r,trace:s,overbounce:a=rt,stepSize:i,maxBumps:u,maxClipPlanes:l,hasTime:m,forward:c,right:f,cmd:p,pmFlags:y,onGround:T,pmMaxSpeed:h,pmDuckSpeed:V,pmWaterAccelerate:A,pmWaterSpeed:C,onLadder:b,watertype:x,groundContents:P,waterlevel:S,viewPitch:v,ladderMod:B}=t,k={...t.velocity},E=Sr(c,f,p);hr(p,T)?E={...E,z:E.z-fr}:Bt(p,16)?E=N(E,{x:0,y:0,z:-C*.5}):Bt(p,8)&&(E=N(E,{x:0,y:0,z:C*.5})),E=Re({wishVelocity:E,onLadder:b,onGround:T,waterlevel:S,watertype:x,groundContents:P,cmd:p,viewPitch:v,maxSpeed:M(y,1)?V:h,ladderMod:B,waterSpeed:C,forward:c,origin:e,mins:n,maxs:r,trace:s});let L=E,_=D(L);if(_!==0&&(L=O(L)),_>h){let J=h/_;E=g(E,J),_=h,_!==0&&(L=O(E))}if(_*=.5,M(y,1)&&_>V){let J=V/_;E=g(E,J),_=V,_!==0&&(L=O(E))}return k=H({velocity:k,wishdir:L,wishspeed:_,accel:A,frametime:o}),ze({origin:e,velocity:k,frametime:o,mins:n,maxs:r,trace:s,overbounce:a,stepSize:i,maxBumps:u,maxClipPlanes:l,hasTime:m})}function xr(t,e,o){return{x:t.x*o.forwardmove+e.x*o.sidemove,y:t.y*o.forwardmove+e.y*o.sidemove,z:0}}function Sr(t,e,o){return{x:t.x*o.forwardmove+e.x*o.sidemove,y:t.y*o.forwardmove+e.y*o.sidemove,z:t.z*o.forwardmove+e.z*o.sidemove}}function Bt(t,e){return!!((t.buttons??0)&e)}function hr(t,e){let o=t.forwardmove===0&&t.sidemove===0,n=!((t.buttons??0)&24);return o&&n&&!e}function br(t,e,o){let n=t.z,r=e*o;return n>0?(n-=r,n<0&&(n=0)):(n+=r,n>0&&(n=0)),{...t,z:n}}function ze(t){let{origin:e,velocity:o,frametime:n,mins:r,maxs:s,trace:a,overbounce:i=rt,stepSize:u,maxBumps:l,maxClipPlanes:m,hasTime:c}=t;return oe({origin:e,velocity:o,frametime:n,trace:a,mins:r,maxs:s,overbounce:i,stepSize:u,maxBumps:l,maxClipPlanes:m,hasTime:c})}var Vr=1,Tr=40,Fe=50,kt=350,Pr=2048,Gt=.1,Cr=800,_r=50,Ut=.7,Ar=18,Nr=1.01,gr=2;function Er(t){let{pmFlags:e,pmTime:o,waterlevel:n,watertype:r,gravity:s,cmd:a,forward:i,origin:u,velocity:l,mins:m,maxs:c,viewheight:f,trace:p,pointContents:y,onGround:T,overbounce:h=Nr,stepSize:V=Ar,maxBumps:A,maxClipPlanes:C}=t;if(o>0)return{pmFlags:e,pmTime:o,velocity:l,performedWaterJump:!1};let b=U(e,128),x=o,P=l,S=O({x:i.x,y:i.y,z:0}),v=ne(S)>0;if(n<2&&v){let z=N(u,g(S,Vr)),j=p(u,z,m,c),Xt=j.contents??0;j.fraction<1&&(Xt&536870912)!==0&&(b=W(b,128))}if(s===0)return{pmFlags:b,pmTime:x,velocity:P,performedWaterJump:!1};if(((a.buttons??0)&8)===0&&a.forwardmove<=0)return{pmFlags:b,pmTime:x,velocity:P,performedWaterJump:!1};if(n!==2)return{pmFlags:b,pmTime:x,velocity:P,performedWaterJump:!1};if((r&8192)!==0)return{pmFlags:b,pmTime:x,velocity:P,performedWaterJump:!1};if(!v)return{pmFlags:b,pmTime:x,velocity:P,performedWaterJump:!1};let B=N(u,g(S,Tr)),k=p(u,B,m,c);if(k.fraction===1||!k.planeNormal||k.planeNormal.z>=Ut)return{pmFlags:b,pmTime:x,velocity:P,performedWaterJump:!1};let E={x:S.x*Fe,y:S.y*Fe,z:kt},L=u,_=!0,I=Rr(s);for(let z=0;z<I;z++){E={x:E.x,y:E.y,z:E.z-s*Gt},E.z<0&&(_=!1);let j=oe({origin:L,velocity:E,frametime:Gt,trace:p,mins:m,maxs:c,overbounce:h,stepSize:V,maxBumps:A,maxClipPlanes:C,hasTime:_});L=j.origin,E=j.velocity}let J=N(L,{x:0,y:0,z:-gr}),w=p(L,J,m,c);return w.fraction===1||!w.planeNormal||w.planeNormal.z<Ut||w.endpos.z<u.z?{pmFlags:b,pmTime:x,velocity:P,performedWaterJump:!1}:T&&Math.abs(u.z-w.endpos.z)<=V?{pmFlags:b,pmTime:x,velocity:P,performedWaterJump:!1}:pe({origin:w.endpos,mins:m,viewheight:f,pointContents:y}).waterlevel>=2?{pmFlags:b,pmTime:x,velocity:P,performedWaterJump:!1}:(b=W(b,8),x=Pr,P={x:S.x*Fe,y:S.y*Fe,z:kt},{pmFlags:b,pmTime:x,velocity:P,performedWaterJump:!0})}function Rr(t){if(t===0)return 0;let e=Math.floor(10*(Cr/t));return e<=0?0:Math.min(_r,e)}var st=[0,-1,1];function at(t){let{origin:e,mins:o,maxs:n,trace:r}=t;return!r(e,e,o,n).allsolid}function vr(t){let{origin:e,velocity:o,mins:n,maxs:r,previousOrigin:s,trace:a}=t;if(at({origin:e,mins:n,maxs:r,trace:a}))return{origin:{...e},velocity:{...o},resolution:"unchanged"};let i=tt({origin:e,mins:n,maxs:r,trace:(u,l,m,c)=>a(u,c,l,m)});return i.result==="fixed"||i.result==="good-position"?{origin:i.origin,velocity:{...o},resolution:"fixed"}:{origin:{...s},velocity:{...o},resolution:"reverted"}}function Or(t){let{origin:e,mins:o,maxs:n,trace:r}=t;for(let s of st)for(let a of st)for(let i of st){let u={x:e.x+i,y:e.y+a,z:e.z+s};if(at({origin:u,mins:o,maxs:n,trace:r}))return{origin:u,snapped:i!==0||a!==0||s!==0}}return{origin:{...e},snapped:!1}}function zr(t,e){return{x:t.x+e.x,y:t.y+e.y,z:t.z+e.z}}function Fr(t){return t>89&&t<180?89:t<271&&t>=180?271:t}function Mr(t){let{pmFlags:e,cmdAngles:o,deltaAngles:n}=t,r;(e&32)!==0?r={x:0,y:o.y+n.y,z:0}:(r=zr(o,n),r={...r,x:Fr(r.x)});let s=De(r);return{viewangles:r,...s}}var Lr=200,wr=200,Dr=200,Ir=140,Wr=150,Br=3;function kr(t){let e=de(t);return e>89&&e<180?89:e<271&&e>=180?271:e}function Gr(t,e){return{x:kr(t.x+e.x),y:de(t.y+e.y),z:de(t.z+e.z)}}function Ur(t,e){let o=e.sensitivityX??e.sensitivity,n=(e.sensitivityY??e.sensitivity)*(e.invertY?-1:1);return{x:t.deltaY*n,y:t.deltaX*o,z:0}}var Ht=(x=>(x[x.bad=0]="bad",x[x.muzzleflash=1]="muzzleflash",x[x.muzzleflash2=2]="muzzleflash2",x[x.temp_entity=3]="temp_entity",x[x.layout=4]="layout",x[x.inventory=5]="inventory",x[x.nop=6]="nop",x[x.disconnect=7]="disconnect",x[x.reconnect=8]="reconnect",x[x.sound=9]="sound",x[x.print=10]="print",x[x.stufftext=11]="stufftext",x[x.serverdata=12]="serverdata",x[x.configstring=13]="configstring",x[x.spawnbaseline=14]="spawnbaseline",x[x.centerprint=15]="centerprint",x[x.download=16]="download",x[x.playerinfo=17]="playerinfo",x[x.packetentities=18]="packetentities",x[x.deltapacketentities=19]="deltapacketentities",x[x.frame=20]="frame",x))(Ht||{}),Kt=(s=>(s[s.bad=0]="bad",s[s.nop=1]="nop",s[s.move=2]="move",s[s.userinfo=3]="userinfo",s[s.stringcmd=4]="stringcmd",s))(Kt||{});var Jt=(d=>(d[d.GUNSHOT=0]="GUNSHOT",d[d.BLOOD=1]="BLOOD",d[d.BLASTER=2]="BLASTER",d[d.RAILTRAIL=3]="RAILTRAIL",d[d.SHOTGUN=4]="SHOTGUN",d[d.EXPLOSION1=5]="EXPLOSION1",d[d.EXPLOSION2=6]="EXPLOSION2",d[d.ROCKET_EXPLOSION=7]="ROCKET_EXPLOSION",d[d.GRENADE_EXPLOSION=8]="GRENADE_EXPLOSION",d[d.SPARKS=9]="SPARKS",d[d.SPLASH=10]="SPLASH",d[d.BUBBLETRAIL=11]="BUBBLETRAIL",d[d.SCREEN_SPARKS=12]="SCREEN_SPARKS",d[d.SHIELD_SPARKS=13]="SHIELD_SPARKS",d[d.BULLET_SPARKS=14]="BULLET_SPARKS",d[d.LASER_SPARKS=15]="LASER_SPARKS",d[d.PARASITE_ATTACK=16]="PARASITE_ATTACK",d[d.ROCKET_EXPLOSION_WATER=17]="ROCKET_EXPLOSION_WATER",d[d.GRENADE_EXPLOSION_WATER=18]="GRENADE_EXPLOSION_WATER",d[d.MEDIC_CABLE_ATTACK=19]="MEDIC_CABLE_ATTACK",d[d.BFG_EXPLOSION=20]="BFG_EXPLOSION",d[d.BFG_BIGEXPLOSION=21]="BFG_BIGEXPLOSION",d[d.BOSSTPORT=22]="BOSSTPORT",d[d.BFG_LASER=23]="BFG_LASER",d[d.GRAPPLE_CABLE=24]="GRAPPLE_CABLE",d[d.WELDING_SPARKS=25]="WELDING_SPARKS",d[d.GREENBLOOD=26]="GREENBLOOD",d[d.BLUEHYPERBLASTER=27]="BLUEHYPERBLASTER",d[d.PLASMA_EXPLOSION=28]="PLASMA_EXPLOSION",d[d.TUNNEL_SPARKS=29]="TUNNEL_SPARKS",d[d.BLASTER2=30]="BLASTER2",d[d.RAILTRAIL2=31]="RAILTRAIL2",d[d.FLAME=32]="FLAME",d[d.LIGHTNING=33]="LIGHTNING",d[d.DEBUGTRAIL=34]="DEBUGTRAIL",d[d.PLAIN_EXPLOSION=35]="PLAIN_EXPLOSION",d[d.FLASHLIGHT=36]="FLASHLIGHT",d[d.FORCEWALL=37]="FORCEWALL",d[d.HEATBEAM=38]="HEATBEAM",d[d.MONSTER_HEATBEAM=39]="MONSTER_HEATBEAM",d[d.STEAM=40]="STEAM",d[d.BUBBLETRAIL2=41]="BUBBLETRAIL2",d[d.MOREBLOOD=42]="MOREBLOOD",d[d.HEATBEAM_SPARKS=43]="HEATBEAM_SPARKS",d[d.HEATBEAM_STEAM=44]="HEATBEAM_STEAM",d[d.CHAINFIST_SMOKE=45]="CHAINFIST_SMOKE",d[d.ELECTRIC_SPARKS=46]="ELECTRIC_SPARKS",d[d.TRACKER_EXPLOSION=47]="TRACKER_EXPLOSION",d[d.TELEPORT_EFFECT=48]="TELEPORT_EFFECT",d[d.DBALL_GOAL=49]="DBALL_GOAL",d[d.WIDOWBEAMOUT=50]="WIDOWBEAMOUT",d[d.NUKEBLAST=51]="NUKEBLAST",d[d.WIDOWSPLASH=52]="WIDOWSPLASH",d[d.EXPLOSION1_BIG=53]="EXPLOSION1_BIG",d[d.EXPLOSION1_NP=54]="EXPLOSION1_NP",d[d.FLECHETTE=55]="FLECHETTE",d))(Jt||{});var ye=.025,Hr=(t,e)=>{let o={...t.origin};o.z-=.25;let n=e(t.origin,o);return{...t,onGround:n.fraction<1}},Kr=(t,e)=>{let o={...t.origin};return o.z+=t.mins.z+1,e(o)&33554432?{...t,waterLevel:1}:{...t,waterLevel:0}},Jr=(t,e,o,n)=>{let r={...t};r=Hr(r,o),r=Kr(r,n);let{origin:s,velocity:a,onGround:i,waterLevel:u}=r,l=Ye({velocity:a,frametime:ye,onGround:i,groundIsSlick:!1,onLadder:!1,waterlevel:u,pmFriction:6,pmStopSpeed:100,pmWaterFriction:1}),m=u>=2?$e({forward:{x:1,y:0,z:0},right:{x:0,y:1,z:0},cmd:e,maxSpeed:320}):qe({forward:{x:1,y:0,z:0},right:{x:0,y:1,z:0},cmd:e,maxSpeed:320}),c=H({velocity:l,wishdir:m.wishdir,wishspeed:m.wishspeed,accel:i?10:1,frametime:ye}),f=o(s,{x:s.x+c.x*ye,y:s.y+c.y*ye,z:s.z+c.z*ye});return{...r,origin:f.endpos,velocity:c}};var it=class{constructor(e){e instanceof Uint8Array?this.view=new DataView(e.buffer,e.byteOffset,e.byteLength):this.view=new DataView(e),this.offset=0,this.length=this.view.byteLength}getPosition(){return this.offset}seek(e){if(e<0||e>this.length)throw new Error(`Seek out of bounds: ${e} (length: ${this.length})`);this.offset=e}hasMore(){return this.offset<this.length}readChar(){let e=this.view.getInt8(this.offset);return this.offset+=1,e}readByte(){let e=this.view.getUint8(this.offset);return this.offset+=1,e}readShort(){let e=this.view.getInt16(this.offset,!0);return this.offset+=2,e}readLong(){let e=this.view.getInt32(this.offset,!0);return this.offset+=4,e}readFloat(){let e=this.view.getFloat32(this.offset,!0);return this.offset+=4,e}readString(){let e="";for(;this.offset<this.length;){let o=this.readChar();if(o===-1||o===0)break;e+=String.fromCharCode(o)}return e}readStringLine(){let e="";for(;this.offset<this.length;){let o=this.readChar();if(o===-1||o===0||o===10)break;e+=String.fromCharCode(o)}return e}readCoord(){return this.readShort()*(1/8)}readAngle(){return this.readChar()*(360/256)}readAngle16(){return this.readShort()*360/65536}readData(e){if(this.offset+e>this.length)throw new Error(`Read out of bounds: ${this.offset+e} (length: ${this.length})`);let o=new Uint8Array(this.view.buffer,this.view.byteOffset+this.offset,e);return this.offset+=e,new Uint8Array(o)}readPos(e){e.x=this.readCoord(),e.y=this.readCoord(),e.z=this.readCoord()}readDir(e){if(this.readByte()>=162){e.x=0,e.y=0,e.z=0;return}e.x=0,e.y=0,e.z=0}};return $t(Xr);})();
2
2
  //# sourceMappingURL=index.global.js.map