mirror of
https://github.com/exogen/t2-mapper.git
synced 2026-03-10 16:00:54 +00:00
609 lines
No EOL
350 KiB
JavaScript
609 lines
No EOL
350 KiB
JavaScript
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,13070,e=>{e.v({Arrow:"KeyboardOverlay-module__HsRBsa__Arrow",Column:"KeyboardOverlay-module__HsRBsa__Column",Key:"KeyboardOverlay-module__HsRBsa__Key",Root:"KeyboardOverlay-module__HsRBsa__Root",Row:"KeyboardOverlay-module__HsRBsa__Row",Spacer:"KeyboardOverlay-module__HsRBsa__Spacer"})},78295,e=>{e.v({Joystick:"TouchControls-module__AkxfgW__Joystick",Left:"TouchControls-module__AkxfgW__Left TouchControls-module__AkxfgW__Joystick",Right:"TouchControls-module__AkxfgW__Right TouchControls-module__AkxfgW__Joystick"})},65883,e=>{e.v({ButtonLabel:"InspectorControls-module__gNRB6W__ButtonLabel",CheckboxField:"InspectorControls-module__gNRB6W__CheckboxField",Controls:"InspectorControls-module__gNRB6W__Controls",Dropdown:"InspectorControls-module__gNRB6W__Dropdown",Field:"InspectorControls-module__gNRB6W__Field",Group:"InspectorControls-module__gNRB6W__Group",IconButton:"InspectorControls-module__gNRB6W__IconButton",LabelledButton:"InspectorControls-module__gNRB6W__LabelledButton",MapInfoButton:"InspectorControls-module__gNRB6W__MapInfoButton InspectorControls-module__gNRB6W__IconButton InspectorControls-module__gNRB6W__LabelledButton",MissionSelectWrapper:"InspectorControls-module__gNRB6W__MissionSelectWrapper",Toggle:"InspectorControls-module__gNRB6W__Toggle InspectorControls-module__gNRB6W__IconButton"})},36679,e=>{e.v({ButtonLabel:"CopyCoordinatesButton-module__BxovtG__ButtonLabel "+e.i(65883).ButtonLabel,ClipboardCheck:"CopyCoordinatesButton-module__BxovtG__ClipboardCheck",MapPin:"CopyCoordinatesButton-module__BxovtG__MapPin",Root:"CopyCoordinatesButton-module__BxovtG__Root "+e.i(65883).IconButton+" "+e.i(65883).LabelledButton,showClipboardCheck:"CopyCoordinatesButton-module__BxovtG__showClipboardCheck"})},76775,(e,t,a)=>{function r(e,t,a,r){return Math.round(e/a)+" "+r+(t>=1.5*a?"s":"")}t.exports=function(e,t){t=t||{};var a,n,i,o,s=typeof e;if("string"===s&&e.length>0){var l=e;if(!((l=String(l)).length>100)){var c=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(l);if(c){var d=parseFloat(c[1]);switch((c[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*d;case"weeks":case"week":case"w":return 6048e5*d;case"days":case"day":case"d":return 864e5*d;case"hours":case"hour":case"hrs":case"hr":case"h":return 36e5*d;case"minutes":case"minute":case"mins":case"min":case"m":return 6e4*d;case"seconds":case"second":case"secs":case"sec":case"s":return 1e3*d;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return d;default:break}}}return}if("number"===s&&isFinite(e)){return t.long?(n=Math.abs(a=e))>=864e5?r(a,n,864e5,"day"):n>=36e5?r(a,n,36e5,"hour"):n>=6e4?r(a,n,6e4,"minute"):n>=1e3?r(a,n,1e3,"second"):a+" ms":(o=Math.abs(i=e))>=864e5?Math.round(i/864e5)+"d":o>=36e5?Math.round(i/36e5)+"h":o>=6e4?Math.round(i/6e4)+"m":o>=1e3?Math.round(i/1e3)+"s":i+"ms"}throw Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},7003,(e,t,a)=>{t.exports=function(t){function a(e){let t,n,i,o=null;function s(...e){if(!s.enabled)return;let r=Number(new Date);s.diff=r-(t||r),s.prev=t,s.curr=r,t=r,e[0]=a.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let n=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(t,r)=>{if("%%"===t)return"%";n++;let i=a.formatters[r];if("function"==typeof i){let a=e[n];t=i.call(s,a),e.splice(n,1),n--}return t}),a.formatArgs.call(s,e),(s.log||a.log).apply(s,e)}return s.namespace=e,s.useColors=a.useColors(),s.color=a.selectColor(e),s.extend=r,s.destroy=a.destroy,Object.defineProperty(s,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==o?o:(n!==a.namespaces&&(n=a.namespaces,i=a.enabled(e)),i),set:e=>{o=e}}),"function"==typeof a.init&&a.init(s),s}function r(e,t){let r=a(this.namespace+(void 0===t?":":t)+e);return r.log=this.log,r}function n(e,t){let a=0,r=0,n=-1,i=0;for(;a<e.length;)if(r<t.length&&(t[r]===e[a]||"*"===t[r]))"*"===t[r]?(n=r,i=a):a++,r++;else{if(-1===n)return!1;r=n+1,a=++i}for(;r<t.length&&"*"===t[r];)r++;return r===t.length}return a.debug=a,a.default=a,a.coerce=function(e){return e instanceof Error?e.stack||e.message:e},a.disable=function(){let e=[...a.names,...a.skips.map(e=>"-"+e)].join(",");return a.enable(""),e},a.enable=function(e){for(let t of(a.save(e),a.namespaces=e,a.names=[],a.skips=[],("string"==typeof e?e:"").trim().replace(/\s+/g,",").split(",").filter(Boolean)))"-"===t[0]?a.skips.push(t.slice(1)):a.names.push(t)},a.enabled=function(e){for(let t of a.skips)if(n(e,t))return!1;for(let t of a.names)if(n(e,t))return!0;return!1},a.humanize=e.r(76775),a.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(t).forEach(e=>{a[e]=t[e]}),a.names=[],a.skips=[],a.formatters={},a.selectColor=function(e){let t=0;for(let a=0;a<e.length;a++)t=(t<<5)-t+e.charCodeAt(a)|0;return a.colors[Math.abs(t)%a.colors.length]},a.enable(a.load()),a}},48450,(e,t,a)=>{let r;var n=e.i(47167);a.formatArgs=function(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;let a="color: "+this.color;e.splice(1,0,a,"color: inherit");let r=0,n=0;e[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(r++,"%c"===e&&(n=r))}),e.splice(n,0,a)},a.save=function(e){try{e?a.storage.setItem("debug",e):a.storage.removeItem("debug")}catch(e){}},a.load=function(){let e;try{e=a.storage.getItem("debug")||a.storage.getItem("DEBUG")}catch(e){}return!e&&void 0!==n.default&&"env"in n.default&&(e=n.default.env.DEBUG),e},a.useColors=function(){let e;return"u">typeof window&&!!window.process&&("renderer"===window.process.type||!!window.process.__nwjs)||!("u">typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("u">typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"u">typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"u">typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"u">typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},a.storage=function(){try{return localStorage}catch(e){}}(),r=!1,a.destroy=()=>{r||(r=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))},a.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],a.log=console.debug||console.log||(()=>{}),t.exports=e.r(7003)(a);let{formatters:i}=t.exports;i.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},28903,e=>{e.v({ButtonLabel:"LoadDemoButton-module__kGZaoW__ButtonLabel "+e.i(65883).ButtonLabel,DemoIcon:"LoadDemoButton-module__kGZaoW__DemoIcon",Root:"LoadDemoButton-module__kGZaoW__Root "+e.i(65883).IconButton+" "+e.i(65883).LabelledButton})},29418,e=>{e.v({Bottom:"PlayerNameplate-module__zYDm0a__Bottom PlayerNameplate-module__zYDm0a__Root",HealthBar:"PlayerNameplate-module__zYDm0a__HealthBar",HealthFill:"PlayerNameplate-module__zYDm0a__HealthFill",IffArrow:"PlayerNameplate-module__zYDm0a__IffArrow",Name:"PlayerNameplate-module__zYDm0a__Name",Root:"PlayerNameplate-module__zYDm0a__Root",Top:"PlayerNameplate-module__zYDm0a__Top PlayerNameplate-module__zYDm0a__Root"})},78779,e=>{e.v({Distance:"FlagMarker-module__INpLba__Distance",Icon:"FlagMarker-module__INpLba__Icon",Root:"FlagMarker-module__INpLba__Root"})},21629,e=>{e.v({PlayPause:"DemoControls-module__PjV4fq__PlayPause",Root:"DemoControls-module__PjV4fq__Root",Seek:"DemoControls-module__PjV4fq__Seek",Speed:"DemoControls-module__PjV4fq__Speed",Time:"DemoControls-module__PjV4fq__Time"})},75840,e=>{e.v({BarFillEnergy:"PlayerHUD-module__-E1Scq__BarFillEnergy",BarFillHealth:"PlayerHUD-module__-E1Scq__BarFillHealth",BarTrack:"PlayerHUD-module__-E1Scq__BarTrack",Bars:"PlayerHUD-module__-E1Scq__Bars",ChatColor0:"PlayerHUD-module__-E1Scq__ChatColor0",ChatColor1:"PlayerHUD-module__-E1Scq__ChatColor1",ChatColor2:"PlayerHUD-module__-E1Scq__ChatColor2",ChatColor3:"PlayerHUD-module__-E1Scq__ChatColor3",ChatColor4:"PlayerHUD-module__-E1Scq__ChatColor4",ChatColor5:"PlayerHUD-module__-E1Scq__ChatColor5",ChatColor6:"PlayerHUD-module__-E1Scq__ChatColor6",ChatColor7:"PlayerHUD-module__-E1Scq__ChatColor7",ChatColor8:"PlayerHUD-module__-E1Scq__ChatColor8",ChatColor9:"PlayerHUD-module__-E1Scq__ChatColor9",ChatMessage:"PlayerHUD-module__-E1Scq__ChatMessage",ChatWindow:"PlayerHUD-module__-E1Scq__ChatWindow",Compass:"PlayerHUD-module__-E1Scq__Compass",CompassNSEW:"PlayerHUD-module__-E1Scq__CompassNSEW",CompassRing:"PlayerHUD-module__-E1Scq__CompassRing",PackInvCount:"PlayerHUD-module__-E1Scq__PackInvCount",PackInvIcon:"PlayerHUD-module__-E1Scq__PackInvIcon",PackInvInfinity:"PlayerHUD-module__-E1Scq__PackInvInfinity",PackInvItem:"PlayerHUD-module__-E1Scq__PackInvItem",PackInvItemActive:"PlayerHUD-module__-E1Scq__PackInvItemActive",PackInvItemDim:"PlayerHUD-module__-E1Scq__PackInvItemDim",PackInventoryHUD:"PlayerHUD-module__-E1Scq__PackInventoryHUD",PlayerHUD:"PlayerHUD-module__-E1Scq__PlayerHUD",Reticle:"PlayerHUD-module__-E1Scq__Reticle",ReticleDot:"PlayerHUD-module__-E1Scq__ReticleDot",ReticleImage:"PlayerHUD-module__-E1Scq__ReticleImage",TeamCount:"PlayerHUD-module__-E1Scq__TeamCount",TeamNameEnemy:"PlayerHUD-module__-E1Scq__TeamNameEnemy",TeamNameFriendly:"PlayerHUD-module__-E1Scq__TeamNameFriendly",TeamRow:"PlayerHUD-module__-E1Scq__TeamRow",TeamScore:"PlayerHUD-module__-E1Scq__TeamScore",TeamScores:"PlayerHUD-module__-E1Scq__TeamScores",TopRight:"PlayerHUD-module__-E1Scq__TopRight",WeaponHUD:"PlayerHUD-module__-E1Scq__WeaponHUD",WeaponSeparator:"PlayerHUD-module__-E1Scq__WeaponSeparator"})},3011,e=>{e.v({CanvasContainer:"page-module__E0kJGG__CanvasContainer",LoadingIndicator:"page-module__E0kJGG__LoadingIndicator",Progress:"page-module__E0kJGG__Progress",ProgressBar:"page-module__E0kJGG__ProgressBar",ProgressText:"page-module__E0kJGG__ProgressText",Spinner:"page-module__E0kJGG__Spinner",loadingComplete:"page-module__E0kJGG__loadingComplete",spin:"page-module__E0kJGG__spin"})},31713,e=>{"use strict";var t,a=e.i(43476),r=e.i(932),n=e.i(71645),i=e.i(75056),o=e.i(90072),s=e.i(66027),l=e.i(54970),c=e.i(12979),d=e.i(32424),u=e.i(71753),h=e.i(15080),m=e.i(62395),f=e.i(75567),g=e.i(47071);let p={value:!0},y=`
|
||
vec3 terrainLinearToSRGB(vec3 linear) {
|
||
vec3 higher = pow(linear, vec3(1.0/2.4)) * 1.055 - 0.055;
|
||
vec3 lower = linear * 12.92;
|
||
return mix(lower, higher, step(vec3(0.0031308), linear));
|
||
}
|
||
|
||
vec3 terrainSRGBToLinear(vec3 srgb) {
|
||
vec3 higher = pow((srgb + 0.055) / 1.055, vec3(2.4));
|
||
vec3 lower = srgb / 12.92;
|
||
return mix(lower, higher, step(vec3(0.04045), srgb));
|
||
}
|
||
|
||
// Debug grid overlay using screen-space derivatives for sharp, anti-aliased lines
|
||
// Returns 1.0 on grid lines, 0.0 elsewhere
|
||
float terrainDebugGrid(vec2 uv, float gridSize, float lineWidth) {
|
||
vec2 scaledUV = uv * gridSize;
|
||
vec2 grid = abs(fract(scaledUV - 0.5) - 0.5) / fwidth(scaledUV);
|
||
float line = min(grid.x, grid.y);
|
||
return 1.0 - min(line / lineWidth, 1.0);
|
||
}
|
||
`;var v=e.i(79123),F=e.i(47021),b=e.i(48066);let S={0:32,1:32,2:32,3:32,4:32,5:32};function x({displacementMap:e,visibilityMask:t,textureNames:r,alphaTextures:i,detailTextureName:s,lightmap:l}){let{debugMode:d}=(0,v.useDebug)(),u=(0,g.useTexture)(r.map(e=>(0,c.terrainTextureToUrl)(e)),e=>{e.forEach(e=>(0,f.setupTexture)(e))}),h=s?(0,c.textureToUrl)(s):null,m=(0,g.useTexture)(h??c.FALLBACK_TEXTURE_URL,e=>{(0,f.setupTexture)(e)}),x=(0,n.useCallback)(e=>{!function({shader:e,baseTextures:t,alphaTextures:a,visibilityMask:r,tiling:n,detailTexture:i=null,lightmap:o=null}){e.uniforms.sunLightPointsDown=p;let s=t.length;if(t.forEach((t,a)=>{e.uniforms[`albedo${a}`]={value:t}}),a.forEach((t,a)=>{e.uniforms[`mask${a}`]={value:t}}),r&&(e.uniforms.visibilityMask={value:r}),t.forEach((t,a)=>{e.uniforms[`tiling${a}`]={value:n[a]??32}}),o&&(e.uniforms.terrainLightmap={value:o}),i&&(e.uniforms.detailTexture={value:i},e.uniforms.detailTiling={value:64},e.uniforms.detailFadeDistance={value:150},e.vertexShader=e.vertexShader.replace("#include <common>",`#include <common>
|
||
varying vec3 vTerrainWorldPos;`),e.vertexShader=e.vertexShader.replace("#include <worldpos_vertex>",`#include <worldpos_vertex>
|
||
vTerrainWorldPos = (modelMatrix * vec4(transformed, 1.0)).xyz;`)),e.fragmentShader=`
|
||
uniform sampler2D albedo0;
|
||
uniform sampler2D albedo1;
|
||
uniform sampler2D albedo2;
|
||
uniform sampler2D albedo3;
|
||
uniform sampler2D albedo4;
|
||
uniform sampler2D albedo5;
|
||
uniform sampler2D mask0;
|
||
uniform sampler2D mask1;
|
||
uniform sampler2D mask2;
|
||
uniform sampler2D mask3;
|
||
uniform sampler2D mask4;
|
||
uniform sampler2D mask5;
|
||
uniform float tiling0;
|
||
uniform float tiling1;
|
||
uniform float tiling2;
|
||
uniform float tiling3;
|
||
uniform float tiling4;
|
||
uniform float tiling5;
|
||
${r?"uniform sampler2D visibilityMask;":""}
|
||
${o?"uniform sampler2D terrainLightmap;":""}
|
||
uniform bool sunLightPointsDown;
|
||
${i?`uniform sampler2D detailTexture;
|
||
uniform float detailTiling;
|
||
uniform float detailFadeDistance;
|
||
varying vec3 vTerrainWorldPos;`:""}
|
||
|
||
${y}
|
||
|
||
// Global variable to store shadow factor from RE_Direct for use in output calculation
|
||
float terrainShadowFactor = 1.0;
|
||
`+e.fragmentShader,r){let t="#include <clipping_planes_fragment>";e.fragmentShader=e.fragmentShader.replace(t,`${t}
|
||
// Early discard for invisible areas (before fog/lighting)
|
||
float visibility = texture2D(visibilityMask, vMapUv).r;
|
||
if (visibility < 0.5) {
|
||
discard;
|
||
}
|
||
`)}e.fragmentShader=e.fragmentShader.replace("#include <map_fragment>",`
|
||
// Sample base albedo layers (sRGB textures auto-decoded to linear by Three.js)
|
||
vec2 baseUv = vMapUv;
|
||
vec3 c0 = texture2D(albedo0, baseUv * vec2(tiling0)).rgb;
|
||
${s>1?"vec3 c1 = texture2D(albedo1, baseUv * vec2(tiling1)).rgb;":""}
|
||
${s>2?"vec3 c2 = texture2D(albedo2, baseUv * vec2(tiling2)).rgb;":""}
|
||
${s>3?"vec3 c3 = texture2D(albedo3, baseUv * vec2(tiling3)).rgb;":""}
|
||
${s>4?"vec3 c4 = texture2D(albedo4, baseUv * vec2(tiling4)).rgb;":""}
|
||
${s>5?"vec3 c5 = texture2D(albedo5, baseUv * vec2(tiling5)).rgb;":""}
|
||
|
||
// Sample alpha masks for all layers (use R channel)
|
||
// Add +0.5 texel offset: Torque samples alpha at grid corners (integer indices),
|
||
// but GPU linear filtering samples at texel centers. This offset aligns them.
|
||
vec2 alphaUv = baseUv + vec2(0.5 / 256.0);
|
||
float a0 = texture2D(mask0, alphaUv).r;
|
||
${s>1?"float a1 = texture2D(mask1, alphaUv).r;":""}
|
||
${s>2?"float a2 = texture2D(mask2, alphaUv).r;":""}
|
||
${s>3?"float a3 = texture2D(mask3, alphaUv).r;":""}
|
||
${s>4?"float a4 = texture2D(mask4, alphaUv).r;":""}
|
||
${s>5?"float a5 = texture2D(mask5, alphaUv).r;":""}
|
||
|
||
// Torque-style additive weighted blending (blender.cc):
|
||
// result = tex0 * alpha0 + tex1 * alpha1 + tex2 * alpha2 + ...
|
||
// Each layer's alpha map defines its contribution weight.
|
||
vec3 blended = c0 * a0;
|
||
${s>1?"blended += c1 * a1;":""}
|
||
${s>2?"blended += c2 * a2;":""}
|
||
${s>3?"blended += c3 * a3;":""}
|
||
${s>4?"blended += c4 * a4;":""}
|
||
${s>5?"blended += c5 * a5;":""}
|
||
|
||
// Assign to diffuseColor before lighting
|
||
vec3 textureColor = blended;
|
||
|
||
${i?`// Detail texture blending (Torque-style multiplicative blend)
|
||
// Sample detail texture at high frequency tiling
|
||
vec3 detailColor = texture2D(detailTexture, baseUv * detailTiling).rgb;
|
||
|
||
// Calculate distance-based fade factor using world positions
|
||
// Torque: distFactor = (zeroDetailDistance - distance) / zeroDetailDistance
|
||
float distToCamera = distance(vTerrainWorldPos, cameraPosition);
|
||
float detailFade = clamp(1.0 - distToCamera / detailFadeDistance, 0.0, 1.0);
|
||
|
||
// Torque blending: dst * lerp(1.0, detailTexel, fadeFactor)
|
||
// Detail textures are authored with bright values (~0.8 mean), not 0.5 gray
|
||
// Direct multiplication adds subtle darkening for surface detail
|
||
textureColor *= mix(vec3(1.0), detailColor, detailFade);`:""}
|
||
|
||
// Store blended texture in diffuseColor (still in linear space here)
|
||
// We'll convert to sRGB in the output calculation
|
||
diffuseColor.rgb = textureColor;
|
||
`),o&&(e.fragmentShader=e.fragmentShader.replace("#include <lights_lambert_pars_fragment>",`#include <lights_lambert_pars_fragment>
|
||
|
||
// Override RE_Direct to extract shadow factor for Torque-style gamma-space lighting
|
||
#undef RE_Direct
|
||
void RE_Direct_TerrainShadow( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
|
||
// Torque lighting (terrLighting.cc): if light points up, terrain gets only ambient
|
||
// This prevents shadow acne from light hitting terrain backfaces
|
||
if (!sunLightPointsDown) {
|
||
terrainShadowFactor = 0.0;
|
||
return;
|
||
}
|
||
// directLight.color = sunColor * shadowFactor (shadow already applied by Three.js)
|
||
// Extract shadow factor by comparing to original sun color
|
||
#if ( NUM_DIR_LIGHTS > 0 )
|
||
vec3 originalSunColor = directionalLights[0].color;
|
||
float sunMax = max(max(originalSunColor.r, originalSunColor.g), originalSunColor.b);
|
||
float shadowedMax = max(max(directLight.color.r, directLight.color.g), directLight.color.b);
|
||
terrainShadowFactor = clamp(shadowedMax / max(sunMax, 0.001), 0.0, 1.0);
|
||
#endif
|
||
// Don't add to reflectedLight - we'll compute lighting in gamma space at output
|
||
}
|
||
#define RE_Direct RE_Direct_TerrainShadow
|
||
|
||
`),e.fragmentShader=e.fragmentShader.replace("#include <lights_fragment_begin>",`#include <lights_fragment_begin>
|
||
// Clear indirect diffuse - we'll compute ambient in gamma space
|
||
#if defined( RE_IndirectDiffuse )
|
||
irradiance = vec3(0.0);
|
||
#endif
|
||
`),e.fragmentShader=e.fragmentShader.replace("#include <lights_fragment_end>",`#include <lights_fragment_end>
|
||
// Clear Three.js lighting - we compute everything in gamma space
|
||
reflectedLight.directDiffuse = vec3(0.0);
|
||
reflectedLight.indirectDiffuse = vec3(0.0);
|
||
`)),e.fragmentShader=e.fragmentShader.replace("#include <opaque_fragment>",`// Torque-style terrain lighting: output = clamp(lighting \xd7 texture, 0, 1) in sRGB space
|
||
{
|
||
// Get texture in sRGB space (undo Three.js linear decode)
|
||
vec3 textureSRGB = terrainLinearToSRGB(diffuseColor.rgb);
|
||
|
||
${o?`
|
||
// Sample terrain lightmap for smooth NdotL
|
||
vec2 lightmapUv = vMapUv + vec2(0.5 / 512.0);
|
||
float lightmapNdotL = texture2D(terrainLightmap, lightmapUv).r;
|
||
|
||
// Get sun and ambient colors from Three.js lights (these ARE sRGB values from mission file)
|
||
// Three.js interprets them as linear, but the numerical values are preserved
|
||
#if ( NUM_DIR_LIGHTS > 0 )
|
||
vec3 sunColorSRGB = directionalLights[0].color;
|
||
#else
|
||
vec3 sunColorSRGB = vec3(0.7);
|
||
#endif
|
||
vec3 ambientColorSRGB = ambientLightColor;
|
||
|
||
// Torque formula (terrLighting.cc:471-483):
|
||
// lighting = ambient + NdotL * shadowFactor * sunColor
|
||
// Clamp lighting to [0,1] before multiplying by texture
|
||
vec3 lightingSRGB = clamp(ambientColorSRGB + lightmapNdotL * terrainShadowFactor * sunColorSRGB, 0.0, 1.0);
|
||
`:`
|
||
// No lightmap - use simple ambient lighting
|
||
vec3 lightingSRGB = ambientLightColor;
|
||
`}
|
||
|
||
// Torque formula: output = clamp(lighting \xd7 texture, 0, 1) in sRGB/gamma space
|
||
vec3 resultSRGB = clamp(lightingSRGB * textureSRGB, 0.0, 1.0);
|
||
|
||
// Convert back to linear for Three.js output pipeline
|
||
outgoingLight = terrainSRGBToLinear(resultSRGB) + totalEmissiveRadiance;
|
||
}
|
||
#include <opaque_fragment>`),e.fragmentShader=e.fragmentShader.replace("#include <tonemapping_fragment>",`#if DEBUG_MODE
|
||
// Debug mode: overlay green grid matching terrain grid squares (256x256)
|
||
float gridIntensity = terrainDebugGrid(vMapUv, 256.0, 1.5);
|
||
vec3 gridColor = vec3(0.0, 0.8, 0.4); // Green
|
||
gl_FragColor.rgb = mix(gl_FragColor.rgb, gridColor, gridIntensity * 0.1);
|
||
#endif
|
||
|
||
#include <tonemapping_fragment>`)}({shader:e,baseTextures:u,alphaTextures:i,visibilityMask:t,tiling:S,detailTexture:h?m:null,lightmap:l}),(0,F.injectCustomFog)(e,b.globalFogUniforms)},[u,i,t,m,h,l]),k=(0,n.useRef)(null);(0,n.useEffect)(()=>{let e=k.current;e&&(e.defines??={},e.defines.DEBUG_MODE=+!!d,e.needsUpdate=!0)},[d]);let w=`${h?"detail":"nodetail"}-${l?"lightmap":"nolightmap"}`;return(0,a.jsx)("meshLambertMaterial",{ref:k,map:e,depthWrite:!0,side:o.FrontSide,defines:{DEBUG_MODE:+!!d},onBeforeCompile:x},w)}function k(e){let t,i,o=(0,r.c)(8),{displacementMap:s,visibilityMask:l,textureNames:c,alphaTextures:d,detailTextureName:u,lightmap:h}=e;return o[0]===Symbol.for("react.memo_cache_sentinel")?(t=(0,a.jsx)("meshLambertMaterial",{color:"rgb(0, 109, 56)",wireframe:!0}),o[0]=t):t=o[0],o[1]!==d||o[2]!==u||o[3]!==s||o[4]!==h||o[5]!==c||o[6]!==l?(i=(0,a.jsx)(n.Suspense,{fallback:t,children:(0,a.jsx)(x,{displacementMap:s,visibilityMask:l,textureNames:c,alphaTextures:d,detailTextureName:u,lightmap:h})}),o[1]=d,o[2]=u,o[3]=s,o[4]=h,o[5]=c,o[6]=l,o[7]=i):i=o[7],i}let w=(0,n.memo)(function(e){let t,n,i,o=(0,r.c)(15),{tileX:s,tileZ:l,blockSize:c,basePosition:d,textureNames:u,geometry:h,displacementMap:m,visibilityMask:f,alphaTextures:g,detailTextureName:p,lightmap:y,visible:v}=e,F=void 0===v||v,b=c/2,S=d.x+s*c+b,x=d.z+l*c+b;o[0]!==S||o[1]!==x?(t=[S,0,x],o[0]=S,o[1]=x,o[2]=t):t=o[2];let w=t;return o[3]!==g||o[4]!==p||o[5]!==m||o[6]!==y||o[7]!==u||o[8]!==f?(n=(0,a.jsx)(k,{displacementMap:m,visibilityMask:f,textureNames:u,alphaTextures:g,detailTextureName:p,lightmap:y}),o[3]=g,o[4]=p,o[5]=m,o[6]=y,o[7]=u,o[8]=f,o[9]=n):n=o[9],o[10]!==h||o[11]!==w||o[12]!==n||o[13]!==F?(i=(0,a.jsx)("mesh",{position:w,geometry:h,castShadow:!0,receiveShadow:!0,visible:F,children:n}),o[10]=h,o[11]=w,o[12]=n,o[13]=F,o[14]=i):i=o[14],i});e.i(13876);var I=e.i(58647);function C(e){return(0,I.useRuntimeObjectByName)(e)}let _=null;function P(e){let t=new Uint8Array(65536);for(let a of(t.fill(255),e)){let e=255&a,r=a>>8&255,n=a>>16,i=256*r;for(let a=0;a<n;a++){let r=i+e+a;r<t.length&&(t[r]=0)}}let a=new o.DataTexture(t,256,256,o.RedFormat,o.UnsignedByteType);return a.colorSpace=o.NoColorSpace,a.wrapS=a.wrapT=o.ClampToEdgeWrapping,a.magFilter=o.NearestFilter,a.minFilter=o.NearestFilter,a.needsUpdate=!0,a}let D=(0,n.memo)(function(e){let t,i,l,d,f,g,p,y,v,F,b,S,x,k,I,D,N,A,G,U,L,z,O,V=(0,r.c)(73),{object:q}=e;V[0]!==q?(t=(0,m.getProperty)(q,"terrainFile"),V[0]=q,V[1]=t):t=V[1];let H=t;V[2]!==q?(i=(0,m.getInt)(q,"squareSize")??8,V[2]=q,V[3]=i):i=V[3];let W=i;V[4]!==q?(l=(0,m.getProperty)(q,"detailTexture"),V[4]=q,V[5]=l):l=V[5];let $=l,Y=256*W,K=function(){let e,t=(0,r.c)(2),a=C("Sky");if(!a)return 600;let n=(0,m.getFloat)(a,"high_visibleDistance");return null!=n&&n>0?n:(t[0]!==a?(e=(0,m.getFloat)(a,"visibleDistance")??600,t[0]=a,t[1]=e):e=t[1],e)}(),X=(0,h.useThree)(M),Z=-(128*W);V[6]!==Z?(d={x:Z,z:Z},V[6]=Z,V[7]=d):d=V[7];let J=d;if(V[8]!==q){let e=(0,m.getProperty)(q,"emptySquares");f=e?e.split(" ").map(T):[],V[8]=q,V[9]=f}else f=V[9];let Q=f,{data:ee}=((O=(0,r.c)(2))[0]!==H?(z={queryKey:["terrain",H],queryFn:()=>(0,c.loadTerrain)(H)},O[0]=H,O[1]=z):z=O[1],(0,s.useQuery)(z));e:{let e;if(!ee){g=null;break e}let t=256*W;V[10]!==t||V[11]!==W||V[12]!==ee.heightMap?(!function(e,t,a){let r=e.attributes.position,n=e.attributes.uv,i=e.attributes.normal,o=r.array,s=n.array,l=i.array,c=r.count,d=(e,a)=>(e=Math.max(0,Math.min(255,e)),t[256*(a=Math.max(0,Math.min(255,a)))+e]/65535*2048),u=(e,a)=>{let r=Math.floor(e=Math.max(0,Math.min(255,e))),n=Math.floor(a=Math.max(0,Math.min(255,a))),i=Math.min(r+1,255),o=Math.min(n+1,255),s=e-r,l=a-n;return(t[256*n+r]/65535*2048*(1-s)+t[256*n+i]/65535*2048*s)*(1-l)+(t[256*o+r]/65535*2048*(1-s)+t[256*o+i]/65535*2048*s)*l};for(let e=0;e<c;e++){let t=s[2*e],r=s[2*e+1],n=d(255&Math.floor(256*t),255&Math.floor(256*r));o[3*e+1]=n;let i=255*t,c=255*r,h=u(i-1,c),m=u(i+1,c),f=(u(i,c+1)-u(i,c-1))/2,g=a,p=(m-h)/2,y=Math.sqrt(f*f+g*g+p*p);y>0?(f/=y,g/=y,p/=y):(f=0,g=1,p=0),l[3*e]=f,l[3*e+1]=g,l[3*e+2]=p}r.needsUpdate=!0,i.needsUpdate=!0}(e=function(e,t){let a=new o.BufferGeometry,r=new Float32Array(198147),n=new Float32Array(198147),i=new Float32Array(132098),s=new Uint32Array(393216),l=0,c=e/256;for(let t=0;t<=256;t++)for(let a=0;a<=256;a++){let o=257*t+a;r[3*o]=a*c-e/2,r[3*o+1]=e/2-t*c,r[3*o+2]=0,n[3*o]=0,n[3*o+1]=0,n[3*o+2]=1,i[2*o]=a/256,i[2*o+1]=1-t/256}for(let e=0;e<256;e++)for(let t=0;t<256;t++){let a=257*e+t,r=a+1,n=(e+1)*257+t,i=n+1;((t^e)&1)==0?(s[l++]=a,s[l++]=n,s[l++]=i,s[l++]=a,s[l++]=i,s[l++]=r):(s[l++]=a,s[l++]=n,s[l++]=r,s[l++]=r,s[l++]=n,s[l++]=i)}return a.setIndex(new o.BufferAttribute(s,1)),a.setAttribute("position",new o.Float32BufferAttribute(r,3)),a.setAttribute("normal",new o.Float32BufferAttribute(n,3)),a.setAttribute("uv",new o.Float32BufferAttribute(i,2)),a.rotateX(-Math.PI/2),a.rotateY(-Math.PI/2),a}(t,0),ee.heightMap,W),V[10]=t,V[11]=W,V[12]=ee.heightMap,V[13]=e):e=V[13],g=e}let et=g;V[14]!==W||V[15]!==ee?(p=()=>{if(ee){var e;return e=ee.heightMap,_=(t,a)=>{let r=Math.max(0,Math.min(255,a/W+128)),n=Math.max(0,Math.min(255,t/W+128)),i=Math.floor(r),o=Math.floor(n),s=Math.min(i+1,255),l=Math.min(o+1,255),c=r-i,d=n-o;return((e[256*o+i]*(1-c)+e[256*o+s]*c)*(1-d)+(e[256*l+i]*(1-c)+e[256*l+s]*c)*d)/65535*2048},E}},y=[ee,W],V[14]=W,V[15]=ee,V[16]=p,V[17]=y):(p=V[16],y=V[17]),(0,n.useEffect)(p,y);let ea=C("Sun");t:{let e,t;if(!ea){let e;V[18]===Symbol.for("react.memo_cache_sentinel")?(e=new o.Vector3(.57735,-.57735,.57735),V[18]=e):e=V[18],v=e;break t}V[19]!==ea?(e=((0,m.getProperty)(ea,"direction")??"0.57735 0.57735 -0.57735").split(" ").map(B),V[19]=ea,V[20]=e):e=V[20];let[a,r,n]=e,i=Math.sqrt(a*a+n*n+r*r),s=a/i,l=n/i,c=r/i;V[21]!==s||V[22]!==l||V[23]!==c?(t=new o.Vector3(s,l,c),V[21]=s,V[22]=l,V[23]=c,V[24]=t):t=V[24],v=t}let er=v;a:{let e;if(!ee){F=null;break a}V[25]!==W||V[26]!==er||V[27]!==ee.heightMap?(e=function(e,t,a){let r=(t,a)=>{let r=Math.max(0,Math.min(255,t)),n=Math.max(0,Math.min(255,a)),i=Math.floor(r),o=Math.floor(n),s=Math.min(i+1,255),l=Math.min(o+1,255),c=r-i,d=n-o;return((e[256*o+i]/65535*(1-c)+e[256*o+s]/65535*c)*(1-d)+(e[256*l+i]/65535*(1-c)+e[256*l+s]/65535*c)*d)*2048},n=new o.Vector3(-t.x,-t.y,-t.z).normalize(),i=new Uint8Array(262144);for(let e=0;e<512;e++)for(let t=0;t<512;t++){let o=t/2+.25,s=e/2+.25,l=r(o,s),c=r(o-.5,s),d=r(o+.5,s),u=r(o,s-.5),h=-((r(o,s+.5)-u)/1),m=-((d-c)/1),f=Math.sqrt(h*h+a*a+m*m),g=Math.max(0,h/f*n.x+a/f*n.y+m/f*n.z),p=1;g>0&&(p=function(e,t,a,r,n,i){let o=r.z/n,s=r.x/n,l=r.y,c=Math.sqrt(o*o+s*s);if(c<1e-4)return 1;let d=.5/c,u=o*d,h=s*d,m=l*d,f=e,g=t,p=a+.1;for(let e=0;e<768&&(f+=u,g+=h,p+=m,!(f<0)&&!(f>=256)&&!(g<0)&&!(g>=256)&&!(p>2048));e++)if(p<i(f,g))return 0;return 1}(o,s,l,n,a,r)),i[512*e+t]=Math.floor(g*p*255)}let s=new o.DataTexture(i,512,512,o.RedFormat,o.UnsignedByteType);return s.colorSpace=o.NoColorSpace,s.generateMipmaps=!0,s.wrapS=o.ClampToEdgeWrapping,s.wrapT=o.ClampToEdgeWrapping,s.magFilter=o.LinearFilter,s.minFilter=o.LinearFilter,s.needsUpdate=!0,s}(ee.heightMap,er,W),V[25]=W,V[26]=er,V[27]=ee.heightMap,V[28]=e):e=V[28],F=e}let en=F;r:{let e;if(!ee){b=null;break r}if(V[29]!==ee.heightMap){let t=function(e){let t=new Float32Array(e.length);for(let a=0;a<e.length;a++)t[a]=e[a]/65535;return t}(ee.heightMap);(e=new o.DataTexture(t,256,256,o.RedFormat,o.FloatType)).colorSpace=o.NoColorSpace,e.generateMipmaps=!1,e.wrapS=o.RepeatWrapping,e.wrapT=o.RepeatWrapping,e.needsUpdate=!0,V[29]=ee.heightMap,V[30]=e}else e=V[30];b=e}let ei=b;V[31]!==Q?(S=P(Q),V[31]=Q,V[32]=S):S=V[32];let eo=S;V[33]===Symbol.for("react.memo_cache_sentinel")?(x=P([]),V[33]=x):x=V[33];let es=x;n:{let e;if(!ee){k=null;break n}V[34]!==ee.alphaMaps?(e=ee.alphaMaps.map(j),V[34]=ee.alphaMaps,V[35]=e):e=V[35],k=e}let el=k,ec=2*Math.ceil(K/Y)+1,ed=ec*ec-1;V[36]!==ed?(I=Array.from({length:ed},R),V[36]=ed,V[37]=I):I=V[37];let eu=I;V[38]!==ed?(D=()=>Array(ed).fill(null),V[38]=ed,V[39]=D):D=V[39];let[eh,em]=(0,n.useState)(D);V[40]===Symbol.for("react.memo_cache_sentinel")?(N={xStart:0,xEnd:0,zStart:0,zEnd:0},V[40]=N):N=V[40];let ef=(0,n.useRef)(N);return(V[41]!==J.x||V[42]!==J.z||V[43]!==Y||V[44]!==X.position.x||V[45]!==X.position.z||V[46]!==ed||V[47]!==K?(A=()=>{let e=X.position.x-J.x,t=X.position.z-J.z,a=Math.floor((e-K)/Y),r=Math.ceil((e+K)/Y),n=Math.floor((t-K)/Y),i=Math.ceil((t+K)/Y),o=ef.current;if(a===o.xStart&&r===o.xEnd&&n===o.zStart&&i===o.zEnd)return;o.xStart=a,o.xEnd=r,o.zStart=n,o.zEnd=i;let s=[];for(let e=a;e<r;e++)for(let t=n;t<i;t++)(0!==e||0!==t)&&s.push({tileX:e,tileZ:t});for(;s.length<ed;)s.push(null);em(s)},V[41]=J.x,V[42]=J.z,V[43]=Y,V[44]=X.position.x,V[45]=X.position.z,V[46]=ed,V[47]=K,V[48]=A):A=V[48],(0,u.useFrame)(A),ee&&et&&ei&&el)?(V[49]!==J||V[50]!==Y||V[51]!==$||V[52]!==eo||V[53]!==el||V[54]!==ei||V[55]!==et||V[56]!==ee.textureNames||V[57]!==en?(G=(0,a.jsx)(w,{tileX:0,tileZ:0,blockSize:Y,basePosition:J,textureNames:ee.textureNames,geometry:et,displacementMap:ei,visibilityMask:eo,alphaTextures:el,detailTextureName:$,lightmap:en}),V[49]=J,V[50]=Y,V[51]=$,V[52]=eo,V[53]=el,V[54]=ei,V[55]=et,V[56]=ee.textureNames,V[57]=en,V[58]=G):G=V[58],V[59]!==J||V[60]!==Y||V[61]!==$||V[62]!==eu||V[63]!==el||V[64]!==ei||V[65]!==et||V[66]!==ee.textureNames||V[67]!==en||V[68]!==eh?(U=eu.map(e=>{let t=eh[e];return(0,a.jsx)(w,{tileX:t?.tileX??0,tileZ:t?.tileZ??0,blockSize:Y,basePosition:J,textureNames:ee.textureNames,geometry:et,displacementMap:ei,visibilityMask:es,alphaTextures:el,detailTextureName:$,lightmap:en,visible:null!==t},e)}),V[59]=J,V[60]=Y,V[61]=$,V[62]=eu,V[63]=el,V[64]=ei,V[65]=et,V[66]=ee.textureNames,V[67]=en,V[68]=eh,V[69]=U):U=V[69],V[70]!==G||V[71]!==U?(L=(0,a.jsxs)(a.Fragment,{children:[G,U]}),V[70]=G,V[71]=U,V[72]=L):L=V[72],L):null});function M(e){return e.camera}function T(e){return parseInt(e,10)}function E(){_=null}function B(e){return parseFloat(e)}function j(e){return(0,f.setupMask)(e)}function R(e,t){return t}let N=(0,n.createContext)(null);function A(){return(0,n.useContext)(N)}function G(e){return(0,a.jsx)(eM,{objectId:e},e)}var U=e.i(8597),L=e.i(78140),z=e.i(89887);let O=`
|
||
vec3 interiorLinearToSRGB(vec3 linear) {
|
||
vec3 higher = pow(linear, vec3(1.0/2.4)) * 1.055 - 0.055;
|
||
vec3 lower = linear * 12.92;
|
||
return mix(lower, higher, step(vec3(0.0031308), linear));
|
||
}
|
||
|
||
vec3 interiorSRGBToLinear(vec3 srgb) {
|
||
vec3 higher = pow((srgb + 0.055) / 1.055, vec3(2.4));
|
||
vec3 lower = srgb / 12.92;
|
||
return mix(lower, higher, step(vec3(0.04045), srgb));
|
||
}
|
||
|
||
// Debug grid overlay function using screen-space derivatives for sharp, anti-aliased lines
|
||
// Returns 1.0 on grid lines, 0.0 elsewhere
|
||
float debugGrid(vec2 uv, float gridSize, float lineWidth) {
|
||
vec2 scaledUV = uv * gridSize;
|
||
vec2 grid = abs(fract(scaledUV - 0.5) - 0.5) / fwidth(scaledUV);
|
||
float line = min(grid.x, grid.y);
|
||
return 1.0 - min(line / lineWidth, 1.0);
|
||
}
|
||
`;function V({materialName:e,material:t,lightMap:r}){let i=(0,v.useDebug)(),s=i?.debugMode??!1,l=(0,c.textureToUrl)(e),d=(0,g.useTexture)(l,e=>(0,f.setupTexture)(e)),u=new Set(t?.userData?.flag_names??[]).has("SelfIlluminating"),h=new Set(t?.userData?.surface_flag_names??[]).has("SurfaceOutsideVisible"),m=(0,n.useCallback)(e=>{let t;(0,F.injectCustomFog)(e,b.globalFogUniforms),t=h??!1,e.uniforms.useSceneLighting={value:t},e.uniforms.interiorDebugColor={value:t?new o.Vector3(0,.4,1):new o.Vector3(1,.2,0)},e.fragmentShader=e.fragmentShader.replace("#include <common>",`#include <common>
|
||
${O}
|
||
uniform bool useSceneLighting;
|
||
uniform vec3 interiorDebugColor;
|
||
`),e.fragmentShader=e.fragmentShader.replace("#include <lights_fragment_maps>",`// Lightmap handled in custom output calculation
|
||
#ifdef USE_LIGHTMAP
|
||
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
|
||
#endif`),e.fragmentShader=e.fragmentShader.replace("#include <opaque_fragment>",`// Torque-style lighting: output = clamp(lighting \xd7 texture, 0, 1) in sRGB space
|
||
// Get texture in sRGB space (undo Three.js linear decode)
|
||
vec3 textureSRGB = interiorLinearToSRGB(diffuseColor.rgb);
|
||
|
||
// Compute lighting in sRGB space
|
||
vec3 lightingSRGB = vec3(0.0);
|
||
|
||
if (useSceneLighting) {
|
||
// Three.js computed: reflectedLight = lighting \xd7 texture_linear / PI
|
||
// Extract pure lighting: lighting = reflectedLight \xd7 PI / texture_linear
|
||
vec3 totalLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
|
||
vec3 safeTexLinear = max(diffuseColor.rgb, vec3(0.001));
|
||
vec3 extractedLighting = totalLight * PI / safeTexLinear;
|
||
// NOTE: extractedLighting is ALREADY sRGB values because mission sun/ambient colors
|
||
// are sRGB values (Torque used them directly in gamma space). Three.js treats them
|
||
// as linear but the numerical values are the same. DO NOT convert to sRGB here!
|
||
// IMPORTANT: Torque clamps scene lighting to [0,1] BEFORE adding to lightmap
|
||
// (sceneLighting.cc line 1785: tmp.clamp())
|
||
lightingSRGB = clamp(extractedLighting, 0.0, 1.0);
|
||
}
|
||
|
||
// Add lightmap contribution (for BOTH outside and inside surfaces)
|
||
// In Torque, scene lighting is ADDED to lightmaps for outside surfaces at mission load
|
||
// (stored in .ml files). Inside surfaces only have base lightmap. Both need lightmap here.
|
||
#ifdef USE_LIGHTMAP
|
||
// Lightmap is stored as linear in Three.js (decoded from sRGB texture), convert back
|
||
lightingSRGB += interiorLinearToSRGB(lightMapTexel.rgb);
|
||
#endif
|
||
// Torque clamps the sum to [0,1] per channel (sceneLighting.cc lines 1817-1827)
|
||
lightingSRGB = clamp(lightingSRGB, 0.0, 1.0);
|
||
|
||
// Torque formula: output = clamp(lighting \xd7 texture, 0, 1) in sRGB/gamma space
|
||
vec3 resultSRGB = clamp(lightingSRGB * textureSRGB, 0.0, 1.0);
|
||
|
||
// Convert back to linear for Three.js output pipeline
|
||
vec3 resultLinear = interiorSRGBToLinear(resultSRGB);
|
||
|
||
// Reassign outgoingLight before opaque_fragment consumes it
|
||
outgoingLight = resultLinear + totalEmissiveRadiance;
|
||
|
||
#include <opaque_fragment>`),e.fragmentShader=e.fragmentShader.replace("#include <tonemapping_fragment>",`// Debug mode: overlay colored grid on top of normal rendering
|
||
// Blue grid = SurfaceOutsideVisible (receives scene ambient light)
|
||
// Red grid = inside surface (no scene ambient light)
|
||
#if DEBUG_MODE && defined(USE_MAP)
|
||
// gridSize=4 creates 4x4 grid per UV tile, lineWidth=1.5 is ~1.5 pixels wide
|
||
float gridIntensity = debugGrid(vMapUv, 4.0, 1.5);
|
||
gl_FragColor.rgb = mix(gl_FragColor.rgb, interiorDebugColor, gridIntensity * 0.1);
|
||
#endif
|
||
|
||
#include <tonemapping_fragment>`)},[h]),p=(0,n.useRef)(null),y=(0,n.useRef)(null);(0,n.useEffect)(()=>{let e=p.current??y.current;e&&(e.defines??={},e.defines.DEBUG_MODE=+!!s,e.needsUpdate=!0)},[s]);let S={DEBUG_MODE:+!!s},x=`${h}`;return u?(0,a.jsx)("meshBasicMaterial",{ref:p,map:d,toneMapped:!1,defines:S,onBeforeCompile:m},x):(0,a.jsx)("meshLambertMaterial",{ref:y,map:d,lightMap:r,toneMapped:!1,defines:S,onBeforeCompile:m},x)}function q(e){if(!e)return null;let t=e.emissiveMap;return t&&(t.colorSpace=o.SRGBColorSpace),t??null}function H(e){let t,i,o,s=(0,r.c)(13),{node:l}=e;e:{let e,a;if(!l.material){let e;s[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],s[0]=e):e=s[0],t=e;break e}if(Array.isArray(l.material)){let e;s[1]!==l.material?(e=l.material.map(W),s[1]=l.material,s[2]=e):e=s[2],t=e;break e}s[3]!==l.material?(e=q(l.material),s[3]=l.material,s[4]=e):e=s[4],s[5]!==e?(a=[e],s[5]=e,s[6]=a):a=s[6],t=a}let c=t;return s[7]!==c||s[8]!==l.material?(i=l.material?(0,a.jsx)(n.Suspense,{fallback:(0,a.jsx)("meshStandardMaterial",{color:"yellow",wireframe:!0}),children:Array.isArray(l.material)?l.material.map((e,t)=>(0,a.jsx)(V,{materialName:e.userData.resource_path,material:e,lightMap:c[t]},t)):(0,a.jsx)(V,{materialName:l.material.userData.resource_path,material:l.material,lightMap:c[0]})}):null,s[7]=c,s[8]=l.material,s[9]=i):i=s[9],s[10]!==l.geometry||s[11]!==i?(o=(0,a.jsx)("mesh",{geometry:l.geometry,castShadow:!0,receiveShadow:!0,children:i}),s[10]=l.geometry,s[11]=i,s[12]=o):o=s[12],o}function W(e){return q(e)}let $=(0,n.memo)(function(e){let t,n,i,o,s,l,d,u=(0,r.c)(10),{object:h,interiorFile:m}=e,{nodes:f}=((l=(0,r.c)(2))[0]!==m?(s=(0,c.interiorToUrl)(m),l[0]=m,l[1]=s):s=l[1],d=s,(0,L.useGLTF)(d)),g=(0,v.useDebug)(),p=g?.debugMode??!1;return u[0]===Symbol.for("react.memo_cache_sentinel")?(t=[0,-Math.PI/2,0],u[0]=t):t=u[0],u[1]!==f?(n=Object.entries(f).filter(Z).map(J),u[1]=f,u[2]=n):n=u[2],u[3]!==p||u[4]!==m||u[5]!==h?(i=p?(0,a.jsxs)(z.FloatingLabel,{children:[h._id,": ",m]}):null,u[3]=p,u[4]=m,u[5]=h,u[6]=i):i=u[6],u[7]!==n||u[8]!==i?(o=(0,a.jsxs)("group",{rotation:t,children:[n,i]}),u[7]=n,u[8]=i,u[9]=o):o=u[9],o});function Y(e){let t,n,i,o,s=(0,r.c)(9),{color:l,label:c}=e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(t=(0,a.jsx)("boxGeometry",{args:[10,10,10]}),s[0]=t):t=s[0],s[1]!==l?(n=(0,a.jsx)("meshStandardMaterial",{color:l,wireframe:!0}),s[1]=l,s[2]=n):n=s[2],s[3]!==l||s[4]!==c?(i=c?(0,a.jsx)(z.FloatingLabel,{color:l,children:c}):null,s[3]=l,s[4]=c,s[5]=i):i=s[5],s[6]!==n||s[7]!==i?(o=(0,a.jsxs)("mesh",{children:[t,n,i]}),s[6]=n,s[7]=i,s[8]=o):o=s[8],o}function K(e){let t,n=(0,r.c)(3),{label:i}=e,o=(0,v.useDebug)(),s=o?.debugMode??!1;return n[0]!==s||n[1]!==i?(t=s?(0,a.jsx)(Y,{color:"red",label:i}):null,n[0]=s,n[1]=i,n[2]=t):t=n[2],t}let X=(0,n.memo)(function(e){let t,i,o,s,l,c,d,u,h,f=(0,r.c)(22),{object:g}=e;f[0]!==g?(t=(0,m.getProperty)(g,"interiorFile"),f[0]=g,f[1]=t):t=f[1];let p=t;f[2]!==g?(i=(0,m.getPosition)(g),f[2]=g,f[3]=i):i=f[3];let y=i;f[4]!==g?(o=(0,m.getScale)(g),f[4]=g,f[5]=o):o=f[5];let v=o;f[6]!==g?(s=(0,m.getRotation)(g),f[6]=g,f[7]=s):s=f[7];let F=s,b=`${g._id}: ${p}`;return f[8]!==b?(l=(0,a.jsx)(K,{label:b}),f[8]=b,f[9]=l):l=f[9],f[10]===Symbol.for("react.memo_cache_sentinel")?(c=(0,a.jsx)(Y,{color:"orange"}),f[10]=c):c=f[10],f[11]!==p||f[12]!==g?(d=(0,a.jsx)(n.Suspense,{fallback:c,children:(0,a.jsx)($,{object:g,interiorFile:p})}),f[11]=p,f[12]=g,f[13]=d):d=f[13],f[14]!==l||f[15]!==d?(u=(0,a.jsx)(U.ErrorBoundary,{fallback:l,children:d}),f[14]=l,f[15]=d,f[16]=u):u=f[16],f[17]!==y||f[18]!==F||f[19]!==v||f[20]!==u?(h=(0,a.jsx)("group",{position:y,quaternion:F,scale:v,children:u}),f[17]=y,f[18]=F,f[19]=v,f[20]=u,f[21]=h):h=f[21],h});function Z(e){let[,t]=e;return t.isMesh}function J(e){let[t,r]=e;return(0,a.jsx)(H,{node:r},t)}var Q=e.i(99143);function ee(e,{path:t}){let[a]=(0,Q.useLoader)(o.CubeTextureLoader,[e],e=>e.setPath(t));return a}ee.preload=(e,{path:t})=>Q.useLoader.preload(o.CubeTextureLoader,[e],e=>e.setPath(t));let et=()=>{};function ea(e){return e.wrapS=o.RepeatWrapping,e.wrapT=o.RepeatWrapping,e.minFilter=o.LinearFilter,e.magFilter=o.LinearFilter,e.colorSpace=o.NoColorSpace,e.needsUpdate=!0,e}let er=`
|
||
attribute float alpha;
|
||
|
||
uniform vec2 uvOffset;
|
||
|
||
varying vec2 vUv;
|
||
varying float vAlpha;
|
||
|
||
void main() {
|
||
// Apply UV offset for scrolling
|
||
vUv = uv + uvOffset;
|
||
vAlpha = alpha;
|
||
|
||
vec4 pos = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
||
// Set depth to far plane so clouds are always visible and behind other geometry
|
||
gl_Position = pos.xyww;
|
||
}
|
||
`,en=`
|
||
uniform sampler2D cloudTexture;
|
||
uniform float debugMode;
|
||
uniform int layerIndex;
|
||
|
||
varying vec2 vUv;
|
||
varying float vAlpha;
|
||
|
||
// Debug grid using screen-space derivatives for sharp, anti-aliased lines
|
||
float debugGrid(vec2 uv, float gridSize, float lineWidth) {
|
||
vec2 scaledUV = uv * gridSize;
|
||
vec2 grid = abs(fract(scaledUV - 0.5) - 0.5) / fwidth(scaledUV);
|
||
float line = min(grid.x, grid.y);
|
||
return 1.0 - min(line / lineWidth, 1.0);
|
||
}
|
||
|
||
void main() {
|
||
vec4 texColor = texture2D(cloudTexture, vUv);
|
||
|
||
// Tribes 2 uses GL_MODULATE: final = texture \xd7 vertex color
|
||
// Vertex color is white with varying alpha, so:
|
||
// Final RGB = Texture RGB \xd7 1.0 = Texture RGB
|
||
// Final Alpha = Texture Alpha \xd7 Vertex Alpha
|
||
float finalAlpha = texColor.a * vAlpha;
|
||
vec3 color = texColor.rgb;
|
||
|
||
// Debug mode: overlay R/G/B grid for layers 0/1/2
|
||
if (debugMode > 0.5) {
|
||
float gridIntensity = debugGrid(vUv, 4.0, 1.5);
|
||
vec3 gridColor;
|
||
if (layerIndex == 0) {
|
||
gridColor = vec3(1.0, 0.0, 0.0); // Red
|
||
} else if (layerIndex == 1) {
|
||
gridColor = vec3(0.0, 1.0, 0.0); // Green
|
||
} else {
|
||
gridColor = vec3(0.0, 0.0, 1.0); // Blue
|
||
}
|
||
color = mix(color, gridColor, gridIntensity * 0.5);
|
||
}
|
||
|
||
// Output clouds with texture color and combined alpha
|
||
gl_FragColor = vec4(color, finalAlpha);
|
||
}
|
||
`;function ei({textureUrl:e,radius:t,heightPercent:r,speed:i,windDirection:s,layerIndex:l}){let{debugMode:c}=(0,v.useDebug)(),{animationEnabled:d}=(0,v.useSettings)(),h=(0,n.useRef)(null),m=(0,g.useTexture)(e,ea),f=(0,n.useMemo)(()=>{let e=r-.05;return function(e,t,a,r){var n;let i,s,l,c,d,u,h,m,f,g,p,y,v,F,b,S,x,k=new o.BufferGeometry,w=new Float32Array(75),I=new Float32Array(50),C=[.05,.05,.05,.05,.05,.05,a,a,a,.05,.05,a,t,a,.05,.05,a,a,a,.05,.05,.05,.05,.05,.05],_=2*e/4;for(let t=0;t<5;t++)for(let a=0;a<5;a++){let r=5*t+a,n=-e+a*_,i=e-t*_,o=e*C[r];w[3*r]=n,w[3*r+1]=o,w[3*r+2]=i,I[2*r]=a,I[2*r+1]=t}n=w,i=e=>({x:n[3*e],y:n[3*e+1],z:n[3*e+2]}),s=(e,t,a,r)=>{n[3*e]=t,n[3*e+1]=a,n[3*e+2]=r},l=i(1),c=i(3),d=i(5),u=i(6),h=i(8),m=i(9),f=i(15),g=i(16),p=i(18),y=i(19),v=i(21),F=i(23),b=d.x+(l.x-d.x)*.5,S=d.y+(l.y-d.y)*.5,x=d.z+(l.z-d.z)*.5,s(0,u.x+(b-u.x)*2,u.y+(S-u.y)*2,u.z+(x-u.z)*2),b=m.x+(c.x-m.x)*.5,S=m.y+(c.y-m.y)*.5,x=m.z+(c.z-m.z)*.5,s(4,h.x+(b-h.x)*2,h.y+(S-h.y)*2,h.z+(x-h.z)*2),b=v.x+(f.x-v.x)*.5,S=v.y+(f.y-v.y)*.5,x=v.z+(f.z-v.z)*.5,s(20,g.x+(b-g.x)*2,g.y+(S-g.y)*2,g.z+(x-g.z)*2),b=F.x+(y.x-F.x)*.5,S=F.y+(y.y-F.y)*.5,x=F.z+(y.z-F.z)*.5,s(24,p.x+(b-p.x)*2,p.y+(S-p.y)*2,p.z+(x-p.z)*2);let P=function(e,t){let a=new Float32Array(25);for(let r=0;r<25;r++){let n=e[3*r],i=e[3*r+2],o=1.3-Math.sqrt(n*n+i*i)/t;o<.4?o=0:o>.8&&(o=1),a[r]=o}return a}(w,e),D=[];for(let e=0;e<4;e++)for(let t=0;t<4;t++){let a=5*e+t,r=a+1,n=a+5,i=n+1;D.push(a,n,i),D.push(a,i,r)}return k.setIndex(D),k.setAttribute("position",new o.Float32BufferAttribute(w,3)),k.setAttribute("uv",new o.Float32BufferAttribute(I,2)),k.setAttribute("alpha",new o.Float32BufferAttribute(P,1)),k.computeBoundingSphere(),k}(t,r,e,0)},[t,r]);(0,n.useEffect)(()=>()=>{f.dispose()},[f]);let p=(0,n.useMemo)(()=>new o.ShaderMaterial({uniforms:{cloudTexture:{value:m},uvOffset:{value:new o.Vector2(0,0)},debugMode:{value:+!!c},layerIndex:{value:l}},vertexShader:er,fragmentShader:en,transparent:!0,depthWrite:!1,side:o.DoubleSide}),[m,c,l]);return(0,n.useEffect)(()=>()=>{p.dispose()},[p]),(0,u.useFrame)(d?(e,t)=>{let a=1e3*t/32;h.current??=new o.Vector2(0,0),h.current.x+=s.x*i*a,h.current.y+=s.y*i*a,h.current.x-=Math.floor(h.current.x),h.current.y-=Math.floor(h.current.y),p.uniforms.uvOffset.value.copy(h.current)}:et),(0,a.jsx)("mesh",{geometry:f,frustumCulled:!1,renderOrder:10,children:(0,a.jsx)("primitive",{object:p,attach:"material"})})}function eo(e){var t;let i,l,d,h,f,g,p,y,v,F,b,S,x,k,w,I,C,_,P,D=(0,r.c)(37),{object:M}=e;D[0]!==M?(i=(0,m.getProperty)(M,"materialList"),D[0]=M,D[1]=i):i=D[1];let{data:T}=(t=i,(_=(0,r.c)(7))[0]!==t?(w=["detailMapList",t],I=()=>(0,c.loadDetailMapList)(t),_[0]=t,_[1]=w,_[2]=I):(w=_[1],I=_[2]),P=!!t,_[3]!==w||_[4]!==I||_[5]!==P?(C={queryKey:w,queryFn:I,enabled:P},_[3]=w,_[4]=I,_[5]=P,_[6]=C):C=_[6],(0,s.useQuery)(C));D[2]!==M?(l=(0,m.getFloat)(M,"visibleDistance")??500,D[2]=M,D[3]=l):l=D[3];let E=.95*l;D[4]!==M?(d=(0,m.getFloat)(M,"cloudSpeed1")??1e-4,D[4]=M,D[5]=d):d=D[5],D[6]!==M?(h=(0,m.getFloat)(M,"cloudSpeed2")??2e-4,D[6]=M,D[7]=h):h=D[7],D[8]!==M?(f=(0,m.getFloat)(M,"cloudSpeed3")??3e-4,D[8]=M,D[9]=f):f=D[9],D[10]!==d||D[11]!==h||D[12]!==f?(g=[d,h,f],D[10]=d,D[11]=h,D[12]=f,D[13]=g):g=D[13];let B=g;D[14]!==M?(p=(0,m.getFloat)(M,"cloudHeightPer1")??.35,D[14]=M,D[15]=p):p=D[15],D[16]!==M?(y=(0,m.getFloat)(M,"cloudHeightPer2")??.25,D[16]=M,D[17]=y):y=D[17],D[18]!==M?(v=(0,m.getFloat)(M,"cloudHeightPer3")??.2,D[18]=M,D[19]=v):v=D[19],D[20]!==p||D[21]!==y||D[22]!==v?(F=[p,y,v],D[20]=p,D[21]=y,D[22]=v,D[23]=F):F=D[23];let j=F;if(D[24]!==M){e:{let e,t=(0,m.getProperty)(M,"windVelocity");if(t){let[e,a]=t.split(" ").map(es);if(0!==e||0!==a){b=new o.Vector2(a,-e).normalize();break e}}D[26]===Symbol.for("react.memo_cache_sentinel")?(e=new o.Vector2(1,0),D[26]=e):e=D[26],b=e}D[24]=M,D[25]=b}else b=D[25];let R=b;t:{let e;if(!T){let e;D[27]===Symbol.for("react.memo_cache_sentinel")?(e=[],D[27]=e):e=D[27],S=e;break t}if(D[28]!==j||D[29]!==B||D[30]!==T){e=[];for(let t=0;t<3;t++){let a=T[7+t];a&&e.push({texture:a,height:j[t],speed:B[t]})}D[28]=j,D[29]=B,D[30]=T,D[31]=e}else e=D[31];S=e}let N=S,A=(0,n.useRef)(null);return(D[32]===Symbol.for("react.memo_cache_sentinel")?(x=e=>{let{camera:t}=e;A.current&&A.current.position.copy(t.position)},D[32]=x):x=D[32],(0,u.useFrame)(x),N&&0!==N.length)?(D[33]!==N||D[34]!==E||D[35]!==R?(k=(0,a.jsx)("group",{ref:A,children:N.map((e,t)=>{let r=(0,c.textureToUrl)(e.texture);return(0,a.jsx)(n.Suspense,{fallback:null,children:(0,a.jsx)(ei,{textureUrl:r,radius:E,heightPercent:e.height,speed:e.speed,windDirection:R,layerIndex:t})},t)})}),D[33]=N,D[34]=E,D[35]=R,D[36]=k):k=D[36],k):null}function es(e){return parseFloat(e)}let el=!1;function ec(e){if(!e)return;let[t,a,r]=e.split(" ").map(e=>parseFloat(e));return[new o.Color().setRGB(t,a,r),new o.Color().setRGB(t,a,r).convertSRGBToLinear()]}function ed({skyBoxFiles:e,fogColor:t,fogState:r}){let{camera:i}=(0,h.useThree)(),s=ee(e,{path:""}),l=!!t,c=(0,n.useMemo)(()=>i.projectionMatrixInverse,[i]),d=(0,n.useMemo)(()=>r?(0,b.packFogVolumeData)(r.fogVolumes):new Float32Array(12),[r]),u=(0,n.useRef)({skybox:{value:s},fogColor:{value:t??new o.Color(0,0,0)},enableFog:{value:l},inverseProjectionMatrix:{value:c},cameraMatrixWorld:{value:i.matrixWorld},cameraHeight:b.globalFogUniforms.cameraHeight,fogVolumeData:{value:d},horizonFogHeight:{value:.18}}),m=(0,n.useMemo)(()=>{if(!r)return .18;let e=.95*r.visibleDistance/Math.sqrt(3);return 60/Math.sqrt(e*e+3600)},[r]);return(0,n.useEffect)(()=>{u.current.skybox.value=s,u.current.fogColor.value=t??new o.Color(0,0,0),u.current.enableFog.value=l,u.current.fogVolumeData.value=d,u.current.horizonFogHeight.value=m},[s,t,l,d,m]),(0,a.jsxs)("mesh",{renderOrder:-1e3,frustumCulled:!1,children:[(0,a.jsxs)("bufferGeometry",{children:[(0,a.jsx)("bufferAttribute",{attach:"attributes-position",array:new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),count:3,itemSize:3}),(0,a.jsx)("bufferAttribute",{attach:"attributes-uv",array:new Float32Array([0,0,2,0,0,2]),count:3,itemSize:2})]}),(0,a.jsx)("shaderMaterial",{uniforms:u.current,vertexShader:`
|
||
varying vec2 vUv;
|
||
|
||
void main() {
|
||
vUv = uv;
|
||
gl_Position = vec4(position.xy, 0.9999, 1.0);
|
||
}
|
||
`,fragmentShader:`
|
||
uniform samplerCube skybox;
|
||
uniform vec3 fogColor;
|
||
uniform bool enableFog;
|
||
uniform mat4 inverseProjectionMatrix;
|
||
uniform mat4 cameraMatrixWorld;
|
||
uniform float cameraHeight;
|
||
uniform float fogVolumeData[12];
|
||
uniform float horizonFogHeight;
|
||
|
||
varying vec2 vUv;
|
||
|
||
// Convert linear to sRGB for display
|
||
// shaderMaterial does NOT get automatic linear->sRGB output conversion
|
||
// Use proper sRGB transfer function (not simplified gamma 2.2) to match Three.js
|
||
vec3 linearToSRGB(vec3 linear) {
|
||
vec3 low = linear * 12.92;
|
||
vec3 high = 1.055 * pow(linear, vec3(1.0 / 2.4)) - 0.055;
|
||
return mix(low, high, step(vec3(0.0031308), linear));
|
||
}
|
||
|
||
void main() {
|
||
vec2 ndc = vUv * 2.0 - 1.0;
|
||
vec4 viewPos = inverseProjectionMatrix * vec4(ndc, 1.0, 1.0);
|
||
viewPos.xyz /= viewPos.w;
|
||
vec3 direction = normalize((cameraMatrixWorld * vec4(viewPos.xyz, 0.0)).xyz);
|
||
direction = vec3(direction.z, direction.y, -direction.x);
|
||
// Sample skybox - Three.js CubeTexture with SRGBColorSpace auto-converts to linear
|
||
vec4 skyColor = textureCube(skybox, direction);
|
||
vec3 finalColor;
|
||
|
||
if (enableFog) {
|
||
vec3 effectiveFogColor = fogColor;
|
||
|
||
// Calculate how much fog volume the ray passes through
|
||
// For skybox at "infinite" distance, the relevant height is how much
|
||
// of the volume is above/below camera depending on view direction
|
||
float volumeFogInfluence = 0.0;
|
||
|
||
for (int i = 0; i < 3; i++) {
|
||
int offset = i * 4;
|
||
float volVisDist = fogVolumeData[offset + 0];
|
||
float volMinH = fogVolumeData[offset + 1];
|
||
float volMaxH = fogVolumeData[offset + 2];
|
||
float volPct = fogVolumeData[offset + 3];
|
||
|
||
if (volVisDist <= 0.0) continue;
|
||
|
||
// Check if camera is inside this volume
|
||
if (cameraHeight >= volMinH && cameraHeight <= volMaxH) {
|
||
// Camera is inside the fog volume
|
||
// Looking horizontally or up at shallow angles means ray travels
|
||
// through more fog before exiting the volume
|
||
float heightAboveCamera = volMaxH - cameraHeight;
|
||
float heightBelowCamera = cameraHeight - volMinH;
|
||
float volumeHeight = volMaxH - volMinH;
|
||
|
||
// For horizontal rays (direction.y ≈ 0), maximum fog influence
|
||
// For rays going up steeply, less fog (exits volume quickly)
|
||
// For rays going down, more fog (travels through volume below)
|
||
float rayInfluence;
|
||
if (direction.y >= 0.0) {
|
||
// Looking up: influence based on how steep we're looking
|
||
// Shallow angles = long path through fog = high influence
|
||
rayInfluence = 1.0 - smoothstep(0.0, 0.3, direction.y);
|
||
} else {
|
||
// Looking down: always high fog (into the volume)
|
||
rayInfluence = 1.0;
|
||
}
|
||
|
||
// Scale by percentage and volume depth factor
|
||
volumeFogInfluence += rayInfluence * volPct;
|
||
}
|
||
}
|
||
|
||
// Base fog factor from view direction (for haze at horizon)
|
||
// In Torque, the fog "bans" (bands) are rendered as geometry from
|
||
// height 0 (HORIZON) to height 60 (OFFSET_HEIGHT) on the skybox.
|
||
// The skybox corner is at mSkyBoxPt.x = mRadius / sqrt(3).
|
||
//
|
||
// horizonFogHeight is the direction.y value where the fog band ends:
|
||
// horizonFogHeight = 60 / sqrt(skyBoxPt.x^2 + 60^2)
|
||
//
|
||
// For Firestorm (visDist=600): mRadius=570, skyBoxPt.x=329, horizonFogHeight≈0.18
|
||
//
|
||
// Torque renders the fog bands as geometry with linear vertex alpha
|
||
// interpolation. We use a squared curve (t^2) to create a gentler
|
||
// falloff at the top of the gradient, matching Tribes 2's appearance.
|
||
float baseFogFactor;
|
||
if (direction.y <= 0.0) {
|
||
// Looking at or below horizon: full fog
|
||
baseFogFactor = 1.0;
|
||
} else if (direction.y >= horizonFogHeight) {
|
||
// Above fog band: no fog
|
||
baseFogFactor = 0.0;
|
||
} else {
|
||
// Within fog band: squared curve for gentler falloff at top
|
||
float t = direction.y / horizonFogHeight;
|
||
baseFogFactor = (1.0 - t) * (1.0 - t);
|
||
}
|
||
|
||
// Combine base fog with volume fog influence
|
||
// When inside a volume, increase fog intensity
|
||
float finalFogFactor = min(1.0, baseFogFactor + volumeFogInfluence * 0.5);
|
||
|
||
finalColor = mix(skyColor.rgb, effectiveFogColor, finalFogFactor);
|
||
} else {
|
||
finalColor = skyColor.rgb;
|
||
}
|
||
// Convert linear result to sRGB for display
|
||
gl_FragColor = vec4(linearToSRGB(finalColor), 1.0);
|
||
}
|
||
`,depthWrite:!1,depthTest:!1})]})}function eu(e){let t,n,i,o,l=(0,r.c)(6),{materialList:d,fogColor:u,fogState:h}=e,{data:m}=((o=(0,r.c)(2))[0]!==d?(i={queryKey:["detailMapList",d],queryFn:()=>(0,c.loadDetailMapList)(d)},o[0]=d,o[1]=i):i=o[1],(0,s.useQuery)(i));l[0]!==m?(t=m?[(0,c.textureToUrl)(m[1]),(0,c.textureToUrl)(m[3]),(0,c.textureToUrl)(m[4]),(0,c.textureToUrl)(m[5]),(0,c.textureToUrl)(m[0]),(0,c.textureToUrl)(m[2])]:null,l[0]=m,l[1]=t):t=l[1];let f=t;return f?(l[2]!==u||l[3]!==h||l[4]!==f?(n=(0,a.jsx)(ed,{skyBoxFiles:f,fogColor:u,fogState:h}),l[2]=u,l[3]=h,l[4]=f,l[5]=n):n=l[5],n):null}function eh({skyColor:e,fogColor:t,fogState:r}){let{camera:i}=(0,h.useThree)(),s=!!t,l=(0,n.useMemo)(()=>i.projectionMatrixInverse,[i]),c=(0,n.useMemo)(()=>r?(0,b.packFogVolumeData)(r.fogVolumes):new Float32Array(12),[r]),d=(0,n.useMemo)(()=>{if(!r)return .18;let e=.95*r.visibleDistance/Math.sqrt(3);return 60/Math.sqrt(e*e+3600)},[r]),u=(0,n.useRef)({skyColor:{value:e},fogColor:{value:t??new o.Color(0,0,0)},enableFog:{value:s},inverseProjectionMatrix:{value:l},cameraMatrixWorld:{value:i.matrixWorld},cameraHeight:b.globalFogUniforms.cameraHeight,fogVolumeData:{value:c},horizonFogHeight:{value:d}});return(0,n.useEffect)(()=>{u.current.skyColor.value=e,u.current.fogColor.value=t??new o.Color(0,0,0),u.current.enableFog.value=s,u.current.fogVolumeData.value=c,u.current.horizonFogHeight.value=d},[e,t,s,c,d]),(0,a.jsxs)("mesh",{renderOrder:-1e3,frustumCulled:!1,children:[(0,a.jsxs)("bufferGeometry",{children:[(0,a.jsx)("bufferAttribute",{attach:"attributes-position",array:new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),count:3,itemSize:3}),(0,a.jsx)("bufferAttribute",{attach:"attributes-uv",array:new Float32Array([0,0,2,0,0,2]),count:3,itemSize:2})]}),(0,a.jsx)("shaderMaterial",{uniforms:u.current,vertexShader:`
|
||
varying vec2 vUv;
|
||
|
||
void main() {
|
||
vUv = uv;
|
||
gl_Position = vec4(position.xy, 0.9999, 1.0);
|
||
}
|
||
`,fragmentShader:`
|
||
uniform vec3 skyColor;
|
||
uniform vec3 fogColor;
|
||
uniform bool enableFog;
|
||
uniform mat4 inverseProjectionMatrix;
|
||
uniform mat4 cameraMatrixWorld;
|
||
uniform float cameraHeight;
|
||
uniform float fogVolumeData[12];
|
||
uniform float horizonFogHeight;
|
||
|
||
varying vec2 vUv;
|
||
|
||
// Convert linear to sRGB for display
|
||
vec3 linearToSRGB(vec3 linear) {
|
||
vec3 low = linear * 12.92;
|
||
vec3 high = 1.055 * pow(linear, vec3(1.0 / 2.4)) - 0.055;
|
||
return mix(low, high, step(vec3(0.0031308), linear));
|
||
}
|
||
|
||
void main() {
|
||
vec2 ndc = vUv * 2.0 - 1.0;
|
||
vec4 viewPos = inverseProjectionMatrix * vec4(ndc, 1.0, 1.0);
|
||
viewPos.xyz /= viewPos.w;
|
||
vec3 direction = normalize((cameraMatrixWorld * vec4(viewPos.xyz, 0.0)).xyz);
|
||
direction = vec3(direction.z, direction.y, -direction.x);
|
||
|
||
vec3 finalColor;
|
||
|
||
if (enableFog) {
|
||
// Calculate volume fog influence (same logic as SkyBoxTexture)
|
||
float volumeFogInfluence = 0.0;
|
||
|
||
for (int i = 0; i < 3; i++) {
|
||
int offset = i * 4;
|
||
float volVisDist = fogVolumeData[offset + 0];
|
||
float volMinH = fogVolumeData[offset + 1];
|
||
float volMaxH = fogVolumeData[offset + 2];
|
||
float volPct = fogVolumeData[offset + 3];
|
||
|
||
if (volVisDist <= 0.0) continue;
|
||
|
||
if (cameraHeight >= volMinH && cameraHeight <= volMaxH) {
|
||
float rayInfluence;
|
||
if (direction.y >= 0.0) {
|
||
rayInfluence = 1.0 - smoothstep(0.0, 0.3, direction.y);
|
||
} else {
|
||
rayInfluence = 1.0;
|
||
}
|
||
volumeFogInfluence += rayInfluence * volPct;
|
||
}
|
||
}
|
||
|
||
// Base fog factor from view direction
|
||
float baseFogFactor;
|
||
if (direction.y <= 0.0) {
|
||
baseFogFactor = 1.0;
|
||
} else if (direction.y >= horizonFogHeight) {
|
||
baseFogFactor = 0.0;
|
||
} else {
|
||
float t = direction.y / horizonFogHeight;
|
||
baseFogFactor = (1.0 - t) * (1.0 - t);
|
||
}
|
||
|
||
// Combine base fog with volume fog influence
|
||
float finalFogFactor = min(1.0, baseFogFactor + volumeFogInfluence * 0.5);
|
||
|
||
finalColor = mix(skyColor, fogColor, finalFogFactor);
|
||
} else {
|
||
finalColor = skyColor;
|
||
}
|
||
|
||
gl_FragColor = vec4(linearToSRGB(finalColor), 1.0);
|
||
}
|
||
`,depthWrite:!1,depthTest:!1})]})}function em(e,t){let{fogDistance:a,visibleDistance:r}=e;return[a,r]}function ef({fogState:e,enabled:t}){let{scene:a,camera:r}=(0,h.useThree)(),i=(0,n.useRef)(null),s=(0,n.useMemo)(()=>(0,b.packFogVolumeData)(e.fogVolumes),[e.fogVolumes]);return(0,n.useEffect)(()=>{el||((0,F.installCustomFogShader)(),el=!0)},[]),(0,n.useEffect)(()=>{(0,b.resetGlobalFogUniforms)();let[t,n]=em(e,r.position.y),l=new o.Fog(e.fogColor,t,n);return a.fog=l,i.current=l,(0,b.updateGlobalFogUniforms)(r.position.y,s),()=>{a.fog=null,i.current=null,(0,b.resetGlobalFogUniforms)()}},[a,r,e,s]),(0,n.useEffect)(()=>{let a=i.current;if(a)if(t){let[t,n]=em(e,r.position.y);a.near=t,a.far=n}else a.near=1e10,a.far=1e10},[t,e,r.position.y]),(0,u.useFrame)(()=>{let a=i.current;if(!a)return;let n=r.position.y;if((0,b.updateGlobalFogUniforms)(n,s,t),t){let[t,r]=em(e,n);a.near=t,a.far=r,a.color.copy(e.fogColor)}}),null}function eg(e){return parseFloat(e)}function ep(e){return parseFloat(e)}function ey(e){return parseFloat(e)}var ev=e.i(91907),eF=e.i(25947),eb=e.i(6112);let eS={1:"Storm",2:"Inferno"},ex=(0,n.createContext)(null);function ek(){let e=(0,n.useContext)(ex);if(!e)throw Error("useCameras must be used within CamerasProvider");return e}function ew({children:e}){let{camera:t}=(0,h.useThree)(),[r,i]=(0,n.useState)(-1),[s,l]=(0,n.useState)({}),[c,d]=(0,n.useState)(()=>({initialized:!1,position:null,quarternion:null})),u=(0,n.useCallback)(e=>{l(t=>({...t,[e.id]:e}))},[]),m=(0,n.useCallback)(e=>{l(t=>{let{[e.id]:a,...r}=t;return r})},[]),f=Object.keys(s).length,g=(0,n.useCallback)(e=>{if(e>=0&&e<f){i(e);let a=Object.keys(s)[e],r=s[a];t.position.copy(r.position);let n=new o.Quaternion().setFromAxisAngle(new o.Vector3(0,1,0),-Math.PI/2);t.quaternion.copy(r.rotation).multiply(n)}},[t,f,s]),p=(0,n.useCallback)(()=>{g(f?(r+1)%f:-1)},[f,r,g]);(0,n.useEffect)(()=>{let e=()=>{let e=window.location.hash;if(e.startsWith("#c")){let[t,a]=e.slice(2).split("~"),r=t.split(",").map(e=>parseFloat(e)),n=a.split(",").map(e=>parseFloat(e));d({initialized:!0,position:new o.Vector3(...r),quarternion:new o.Quaternion(...n)})}else d({initialized:!0,position:null,quarternion:null})};return window.addEventListener("hashchange",e),e(),()=>{window.removeEventListener("hashchange",e)}},[]),(0,n.useEffect)(()=>{c.initialized&&c.position&&(t.position.copy(c.position),c.quarternion&&t.quaternion.copy(c.quarternion))},[t,c]),(0,n.useEffect)(()=>{c.initialized&&!c.position&&f>0&&-1===r&&g(0)},[f,g,r,c]);let y=(0,n.useMemo)(()=>({registerCamera:u,unregisterCamera:m,nextCamera:p,setCameraIndex:g,cameraCount:f}),[u,m,p,g,f]);return 0===f&&-1!==r&&i(-1),(0,a.jsx)(ex.Provider,{value:y,children:e})}let eI=(0,n.createContext)(null),eC=eI.Provider,e_=(0,n.lazy)(()=>e.A(61921).then(e=>({default:e.AudioEmitter}))),eP={AudioEmitter:function(e){let t,n=(0,r.c)(3),{audioEnabled:i}=(0,v.useSettings)();return n[0]!==i||n[1]!==e?(t=i?(0,a.jsx)(e_,{...e}):null,n[0]=i,n[1]=e,n[2]=t):t=n[2],t},Camera:function(e){let t,a,i,s,l,c=(0,r.c)(14),{object:d}=e,{registerCamera:u,unregisterCamera:h}=ek(),f=(0,n.useId)();c[0]!==d?(t=(0,m.getProperty)(d,"dataBlock"),c[0]=d,c[1]=t):t=c[1];let g=t;c[2]!==d?(a=(0,m.getPosition)(d),c[2]=d,c[3]=a):a=c[3];let p=a;c[4]!==d?(i=(0,m.getRotation)(d),c[4]=d,c[5]=i):i=c[5];let y=i;return c[6]!==g||c[7]!==f||c[8]!==p||c[9]!==y||c[10]!==u||c[11]!==h?(s=()=>{if("Observer"===g){let e={id:f,position:new o.Vector3(...p),rotation:y};return u(e),()=>{h(e)}}},l=[f,g,u,h,p,y],c[6]=g,c[7]=f,c[8]=p,c[9]=y,c[10]=u,c[11]=h,c[12]=s,c[13]=l):(s=c[12],l=c[13]),(0,n.useEffect)(s,l),null},ForceFieldBare:(0,n.lazy)(()=>e.A(25147).then(e=>({default:e.ForceFieldBare}))),InteriorInstance:X,Item:function(e){let t,i,o,s,l,c,d,h,f,g,p,y,F=(0,r.c)(32),{object:b}=e,S=A();F[0]!==b?(t=(0,m.getProperty)(b,"dataBlock")??"",F[0]=b,F[1]=t):t=F[1];let x=t,k=(0,eb.useDatablock)(x);F[2]!==k||F[3]!==b?(i=function(e){if("string"==typeof e){let t=e.toLowerCase();return"0"!==t&&"false"!==t&&""!==t}return!!e}((0,m.getProperty)(b,"rotate")??(0,m.getProperty)(k,"rotate")),F[2]=k,F[3]=b,F[4]=i):i=F[4];let w=i;F[5]!==b?(o=(0,m.getPosition)(b),F[5]=b,F[6]=o):o=F[6];let I=o;F[7]!==b?(s=(0,m.getScale)(b),F[7]=b,F[8]=s):s=F[8];let C=s;F[9]!==b?(l=(0,m.getRotation)(b),F[9]=b,F[10]=l):l=F[10];let _=l,{animationEnabled:P}=(0,v.useSettings)(),D=(0,n.useRef)(null);F[11]!==P||F[12]!==w?(c=()=>{if(!D.current||!w||!P)return;let e=performance.now()/1e3;D.current.rotation.y=e/3*Math.PI*2},F[11]=P,F[12]=w,F[13]=c):c=F[13],(0,u.useFrame)(c),F[14]!==k?(d=(0,m.getProperty)(k,"shapeFile"),F[14]=k,F[15]=d):d=F[15];let M=d;M||console.error(`<Item> missing shape for datablock: ${x}`);let T=x?.toLowerCase()==="flag",E=S?.team??null,B=E&&E>0?eS[E]:null,j=T&&B?`${B} Flag`:null;return F[16]!==_||F[17]!==w?(h=!w&&{quaternion:_},F[16]=_,F[17]=w,F[18]=h):h=F[18],F[19]!==j?(f=j?(0,a.jsx)(z.FloatingLabel,{opacity:.6,children:j}):null,F[19]=j,F[20]=f):f=F[20],F[21]!==f?(g=(0,a.jsx)(ev.ShapeRenderer,{loadingColor:"pink",children:f}),F[21]=f,F[22]=g):g=F[22],F[23]!==I||F[24]!==C||F[25]!==g||F[26]!==h?(p=(0,a.jsx)("group",{ref:D,position:I,...h,scale:C,children:g}),F[23]=I,F[24]=C,F[25]=g,F[26]=h,F[27]=p):p=F[27],F[28]!==b||F[29]!==M||F[30]!==p?(y=(0,a.jsx)(eF.ShapeInfoProvider,{type:"Item",object:b,shapeName:M,children:p}),F[28]=b,F[29]=M,F[30]=p,F[31]=y):y=F[31],y},SimGroup:function(e){let t,n,i,o,s=(0,r.c)(17),{object:l}=e,c=(0,I.useRuntimeObjectById)(l._id)??l,d=A();s[0]!==c._children?(t=c._children??[],s[0]=c._children,s[1]=t):t=s[1];let u=(0,I.useRuntimeChildIds)(c._id,t),h=null,m=!1;if(d&&d.hasTeams){if(m=!0,null!=d.team)h=d.team;else if(c._name){let e;if(s[2]!==c._name){let t;s[4]===Symbol.for("react.memo_cache_sentinel")?(t=/^team(\d+)$/i,s[4]=t):t=s[4],e=c._name.match(t),s[2]=c._name,s[3]=e}else e=s[3];let t=e;t&&(h=parseInt(t[1],10))}}else if(c._name){let e;s[5]!==c._name?(e=c._name.toLowerCase(),s[5]=c._name,s[6]=e):e=s[6],m="teams"===e}s[7]!==m||s[8]!==c||s[9]!==d||s[10]!==h?(n={object:c,parent:d,hasTeams:m,team:h},s[7]=m,s[8]=c,s[9]=d,s[10]=h,s[11]=n):n=s[11];let f=n;return s[12]!==u?(i=u.map(G),s[12]=u,s[13]=i):i=s[13],s[14]!==f||s[15]!==i?(o=(0,a.jsx)(N.Provider,{value:f,children:i}),s[14]=f,s[15]=i,s[16]=o):o=s[16],o},Sky:function({object:e}){let{fogEnabled:t,highQualityFog:r}=(0,v.useSettings)(),i=(0,m.getProperty)(e,"materialList"),s=(0,n.useMemo)(()=>ec((0,m.getProperty)(e,"SkySolidColor")),[e]),l=(0,m.getInt)(e,"useSkyTextures")??1,c=(0,n.useMemo)(()=>(function(e,t=!0){let a=(0,m.getFloat)(e,"fogDistance")??0,r=(0,m.getFloat)(e,"visibleDistance")??1e3,n=(0,m.getFloat)(e,"high_fogDistance"),i=(0,m.getFloat)(e,"high_visibleDistance"),s=t&&null!=n&&n>0?n:a,l=t&&null!=i&&i>0?i:r,c=function(e){if(!e)return new o.Color(.5,.5,.5);let[t,a,r]=e.split(" ").map(e=>parseFloat(e));return new o.Color().setRGB(t,a,r).convertSRGBToLinear()}((0,m.getProperty)(e,"fogColor")),d=[];for(let t=1;t<=3;t++){let a=function(e,t=1){if(!e)return null;let a=e.split(" ").map(e=>parseFloat(e));if(a.length<3)return null;let[r,n,i]=a;return r<=0||i<=n?null:{visibleDistance:r,minHeight:n,maxHeight:i,percentage:Math.max(0,Math.min(1,t))}}((0,m.getProperty)(e,`fogVolume${t}`),1);a&&d.push(a)}let u=d.reduce((e,t)=>Math.max(e,t.maxHeight),0);return{fogDistance:s,visibleDistance:l,fogColor:c,fogVolumes:d,fogLine:u,enabled:l>s}})(e,r),[e,r]),d=(0,n.useMemo)(()=>ec((0,m.getProperty)(e,"fogColor")),[e]),u=s||d,f=c.enabled&&t,g=c.fogColor,{scene:p,gl:y}=(0,h.useThree)();(0,n.useEffect)(()=>{if(f){let e=g.clone();p.background=e,y.setClearColor(e)}else if(u){let e=u[0].clone();p.background=e,y.setClearColor(e)}else p.background=null;return()=>{p.background=null}},[p,y,f,g,u]);let F=s?.[1];return(0,a.jsxs)(a.Fragment,{children:[i&&l?(0,a.jsx)(n.Suspense,{fallback:null,children:(0,a.jsx)(eu,{materialList:i,fogColor:f?g:void 0,fogState:f?c:void 0},i)}):F?(0,a.jsx)(eh,{skyColor:F,fogColor:f?g:void 0,fogState:f?c:void 0}):null,(0,a.jsx)(n.Suspense,{children:(0,a.jsx)(eo,{object:e})}),c.enabled?(0,a.jsx)(ef,{fogState:c,enabled:t}):null]})},StaticShape:function(e){let t,n,i,o,s,l,c,d,u=(0,r.c)(19),{object:h}=e;u[0]!==h?(t=(0,m.getProperty)(h,"dataBlock")??"",u[0]=h,u[1]=t):t=u[1];let f=t,g=(0,eb.useDatablock)(f);u[2]!==h?(n=(0,m.getPosition)(h),u[2]=h,u[3]=n):n=u[3];let p=n;u[4]!==h?(i=(0,m.getRotation)(h),u[4]=h,u[5]=i):i=u[5];let y=i;u[6]!==h?(o=(0,m.getScale)(h),u[6]=h,u[7]=o):o=u[7];let v=o;u[8]!==g?(s=(0,m.getProperty)(g,"shapeFile"),u[8]=g,u[9]=s):s=u[9];let F=s;return F||console.error(`<StaticShape> missing shape for datablock: ${f}`),u[10]===Symbol.for("react.memo_cache_sentinel")?(l=(0,a.jsx)(ev.ShapeRenderer,{}),u[10]=l):l=u[10],u[11]!==p||u[12]!==y||u[13]!==v?(c=(0,a.jsx)("group",{position:p,quaternion:y,scale:v,children:l}),u[11]=p,u[12]=y,u[13]=v,u[14]=c):c=u[14],u[15]!==h||u[16]!==F||u[17]!==c?(d=(0,a.jsx)(eF.ShapeInfoProvider,{type:"StaticShape",object:h,shapeName:F,children:c}),u[15]=h,u[16]=F,u[17]=c,u[18]=d):d=u[18],d},Sun:function(e){let t,i,s,l,c,d,u,h,f,g,y=(0,r.c)(25),{object:v}=e;y[0]!==v?(t=((0,m.getProperty)(v,"direction")??"0.57735 0.57735 -0.57735").split(" ").map(ey),y[0]=v,y[1]=t):t=y[1];let[F,b,S]=t,x=Math.sqrt(F*F+S*S+b*b),k=F/x,w=S/x,I=b/x;y[2]!==k||y[3]!==w||y[4]!==I?(i=new o.Vector3(k,w,I),y[2]=k,y[3]=w,y[4]=I,y[5]=i):i=y[5];let C=i,_=-(5e3*C.x),P=-(5e3*C.y),D=-(5e3*C.z);y[6]!==_||y[7]!==P||y[8]!==D?(s=new o.Vector3(_,P,D),y[6]=_,y[7]=P,y[8]=D,y[9]=s):s=y[9];let M=s;if(y[10]!==v){let[e,t,a]=((0,m.getProperty)(v,"color")??"0.7 0.7 0.7 1").split(" ").map(ep);l=new o.Color(e,t,a),y[10]=v,y[11]=l}else l=y[11];let T=l;if(y[12]!==v){let[e,t,a]=((0,m.getProperty)(v,"ambient")??"0.5 0.5 0.5 1").split(" ").map(eg);c=new o.Color(e,t,a),y[12]=v,y[13]=c}else c=y[13];let E=c,B=C.y<0;return y[14]!==B?(d=()=>{p.value=B},u=[B],y[14]=B,y[15]=d,y[16]=u):(d=y[15],u=y[16]),(0,n.useEffect)(d,u),y[17]!==T||y[18]!==M?(h=(0,a.jsx)("directionalLight",{position:M,color:T,intensity:1,castShadow:!0,"shadow-mapSize-width":8192,"shadow-mapSize-height":8192,"shadow-camera-left":-4096,"shadow-camera-right":4096,"shadow-camera-top":4096,"shadow-camera-bottom":-4096,"shadow-camera-near":100,"shadow-camera-far":12e3,"shadow-bias":-1e-5,"shadow-normalBias":.4,"shadow-radius":2}),y[17]=T,y[18]=M,y[19]=h):h=y[19],y[20]!==E?(f=(0,a.jsx)("ambientLight",{color:E,intensity:1}),y[20]=E,y[21]=f):f=y[21],y[22]!==h||y[23]!==f?(g=(0,a.jsxs)(a.Fragment,{children:[h,f]}),y[22]=h,y[23]=f,y[24]=g):g=y[24],g},TerrainBlock:D,TSStatic:function(e){let t,n,i,o,s,l,c,d=(0,r.c)(17),{object:u}=e;d[0]!==u?(t=(0,m.getProperty)(u,"shapeName"),d[0]=u,d[1]=t):t=d[1];let h=t;d[2]!==u?(n=(0,m.getPosition)(u),d[2]=u,d[3]=n):n=d[3];let f=n;d[4]!==u?(i=(0,m.getRotation)(u),d[4]=u,d[5]=i):i=d[5];let g=i;d[6]!==u?(o=(0,m.getScale)(u),d[6]=u,d[7]=o):o=d[7];let p=o;return h||console.error("<TSStatic> missing shapeName for object",u),d[8]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsx)(ev.ShapeRenderer,{}),d[8]=s):s=d[8],d[9]!==f||d[10]!==g||d[11]!==p?(l=(0,a.jsx)("group",{position:f,quaternion:g,scale:p,children:s}),d[9]=f,d[10]=g,d[11]=p,d[12]=l):l=d[12],d[13]!==u||d[14]!==h||d[15]!==l?(c=(0,a.jsx)(eF.ShapeInfoProvider,{type:"TSStatic",object:u,shapeName:h,children:l}),d[13]=u,d[14]=h,d[15]=l,d[16]=c):c=d[16],c},Turret:function(e){let t,n,i,o,s,l,c,d,u,h,f,g=(0,r.c)(27),{object:p}=e;g[0]!==p?(t=(0,m.getProperty)(p,"dataBlock")??"",g[0]=p,g[1]=t):t=g[1];let y=t;g[2]!==p?(n=(0,m.getProperty)(p,"initialBarrel"),g[2]=p,g[3]=n):n=g[3];let v=n,F=(0,eb.useDatablock)(y),b=(0,eb.useDatablock)(v);g[4]!==p?(i=(0,m.getPosition)(p),g[4]=p,g[5]=i):i=g[5];let S=i;g[6]!==p?(o=(0,m.getRotation)(p),g[6]=p,g[7]=o):o=g[7];let x=o;g[8]!==p?(s=(0,m.getScale)(p),g[8]=p,g[9]=s):s=g[9];let k=s;g[10]!==F?(l=(0,m.getProperty)(F,"shapeFile"),g[10]=F,g[11]=l):l=g[11];let w=l;g[12]!==b?(c=(0,m.getProperty)(b,"shapeFile"),g[12]=b,g[13]=c):c=g[13];let I=c;return w||console.error(`<Turret> missing shape for datablock: ${y}`),v&&!I&&console.error(`<Turret> missing shape for barrel datablock: ${v}`),g[14]===Symbol.for("react.memo_cache_sentinel")?(d=(0,a.jsx)(ev.ShapeRenderer,{}),g[14]=d):d=g[14],g[15]!==I||g[16]!==p?(u=I?(0,a.jsx)(eF.ShapeInfoProvider,{type:"Turret",object:p,shapeName:I,children:(0,a.jsx)("group",{position:[0,1.5,0],children:(0,a.jsx)(ev.ShapeRenderer,{})})}):null,g[15]=I,g[16]=p,g[17]=u):u=g[17],g[18]!==S||g[19]!==x||g[20]!==k||g[21]!==u?(h=(0,a.jsxs)("group",{position:S,quaternion:x,scale:k,children:[d,u]}),g[18]=S,g[19]=x,g[20]=k,g[21]=u,g[22]=h):h=g[22],g[23]!==p||g[24]!==w||g[25]!==h?(f=(0,a.jsx)(eF.ShapeInfoProvider,{type:"Turret",object:p,shapeName:w,children:h}),g[23]=p,g[24]=w,g[25]=h,g[26]=f):f=g[26],f},WaterBlock:(0,n.lazy)(()=>e.A(18599).then(e=>({default:e.WaterBlock}))),WayPoint:function(e){let t,n,i,o=(0,r.c)(7),{object:s}=e;o[0]!==s?(t=(0,m.getPosition)(s),o[0]=s,o[1]=t):t=o[1];let l=t;o[2]!==s?(n=(0,m.getProperty)(s,"name"),o[2]=s,o[3]=n):n=o[3];let c=n;return o[4]!==c||o[5]!==l?(i=c?(0,a.jsx)(z.FloatingLabel,{position:l,opacity:.6,children:c}):null,o[4]=c,o[5]=l,o[6]=i):i=o[6],i}},eD=new Set(["ForceFieldBare","Item","StaticShape","Turret"]);function eM(e){let t,i,o,s=(0,r.c)(13),{object:l,objectId:c}=e,d=(0,I.useRuntimeObjectById)(c??l?._id)??l,{missionType:u}=(0,n.useContext)(eI),h=(0,I.useEngineSelector)(eT);e:{let e,a;if(!d){t=!1;break e}s[0]!==d?(e=new Set(((0,m.getProperty)(d,"missionTypesList")??"").toLowerCase().split(/\s+/).filter(Boolean)),s[0]=d,s[1]=e):e=s[1];let r=e;s[2]!==u||s[3]!==r?(a=!r.size||r.has(u.toLowerCase()),s[2]=u,s[3]=r,s[4]=a):a=s[4],t=a}let f=t;if(!d)return null;let g=eP[d._className];s[5]!==h||s[6]!==d._className?(i=h&&eD.has(d._className),s[5]=h,s[6]=d._className,s[7]=i):i=s[7];let p=i;return s[8]!==g||s[9]!==p||s[10]!==d||s[11]!==f?(o=f&&g?(0,a.jsx)(n.Suspense,{children:!p&&(0,a.jsx)(g,{object:d})}):null,s[8]=g,s[9]=p,s[10]=d,s[11]=f,s[12]=o):o=s[12],o}function eT(e){return null!=e.playback.recording}var eE=e.i(51475);let eB=(0,n.createContext)(null);function ej(e){let t,n,i=(0,r.c)(5),{runtime:o,children:s}=e;return i[0]!==s?(t=(0,a.jsx)(eE.TickProvider,{children:s}),i[0]=s,i[1]=t):t=i[1],i[2]!==o||i[3]!==t?(n=(0,a.jsx)(eB.Provider,{value:o,children:t}),i[2]=o,i[3]=t,i[4]=n):n=i[4],n}var eR=e.i(86608),eN=e.i(38433),eA=e.i(33870),eG=e.i(91996),eU=e.i(7368);let eL=(0,d.createScriptLoader)(),ez=(0,eA.createScriptCache)(),eO={findFiles:e=>{let t=(0,l.default)(e,{nocase:!0});return(0,eG.getResourceList)().filter(e=>t(e)).map(e=>{let[,t]=(0,eG.getSourceAndPath)(e);return t})},isFile:e=>null!=(0,eG.getResourceMap)()[(0,eG.getResourceKey)(e)]};function eV(e){"batch.flushed"===e.type&&I.engineStore.getState().applyRuntimeBatch(e.events,{tick:e.tick})}function eq(e){e instanceof Error&&"AbortError"===e.name||console.error("Mission runtime failed to become ready:",e)}let eH=(0,n.memo)(function(e){let t,i,o,l,d,u,h,m,f=(0,r.c)(17),{name:g,missionType:p,onLoadingChange:y}=e,{data:v}=((m=(0,r.c)(2))[0]!==g?(h={queryKey:["parsedMission",g],queryFn:()=>(0,c.loadMission)(g)},m[0]=g,m[1]=h):h=m[1],(0,s.useQuery)(h)),{missionGroup:F,runtime:b,progress:S}=function(e,t,a){let i,o,s,l=(0,r.c)(6);l[0]===Symbol.for("react.memo_cache_sentinel")?(i={missionGroup:void 0,runtime:void 0,progress:0},l[0]=i):i=l[0];let[c,d]=(0,n.useState)(i);return l[1]!==e||l[2]!==t||l[3]!==a?(o=()=>{if(!a)return;let r=new AbortController,n=!1,i=null,o=(0,eN.createProgressTracker)(),s=()=>{d(e=>({...e,progress:o.progress}))};o.on("update",s);let{runtime:l,ready:c}=(0,eR.runServer)({missionName:e,missionType:t,runtimeOptions:{loadScript:eL,fileSystem:eO,cache:ez,signal:r.signal,progress:o,ignoreScripts:eU.ignoreScripts}});return c.then(()=>{n||r.signal.aborted||(I.engineStore.getState().setRuntime(l),d({missionGroup:l.getObjectByName("MissionGroup"),runtime:l,progress:1}))}).catch(eq),i=l.subscribeRuntimeEvents(eV),I.engineStore.getState().setRuntime(l),()=>{n=!0,o.off("update",s),r.abort(),i?.(),I.engineStore.getState().clearRuntime(),l.destroy()}},s=[e,t,a],l[1]=e,l[2]=t,l[3]=a,l[4]=o,l[5]=s):(o=l[4],s=l[5]),(0,n.useEffect)(o,s),c}(g,p,v),x=!v||!F||!b;f[0]!==F||f[1]!==p||f[2]!==v?(t={metadata:v,missionType:p,missionGroup:F},f[0]=F,f[1]=p,f[2]=v,f[3]=t):t=f[3];let k=t;return(f[4]!==x||f[5]!==y||f[6]!==S?(i=()=>{y?.(x,S)},o=[x,S,y],f[4]=x,f[5]=y,f[6]=S,f[7]=i,f[8]=o):(i=f[7],o=f[8]),(0,n.useEffect)(i,o),x)?null:(f[9]!==F?(l=(0,a.jsx)(eM,{object:F}),f[9]=F,f[10]=l):l=f[10],f[11]!==b||f[12]!==l?(d=(0,a.jsx)(ej,{runtime:b,children:l}),f[11]=b,f[12]=l,f[13]=d):d=f[13],f[14]!==k||f[15]!==d?(u=(0,a.jsx)(eC,{value:k,children:d}),f[14]=k,f[15]=d,f[16]=u):u=f[16],u)});var eW=e.i(17751),e$=e.i(12598),eY=e.i(8155);let eK=e=>{let t=(0,eY.createStore)(e),a=e=>(function(e,t=e=>e){let a=n.default.useSyncExternalStore(e.subscribe,n.default.useCallback(()=>t(e.getState()),[e,t]),n.default.useCallback(()=>t(e.getInitialState()),[e,t]));return n.default.useDebugValue(a),a})(t,e);return Object.assign(a,t),a};var eX=e.i(79473);let eZ=n.createContext(null);function eJ({map:e,children:t,onChange:a,domElement:r}){let i=e.map(e=>e.name+e.keys).join("-"),o=n.useMemo(()=>{let t;return(t=(0,eX.subscribeWithSelector)(()=>e.reduce((e,t)=>({...e,[t.name]:!1}),{})))?eK(t):eK},[i]),s=n.useMemo(()=>[o.subscribe,o.getState,o],[i]),l=o.setState;return n.useEffect(()=>{let t=e.map(({name:e,keys:t,up:r})=>({keys:t,up:r,fn:t=>{l({[e]:t}),a&&a(e,t,s[1]())}})).reduce((e,{keys:t,fn:a,up:r=!0})=>(t.forEach(t=>e[t]={fn:a,pressed:!1,up:r}),e),{}),n=({key:e,code:a})=>{let r=t[e]||t[a];if(!r)return;let{fn:n,pressed:i,up:o}=r;r.pressed=!0,(o||!i)&&n(!0)},i=({key:e,code:a})=>{let r=t[e]||t[a];if(!r)return;let{fn:n,up:i}=r;r.pressed=!1,i&&n(!1)},o=r||window;return o.addEventListener("keydown",n,{passive:!0}),o.addEventListener("keyup",i,{passive:!0}),()=>{o.removeEventListener("keydown",n),o.removeEventListener("keyup",i)}},[r,i]),n.createElement(eZ.Provider,{value:s,children:t})}function eQ(e){let[t,a,r]=n.useContext(eZ);return e?r(e):[t,a]}var e0=e.i(85413),e1=Object.defineProperty,e2=(e,t,a)=>{let r;return(r="symbol"!=typeof t?t+"":t)in e?e1(e,r,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[r]=a,a};let e3=new o.Euler(0,0,0,"YXZ"),e5=new o.Vector3,e4={type:"change"},e6={type:"lock"},e8={type:"unlock"},e7=Math.PI/2;class e9 extends e0.EventDispatcher{constructor(e,t){super(),e2(this,"camera"),e2(this,"domElement"),e2(this,"isLocked"),e2(this,"minPolarAngle"),e2(this,"maxPolarAngle"),e2(this,"pointerSpeed"),e2(this,"onMouseMove",e=>{this.domElement&&!1!==this.isLocked&&(e3.setFromQuaternion(this.camera.quaternion),e3.y-=.002*e.movementX*this.pointerSpeed,e3.x-=.002*e.movementY*this.pointerSpeed,e3.x=Math.max(e7-this.maxPolarAngle,Math.min(e7-this.minPolarAngle,e3.x)),this.camera.quaternion.setFromEuler(e3),this.dispatchEvent(e4))}),e2(this,"onPointerlockChange",()=>{this.domElement&&(this.domElement.ownerDocument.pointerLockElement===this.domElement?(this.dispatchEvent(e6),this.isLocked=!0):(this.dispatchEvent(e8),this.isLocked=!1))}),e2(this,"onPointerlockError",()=>{console.error("THREE.PointerLockControls: Unable to use Pointer Lock API")}),e2(this,"connect",e=>{this.domElement=e||this.domElement,this.domElement&&(this.domElement.ownerDocument.addEventListener("mousemove",this.onMouseMove),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError))}),e2(this,"disconnect",()=>{this.domElement&&(this.domElement.ownerDocument.removeEventListener("mousemove",this.onMouseMove),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError))}),e2(this,"dispose",()=>{this.disconnect()}),e2(this,"getObject",()=>this.camera),e2(this,"direction",new o.Vector3(0,0,-1)),e2(this,"getDirection",e=>e.copy(this.direction).applyQuaternion(this.camera.quaternion)),e2(this,"moveForward",e=>{e5.setFromMatrixColumn(this.camera.matrix,0),e5.crossVectors(this.camera.up,e5),this.camera.position.addScaledVector(e5,e)}),e2(this,"moveRight",e=>{e5.setFromMatrixColumn(this.camera.matrix,0),this.camera.position.addScaledVector(e5,e)}),e2(this,"lock",()=>{this.domElement&&this.domElement.requestPointerLock()}),e2(this,"unlock",()=>{this.domElement&&this.domElement.ownerDocument.exitPointerLock()}),this.camera=e,this.domElement=t,this.isLocked=!1,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.pointerSpeed=1,t&&this.connect(t)}}(t={}).forward="forward",t.backward="backward",t.left="left",t.right="right",t.up="up",t.down="down",t.lookUp="lookUp",t.lookDown="lookDown",t.lookLeft="lookLeft",t.lookRight="lookRight",t.camera1="camera1",t.camera2="camera2",t.camera3="camera3",t.camera4="camera4",t.camera5="camera5",t.camera6="camera6",t.camera7="camera7",t.camera8="camera8",t.camera9="camera9";let te=Math.PI/2-.01;function tt(){let e,t,a,i,s,l,c,d,m,f,g,p,y,F=(0,r.c)(26),{speedMultiplier:b,setSpeedMultiplier:S}=(0,v.useControls)(),[x,k]=eQ(),{camera:w,gl:I}=(0,h.useThree)(),{nextCamera:C,setCameraIndex:_,cameraCount:P}=ek(),D=(0,n.useRef)(null);F[0]===Symbol.for("react.memo_cache_sentinel")?(e=new o.Vector3,F[0]=e):e=F[0];let M=(0,n.useRef)(e);F[1]===Symbol.for("react.memo_cache_sentinel")?(t=new o.Vector3,F[1]=t):t=F[1];let T=(0,n.useRef)(t);F[2]===Symbol.for("react.memo_cache_sentinel")?(a=new o.Vector3,F[2]=a):a=F[2];let E=(0,n.useRef)(a);F[3]===Symbol.for("react.memo_cache_sentinel")?(i=new o.Euler(0,0,0,"YXZ"),F[3]=i):i=F[3];let B=(0,n.useRef)(i);return F[4]!==w||F[5]!==I.domElement?(s=()=>{let e=new e9(w,I.domElement);return D.current=e,()=>{e.dispose()}},l=[w,I.domElement],F[4]=w,F[5]=I.domElement,F[6]=s,F[7]=l):(s=F[6],l=F[7]),(0,n.useEffect)(s,l),F[8]!==w||F[9]!==I.domElement||F[10]!==C?(c=()=>{let e=I.domElement,t=new o.Euler(0,0,0,"YXZ"),a=!1,r=!1,n=0,i=0,s=t=>{D.current?.isLocked||t.target===e&&(a=!0,r=!1,n=t.clientX,i=t.clientY)},l=e=>{!a||!r&&3>Math.abs(e.clientX-n)&&3>Math.abs(e.clientY-i)||(r=!0,t.setFromQuaternion(w.quaternion,"YXZ"),t.y=t.y-.003*e.movementX,t.x=t.x-.003*e.movementY,t.x=Math.max(-te,Math.min(te,t.x)),w.quaternion.setFromEuler(t))},c=()=>{a=!1},d=t=>{let a=D.current;!a||a.isLocked?C():t.target!==e||r||a.lock()};return e.addEventListener("mousedown",s),document.addEventListener("mousemove",l),document.addEventListener("mouseup",c),document.addEventListener("click",d),()=>{e.removeEventListener("mousedown",s),document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",c),document.removeEventListener("click",d)}},d=[w,I.domElement,C],F[8]=w,F[9]=I.domElement,F[10]=C,F[11]=c,F[12]=d):(c=F[11],d=F[12]),(0,n.useEffect)(c,d),F[13]!==P||F[14]!==_||F[15]!==x?(m=()=>{let e=["camera1","camera2","camera3","camera4","camera5","camera6","camera7","camera8","camera9"];return x(t=>{for(let a=0;a<e.length;a++)if(t[e[a]]&&a<P){_(a);break}})},f=[x,_,P],F[13]=P,F[14]=_,F[15]=x,F[16]=m,F[17]=f):(m=F[16],f=F[17]),(0,n.useEffect)(m,f),F[18]!==I.domElement||F[19]!==S?(g=()=>{let e=e=>{e.preventDefault();let t=e.deltaY>0?-1:1,a=Math.max(.05,Math.min(.5,Math.abs(.01*e.deltaY)))*t;S(e=>Math.max(.1,Math.min(5,Math.round((e+a)*20)/20)))},t=I.domElement;return t.addEventListener("wheel",e,{passive:!1}),()=>{t.removeEventListener("wheel",e)}},p=[I.domElement,S],F[18]=I.domElement,F[19]=S,F[20]=g,F[21]=p):(g=F[20],p=F[21]),(0,n.useEffect)(g,p),F[22]!==w||F[23]!==k||F[24]!==b?(y=(e,t)=>{let{forward:a,backward:r,left:n,right:i,up:o,down:s,lookUp:l,lookDown:c,lookLeft:d,lookRight:u}=k();if((l||c||d||u)&&(B.current.setFromQuaternion(w.quaternion,"YXZ"),d&&(B.current.y=B.current.y+ +t),u&&(B.current.y=B.current.y-t),l&&(B.current.x=B.current.x+ +t),c&&(B.current.x=B.current.x-t),B.current.x=Math.max(-te,Math.min(te,B.current.x)),w.quaternion.setFromEuler(B.current)),!a&&!r&&!n&&!i&&!o&&!s)return;let h=80*b;w.getWorldDirection(M.current),M.current.normalize(),T.current.crossVectors(w.up,M.current).normalize(),E.current.set(0,0,0),a&&E.current.add(M.current),r&&E.current.sub(M.current),n&&E.current.add(T.current),i&&E.current.sub(T.current),o&&(E.current.y=E.current.y+1),s&&(E.current.y=E.current.y-1),E.current.lengthSq()>0&&(E.current.normalize().multiplyScalar(h*t),w.position.add(E.current))},F[22]=w,F[23]=k,F[24]=b,F[25]=y):y=F[25],(0,u.useFrame)(y),null}let ta=[{name:"forward",keys:["KeyW"]},{name:"backward",keys:["KeyS"]},{name:"left",keys:["KeyA"]},{name:"right",keys:["KeyD"]},{name:"up",keys:["Space"]},{name:"down",keys:["ShiftLeft","ShiftRight"]},{name:"lookUp",keys:["ArrowUp"]},{name:"lookDown",keys:["ArrowDown"]},{name:"lookLeft",keys:["ArrowLeft"]},{name:"lookRight",keys:["ArrowRight"]},{name:"camera1",keys:["Digit1"]},{name:"camera2",keys:["Digit2"]},{name:"camera3",keys:["Digit3"]},{name:"camera4",keys:["Digit4"]},{name:"camera5",keys:["Digit5"]},{name:"camera6",keys:["Digit6"]},{name:"camera7",keys:["Digit7"]},{name:"camera8",keys:["Digit8"]},{name:"camera9",keys:["Digit9"]}];function tr(){let e,t,i=(0,r.c)(2);return i[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],i[0]=e):e=i[0],(0,n.useEffect)(tn,e),i[1]===Symbol.for("react.memo_cache_sentinel")?(t=(0,a.jsx)(tt,{}),i[1]=t):t=i[1],t}function tn(){return window.addEventListener("keydown",ti,{capture:!0}),window.addEventListener("keyup",ti,{capture:!0}),()=>{window.removeEventListener("keydown",ti,{capture:!0}),window.removeEventListener("keyup",ti,{capture:!0})}}function ti(e){(e.metaKey||e.ctrlKey)&&"k"===e.key||e.metaKey&&e.stopImmediatePropagation()}function to(e){let t,n=(0,r.c)(2),{children:i}=e;return n[0]!==i?(t=(0,a.jsx)(a.Fragment,{children:i}),n[0]=i,n[1]=t):t=n[1],t}function ts(){return(0,I.useEngineSelector)(tl)}function tl(e){return e.playback.recording}function tc(e){return"playing"===e.playback.status}function td(e){return e.playback.timeMs/1e3}function tu(e){return e.playback.durationMs/1e3}function th(e){return e.playback.rate}function tm(){let e,t,a,n,i,o,s=(0,r.c)(17),l=ts(),c=(0,I.useEngineSelector)(ty),d=(0,I.useEngineSelector)(tp),u=(0,I.useEngineSelector)(tg),h=(0,I.useEngineSelector)(tf);s[0]!==c?(e=e=>{c(e)},s[0]=c,s[1]=e):e=s[1];let m=e;s[2]!==l||s[3]!==d?(t=()=>{l&&d("playing")},s[2]=l,s[3]=d,s[4]=t):t=s[4];let f=t;s[5]!==d?(a=()=>{d("paused")},s[5]=d,s[6]=a):a=s[6];let g=a;s[7]!==u?(n=e=>{u(1e3*e)},s[7]=u,s[8]=n):n=s[8];let p=n;s[9]!==h?(i=e=>{h(e)},s[9]=h,s[10]=i):i=s[10];let y=i;return s[11]!==g||s[12]!==f||s[13]!==p||s[14]!==m||s[15]!==y?(o={setRecording:m,play:f,pause:g,seek:p,setSpeed:y},s[11]=g,s[12]=f,s[13]=p,s[14]=m,s[15]=y,s[16]=o):o=s[16],o}function tf(e){return e.setPlaybackRate}function tg(e){return e.setPlaybackTime}function tp(e){return e.setPlaybackStatus}function ty(e){return e.setDemoRecording}var tv=e.i(13070);function tF(){let e,t,n,i,o,s,l,c,d,u,h,m,f,g,p,y,v,F,b,S,x,k,w,I,C=(0,r.c)(51),_=ts(),P=eQ(tD),D=eQ(tP),M=eQ(t_),T=eQ(tC),E=eQ(tI),B=eQ(tw),j=eQ(tk),R=eQ(tx),N=eQ(tS),A=eQ(tb);return _?null:(C[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,a.jsx)("div",{className:tv.default.Spacer}),C[0]=e):e=C[0],C[1]!==P?(t=(0,a.jsx)("div",{className:tv.default.Key,"data-pressed":P,children:"W"}),C[1]=P,C[2]=t):t=C[2],C[3]===Symbol.for("react.memo_cache_sentinel")?(n=(0,a.jsx)("div",{className:tv.default.Spacer}),C[3]=n):n=C[3],C[4]!==t?(i=(0,a.jsxs)("div",{className:tv.default.Row,children:[e,t,n]}),C[4]=t,C[5]=i):i=C[5],C[6]!==M?(o=(0,a.jsx)("div",{className:tv.default.Key,"data-pressed":M,children:"A"}),C[6]=M,C[7]=o):o=C[7],C[8]!==D?(s=(0,a.jsx)("div",{className:tv.default.Key,"data-pressed":D,children:"S"}),C[8]=D,C[9]=s):s=C[9],C[10]!==T?(l=(0,a.jsx)("div",{className:tv.default.Key,"data-pressed":T,children:"D"}),C[10]=T,C[11]=l):l=C[11],C[12]!==o||C[13]!==s||C[14]!==l?(c=(0,a.jsxs)("div",{className:tv.default.Row,children:[o,s,l]}),C[12]=o,C[13]=s,C[14]=l,C[15]=c):c=C[15],C[16]!==i||C[17]!==c?(d=(0,a.jsxs)("div",{className:tv.default.Column,children:[i,c]}),C[16]=i,C[17]=c,C[18]=d):d=C[18],C[19]===Symbol.for("react.memo_cache_sentinel")?(u=(0,a.jsx)("span",{className:tv.default.Arrow,children:"↑"}),C[19]=u):u=C[19],C[20]!==E?(h=(0,a.jsx)("div",{className:tv.default.Row,children:(0,a.jsxs)("div",{className:tv.default.Key,"data-pressed":E,children:[u," Space"]})}),C[20]=E,C[21]=h):h=C[21],C[22]===Symbol.for("react.memo_cache_sentinel")?(m=(0,a.jsx)("span",{className:tv.default.Arrow,children:"↓"}),C[22]=m):m=C[22],C[23]!==B?(f=(0,a.jsx)("div",{className:tv.default.Row,children:(0,a.jsxs)("div",{className:tv.default.Key,"data-pressed":B,children:[m," Shift"]})}),C[23]=B,C[24]=f):f=C[24],C[25]!==h||C[26]!==f?(g=(0,a.jsxs)("div",{className:tv.default.Column,children:[h,f]}),C[25]=h,C[26]=f,C[27]=g):g=C[27],C[28]===Symbol.for("react.memo_cache_sentinel")?(p=(0,a.jsx)("div",{className:tv.default.Spacer}),C[28]=p):p=C[28],C[29]!==j?(y=(0,a.jsx)("div",{className:tv.default.Key,"data-pressed":j,children:"↑"}),C[29]=j,C[30]=y):y=C[30],C[31]===Symbol.for("react.memo_cache_sentinel")?(v=(0,a.jsx)("div",{className:tv.default.Spacer}),C[31]=v):v=C[31],C[32]!==y?(F=(0,a.jsxs)("div",{className:tv.default.Row,children:[p,y,v]}),C[32]=y,C[33]=F):F=C[33],C[34]!==N?(b=(0,a.jsx)("div",{className:tv.default.Key,"data-pressed":N,children:"←"}),C[34]=N,C[35]=b):b=C[35],C[36]!==R?(S=(0,a.jsx)("div",{className:tv.default.Key,"data-pressed":R,children:"↓"}),C[36]=R,C[37]=S):S=C[37],C[38]!==A?(x=(0,a.jsx)("div",{className:tv.default.Key,"data-pressed":A,children:"→"}),C[38]=A,C[39]=x):x=C[39],C[40]!==b||C[41]!==S||C[42]!==x?(k=(0,a.jsxs)("div",{className:tv.default.Row,children:[b,S,x]}),C[40]=b,C[41]=S,C[42]=x,C[43]=k):k=C[43],C[44]!==F||C[45]!==k?(w=(0,a.jsxs)("div",{className:tv.default.Column,children:[F,k]}),C[44]=F,C[45]=k,C[46]=w):w=C[46],C[47]!==g||C[48]!==w||C[49]!==d?(I=(0,a.jsxs)("div",{className:tv.default.Root,children:[d,g,w]}),C[47]=g,C[48]=w,C[49]=d,C[50]=I):I=C[50],I)}function tb(e){return e.lookRight}function tS(e){return e.lookLeft}function tx(e){return e.lookDown}function tk(e){return e.lookUp}function tw(e){return e.down}function tI(e){return e.up}function tC(e){return e.right}function t_(e){return e.left}function tP(e){return e.backward}function tD(e){return e.forward}var tM=e.i(78295);function tT(e){let t=e.querySelector(".back");t&&(t.style.background="rgba(3, 79, 76, 0.6)",t.style.border="1px solid rgba(0, 219, 223, 0.5)",t.style.boxShadow="inset 0 0 10px rgba(0, 0, 0, 0.7)");let a=e.querySelector(".front");a&&(a.style.background="radial-gradient(circle at 50% 50%, rgba(23, 247, 198, 0.9) 0%, rgba(9, 184, 170, 0.95) 100%)",a.style.border="2px solid rgba(255, 255, 255, 0.4)",a.style.boxShadow="0 2px 4px rgba(0, 0, 0, 0.5), 0 1px 1px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.15), inset 0 -1px 2px rgba(0, 0, 0, 0.3)")}let tE=Math.PI/2-.01;function tB({joystickState:t,joystickZone:r,lookJoystickState:i,lookJoystickZone:o}){let{touchMode:s}=(0,v.useControls)();(0,n.useEffect)(()=>{let a=r.current;if(!a)return;let n=null,i=!1;return e.A(84968).then(e=>{i||(n=e.default.create({zone:a,mode:"static",position:{left:"70px",bottom:"70px"},size:120,restOpacity:.9}),tT(a),n.on("move",(e,a)=>{t.current.angle=a.angle.radian,t.current.force=Math.min(1,a.force)}),n.on("end",()=>{t.current.force=0}))}),()=>{i=!0,n?.destroy()}},[t,r,s]),(0,n.useEffect)(()=>{if("dualStick"!==s)return;let t=o.current;if(!t)return;let a=null,r=!1;return e.A(84968).then(e=>{r||(a=e.default.create({zone:t,mode:"static",position:{right:"70px",bottom:"70px"},size:120,restOpacity:.9}),tT(t),a.on("move",(e,t)=>{i.current.angle=t.angle.radian,i.current.force=Math.min(1,t.force)}),a.on("end",()=>{i.current.force=0}))}),()=>{r=!0,a?.destroy()}},[s,i,o]);let l=()=>{document.activeElement instanceof HTMLElement&&document.activeElement.blur()};return"dualStick"===s?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{ref:r,className:tM.default.Left,onContextMenu:e=>e.preventDefault(),onTouchStart:l}),(0,a.jsx)("div",{ref:o,className:tM.default.Right,onContextMenu:e=>e.preventDefault(),onTouchStart:l})]}):(0,a.jsx)("div",{ref:r,className:tM.default.Joystick,onContextMenu:e=>e.preventDefault(),onTouchStart:l})}function tj(e){let t,a,i,s,l,c,d,m,f,g,p=(0,r.c)(25),{joystickState:y,joystickZone:F,lookJoystickState:b}=e,{speedMultiplier:S,touchMode:x}=(0,v.useControls)(),{camera:k,gl:w}=(0,h.useThree)();p[0]===Symbol.for("react.memo_cache_sentinel")?(t=new o.Euler(0,0,0,"YXZ"),p[0]=t):t=p[0];let I=(0,n.useRef)(t),C=(0,n.useRef)(null);p[1]===Symbol.for("react.memo_cache_sentinel")?(a={x:0,y:0},p[1]=a):a=p[1];let _=(0,n.useRef)(a);p[2]===Symbol.for("react.memo_cache_sentinel")?(i=new o.Vector3,p[2]=i):i=p[2];let P=(0,n.useRef)(i);p[3]===Symbol.for("react.memo_cache_sentinel")?(s=new o.Vector3,p[3]=s):s=p[3];let D=(0,n.useRef)(s);p[4]===Symbol.for("react.memo_cache_sentinel")?(l=new o.Vector3,p[4]=l):l=p[4];let M=(0,n.useRef)(l);return p[5]!==k.quaternion?(c=()=>{I.current.setFromQuaternion(k.quaternion,"YXZ")},p[5]=k.quaternion,p[6]=c):c=p[6],p[7]!==k?(d=[k],p[7]=k,p[8]=d):d=p[8],(0,n.useEffect)(c,d),p[9]!==k.quaternion||p[10]!==w.domElement||p[11]!==F||p[12]!==x?(m=()=>{if("moveLookStick"!==x)return;let e=w.domElement,t=e=>{let t=F.current;if(!t)return!1;let a=t.getBoundingClientRect();return e.clientX>=a.left&&e.clientX<=a.right&&e.clientY>=a.top&&e.clientY<=a.bottom},a=e=>{if(null===C.current)for(let a=0;a<e.changedTouches.length;a++){let r=e.changedTouches[a];if(!t(r)){C.current=r.identifier,_.current={x:r.clientX,y:r.clientY};break}}},r=e=>{if(null!==C.current)for(let t=0;t<e.changedTouches.length;t++){let a=e.changedTouches[t];if(a.identifier===C.current){let e=a.clientX-_.current.x,t=a.clientY-_.current.y;_.current={x:a.clientX,y:a.clientY},I.current.setFromQuaternion(k.quaternion,"YXZ"),I.current.y=I.current.y-.004*e,I.current.x=I.current.x-.004*t,I.current.x=Math.max(-tE,Math.min(tE,I.current.x)),k.quaternion.setFromEuler(I.current);break}}},n=e=>{for(let t=0;t<e.changedTouches.length;t++)if(e.changedTouches[t].identifier===C.current){C.current=null;break}};return e.addEventListener("touchstart",a,{passive:!0}),e.addEventListener("touchmove",r,{passive:!0}),e.addEventListener("touchend",n,{passive:!0}),e.addEventListener("touchcancel",n,{passive:!0}),()=>{e.removeEventListener("touchstart",a),e.removeEventListener("touchmove",r),e.removeEventListener("touchend",n),e.removeEventListener("touchcancel",n),C.current=null}},p[9]=k.quaternion,p[10]=w.domElement,p[11]=F,p[12]=x,p[13]=m):m=p[13],p[14]!==k||p[15]!==w.domElement||p[16]!==F||p[17]!==x?(f=[k,w.domElement,F,x],p[14]=k,p[15]=w.domElement,p[16]=F,p[17]=x,p[18]=f):f=p[18],(0,n.useEffect)(m,f),p[19]!==k||p[20]!==y.current||p[21]!==b||p[22]!==S||p[23]!==x?(g=(e,t)=>{let{force:a,angle:r}=y.current;if("dualStick"===x){let e=b.current;if(e.force>.15){let a=(e.force-.15)/.85,r=Math.cos(e.angle),n=Math.sin(e.angle);I.current.setFromQuaternion(k.quaternion,"YXZ"),I.current.y=I.current.y-r*a*2.5*t,I.current.x=I.current.x+n*a*2.5*t,I.current.x=Math.max(-tE,Math.min(tE,I.current.x)),k.quaternion.setFromEuler(I.current)}if(a>.08){let e=80*S*((a-.08)/.92),n=Math.cos(r),i=Math.sin(r);k.getWorldDirection(P.current),P.current.normalize(),D.current.crossVectors(k.up,P.current).normalize(),M.current.set(0,0,0).addScaledVector(P.current,i).addScaledVector(D.current,-n),M.current.lengthSq()>0&&(M.current.normalize().multiplyScalar(e*t),k.position.add(M.current))}}else if("moveLookStick"===x&&a>0){let e=80*S*.5;if(k.getWorldDirection(P.current),P.current.normalize(),M.current.copy(P.current).multiplyScalar(e*t),k.position.add(M.current),a>=.15){let e=Math.cos(r),n=Math.sin(r),i=(a-.15)/.85;I.current.setFromQuaternion(k.quaternion,"YXZ"),I.current.y=I.current.y-e*i*1.25*t,I.current.x=I.current.x+n*i*1.25*t,I.current.x=Math.max(-tE,Math.min(tE,I.current.x)),k.quaternion.setFromEuler(I.current)}}},p[19]=k,p[20]=y.current,p[21]=b,p[22]=S,p[23]=x,p[24]=g):g=p[24],(0,u.useFrame)(g),null}var tR=e.i(11889),tN=e.i(56373),tA=e.i(86447),tG=e.i(1559),tU=e.i(78440),tL=e.i(59129),tz=e.i(25998),tO=e.i(18364),tV=e.i(70238),tq=e.i(29402),tH=e.i(97442);let tW=new Set(["SkiFree","SkiFree_Daily","SkiFree_Randomizer"]),t$={"missions.vl2":"Official","TR2final105-client.vl2":"Team Rabbit 2","z_mappacks/CTF/Classic_maps_v1.vl2":"Classic","z_mappacks/CTF/DynamixFinalPack.vl2":"Official","z_mappacks/CTF/KryMapPack_b3EDIT.vl2":"KryMapPack","z_mappacks/CTF/S5maps.vl2":"S5","z_mappacks/CTF/S8maps.vl2":"S8","z_mappacks/CTF/TWL-MapPack.vl2":"TWL","z_mappacks/CTF/TWL-MapPackEDIT.vl2":"TWL","z_mappacks/CTF/TWL2-MapPack.vl2":"TWL2","z_mappacks/CTF/TWL2-MapPackEDIT.vl2":"TWL2","z_mappacks/TWL_T2arenaOfficialMaps.vl2":"Arena","z_mappacks/xPack2.vl2":"xPack2","z_mappacks/z_DMP2-V0.6.vl2":"DMP2 (Discord Map Pack)","z_mappacks/zDMP-4.7.3DX.vl2":"DMP (Discord Map Pack)","z_mappacks/zDMP-4.7.3DX-ServerOnly.vl2":"DMP (Discord Map Pack)"},tY={"z_mappacks/DM":"DM","z_mappacks/LCTF":"LCTF","z_mappacks/Lak":"LakRabbit"},tK=(0,eG.getMissionList)().filter(e=>!tW.has(e)).map(e=>{let t,a=(0,eG.getMissionInfo)(e),[r]=(0,eG.getSourceAndPath)(a.resourcePath),n=(t=r.match(/^(.*)(\/[^/]+)$/))?t[1]:"",i=t$[r]??tY[n]??null;return{resourcePath:a.resourcePath,missionName:e,displayName:a.displayName,sourcePath:r,groupName:i,missionTypes:a.missionTypes}}),tX=new Map(tK.map(e=>[e.missionName,e])),tZ=function(e){let t=new Map;for(let a of e){let e=t.get(a.groupName)??[];e.push(a),t.set(a.groupName,e)}return t.forEach((e,a)=>{t.set(a,(0,tq.default)(e,[e=>(e.displayName||e.missionName).toLowerCase()],["asc"]))}),(0,tq.default)(Array.from(t.entries()),[([e])=>"Official"===e?0:null==e?2:1,([e])=>e?e.toLowerCase():""],["asc","asc"])}(tK),tJ="u">typeof navigator&&/Mac|iPhone|iPad|iPod/.test(navigator.platform);function tQ(e){let t,n,i,o,s,l=(0,r.c)(12),{mission:c}=e,d=c.displayName||c.missionName;return l[0]!==d?(t=(0,a.jsx)("span",{className:tH.default.ItemName,children:d}),l[0]=d,l[1]=t):t=l[1],l[2]!==c.missionTypes?(n=c.missionTypes.length>0&&(0,a.jsx)("span",{className:tH.default.ItemTypes,children:c.missionTypes.map(t0)}),l[2]=c.missionTypes,l[3]=n):n=l[3],l[4]!==t||l[5]!==n?(i=(0,a.jsxs)("span",{className:tH.default.ItemHeader,children:[t,n]}),l[4]=t,l[5]=n,l[6]=i):i=l[6],l[7]!==c.missionName?(o=(0,a.jsx)("span",{className:tH.default.ItemMissionName,children:c.missionName}),l[7]=c.missionName,l[8]=o):o=l[8],l[9]!==i||l[10]!==o?(s=(0,a.jsxs)(a.Fragment,{children:[i,o]}),l[9]=i,l[10]=o,l[11]=s):s=l[11],s}function t0(e){return(0,a.jsx)("span",{className:tH.default.ItemType,"data-mission-type":e,children:e},e)}function t1(e){let t,i,o,s,l,c,d,u,h,m,f,g,p,y,v,F,b,S=(0,r.c)(46),{value:x,missionType:k,onChange:w,disabled:I}=e,[C,_]=(0,n.useState)(""),P=(0,n.useRef)(null),D=(0,n.useRef)(k);S[0]===Symbol.for("react.memo_cache_sentinel")?(t=e=>{(0,n.startTransition)(()=>_(e))},S[0]=t):t=S[0];let M=(0,tO.useComboboxStore)({resetValueOnHide:!0,selectedValue:x,setSelectedValue:e=>{if(e){let t=D.current,a=(0,eG.getMissionInfo)(e).missionTypes;t&&a.includes(t)||(t=a[0]),w({missionName:e,missionType:t}),P.current?.blur()}},setValue:t});S[1]!==M?(i=()=>{let e=e=>{"k"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),P.current?.focus(),M.show())};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},o=[M],S[1]=M,S[2]=i,S[3]=o):(i=S[2],o=S[3]),(0,n.useEffect)(i,o),S[4]!==x?(s=tX.get(x),S[4]=x,S[5]=s):s=S[5];let T=s;e:{let e,t;if(!C){let e;S[6]===Symbol.for("react.memo_cache_sentinel")?(e={type:"grouped",groups:tZ},S[6]=e):e=S[6],l=e;break e}S[7]!==C?(e=(0,tV.matchSorter)(tK,C,{keys:["displayName","missionName","missionTypes","groupName"]}),S[7]=C,S[8]=e):e=S[8];let a=e;S[9]!==a?(t={type:"flat",missions:a},S[9]=a,S[10]=t):t=S[10],l=t}let E=l,B=T?T.displayName||T.missionName:x,j="flat"===E.type?0===E.missions.length:0===E.groups.length,R=e=>(0,a.jsx)(tN.ComboboxItem,{value:e.missionName,className:tH.default.Item,focusOnHover:!0,onClick:t=>{if(t.target&&t.target instanceof HTMLElement){let a=t.target.dataset.missionType;a?(D.current=a,e.missionName===x&&w({missionName:e.missionName,missionType:a})):D.current=null}else D.current=null},children:(0,a.jsx)(tQ,{mission:e})},e.missionName),N=tU.ComboboxProvider;S[11]!==M?(c=()=>{try{document.exitPointerLock()}catch{}M.show()},d=e=>{"Escape"!==e.key||M.getState().open||P.current?.blur()},S[11]=M,S[12]=c,S[13]=d):(c=S[12],d=S[13]),S[14]!==I||S[15]!==B||S[16]!==c||S[17]!==d?(u=(0,a.jsx)(tR.Combobox,{ref:P,autoSelect:!0,disabled:I,placeholder:B,className:tH.default.Input,onFocus:c,onKeyDown:d}),S[14]=I,S[15]=B,S[16]=c,S[17]=d,S[18]=u):u=S[18],S[19]!==B?(h=(0,a.jsx)("span",{className:tH.default.SelectedName,children:B}),S[19]=B,S[20]=h):h=S[20],S[21]!==k?(m=k&&(0,a.jsx)("span",{className:tH.default.ItemType,"data-mission-type":k,children:k}),S[21]=k,S[22]=m):m=S[22],S[23]!==m||S[24]!==h?(f=(0,a.jsxs)("div",{className:tH.default.SelectedValue,children:[h,m]}),S[23]=m,S[24]=h,S[25]=f):f=S[25],S[26]===Symbol.for("react.memo_cache_sentinel")?(g=(0,a.jsx)("kbd",{className:tH.default.Shortcut,children:tJ?"⌘K":"^K"}),S[26]=g):g=S[26],S[27]!==f||S[28]!==u?(p=(0,a.jsxs)("div",{className:tH.default.InputWrapper,children:[u,f,g]}),S[27]=f,S[28]=u,S[29]=p):p=S[29];let A=tG.ComboboxPopover,G=tH.default,U=tA.ComboboxList,L=tH.default,z="flat"===E.type?E.missions.map(R):E.groups.map(e=>{let[t,r]=e;return t?(0,a.jsxs)(tL.ComboboxGroup,{className:tH.default.Group,children:[(0,a.jsx)(tz.ComboboxGroupLabel,{className:tH.default.GroupLabel,children:t}),r.map(R)]},t):(0,a.jsx)(n.Fragment,{children:r.map(R)},"ungrouped")});return S[30]!==j?(y=j&&(0,a.jsx)("div",{className:tH.default.NoResults,children:"No missions found"}),S[30]=j,S[31]=y):y=S[31],S[32]!==U||S[33]!==L.List||S[34]!==z||S[35]!==y?(v=(0,a.jsxs)(U,{className:L.List,children:[z,y]}),S[32]=U,S[33]=L.List,S[34]=z,S[35]=y,S[36]=v):v=S[36],S[37]!==A||S[38]!==G.Popover||S[39]!==v?(F=(0,a.jsx)(A,{gutter:4,fitViewport:!0,autoFocusOnHide:!1,className:G.Popover,children:v}),S[37]=A,S[38]=G.Popover,S[39]=v,S[40]=F):F=S[40],S[41]!==N||S[42]!==M||S[43]!==p||S[44]!==F?(b=(0,a.jsxs)(N,{store:M,children:[p,F]}),S[41]=N,S[42]=M,S[43]=p,S[44]=F,S[45]=b):b=S[45],b}var t2=e.i(11152),t3=e.i(40141);function t5(e){return(0,t3.GenIcon)({tag:"svg",attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M192 0c-41.8 0-77.4 26.7-90.5 64L64 64C28.7 64 0 92.7 0 128L0 448c0 35.3 28.7 64 64 64l256 0c35.3 0 64-28.7 64-64l0-320c0-35.3-28.7-64-64-64l-37.5 0C269.4 26.7 233.8 0 192 0zm0 64a32 32 0 1 1 0 64 32 32 0 1 1 0-64zM305 273L177 401c-9.4 9.4-24.6 9.4-33.9 0L79 337c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l47 47L271 239c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9z"},child:[]}]})(e)}var t4=e.i(36679);function t6(e){let t,i,o,s,l,c=(0,r.c)(11),{cameraRef:d,missionName:u,missionType:h}=e,{fogEnabled:m}=(0,v.useSettings)(),[f,g]=(0,n.useState)(!1),p=(0,n.useRef)(null);c[0]!==d||c[1]!==m||c[2]!==u||c[3]!==h?(t=async()=>{clearTimeout(p.current);let e=d.current;if(!e)return;let t=function({position:e,quaternion:t}){let a=e=>parseFloat(e.toFixed(3)),r=`${a(e.x)},${a(e.y)},${a(e.z)}`,n=`${a(t.x)},${a(t.y)},${a(t.z)},${a(t.w)}`;return`#c${r}~${n}`}(e),a=new URLSearchParams;a.set("mission",`${u}~${h}`),a.set("fog",m.toString());let r=`${window.location.pathname}?${a}${t}`,n=`${window.location.origin}${r}`;window.history.replaceState(null,"",r);try{await navigator.clipboard.writeText(n),g(!0),p.current=setTimeout(()=>{g(!1)},1100)}catch(e){console.error(e)}},c[0]=d,c[1]=m,c[2]=u,c[3]=h,c[4]=t):t=c[4];let y=t,F=f?"true":"false";return c[5]===Symbol.for("react.memo_cache_sentinel")?(i=(0,a.jsx)(t2.FaMapPin,{className:t4.default.MapPin}),o=(0,a.jsx)(t5,{className:t4.default.ClipboardCheck}),s=(0,a.jsx)("span",{className:t4.default.ButtonLabel,children:" Copy coordinates URL"}),c[5]=i,c[6]=o,c[7]=s):(i=c[5],o=c[6],s=c[7]),c[8]!==y||c[9]!==F?(l=(0,a.jsxs)("button",{type:"button",className:t4.default.Root,"aria-label":"Copy coordinates URL",title:"Copy coordinates URL",onClick:y,"data-copied":F,id:"copyCoordinatesButton",children:[i,o,s]}),c[8]=y,c[9]=F,c[10]=l):l=c[10],l}function t8(e){return(0,t3.GenIcon)({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0V0z"},child:[]},{tag:"path",attr:{d:"M21 3H3c-1.11 0-2 .89-2 2v12a2 2 0 0 0 2 2h5v2h8v-2h5c1.1 0 1.99-.9 1.99-2L23 5a2 2 0 0 0-2-2zm0 14H3V5h18v12zm-5-6-7 4V7z"},child:[]}]})(e)}var t7={},t9=function(e,t,a,r,n){var i=new Worker(t7[t]||(t7[t]=URL.createObjectURL(new Blob([e+';addEventListener("error",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})'],{type:"text/javascript"}))));return i.onmessage=function(e){var t=e.data,a=t.$e$;if(a){var r=Error(a[0]);r.code=a[1],r.stack=a[2],n(r,null)}else n(null,t)},i.postMessage(a,r),i},ae=Uint8Array,at=Uint16Array,aa=Int32Array,ar=new ae([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),an=new ae([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),ai=new ae([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ao=function(e,t){for(var a=new at(31),r=0;r<31;++r)a[r]=t+=1<<e[r-1];for(var n=new aa(a[30]),r=1;r<30;++r)for(var i=a[r];i<a[r+1];++i)n[i]=i-a[r]<<5|r;return{b:a,r:n}},as=ao(ar,2),al=as.b,ac=as.r;al[28]=258,ac[258]=28;for(var ad=ao(an,0),au=ad.b,ah=ad.r,am=new at(32768),af=0;af<32768;++af){var ag=(43690&af)>>1|(21845&af)<<1;ag=(61680&(ag=(52428&ag)>>2|(13107&ag)<<2))>>4|(3855&ag)<<4,am[af]=((65280&ag)>>8|(255&ag)<<8)>>1}for(var ap=function(e,t,a){for(var r,n=e.length,i=0,o=new at(t);i<n;++i)e[i]&&++o[e[i]-1];var s=new at(t);for(i=1;i<t;++i)s[i]=s[i-1]+o[i-1]<<1;if(a){r=new at(1<<t);var l=15-t;for(i=0;i<n;++i)if(e[i])for(var c=i<<4|e[i],d=t-e[i],u=s[e[i]-1]++<<d,h=u|(1<<d)-1;u<=h;++u)r[am[u]>>l]=c}else for(i=0,r=new at(n);i<n;++i)e[i]&&(r[i]=am[s[e[i]-1]++]>>15-e[i]);return r},ay=new ae(288),af=0;af<144;++af)ay[af]=8;for(var af=144;af<256;++af)ay[af]=9;for(var af=256;af<280;++af)ay[af]=7;for(var af=280;af<288;++af)ay[af]=8;for(var av=new ae(32),af=0;af<32;++af)av[af]=5;var aF=ap(ay,9,0),ab=ap(ay,9,1),aS=ap(av,5,0),ax=ap(av,5,1),ak=function(e){for(var t=e[0],a=1;a<e.length;++a)e[a]>t&&(t=e[a]);return t},aw=function(e,t,a){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(7&t)&a},aI=function(e,t){var a=t/8|0;return(e[a]|e[a+1]<<8|e[a+2]<<16)>>(7&t)},aC=function(e){return(e+7)/8|0},a_=function(e,t,a){return(null==t||t<0)&&(t=0),(null==a||a>e.length)&&(a=e.length),new ae(e.subarray(t,a))},aP=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],aD=function(e,t,a){var r=Error(t||aP[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,aD),!a)throw r;return r},aM=function(e,t,a,r){var n=e.length,i=r?r.length:0;if(!n||t.f&&!t.l)return a||new ae(0);var o=!a,s=o||2!=t.i,l=t.i;o&&(a=new ae(3*n));var c=function(e){var t=a.length;if(e>t){var r=new ae(Math.max(2*t,e));r.set(a),a=r}},d=t.f||0,u=t.p||0,h=t.b||0,m=t.l,f=t.d,g=t.m,p=t.n,y=8*n;do{if(!m){d=aw(e,u,1);var v=aw(e,u+1,3);if(u+=3,v)if(1==v)m=ab,f=ax,g=9,p=5;else if(2==v){var F=aw(e,u,31)+257,b=aw(e,u+10,15)+4,S=F+aw(e,u+5,31)+1;u+=14;for(var x=new ae(S),k=new ae(19),w=0;w<b;++w)k[ai[w]]=aw(e,u+3*w,7);u+=3*b;for(var I=ak(k),C=(1<<I)-1,_=ap(k,I,1),w=0;w<S;){var P=_[aw(e,u,C)];u+=15&P;var D=P>>4;if(D<16)x[w++]=D;else{var M=0,T=0;for(16==D?(T=3+aw(e,u,3),u+=2,M=x[w-1]):17==D?(T=3+aw(e,u,7),u+=3):18==D&&(T=11+aw(e,u,127),u+=7);T--;)x[w++]=M}}var E=x.subarray(0,F),B=x.subarray(F);g=ak(E),p=ak(B),m=ap(E,g,1),f=ap(B,p,1)}else aD(1);else{var D=aC(u)+4,j=e[D-4]|e[D-3]<<8,R=D+j;if(R>n){l&&aD(0);break}s&&c(h+j),a.set(e.subarray(D,R),h),t.b=h+=j,t.p=u=8*R,t.f=d;continue}if(u>y){l&&aD(0);break}}s&&c(h+131072);for(var N=(1<<g)-1,A=(1<<p)-1,G=u;;G=u){var M=m[aI(e,u)&N],U=M>>4;if((u+=15&M)>y){l&&aD(0);break}if(M||aD(2),U<256)a[h++]=U;else if(256==U){G=u,m=null;break}else{var L=U-254;if(U>264){var w=U-257,z=ar[w];L=aw(e,u,(1<<z)-1)+al[w],u+=z}var O=f[aI(e,u)&A],V=O>>4;O||aD(3),u+=15&O;var B=au[V];if(V>3){var z=an[V];B+=aI(e,u)&(1<<z)-1,u+=z}if(u>y){l&&aD(0);break}s&&c(h+131072);var q=h+L;if(h<B){var H=i-B,W=Math.min(B,q);for(H+h<0&&aD(3);h<W;++h)a[h]=r[H+h]}for(;h<q;++h)a[h]=a[h-B]}}t.l=m,t.p=G,t.b=h,t.f=d,m&&(d=1,t.m=g,t.d=f,t.n=p)}while(!d)return h!=a.length&&o?a_(a,0,h):a.subarray(0,h)},aT=function(e,t,a){a<<=7&t;var r=t/8|0;e[r]|=a,e[r+1]|=a>>8},aE=function(e,t,a){a<<=7&t;var r=t/8|0;e[r]|=a,e[r+1]|=a>>8,e[r+2]|=a>>16},aB=function(e,t){for(var a=[],r=0;r<e.length;++r)e[r]&&a.push({s:r,f:e[r]});var n=a.length,i=a.slice();if(!n)return{t:aL,l:0};if(1==n){var o=new ae(a[0].s+1);return o[a[0].s]=1,{t:o,l:1}}a.sort(function(e,t){return e.f-t.f}),a.push({s:-1,f:25001});var s=a[0],l=a[1],c=0,d=1,u=2;for(a[0]={s:-1,f:s.f+l.f,l:s,r:l};d!=n-1;)s=a[a[c].f<a[u].f?c++:u++],l=a[c!=d&&a[c].f<a[u].f?c++:u++],a[d++]={s:-1,f:s.f+l.f,l:s,r:l};for(var h=i[0].s,r=1;r<n;++r)i[r].s>h&&(h=i[r].s);var m=new at(h+1),f=aj(a[d-1],m,0);if(f>t){var r=0,g=0,p=f-t,y=1<<p;for(i.sort(function(e,t){return m[t.s]-m[e.s]||e.f-t.f});r<n;++r){var v=i[r].s;if(m[v]>t)g+=y-(1<<f-m[v]),m[v]=t;else break}for(g>>=p;g>0;){var F=i[r].s;m[F]<t?g-=1<<t-m[F]++-1:++r}for(;r>=0&&g;--r){var b=i[r].s;m[b]==t&&(--m[b],++g)}f=t}return{t:new ae(m),l:f}},aj=function(e,t,a){return -1==e.s?Math.max(aj(e.l,t,a+1),aj(e.r,t,a+1)):t[e.s]=a},aR=function(e){for(var t=e.length;t&&!e[--t];);for(var a=new at(++t),r=0,n=e[0],i=1,o=function(e){a[r++]=e},s=1;s<=t;++s)if(e[s]==n&&s!=t)++i;else{if(!n&&i>2){for(;i>138;i-=138)o(32754);i>2&&(o(i>10?i-11<<5|28690:i-3<<5|12305),i=0)}else if(i>3){for(o(n),--i;i>6;i-=6)o(8304);i>2&&(o(i-3<<5|8208),i=0)}for(;i--;)o(n);i=1,n=e[s]}return{c:a.subarray(0,r),n:t}},aN=function(e,t){for(var a=0,r=0;r<t.length;++r)a+=e[r]*t[r];return a},aA=function(e,t,a){var r=a.length,n=aC(t+2);e[n]=255&r,e[n+1]=r>>8,e[n+2]=255^e[n],e[n+3]=255^e[n+1];for(var i=0;i<r;++i)e[n+i+4]=a[i];return(n+4+r)*8},aG=function(e,t,a,r,n,i,o,s,l,c,d){aT(t,d++,a),++n[256];for(var u,h,m,f,g=aB(n,15),p=g.t,y=g.l,v=aB(i,15),F=v.t,b=v.l,S=aR(p),x=S.c,k=S.n,w=aR(F),I=w.c,C=w.n,_=new at(19),P=0;P<x.length;++P)++_[31&x[P]];for(var P=0;P<I.length;++P)++_[31&I[P]];for(var D=aB(_,7),M=D.t,T=D.l,E=19;E>4&&!M[ai[E-1]];--E);var B=c+5<<3,j=aN(n,ay)+aN(i,av)+o,R=aN(n,p)+aN(i,F)+o+14+3*E+aN(_,M)+2*_[16]+3*_[17]+7*_[18];if(l>=0&&B<=j&&B<=R)return aA(t,d,e.subarray(l,l+c));if(aT(t,d,1+(R<j)),d+=2,R<j){u=ap(p,y,0),h=p,m=ap(F,b,0),f=F;var N=ap(M,T,0);aT(t,d,k-257),aT(t,d+5,C-1),aT(t,d+10,E-4),d+=14;for(var P=0;P<E;++P)aT(t,d+3*P,M[ai[P]]);d+=3*E;for(var A=[x,I],G=0;G<2;++G)for(var U=A[G],P=0;P<U.length;++P){var L=31&U[P];aT(t,d,N[L]),d+=M[L],L>15&&(aT(t,d,U[P]>>5&127),d+=U[P]>>12)}}else u=aF,h=ay,m=aS,f=av;for(var P=0;P<s;++P){var z=r[P];if(z>255){var L=z>>18&31;aE(t,d,u[L+257]),d+=h[L+257],L>7&&(aT(t,d,z>>23&31),d+=ar[L]);var O=31&z;aE(t,d,m[O]),d+=f[O],O>3&&(aE(t,d,z>>5&8191),d+=an[O])}else aE(t,d,u[z]),d+=h[z]}return aE(t,d,u[256]),d+h[256]},aU=new aa([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),aL=new ae(0),az=function(e,t,a,r,n,i){var o=i.z||e.length,s=new ae(r+o+5*(1+Math.ceil(o/7e3))+n),l=s.subarray(r,s.length-n),c=i.l,d=7&(i.r||0);if(t){d&&(l[0]=i.r>>3);for(var u=aU[t-1],h=u>>13,m=8191&u,f=(1<<a)-1,g=i.p||new at(32768),p=i.h||new at(f+1),y=Math.ceil(a/3),v=2*y,F=function(t){return(e[t]^e[t+1]<<y^e[t+2]<<v)&f},b=new aa(25e3),S=new at(288),x=new at(32),k=0,w=0,I=i.i||0,C=0,_=i.w||0,P=0;I+2<o;++I){var D=F(I),M=32767&I,T=p[D];if(g[M]=T,p[D]=M,_<=I){var E=o-I;if((k>7e3||C>24576)&&(E>423||!c)){d=aG(e,l,0,b,S,x,w,C,P,I-P,d),C=k=w=0,P=I;for(var B=0;B<286;++B)S[B]=0;for(var B=0;B<30;++B)x[B]=0}var j=2,R=0,N=m,A=M-T&32767;if(E>2&&D==F(I-A))for(var G=Math.min(h,E)-1,U=Math.min(32767,I),L=Math.min(258,E);A<=U&&--N&&M!=T;){if(e[I+j]==e[I+j-A]){for(var z=0;z<L&&e[I+z]==e[I+z-A];++z);if(z>j){if(j=z,R=A,z>G)break;for(var O=Math.min(A,z-2),V=0,B=0;B<O;++B){var q=I-A+B&32767,H=g[q],W=q-H&32767;W>V&&(V=W,T=q)}}}T=g[M=T],A+=M-T&32767}if(R){b[C++]=0x10000000|ac[j]<<18|ah[R];var $=31&ac[j],Y=31&ah[R];w+=ar[$]+an[Y],++S[257+$],++x[Y],_=I+j,++k}else b[C++]=e[I],++S[e[I]]}}for(I=Math.max(I,_);I<o;++I)b[C++]=e[I],++S[e[I]];d=aG(e,l,c,b,S,x,w,C,P,I-P,d),c||(i.r=7&d|l[d/8|0]<<3,d-=7,i.h=p,i.p=g,i.i=I,i.w=_)}else{for(var I=i.w||0;I<o+c;I+=65535){var K=I+65535;K>=o&&(l[d/8|0]=c,K=o),d=aA(l,d+1,e.subarray(I,K))}i.i=o}return a_(s,0,r+aC(d)+n)},aO=function(){for(var e=new Int32Array(256),t=0;t<256;++t){for(var a=t,r=9;--r;)a=(1&a&&-0x12477ce0)^a>>>1;e[t]=a}return e}(),aV=function(){var e=-1;return{p:function(t){for(var a=e,r=0;r<t.length;++r)a=aO[255&a^t[r]]^a>>>8;e=a},d:function(){return~e}}},aq=function(){var e=1,t=0;return{p:function(a){for(var r=e,n=t,i=0|a.length,o=0;o!=i;){for(var s=Math.min(o+2655,i);o<s;++o)n+=r+=a[o];r=(65535&r)+15*(r>>16),n=(65535&n)+15*(n>>16)}e=r,t=n},d:function(){return e%=65521,t%=65521,(255&e)<<24|(65280&e)<<8|(255&t)<<8|t>>8}}},aH=function(e,t,a,r,n){if(!n&&(n={l:1},t.dictionary)){var i=t.dictionary.subarray(-32768),o=new ae(i.length+e.length);o.set(i),o.set(e,i.length),e=o,n.w=i.length}return az(e,null==t.level?6:t.level,null==t.mem?n.l?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):20:12+t.mem,a,r,n)},aW=function(e,t){var a={};for(var r in e)a[r]=e[r];for(var r in t)a[r]=t[r];return a},a$=function(e,t,a){for(var r=e(),n=e.toString(),i=n.slice(n.indexOf("[")+1,n.lastIndexOf("]")).replace(/\s+/g,"").split(","),o=0;o<r.length;++o){var s=r[o],l=i[o];if("function"==typeof s){t+=";"+l+"=";var c=s.toString();if(s.prototype)if(-1!=c.indexOf("[native code]")){var d=c.indexOf(" ",8)+1;t+=c.slice(d,c.indexOf("(",d))}else for(var u in t+=c,s.prototype)t+=";"+l+".prototype."+u+"="+s.prototype[u].toString();else t+=c}else a[l]=s}return t},aY=[],aK=function(e){var t=[];for(var a in e)e[a].buffer&&t.push((e[a]=new e[a].constructor(e[a])).buffer);return t},aX=function(e,t,a,r){if(!aY[a]){for(var n="",i={},o=e.length-1,s=0;s<o;++s)n=a$(e[s],n,i);aY[a]={c:a$(e[o],n,i),e:i}}var l=aW({},aY[a].e);return t9(aY[a].c+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+t.toString()+"}",a,l,aK(l),r)},aZ=function(){return[ae,at,aa,ar,an,ai,al,au,ab,ax,am,aP,ap,ak,aw,aI,aC,a_,aD,aM,rh,a1,a2]},aJ=function(){return[ae,at,aa,ar,an,ai,ac,ah,aF,ay,aS,av,am,aU,aL,ap,aT,aE,aB,aj,aR,aN,aA,aG,aC,a_,az,aH,rc,a1]},aQ=function(){return[rt,ra]},a0=function(){return[ri]},a1=function(e){return postMessage(e,[e.buffer])},a2=function(e){return e&&{out:e.size&&new ae(e.size),dictionary:e.dictionary}},a3=function(e,t,a,r,n,i){var o=aX(a,r,n,function(e,t){o.terminate(),i(e,t)});return o.postMessage([e,t],t.consume?[e.buffer]:[]),function(){o.terminate()}},a5=function(e){return e.ondata=function(e,t){return postMessage([e,t],[e.buffer])},function(t){t.data.length?(e.push(t.data[0],t.data[1]),postMessage([t.data[0].length])):e.flush()}},a4=function(e,t,a,r,n,i,o){var s,l=aX(e,r,n,function(e,a){e?(l.terminate(),t.ondata.call(t,e)):Array.isArray(a)?1==a.length?(t.queuedSize-=a[0],t.ondrain&&t.ondrain(a[0])):(a[1]&&l.terminate(),t.ondata.call(t,e,a[0],a[1])):o(a)});l.postMessage(a),t.queuedSize=0,t.push=function(e,a){t.ondata||aD(5),s&&t.ondata(aD(4,0,1),null,!!a),t.queuedSize+=e.length,l.postMessage([e,s=a],[e.buffer])},t.terminate=function(){l.terminate()},i&&(t.flush=function(){l.postMessage([])})},a6=function(e,t){return e[t]|e[t+1]<<8},a8=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},a7=function(e,t){return a8(e,t)+0x100000000*a8(e,t+4)},a9=function(e,t,a){for(;a;++t)e[t]=a,a>>>=8},re=function(e,t){var a=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:2*(9==t.level),e[9]=3,0!=t.mtime&&a9(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),a){e[3]=8;for(var r=0;r<=a.length;++r)e[r+10]=a.charCodeAt(r)}},rt=function(e){(31!=e[0]||139!=e[1]||8!=e[2])&&aD(6,"invalid gzip data");var t=e[3],a=10;4&t&&(a+=(e[10]|e[11]<<8)+2);for(var r=(t>>3&1)+(t>>4&1);r>0;r-=!e[a++]);return a+(2&t)},ra=function(e){var t=e.length;return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0},rr=function(e){return 10+(e.filename?e.filename.length+1:0)},rn=function(e,t){var a=t.level;if(e[0]=120,e[1]=(0==a?0:a<6?1:9==a?3:2)<<6|(t.dictionary&&32),e[1]|=31-(e[0]<<8|e[1])%31,t.dictionary){var r=aq();r.p(t.dictionary),a9(e,2,r.d())}},ri=function(e,t){return((15&e[0])!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&aD(6,"invalid zlib data"),(e[1]>>5&1)==+!t&&aD(6,"invalid zlib data: "+(32&e[1]?"need":"unexpected")+" dictionary"),(e[1]>>3&4)+2};function ro(e,t){return"function"==typeof e&&(t=e,e={}),this.ondata=t,e}var rs=function(){function e(e,t){if("function"==typeof e&&(t=e,e={}),this.ondata=t,this.o=e||{},this.s={l:0,i:32768,w:32768,z:32768},this.b=new ae(98304),this.o.dictionary){var a=this.o.dictionary.subarray(-32768);this.b.set(a,32768-a.length),this.s.i=32768-a.length}}return e.prototype.p=function(e,t){this.ondata(aH(e,this.o,0,0,this.s),t)},e.prototype.push=function(e,t){this.ondata||aD(5),this.s.l&&aD(4);var a=e.length+this.s.z;if(a>this.b.length){if(a>2*this.b.length-32768){var r=new ae(-32768&a);r.set(this.b.subarray(0,this.s.z)),this.b=r}var n=this.b.length-this.s.z;this.b.set(e.subarray(0,n),this.s.z),this.s.z=this.b.length,this.p(this.b,!1),this.b.set(this.b.subarray(-32768)),this.b.set(e.subarray(n),32768),this.s.z=e.length-n+32768,this.s.i=32766,this.s.w=32768}else this.b.set(e,this.s.z),this.s.z+=e.length;this.s.l=1&t,(this.s.z>this.s.w+8191||t)&&(this.p(this.b,t||!1),this.s.w=this.s.i,this.s.i-=2)},e.prototype.flush=function(){this.ondata||aD(5),this.s.l&&aD(4),this.p(this.b,!1),this.s.w=this.s.i,this.s.i-=2},e}(),rl=function(e,t){a4([aJ,function(){return[a5,rs]}],this,ro.call(this,e,t),function(e){onmessage=a5(new rs(e.data))},6,1)};function rc(e,t){return aH(e,t||{},0,0)}var rd=function(){function e(e,t){"function"==typeof e&&(t=e,e={}),this.ondata=t;var a=e&&e.dictionary&&e.dictionary.subarray(-32768);this.s={i:0,b:a?a.length:0},this.o=new ae(32768),this.p=new ae(0),a&&this.o.set(a)}return e.prototype.e=function(e){if(this.ondata||aD(5),this.d&&aD(4),this.p.length){if(e.length){var t=new ae(this.p.length+e.length);t.set(this.p),t.set(e,this.p.length),this.p=t}}else this.p=e},e.prototype.c=function(e){this.s.i=+(this.d=e||!1);var t=this.s.b,a=aM(this.p,this.s,this.o);this.ondata(a_(a,t,this.s.b),this.d),this.o=a_(a,this.s.b-32768),this.s.b=this.o.length,this.p=a_(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(e,t){this.e(e),this.c(t)},e}(),ru=function(e,t){a4([aZ,function(){return[a5,rd]}],this,ro.call(this,e,t),function(e){onmessage=a5(new rd(e.data))},7,0)};function rh(e,t){return aM(e,{i:2},t&&t.out,t&&t.dictionary)}(function(){function e(e,t){this.c=aV(),this.l=0,this.v=1,rs.call(this,e,t)}e.prototype.push=function(e,t){this.c.p(e),this.l+=e.length,rs.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){var a=aH(e,this.o,this.v&&rr(this.o),t&&8,this.s);this.v&&(re(a,this.o),this.v=0),t&&(a9(a,a.length-8,this.c.d()),a9(a,a.length-4,this.l)),this.ondata(a,t)},e.prototype.flush=function(){rs.prototype.flush.call(this)}})();var rm=function(){function e(e,t){this.v=1,this.r=0,rd.call(this,e,t)}return e.prototype.push=function(e,t){if(rd.prototype.e.call(this,e),this.r+=e.length,this.v){var a=this.p.subarray(this.v-1),r=a.length>3?rt(a):4;if(r>a.length){if(!t)return}else this.v>1&&this.onmember&&this.onmember(this.r-a.length);this.p=a.subarray(r),this.v=0}rd.prototype.c.call(this,t),!this.s.f||this.s.l||t||(this.v=aC(this.s.p)+9,this.s={i:0},this.o=new ae(0),this.push(new ae(0),t))},e}(),rf=function(e,t){var a=this;a4([aZ,aQ,function(){return[a5,rd,rm]}],this,ro.call(this,e,t),function(e){var t=new rm(e.data);t.onmember=function(e){return postMessage(e)},onmessage=a5(t)},9,0,function(e){return a.onmember&&a.onmember(e)})},rg=(function(){function e(e,t){this.c=aq(),this.v=1,rs.call(this,e,t)}e.prototype.push=function(e,t){this.c.p(e),rs.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){var a=aH(e,this.o,this.v&&(this.o.dictionary?6:2),t&&4,this.s);this.v&&(rn(a,this.o),this.v=0),t&&a9(a,a.length-4,this.c.d()),this.ondata(a,t)},e.prototype.flush=function(){rs.prototype.flush.call(this)}}(),function(){function e(e,t){rd.call(this,e,t),this.v=e&&e.dictionary?2:1}return e.prototype.push=function(e,t){if(rd.prototype.e.call(this,e),this.v){if(this.p.length<6&&!t)return;this.p=this.p.subarray(ri(this.p,this.v-1)),this.v=0}t&&(this.p.length<4&&aD(6,"invalid zlib data"),this.p=this.p.subarray(0,-4)),rd.prototype.c.call(this,t)},e}()),rp=function(e,t){a4([aZ,a0,function(){return[a5,rd,rg]}],this,ro.call(this,e,t),function(e){onmessage=a5(new rg(e.data))},11,0)},ry=function(){function e(e,t){this.o=ro.call(this,e,t)||{},this.G=rm,this.I=rd,this.Z=rg}return e.prototype.i=function(){var e=this;this.s.ondata=function(t,a){e.ondata(t,a)}},e.prototype.push=function(e,t){if(this.ondata||aD(5),this.s)this.s.push(e,t);else{if(this.p&&this.p.length){var a=new ae(this.p.length+e.length);a.set(this.p),a.set(e,this.p.length)}else this.p=e;this.p.length>2&&(this.s=31==this.p[0]&&139==this.p[1]&&8==this.p[2]?new this.G(this.o):(15&this.p[0])!=8||this.p[0]>>4>7||(this.p[0]<<8|this.p[1])%31?new this.I(this.o):new this.Z(this.o),this.i(),this.s.push(this.p,t),this.p=null)}},e}();function rv(e,t){ry.call(this,e,t),this.queuedSize=0,this.G=rf,this.I=ru,this.Z=rp}rv.prototype.i=function(){var e=this;this.s.ondata=function(t,a,r){e.ondata(t,a,r)},this.s.ondrain=function(t){e.queuedSize-=t,e.ondrain&&e.ondrain(t)}},rv.prototype.push=function(e,t){this.queuedSize+=e.length,ry.prototype.push.call(this,e,t)};var rF="u">typeof TextEncoder&&new TextEncoder,rb="u">typeof TextDecoder&&new TextDecoder,rS=0;try{rb.decode(aL,{stream:!0}),rS=1}catch(e){}var rx=function(e){for(var t="",a=0;;){var r=e[a++],n=(r>127)+(r>223)+(r>239);if(a+n>e.length)return{s:t,r:a_(e,a-1)};n?3==n?t+=String.fromCharCode(55296|(r=((15&r)<<18|(63&e[a++])<<12|(63&e[a++])<<6|63&e[a++])-65536)>>10,56320|1023&r):1&n?t+=String.fromCharCode((31&r)<<6|63&e[a++]):t+=String.fromCharCode((15&r)<<12|(63&e[a++])<<6|63&e[a++]):t+=String.fromCharCode(r)}};function rk(e,t){if(t){for(var a=new ae(e.length),r=0;r<e.length;++r)a[r]=e.charCodeAt(r);return a}if(rF)return rF.encode(e);for(var n=e.length,i=new ae(e.length+(e.length>>1)),o=0,s=function(e){i[o++]=e},r=0;r<n;++r){if(o+5>i.length){var l=new ae(o+8+(n-r<<1));l.set(i),i=l}var c=e.charCodeAt(r);c<128||t?s(c):(c<2048?s(192|c>>6):(c>55295&&c<57344?(s(240|(c=65536+(1047552&c)|1023&e.charCodeAt(++r))>>18),s(128|c>>12&63)):s(224|c>>12),s(128|c>>6&63)),s(128|63&c))}return a_(i,0,o)}(function(e){this.ondata=e,rS?this.t=new TextDecoder:this.p=aL}).prototype.push=function(e,t){if(this.ondata||aD(5),t=!!t,this.t){this.ondata(this.t.decode(e,{stream:!0}),t),t&&(this.t.decode().length&&aD(8),this.t=null);return}this.p||aD(4);var a=new ae(this.p.length+e.length);a.set(this.p),a.set(e,this.p.length);var r=rx(a),n=r.s,i=r.r;t?(i.length&&aD(8),this.p=null):this.p=i,this.ondata(n,t)},(function(e){this.ondata=e}).prototype.push=function(e,t){this.ondata||aD(5),this.d&&aD(4),this.ondata(rk(e),this.d=t||!1)};var rw=function(e){return 1==e?3:e<6?2:+(9==e)},rI=function(e,t){for(;1!=a6(e,t);t+=4+a6(e,t+2));return[a7(e,t+12),a7(e,t+4),a7(e,t+20)]},rC=function(e){var t=0;if(e)for(var a in e){var r=e[a].length;r>65535&&aD(9),t+=r+4}return t},r_=function(e,t,a,r,n,i,o,s){var l=r.length,c=a.extra,d=s&&s.length,u=rC(c);a9(e,t,null!=o?0x2014b50:0x4034b50),t+=4,null!=o&&(e[t++]=20,e[t++]=a.os),e[t]=20,t+=2,e[t++]=a.flag<<1|(i<0&&8),e[t++]=n&&8,e[t++]=255&a.compression,e[t++]=a.compression>>8;var h=new Date(null==a.mtime?Date.now():a.mtime),m=h.getFullYear()-1980;if((m<0||m>119)&&aD(10),a9(e,t,m<<25|h.getMonth()+1<<21|h.getDate()<<16|h.getHours()<<11|h.getMinutes()<<5|h.getSeconds()>>1),t+=4,-1!=i&&(a9(e,t,a.crc),a9(e,t+4,i<0?-i-2:i),a9(e,t+8,a.size)),a9(e,t+12,l),a9(e,t+14,u),t+=16,null!=o&&(a9(e,t,d),a9(e,t+6,a.attrs),a9(e,t+10,o),t+=14),e.set(r,t),t+=l,u)for(var f in c){var g=c[f],p=g.length;a9(e,t,+f),a9(e,t+2,p),e.set(g,t+4),t+=4+p}return d&&(e.set(s,t),t+=d),t},rP=function(e,t,a,r,n){a9(e,t,0x6054b50),a9(e,t+8,a),a9(e,t+10,a),a9(e,t+12,r),a9(e,t+16,n)},rD=function(){function e(e){this.filename=e,this.c=aV(),this.size=0,this.compression=0}return e.prototype.process=function(e,t){this.ondata(null,e,t)},e.prototype.push=function(e,t){this.ondata||aD(5),this.c.p(e),this.size+=e.length,t&&(this.crc=this.c.d()),this.process(e,t||!1)},e}();function rM(e,t){var a=this;t||(t={}),rD.call(this,e),this.d=new rs(t,function(e,t){a.ondata(null,e,t)}),this.compression=8,this.flag=rw(t.level)}function rT(e,t){var a=this;t||(t={}),rD.call(this,e),this.d=new rl(t,function(e,t,r){a.ondata(e,t,r)}),this.compression=8,this.flag=rw(t.level),this.terminate=this.d.terminate}function rE(e){this.ondata=e,this.u=[],this.d=1}rM.prototype.process=function(e,t){try{this.d.push(e,t)}catch(e){this.ondata(e,null,t)}},rM.prototype.push=function(e,t){rD.prototype.push.call(this,e,t)},rT.prototype.process=function(e,t){this.d.push(e,t)},rT.prototype.push=function(e,t){rD.prototype.push.call(this,e,t)},rE.prototype.add=function(e){var t=this;if(this.ondata||aD(5),2&this.d)this.ondata(aD(4+(1&this.d)*8,0,1),null,!1);else{var a=rk(e.filename),r=a.length,n=e.comment,i=n&&rk(n),o=r!=e.filename.length||i&&n.length!=i.length,s=r+rC(e.extra)+30;r>65535&&this.ondata(aD(11,0,1),null,!1);var l=new ae(s);r_(l,0,e,a,o,-1);var c=[l],d=function(){for(var e=0,a=c;e<a.length;e++){var r=a[e];t.ondata(null,r,!1)}c=[]},u=this.d;this.d=0;var h=this.u.length,m=aW(e,{f:a,u:o,o:i,t:function(){e.terminate&&e.terminate()},r:function(){if(d(),u){var e=t.u[h+1];e?e.r():t.d=1}u=1}}),f=0;e.ondata=function(a,r,n){if(a)t.ondata(a,r,n),t.terminate();else if(f+=r.length,c.push(r),n){var i=new ae(16);a9(i,0,0x8074b50),a9(i,4,e.crc),a9(i,8,f),a9(i,12,e.size),c.push(i),m.c=f,m.b=s+f+16,m.crc=e.crc,m.size=e.size,u&&m.r(),u=1}else u&&d()},this.u.push(m)}},rE.prototype.end=function(){var e=this;2&this.d?this.ondata(aD(4+(1&this.d)*8,0,1),null,!0):(this.d?this.e():this.u.push({r:function(){1&e.d&&(e.u.splice(-1,1),e.e())},t:function(){}}),this.d=3)},rE.prototype.e=function(){for(var e=0,t=0,a=0,r=0,n=this.u;r<n.length;r++){var i=n[r];a+=46+i.f.length+rC(i.extra)+(i.o?i.o.length:0)}for(var o=new ae(a+22),s=0,l=this.u;s<l.length;s++){var i=l[s];r_(o,e,i,i.f,i.u,-i.c-2,t,i.o),e+=46+i.f.length+rC(i.extra)+(i.o?i.o.length:0),t+=i.b}rP(o,e,this.u.length,a,t),this.ondata(null,o,!0),this.d=2},rE.prototype.terminate=function(){for(var e=0,t=this.u;e<t.length;e++)t[e].t();this.d=2};var rB=function(){function e(){}return e.prototype.push=function(e,t){this.ondata(null,e,t)},e.compression=0,e}();function rj(){var e=this;this.i=new rd(function(t,a){e.ondata(null,t,a)})}function rR(e,t){var a=this;t<32e4?this.i=new rd(function(e,t){a.ondata(null,e,t)}):(this.i=new ru(function(e,t,r){a.ondata(e,t,r)}),this.terminate=this.i.terminate)}function rN(e){this.onfile=e,this.k=[],this.o={0:rB},this.p=aL}rj.prototype.push=function(e,t){try{this.i.push(e,t)}catch(e){this.ondata(e,null,t)}},rj.compression=8,rR.prototype.push=function(e,t){this.i.terminate&&(e=a_(e,0)),this.i.push(e,t)},rR.compression=8,rN.prototype.push=function(e,t){var a=this;if(this.onfile||aD(5),this.p||aD(4),this.c>0){var r=Math.min(this.c,e.length),n=e.subarray(0,r);if(this.c-=r,this.d?this.d.push(n,!this.c):this.k[0].push(n),(e=e.subarray(r)).length)return this.push(e,t)}else{var i=0,o=0,s=void 0,l=void 0;this.p.length?e.length?((l=new ae(this.p.length+e.length)).set(this.p),l.set(e,this.p.length)):l=this.p:l=e;for(var c=l.length,d=this.c,u=d&&this.d,h=this;o<c-4&&"break"!==function(){var e=a8(l,o);if(0x4034b50==e){i=1,s=o,h.d=null,h.c=0;var t=a6(l,o+6),r=a6(l,o+8),n=8&t,u=a6(l,o+26),m=a6(l,o+28);if(c>o+30+u+m){var f,g,p=[];h.k.unshift(p),i=2;var y=a8(l,o+18),v=a8(l,o+22),F=function(e,t){if(t){for(var a="",r=0;r<e.length;r+=16384)a+=String.fromCharCode.apply(null,e.subarray(r,r+16384));return a}if(rb)return rb.decode(e);var n=rx(e),i=n.s,a=n.r;return a.length&&aD(8),i}(l.subarray(o+30,o+=30+u),!(2048&t));0xffffffff==y?(y=(f=n?[-2]:rI(l,o))[0],v=f[1]):n&&(y=-1),o+=m,h.c=y;var b={name:F,compression:r,start:function(){if(b.ondata||aD(5),y){var e=a.o[r];e||b.ondata(aD(14,"unknown compression type "+r,1),null,!1),(g=y<0?new e(F):new e(F,y,v)).ondata=function(e,t,a){b.ondata(e,t,a)};for(var t=0;t<p.length;t++){var n=p[t];g.push(n,!1)}a.k[0]==p&&a.c?a.d=g:g.push(aL,!0)}else b.ondata(null,aL,!0)},terminate:function(){g&&g.terminate&&g.terminate()}};y>=0&&(b.size=y,b.originalSize=v),h.onfile(b)}return"break"}if(d){if(0x8074b50==e)return s=o+=12+(-2==d&&8),i=3,h.c=0,"break";else if(0x2014b50==e)return s=o-=4,i=3,h.c=0,"break"}}();++o);if(this.p=aL,d<0){var m=i?l.subarray(0,s-12-(-2==d&&8)-(0x8074b50==a8(l,s-16)&&4)):l.subarray(0,o);u?u.push(m,!!i):this.k[+(2==i)].push(m)}if(2&i)return this.push(l.subarray(o),t);this.p=l.subarray(o)}t&&(this.c&&aD(13),this.p=null)},rN.prototype.register=function(e){this.o[e.compression]=e},"function"==typeof queueMicrotask&&queueMicrotask;var rA=e.i(48450);let rG=[0,0,0,0,0,0,0,0,0,329,21,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2809,68,0,27,0,58,3,62,4,7,0,0,15,65,554,3,394,404,189,117,30,51,27,15,34,32,80,1,142,3,142,39,0,144,125,44,122,275,70,135,61,127,8,12,113,246,122,36,185,1,149,309,335,12,11,14,54,151,0,0,2,0,0,211,0,2090,344,736,993,2872,701,605,646,1552,328,305,1240,735,1533,1713,562,3,1775,1149,1469,979,407,553,59,279,31,0,0,0,68,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];function rU(e){return e.node?e.node.pop:e.leaf.pop}let rL=new class{nodes=[];leaves=[];tablesBuilt=!1;buildTables(){if(this.tablesBuilt)return;this.tablesBuilt=!0,this.leaves=[];for(let t=0;t<256;t++){var e;this.leaves.push({pop:rG[t]+ +((e=t)>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122)+1,symbol:t,numBits:0,code:0})}this.nodes=[{pop:0,index0:0,index1:0}];let t=256,a=[];for(let e=0;e<256;e++)a.push({node:null,leaf:this.leaves[e]});for(;1!==t;){let e=0xfffffffe,r=0xffffffff,n=-1,i=-1;for(let o=0;o<t;o++){let t=rU(a[o]);t<e?(r=e,i=n,e=t,n=o):t<r&&(r=t,i=o)}let o={pop:rU(a[n])+rU(a[i]),index0:this.determineIndex(a[n]),index1:this.determineIndex(a[i])};this.nodes.push(o);let s=n<i?n:i,l=n>i?n:i;a[s]={node:o,leaf:null},l!==t-1&&(a[l]=a[t-1]),t--}this.nodes[0]=a[0].node,this.generateCodes(0,0,0)}determineIndex(e){return null!==e.leaf?-(this.leaves.indexOf(e.leaf)+1):this.nodes.indexOf(e.node)}generateCodes(e,t,a){if(t<0){let r=this.leaves[-(t+1)];r.code=e,r.numBits=a}else{let r=this.nodes[t];this.generateCodes(e,r.index0,a+1),this.generateCodes(e|1<<a,r.index1,a+1)}}readHuffBuffer(e){if(this.tablesBuilt||this.buildTables(),e.readFlag()){let t=e.readInt(8),a=[];for(let r=0;r<t;r++){let t=0;for(;;)if(t>=0)t=e.readFlag()?this.nodes[t].index1:this.nodes[t].index0;else{a.push(this.leaves[-(t+1)].symbol);break}}return String.fromCharCode(...a)}{let t=e.readInt(8);return String.fromCharCode(...e.readBytes(t))}}};class rz{data;bitNum;maxReadBitNum;error;stringBuffer=null;constructor(e,t=0){this.data=e,this.bitNum=t,this.maxReadBitNum=e.length<<3,this.error=!1}getCurPos(){return this.bitNum}setCurPos(e){this.bitNum=e}getBytePosition(){return this.bitNum+7>>3}isError(){return this.error}isFull(){return this.bitNum>this.maxReadBitNum}getRemainingBits(){return this.maxReadBitNum-this.bitNum}getMaxPos(){return this.maxReadBitNum}readFlag(){if(this.bitNum>=this.maxReadBitNum)return this.error=!0,!1;let e=1<<(7&this.bitNum),t=(this.data[this.bitNum>>3]&e)!=0;return this.bitNum++,t}readInt(e){if(0===e)return 0;if(this.bitNum+e>this.maxReadBitNum)return this.error=!0,0;let t=this.bitNum>>3,a=7&this.bitNum;if(this.bitNum+=e,e+a<=32){let r=0,n=e+a+7>>3;for(let e=0;e<n&&t+e<this.data.length;e++)r|=this.data[t+e]<<8*e;return(r>>>=a,32===e)?r>>>0:r&(1<<e)-1}let r=0,n=e+a+7>>3;for(let e=0;e<n&&t+e<this.data.length;e++)r+=this.data[t+e]*2**(8*e);return(r=Math.floor(r/2**a),32===e)?r>>>0:r&(1<<e)-1}readSignedInt(e){return this.readFlag()?-this.readInt(e-1):this.readInt(e-1)}readFloat(e){return this.readInt(e)/((1<<e)-1)}readSignedFloat(e){return 2*this.readInt(e)/((1<<e)-1)-1}readRangedU32(e,t){let a=Math.ceil(Math.log2(t-e+1))||1;return this.readInt(a)+e}readBitsBuffer(e){if(0===e)return new Uint8Array(0);let t=e+7>>3,a=new Uint8Array(t),r=this.bitNum>>3,n=7&this.bitNum,i=8-n;if(0===n)a.set(this.data.subarray(r,r+t));else{let e=this.data[r];for(let o=0;o<t;o++){let t=r+o+1<this.data.length?this.data[r+o+1]:0;a[o]=(e>>n|t<<i)&255,e=t}}let o=7&e;return 0!==o&&(a[t-1]&=(1<<o)-1),this.bitNum+=e,a}readBytes(e){return Array.from(this.readBitsBuffer(8*e))}readU8(){return this.readInt(8)}readU16(){return this.readInt(16)}readU32(){return this.readInt(32)}readS32(){return 0|this.readU32()}static f32Buf=new ArrayBuffer(4);static f32View=new DataView(rz.f32Buf);static f32U8=new Uint8Array(rz.f32Buf);readF32(){if(this.bitNum+32>this.maxReadBitNum)return this.error=!0,0;let e=this.bitNum>>3,t=7&this.bitNum,a=rz.f32U8;if(0===t)a[0]=this.data[e],a[1]=this.data[e+1],a[2]=this.data[e+2],a[3]=this.data[e+3];else{let r=8-t;for(let n=0;n<4;n++){let i=this.data[e+n],o=e+n+1<this.data.length?this.data[e+n+1]:0;a[n]=(i>>t|o<<r)&255}}return this.bitNum+=32,rz.f32View.getFloat32(0,!0)}readBool(){return 0!==this.readU8()}readNormalVector(e){let t=this.readSignedFloat(e+1)*Math.PI,a=this.readSignedFloat(e)*(Math.PI/2);return{x:Math.sin(t)*Math.cos(a),y:Math.cos(t)*Math.cos(a),z:Math.sin(a)}}readAffineTransform(){let e={x:this.readF32(),y:this.readF32(),z:this.readF32()},t=this.readF32(),a=this.readF32(),r=this.readF32(),n=Math.sqrt(Math.max(0,1-(t*t+a*a+r*r)));return this.readFlag()&&(n=-n),{position:e,rotation:{x:t,y:a,z:r,w:n}}}readString(){if(null!==this.stringBuffer&&this.readFlag()){let e=this.readInt(8),t=rL.readHuffBuffer(this),a=this.stringBuffer.substring(0,e)+t;return this.stringBuffer=a,a}let e=rL.readHuffBuffer(this);return null!==this.stringBuffer&&(this.stringBuffer=e),e}setStringBuffer(e){this.stringBuffer=e?"":null}skipBits(e){this.bitNum+=e}readPoint3F(){return{x:this.readF32(),y:this.readF32(),z:this.readF32()}}readCompressedPoint(e,t=.01){let a=this.readInt(2);if(3===a)return{x:this.readF32(),y:this.readF32(),z:this.readF32()};let r=[16,18,20][a],n=this.readSignedInt(r),i=this.readSignedInt(r),o=this.readSignedInt(r);return{x:e.x+n*t,y:e.y+i*t,z:e.z+o*t}}readMatrixF(){let e=Array(16);for(let t=0;t<16;t++)e[t]=this.readF32();return{elements:e,position:{x:e[12],y:e[13],z:e[14]}}}unpackNetString(){switch(this.readInt(2)){case 0:default:return"";case 1:return this.readString();case 2:{let e=this.readInt(10);return`\x01${e}`}case 3:{let e,t=this.readFlag();return e=this.readFlag()?this.readInt(7):this.readFlag()?this.readInt(15):this.readInt(31),t&&(e=-e),String(e)}}}savePos(){return this.bitNum}restorePos(e){this.bitNum=e,this.error=!1}getBuffer(){return this.data}}let rO=["AudioDescription","AudioEnvironment","AudioProfile","AudioSampleEnvironment","BombProjectileData","CameraData","CannedChatItem","CommanderIconData","DebrisData","DecalData","ELFProjectileData","EffectProfile","EnergyProjectileData","ExplosionData","FireballAtmosphereData","FlareProjectileData","FlyingVehicleData","ForceFieldBareData","GameBaseData","GrenadeProjectileData","HoverVehicleData","ItemData","JetEffectData","LightningData","LinearFlareProjectileData","LinearProjectileData","MissionMarkerData","ParticleData","ParticleEmissionDummyData","ParticleEmitterData","PlayerData","PrecipitationData","ProjectileData","RepairProjectileData","RunningLightData","SeekerProjectileData","SensorData","ShapeBaseData","ShapeBaseImageData","ShockLanceProjectileData","ShockwaveData","SimDataBlock","SniperProjectileData","SplashData","StaticShapeData","StationFXPersonalData","StationFXVehicleData","TSShapeConstructor","TargetProjectileData","TracerProjectileData","TriggerData","TurretData","TurretImageData","WheeledVehicleData"],rV=["AIObjective","AudioEmitter","BeaconObject","BombProjectile","Camera","Debris","ELFProjectile","EnergyProjectile","FireballAtmosphere","FlareProjectile","FlyingVehicle","ForceFieldBare","GameBase","GrenadeProjectile","HoverVehicle","InteriorInstance","Item","Lightning","LinearFlareProjectile","LinearProjectile","Marker","MissionArea","MissionMarker","ParticleEmissionDummy","PhysicalZone","Player","Precipitation","Projectile","RepairProjectile","ScopeAlwaysShape","SeekerProjectile","ShapeBase","ShockLanceProjectile","Shockwave","SimpleNetObject","Sky","SniperProjectile","SpawnSphere","Splash","StaticShape","StationFXPersonal","StationFXVehicle","Sun","TSStatic","TargetProjectile","TerrainBlock","TracerProjectile","Trigger","Turret","VehicleBlocker","WaterBlock","WayPoint","WheeledVehicle"],rq=["CRCChallengeEvent","CRCChallengeResponseEvent","FogChallengeEvent","GhostAlwaysObjectEvent","GhostingMessageEvent","GravityEvent","LightningStrikeEvent","NetStringEvent","PathManagerEvent","RemoteCommandEvent","RemoveClientTargetTypeEvent","ResetClientTargetsEvent","SensorGroupColorEvent","SetMissionCRCEvent","SetObjectActiveImageEvent","SetSensorGroupEvent","SetServerTargetEvent","Sim2DAudioEvent","Sim3DAudioEvent","SimDataBlockEvent","SimTargetAudioEvent","SimVoiceStreamEvent","SimpleMessageEvent","TargetFreeEvent","TargetInfoEvent","TargetToEvent"],rH=(0,rA.default)("t2-demo-parser:ghosts");class rW{registry;ghostTracker;compressionPoint={x:0,y:0,z:0};controlParserByGhostIndex=new Map;dataBlockDataMap;lastSeqRecvdAtSend=Array(32).fill(0);lastSeqRecvd=0;highestAckedSeq=0;lastSendSeq=0;recvAckMask=0;connectSequence=0;lastRecvAckAck=0;_connectionEstablished=!1;nextRecvEventSeq=0;pendingGuaranteedEvents=[];controlObjectParsed=0;controlObjectFailed=0;eventsParsed=0;eventsFailed=0;ghostCreatesParsed=0;ghostUpdatesParsed=0;ghostDeletes=0;ghostsFailed=0;ghostsTrackerDiverged=0;packetsParsed=0;protocolRejected=0;protocolNoDispatch=0;constructor(e,t,a){this.registry=e,this.ghostTracker=t,this.dataBlockDataMap=a?.dataBlockDataMap,a?.connectionProtocolState&&this.setConnectionProtocolState(a.connectionProtocolState),"number"==typeof a?.nextRecvEventSeq&&(this.nextRecvEventSeq=a.nextRecvEventSeq>>>0)}getCompressionPoint(){return this.compressionPoint}getConnectionContext(){let e=this.dataBlockDataMap;return{compressionPoint:this.compressionPoint,ghostTracker:this.ghostTracker,getDataBlockParser:e=>this.registry.getDataBlockParser(e),getDataBlockData:e?t=>e.get(t):void 0,getGhostParser:e=>this.registry.getGhostParser(e)}}_setNextRecvEventSeq(e){this.nextRecvEventSeq=e>>>0}setConnectionProtocolState(e){for(this.lastSeqRecvdAtSend=e.lastSeqRecvdAtSend.slice(0,32);this.lastSeqRecvdAtSend.length<32;)this.lastSeqRecvdAtSend.push(0);this.lastSeqRecvd=e.lastSeqRecvd>>>0,this.highestAckedSeq=e.highestAckedSeq>>>0,this.lastSendSeq=e.lastSendSeq>>>0,this.recvAckMask=e.ackMask>>>0,this.connectSequence=e.connectSequence>>>0,this.lastRecvAckAck=e.lastRecvAckAck>>>0,this._connectionEstablished=e.connectionEstablished}onSendPacketTrigger(){this.lastSendSeq=this.lastSendSeq+1>>>0,this.lastSeqRecvdAtSend[31&this.lastSendSeq]=this.lastSeqRecvd>>>0}applyProtocolHeader(e){if(e.connectSeqBit!==(1&this.connectSequence)||e.ackByteCount>4||e.packetType>2)return{accepted:!1,dispatchData:!1};let t=(e.seqNumber|0xfffffe00&this.lastSeqRecvd)>>>0;if(t<this.lastSeqRecvd&&(t=t+512>>>0),this.lastSeqRecvd+31<t)return{accepted:!1,dispatchData:!1};let a=(e.highestAck|0xfffffe00&this.highestAckedSeq)>>>0;if(a<this.highestAckedSeq&&(a=a+512>>>0),this.lastSendSeq<a)return{accepted:!1,dispatchData:!1};let r=t-this.lastSeqRecvd&31;this.recvAckMask=this.recvAckMask<<r>>>0,0===e.packetType&&(this.recvAckMask=(1|this.recvAckMask)>>>0);for(let t=this.highestAckedSeq+1;t<=a;t++)(e.ackMask&1<<(a-t&31))!=0&&(this.lastRecvAckAck=this.lastSeqRecvdAtSend[31&t]>>>0);t-this.lastRecvAckAck>32&&(this.lastRecvAckAck=t-32),this.highestAckedSeq=a;let n=this.lastSeqRecvd!==t&&0===e.packetType;return this.lastSeqRecvd=t,{accepted:!0,dispatchData:n}}parsePacket(e){let t=new rz(e),a=this.readDnetHeader(t),r=this.applyProtocolHeader(a);if(this.packetsParsed++,!r.accepted)return this.protocolRejected++,{dnetHeader:a,rateInfo:{},gameState:this.emptyGameState(),events:[],ghosts:[]};if(!r.dispatchData)return this.protocolNoDispatch++,{dnetHeader:a,rateInfo:{},gameState:this.emptyGameState(),events:[],ghosts:[]};let n=this.readRateInfo(t);t.setStringBuffer(!0);let i=this.readGameState(t),o=void 0===i.controlObjectDataStart||void 0!==i.controlObjectData,s=o?this.readEvents(t):[],l=s[s.length-1],c=!l||l.dataBitsEnd!==l.dataBitsStart,d=o&&c?t.getCurPos():void 0,u=o&&c?this.readGhosts(t,a.seqNumber):[];return t.setStringBuffer(!1),{dnetHeader:a,rateInfo:n,gameState:i,events:s,ghosts:u,ghostSectionStart:d}}readDnetHeader(e){let t=e.readFlag(),a=e.readInt(1),r=e.readInt(9),n=e.readInt(9),i=e.readInt(2),o=e.readInt(3),s=o>0?e.readInt(8*o):0;return{gameFlag:t,connectSeqBit:a,seqNumber:r,highestAck:n,packetType:i,ackByteCount:o,ackMask:s}}readRateInfo(e){let t={};return e.readFlag()&&(t.updateDelay=e.readInt(10),t.packetSize=e.readInt(10)),e.readFlag()&&(t.maxUpdateDelay=e.readInt(10),t.maxPacketSize=e.readInt(10)),t}readGameState(e){let t,a,r,n,i,o,s,l,c,d,u,h,m,f,g,p=e.readInt(32);e.readFlag()&&(e.readFlag()&&(t=e.readFloat(7)),e.readFlag()&&(a=1.5*e.readFloat(7))),e.readFlag()&&(r=e.readFlag(),n=e.readFlag()),e.readFlag()&&((i=e.readFlag())&&(o={x:e.readF32(),y:e.readF32(),z:e.readF32()}),1===(s=e.readRangedU32(0,2))?e.readFlag()&&(l=e.readRangedU32(0,1023)):2===s&&(c={x:e.readF32(),y:e.readF32(),z:e.readF32()}));let y=e.readFlag(),v=e.readFlag();if(e.readFlag())if(e.readFlag()){let g=e.readInt(10);d=g,u=e.getCurPos();let F=e.savePos(),b=this.ghostTracker.getGhost(g),S=b?this.registry.getGhostParser(b.classId):void 0,x=this.controlParserByGhostIndex.get(g),k=this.registry.getGhostParser(25),w=this.registry.getGhostParser(4),I=[],C=new Set,_=e=>{!e?.readPacketData||C.has(e.name)||(C.add(e.name),I.push(e))};_(S),_(x),_(k),_(w);let P=!1;for(let t of I){e.restorePos(F);try{let a=this.getConnectionContext(),r=t.readPacketData(e,a);if(e.getCurPos()-u<=0||e.isError())continue;m=r,h=e.getCurPos(),this.controlParserByGhostIndex.set(g,t),a.compressionPoint!==this.compressionPoint&&(this.compressionPoint=a.compressionPoint,f=this.compressionPoint),this.controlObjectParsed++,P=!0;break}catch{}}if(!P)return e.restorePos(F),h=u,this.controlObjectFailed++,{lastMoveAck:p,damageFlash:t,whiteOut:a,selfLocked:r,selfHomed:n,seekerTracking:i,seekerTrackingPos:o,seekerMode:s,seekerObjectGhostIndex:l,targetPos:c,pinged:y,jammed:v,controlObjectGhostIndex:d,controlObjectDataStart:u,controlObjectDataEnd:h,controlObjectData:m,targetVisibility:[]}}else f={x:e.readF32(),y:e.readF32(),z:e.readF32()},this.compressionPoint=f;let F=[];for(;e.readFlag();)F.push({index:e.readInt(4),mask:e.readInt(32)});return e.readFlag()&&(g=e.readInt(8)),{lastMoveAck:p,damageFlash:t,whiteOut:a,selfLocked:r,selfHomed:n,seekerTracking:i,seekerTrackingPos:o,seekerMode:s,seekerObjectGhostIndex:l,targetPos:c,pinged:y,jammed:v,controlObjectGhostIndex:d,controlObjectDataStart:u,controlObjectDataEnd:h,controlObjectData:m,compressionPoint:f,targetVisibility:F.length>0?F:void 0,cameraFov:g}}readEvents(e){let t=[],a=!0,r=-2;for(;;){let n,i,o,s=e.readFlag();if(a&&!s){if(a=!1,!e.readFlag()){this.dispatchGuaranteedEvents(t);break}}else if(a||s){if(!s)break}else{this.dispatchGuaranteedEvents(t);break}!a&&(r=n=e.readFlag()?r+1&127:e.readInt(7),(i=n|0xffffff80&this.nextRecvEventSeq)<this.nextRecvEventSeq&&(i+=128));let l=e.readInt(6)+255,c=e.getCurPos(),d=this.registry.getEventParser(l);if(d)try{let t=this.getConnectionContext();o=d.unpack(e,t),this.eventsParsed++}catch{this.eventsFailed++,t.push({classId:l,guaranteed:!a,sequenceNumber:n,absoluteSequenceNumber:i,dataBitsStart:c,dataBitsEnd:c});break}else{t.push({classId:l,guaranteed:!a,sequenceNumber:n,absoluteSequenceNumber:i,dataBitsStart:c,dataBitsEnd:c});break}let u={classId:l,guaranteed:!a,sequenceNumber:n,absoluteSequenceNumber:i,dataBitsStart:c,dataBitsEnd:e.getCurPos(),parsedData:o};a?(t.push(u),o&&this.applyEventSideEffects(o)):void 0!==i&&this.enqueueGuaranteedEvent(i,u)}return t}enqueueGuaranteedEvent(e,t){let a=0;for(;a<this.pendingGuaranteedEvents.length&&this.pendingGuaranteedEvents[a].absoluteSequenceNumber<e;)a++;this.pendingGuaranteedEvents.splice(a,0,{absoluteSequenceNumber:e,event:t})}dispatchGuaranteedEvents(e){for(;this.pendingGuaranteedEvents.length>0&&this.pendingGuaranteedEvents[0].absoluteSequenceNumber===this.nextRecvEventSeq;){let t=this.pendingGuaranteedEvents.shift();if(!t)break;this.nextRecvEventSeq=this.nextRecvEventSeq+1>>>0,e.push(t.event),t.event.parsedData&&this.applyEventSideEffects(t.event.parsedData)}}applyEventSideEffects(e){let t=e.type;if("GhostingMessageEvent"===t){let t=e.message;"number"==typeof t&&2===t&&this.ghostTracker.clear();return}if("GhostAlwaysObjectEvent"===t){let t=e.ghostIndex,a=e.classId;if("number"==typeof t&&"number"==typeof a){let e=this.registry.getGhostParser(a);this.ghostTracker.createGhost(t,a,e?.name??`unknown_${a}`)}}"SimDataBlockEvent"===t&&this.dataBlockDataMap&&e.dataBlockData&&"number"==typeof e.objectId&&this.dataBlockDataMap.set(e.objectId,e.dataBlockData)}readGhosts(e,t){let a=[];if(!e.readFlag())return a;let r=e.readInt(3)+3;for(;e.readFlag();){let n;if(e.isError())break;let i=e.readInt(r);if(e.isError())break;if(e.readFlag()){this.ghostTracker.deleteGhost(i),this.ghostDeletes++,a.push({index:i,type:"delete",updateBitsStart:e.getCurPos(),updateBitsEnd:e.getCurPos()});continue}let o=!this.ghostTracker.hasGhost(i);n=o?e.readInt(7)+0:this.ghostTracker.getGhost(i)?.classId;let s=e.getCurPos(),l=void 0!==n?this.registry.getGhostParser(n):void 0;if(o&&!l){this.ghostsTrackerDiverged++,rH("DIVERGED pkt=%d seq=%d idx=%d classId=%d bit=%d/%d trackerSize=%d (server sent UPDATE for ghost not in our tracker; 7-bit classId is actually update data)",this.packetsParsed,t,i,n,s,e.getMaxPos(),this.ghostTracker.size()),a.push({index:i,type:"create",classId:n,updateBitsStart:s,updateBitsEnd:s});break}let c=!1;if(l)try{let t=this.getConnectionContext();t.currentGhostIndex=i;let r=l.unpackUpdate(e,o,t),d=e.getCurPos();o&&void 0!==n?(this.ghostTracker.createGhost(i,n,l.name),this.ghostCreatesParsed++):this.ghostUpdatesParsed++,a.push({index:i,type:o?"create":"update",classId:n,updateBitsStart:s,updateBitsEnd:d,parsedData:r}),c=!0}catch(d){this.ghostsFailed++;let r=o?"create":"update",c=d instanceof Error?d.message:String(d);rH("FAIL pkt=%d seq=%d #%d idx=%d op=%s classId=%d parser=%s bit=%d/%d trackerSize=%d err=%s",this.packetsParsed,t,a.length,i,r,n,l.name,s,e.getMaxPos(),this.ghostTracker.size(),c)}if(!c){rH("STOP pkt=%d seq=%d idx=%d op=%s classId=%d parser=%s bit=%d/%d",this.packetsParsed,t,i,o?"create":"update",n,l?.name??"NONE",s,e.getMaxPos()),a.push({index:i,type:o?"create":"update",classId:n,updateBitsStart:s,updateBitsEnd:s});break}}return a}emptyGameState(){return{lastMoveAck:0,pinged:!1,jammed:!1}}}class r${eventParsers=new Map;ghostParsers=new Map;dataBlockParsers=new Map;eventCatalog=new Map;ghostCatalog=new Map;dataBlockCatalog=new Map;catalogEvent(e){this.eventCatalog.set(e.name,e)}catalogGhost(e){this.ghostCatalog.set(e.name,e)}catalogDataBlock(e){this.dataBlockCatalog.set(e.name,e)}bindDeterministicDataBlocks(e,t){let a=0,r=[];for(let n=0;n<e.length;n++){let i=e[n],o=this.dataBlockCatalog.get(i);o?(this.dataBlockParsers.set(t+n,o),a++):r.push(i)}return{bound:a,missing:r}}bindDeterministicEvents(e,t){let a=0,r=[];for(let n=0;n<e.length;n++){let i=e[n],o=this.eventCatalog.get(i);o?(this.eventParsers.set(t+n,o),a++):r.push(i)}return{bound:a,missing:r}}bindDeterministicGhosts(e,t){let a=0,r=[];for(let n=0;n<e.length;n++){let i=e[n],o=this.ghostCatalog.get(i);o?(this.ghostParsers.set(t+n,o),a++):r.push(i)}return{bound:a,missing:r}}getEventParser(e){return this.eventParsers.get(e)}getGhostParser(e){return this.ghostParsers.get(e)}getDataBlockParser(e){return this.dataBlockParsers.get(e)}getGhostCatalog(){return this.ghostCatalog}getEventBindings(){let e=new Map;for(let[t,a]of this.eventParsers)e.set(t,a.name);return e}getGhostBindings(){let e=new Map;for(let[t,a]of this.ghostParsers)e.set(t,a.name);return e}}class rY{ghosts=new Map;getGhost(e){return this.ghosts.get(e)}hasGhost(e){return this.ghosts.has(e)}createGhost(e,t,a){let r={classId:t,className:a,state:{}};return this.ghosts.set(e,r),r}deleteGhost(e){this.ghosts.delete(e)}getAllGhosts(){return this.ghosts}size(){return this.ghosts.size}clear(){this.ghosts.clear()}}function rK(e){let t=e.readFlag()?e.readInt(16):0,a=e.readFlag()?e.readInt(16):0,r=e.readFlag()?e.readInt(16):0,n=e.readInt(6),i=e.readInt(6),o=e.readInt(6),s=e.readFlag(),l=[];for(let t=0;t<6;t++)l.push(e.readFlag());return{pyaw:t,ppitch:a,proll:r,px:n,py:i,pz:o,freeLook:s,trigger:l}}function rX(e){return e.readInt(11)}function rZ(e,t,a){let r={};return e.readFlag()&&(r.dataBlockId=rX(e)),e.readFlag()&&(r.targetId=e.readFlag()?e.readInt(9):-1),r}function rJ(e,t,a){let r=rZ(e,t,a);if(!e.readFlag())return r;if(e.readFlag()&&(r.damageLevel=e.readFloat(6),r.damageState=e.readInt(2),r.blowApart=e.readFlag(),r.damageDir=e.readNormalVector(8)),e.readFlag()){let t=[];for(let a=0;a<4;a++)if(e.readFlag()){let r=e.readFlag(),n={index:a,playing:r};r&&(n.profileId=rX(e)),t.push(n)}t.length>0&&(r.sounds=t)}if(e.readFlag()){let t=[];for(let a=0;a<4;a++)e.readFlag()&&t.push({index:a,sequence:e.readInt(5),state:e.readInt(2),forward:e.readFlag(),atEnd:e.readFlag()});t.length>0&&(r.threads=t)}let n=!1;if(e.readFlag()){let a=[];for(let r=0;r<8;r++)if(e.readFlag()){let i={index:r};e.readFlag()?i.dataBlockId=rX(e):i.dataBlockId=0,e.readFlag()&&(e.readFlag()?i.skinTagIndex=e.readInt(10):i.skinName=e.readString(),n=!0),i.triggerDown=e.readFlag(),i.loaded=e.readFlag(),i.ammo=e.readFlag(),i.wet=e.readFlag(),i.target=e.readFlag(),i.fireCount=e.readInt(3),t&&(i.imageExtraFlag=e.readFlag()),a.push(i)}a.length>0&&(r.images=a)}if(e.readFlag()){if(e.readFlag()){r.stateAEnabled=e.readFlag(),r.stateB=e.readFlag();let t=e.readFlag();r.hasInvulnerability=t,t?(r.invulnerabilityVisual=e.readFlag(),r.invulnerabilityTicks=e.readU32()):r.binaryCloak=e.readFlag()}if(e.readFlag())if(e.readFlag()){let t=e.readFlag();r.stateBMode=t,t?r.energyPackOn=!0:r.energyPackOn=!1}else r.shieldNormal=e.readNormalVector(8),r.energyPercent=e.readFloat(5);e.readFlag()&&(r.stateValue1=e.readU32(),r.stateValue2=e.readU32())}return n&&(r.imageSkinDirty=!0),e.readFlag()&&(e.readFlag()?(r.mountObject=e.readInt(10),r.mountNode=e.readInt(5)):r.mountObject=-1),r}function rQ(e,t,a){let r=rJ(e,t,a);if(e.readFlag()&&(r.impactSound=e.readInt(3)),e.readFlag()&&(r.action=e.readInt(8),r.actionHoldAtEnd=e.readFlag(),r.actionAtEnd=e.readFlag(),r.actionFirstPerson=e.readFlag(),!r.actionAtEnd&&e.readFlag()&&(r.actionAnimPos=e.readSignedFloat(6))),e.readFlag()&&(r.armAction=e.readInt(8)),e.readFlag())return r;if(e.readFlag()){if(r.actionState=e.readInt(3),e.readFlag()&&(r.recoverTicks=e.readInt(7)),r.moveFlag0=e.readFlag(),r.moveFlag1=e.readFlag(),r.position=e.readCompressedPoint(a.compressionPoint),e.readFlag()){let t=e.readInt(13)/32,a=e.readNormalVector(10);r.velocity={x:a.x*t,y:a.y*t,z:a.z*t}}else r.velocity={x:0,y:0,z:0};r.headX=e.readSignedFloat(6),r.headZ=e.readSignedFloat(6),r.rotationZ=2*e.readFloat(7)*Math.PI,r.move=rK(e),r.allowWarp=e.readFlag()}return r.energy=e.readFloat(5),r}function r0(e,t){let a={};if(a.energyLevel=e.readF32(),a.rechargeRate=e.readF32(),a.actionState=e.readInt(3),e.readFlag()&&(a.recoverTicks=e.readInt(7)),e.readFlag()&&(a.jumpDelay=e.readInt(7)),e.readFlag()){let r={x:e.readF32(),y:e.readF32(),z:e.readF32()};a.position=r,t.compressionPoint=r,a.velocity={x:e.readF32(),y:e.readF32(),z:e.readF32()},a.jumpSurfaceLastContact=e.readInt(4)}if(a.headX=e.readF32(),a.headZ=e.readF32(),a.rotationZ=e.readF32(),e.readFlag()){let r=e.readInt(10);a.controlObjectGhost=r;let n=t.ghostTracker.getGhost(r),i=n?t.getGhostParser?.(n.classId):void 0;if(i?.readPacketData){let n=t.currentGhostIndex;t.currentGhostIndex=r,a.controlObjectData=i.readPacketData(e,t),t.currentGhostIndex=n}}return a.disableMove=e.readFlag(),a.pilot=e.readFlag(),a}function r1(e,t,a){let r=rJ(e,t,a);return(r.jetting=e.readFlag(),e.readFlag())?r._controlledEarlyReturn=!0:(r.steeringYaw=e.readFloat(9),r.steeringPitch=e.readFloat(9),r.move=rK(e),r.frozen=e.readFlag(),e.readFlag()&&(r.position=e.readCompressedPoint(a.compressionPoint),r.angPosition={x:e.readF32(),y:e.readF32(),z:e.readF32(),w:e.readF32()},r.linMomentum=e.readPoint3F(),r.angMomentum=e.readPoint3F()),e.readFlag()&&(r.energy=e.readFloat(8))),r}function r2(e,t){let a={};a.energyLevel=e.readF32(),a.rechargeRate=e.readF32(),a.steering={x:e.readF32(),y:e.readF32()};let r={x:e.readF32(),y:e.readF32(),z:e.readF32()};return a.linPosition=r,a.angPosition={x:e.readF32(),y:e.readF32(),z:e.readF32(),w:e.readF32()},a.linMomentum=e.readPoint3F(),a.angMomentum=e.readPoint3F(),a.disableMove=e.readFlag(),a.frozen=e.readFlag(),t.compressionPoint=r,a}function r3(e,t){let a=r2(e,t);a.braking=e.readFlag();let r=4,n=t.currentGhostIndex;if(void 0!==n){let e=nR.get(n);void 0!==e&&(r=e)}let i=[];for(let t=0;t<r;t++)i.push({avel:e.readF32(),Dy:e.readF32(),Dx:e.readF32()});return a.wheels=i,a}function r5(e,t,a){let r=r1(e,t,a);return e.readFlag()||(r.createHeightOn=e.readFlag(),r.thrustDirection=e.readInt(3)),r}function r4(e,t,a){let r=r1(e,t,a);return r.thrustDirection=e.readInt(3),r}function r6(e,t,a){let r=rJ(e,t,a);if(e.readFlag()&&(r.rotate=e.readFlag(),r.isStatic=e.readFlag(),r.collideable=e.readFlag(),e.readFlag()&&(r.scale=e.readPoint3F())),e.readFlag()&&(r.collisionObject=e.readInt(10)),e.readFlag()&&(r.rotation={zSign:e.readFlag()?-1:1,angle:e.readF32()}),e.readFlag()){r.position=e.readPoint3F();let t=e.readFlag();r.atRest=t,t||(r.velocity=e.readPoint3F()),r.warp=e.readFlag()}return r}function r8(e,t,a){let r=rJ(e,t,a);return e.readFlag()&&(r.transform=e.readAffineTransform(),r.position=r.transform.position,r.scale=e.readPoint3F()),r.powered=e.readFlag(),r}function r7(e,t,a){return r8(e,t,a)}function r9(e,t,a){return{position:e.readPoint3F()}}function ne(e,t,a){return{message:e.readString()}}function nt(e,t,a){let r=r8(e,t,a);return e.readFlag()&&(r.beaconType=e.readInt(2)),r}function na(e,t,a){let r=rJ(e,t,a);return e.readFlag()&&(r.transform=e.readAffineTransform(),r.position=r.transform.position,r.scale=e.readPoint3F()),r}function nr(e,t,a){let r=rZ(e,t,a);r.value0=e.readF32(),r.value1=e.readF32(),r.value2=e.readF32(),r.value3=e.readF32(),r.value4=e.readF32(),r.value5=e.readF32(),r.bool0=e.readBool(),r.bool1=e.readBool(),r.bool2=e.readBool(),r.bool3=e.readBool(),r.value6=e.readF32(),r.value7=e.readF32(),r.value8=e.readF32(),r.value9=e.readF32(),r.value10=e.readF32(),r.value11=e.readF32(),r.bool4=e.readBool(),r.bool5=e.readBool(),r.value12=e.readF32(),r.value13=e.readF32(),r.value14=e.readF32(),r.bool6=e.readBool(),r.string0=e.readString(),r.string1=e.readString();let n=[];for(let t=0;t<2;t++)n.push(e.readFlag()?rX(e):-1);return r.objectRefs=n,r.objectRef2=e.readFlag()?rX(e):-1,r}function nn(e,t,a){return rZ(e,t,a)}function ni(e,t,a){let r={};return(e.readFlag()&&(r.dataBlockId=rX(e)),e.readFlag()&&(r.targetId=e.readFlag()?e.readInt(9):-1),e.readFlag())?(r.position={x:e.readF32(),y:e.readF32(),z:e.readF32()},r.velocity={x:e.readF32(),y:e.readF32(),z:e.readF32()},r.currTick=e.readInt(12),e.readFlag()&&(r.resetFlag=!0),e.readFlag()&&(r.explodePoint={x:e.readF32(),y:e.readF32(),z:e.readF32()},r.explodeNormal={x:e.readF32(),y:e.readF32(),z:e.readF32()}),e.readFlag()?(r.sourceObject=e.readInt(11),r.sourceSlot=e.readInt(3)):(r.sourceObject=-1,r.sourceSlot=-1),e.readFlag()?r.vehicleObject=e.readInt(11):r.vehicleObject=0,r):(e.readFlag()&&(r.position={x:e.readF32(),y:e.readF32(),z:e.readF32()},r.velocity={x:e.readF32(),y:e.readF32(),z:e.readF32()}),e.readFlag()&&(r.endPoint={x:e.readF32(),y:e.readF32(),z:e.readF32()},r.endNormal={x:e.readF32(),y:e.readF32(),z:e.readF32()}),r)}function no(e,t,a){let r=rZ(e,t,a);return e.readFlag()?(r.position=e.readPoint3F(),r.velocity=e.readPoint3F(),r.currTick=e.readRangedU32(0,4095),r.quickSplash=e.readFlag(),e.readFlag()&&(r.explodePoint=e.readPoint3F(),r.explodeNormal=e.readPoint3F()),e.readFlag()&&(r.sourceObject=e.readRangedU32(0,1024),r.sourceSlot=e.readRangedU32(0,7)),e.readFlag()&&(r.vehicleObject=e.readRangedU32(0,1024))):(e.readFlag()&&(r.position=e.readPoint3F(),r.velocity=e.readPoint3F()),e.readFlag()&&(r.explodePoint=e.readPoint3F(),r.explodeNormal=e.readPoint3F())),r}function ns(e,t,a){let r=rZ(e,t,a);return e.readFlag()?(r.position={x:e.readF32(),y:e.readF32(),z:e.readF32()},r.velocity={x:e.readF32(),y:e.readF32(),z:e.readF32()},r.orientation={x:e.readF32(),y:e.readF32(),z:e.readF32()},e.readFlag()?(r.sourceObject=e.readInt(11),r.sourceSlot=e.readInt(3)):(r.sourceObject=-1,r.sourceSlot=-1),e.readFlag()?e.readFlag()?(r.targetGhost=e.readInt(11),r.targetMode=0):(r.targetDirection={x:e.readF32(),y:e.readF32(),z:e.readF32()},r.targetMode=1):r.targetMode=2,r.timeoutReset=e.readFlag(),r):(e.readFlag()?(r.explodePosition={x:e.readF32(),y:e.readF32(),z:e.readF32()},r.explodeNormal={x:e.readF32(),y:e.readF32(),z:e.readF32()}):(r.position={x:e.readF32(),y:e.readF32(),z:e.readF32()},r.velocity={x:e.readF32(),y:e.readF32(),z:e.readF32()},e.readFlag()?e.readFlag()?(r.targetGhost=e.readInt(11),r.targetMode=0):(r.targetDirection={x:e.readF32(),y:e.readF32(),z:e.readF32()},r.targetMode=1):r.targetMode=2),r)}function nl(e,t,a){let r=r8(e,t,a);return e.readFlag()&&(r.capacitorEnergy=e.readFloat(8)),e.readFlag()||e.readFlag()&&(r.phi=e.readFloat(10),r.theta=e.readFloat(10),r.activationLevel=e.readFloat(8)),r}function nc(e,t,a){let r={};return e.readFlag()?(r.crc=e.readU32(),r.interiorFile=e.readString(),r.showTerrainInside=e.readFlag(),r.transform=e.readMatrixF(),r.scale=e.readPoint3F(),r.alarmState=e.readFlag(),r.skinBase=e.readString(),e.readFlag()&&(r.audioProfileId=rX(e)),e.readFlag()&&(r.audioEnvironmentId=rX(e))):(e.readFlag()&&(r.transform=e.readMatrixF(),r.scale=e.readPoint3F()),r.alarmState=e.readFlag(),e.readFlag()&&(r.skinBase=e.readString()),e.readFlag()&&(e.readFlag()&&(r.audioProfileId=rX(e)),e.readFlag()&&(r.audioEnvironmentId=rX(e)))),r}function nd(e,t,a){let r=rJ(e,t,a);return e.readFlag()||e.readFlag()&&(r.posX=e.readF32(),r.posY=e.readF32(),r.posZ=e.readF32(),r.fovOrDist=e.readF32(),r.orbitParam=e.readF32()),r}function nu(e,t){let a={};a.energyLevel=e.readF32(),a.rechargeRate=e.readF32();let r={x:e.readF32(),y:e.readF32(),z:e.readF32()};a.position=r,a.rotX=e.readF32(),a.rotZ=e.readF32();let n=e.readInt(3);return a.cameraMode=n,(3===n||4===n)&&(a.minOrbitDist=e.readF32(),a.maxOrbitDist=e.readF32(),a.curOrbitDist=e.readF32(),3===n&&(a.observingClientObject=e.readFlag(),a.orbitObjectGhostIndex=e.readInt(10)),4===n&&(a.orbitPoint=e.readCompressedPoint(t.compressionPoint,.01))),t.compressionPoint=r,a}function nh(e,t,a){let r=rZ(e,t,a);return e.readFlag()?e.readFlag()?(r.hidden=!0,r.explodePosition=e.readCompressedPoint(a.compressionPoint),r.explodeNormal=e.readNormalVector(14),r.endedWithDecal=e.readFlag()):(r.position=e.readCompressedPoint(a.compressionPoint),r.direction=e.readNormalVector(14),r.currTick=e.readRangedU32(0,511),e.readFlag()&&(r.sourceObject=e.readInt(10),r.sourceSlot=e.readRangedU32(0,7),e.readFlag()&&(r.excessVel=e.readRangedU32(0,255),r.excessDir=e.readNormalVector(7))),e.readFlag()&&(r.vehicleObject=e.readInt(10))):(r.explodePosition=e.readCompressedPoint(a.compressionPoint),r.explodeNormal=e.readNormalVector(14),r.endedWithDecal=e.readFlag()),r}function nm(e,t,a){let r=rZ(e,t,a);return e.readFlag()&&e.readFlag()&&(r.sourceObject=e.readRangedU32(0,1024),r.sourceSlot=e.readRangedU32(0,7),r.targetObject=e.readRangedU32(0,1024)),r}function nf(e,t,a){let r=rZ(e,t,a);return e.readFlag()&&e.readFlag()&&(r.sourceObject=e.readRangedU32(0,1024),r.sourceSlot=e.readRangedU32(0,7),r.repairingObject=e.readRangedU32(0,1024)),r}function ng(e,t,a){let r=rZ(e,t,a);return e.readFlag()?(r.initialPosition=e.readPoint3F(),r.endPos=e.readPoint3F(),r.truncated=e.readFlag(),e.readFlag()&&(r.sourceObject=e.readRangedU32(0,1024),r.sourceSlot=e.readRangedU32(0,7),r.clientOwned=e.readFlag())):(e.readFlag()?(r.sourceObject=e.readRangedU32(0,1024),r.sourceSlot=e.readRangedU32(0,7),r.clientOwned=e.readFlag()):r.initialPosition=e.readPoint3F(),r.endPos=e.readPoint3F(),r.truncated=e.readFlag()),r}function np(e,t,a){let r=na(e,t,a);return e.readFlag()&&(r.name=e.readString()),e.readFlag()&&(r.teamId=e.readS32()),e.readFlag()&&(r.hidden=e.readFlag()),r}function ny(e,t,a){let r=na(e,t,a);return e.readFlag()&&(r.radius=e.readF32(),r.sphereWeight=e.readF32(),r.indoorWeight=e.readF32(),r.outdoorWeight=e.readF32()),r}function nv(e,t,a){let r=rZ(e,t,a);if(e.readFlag()?(r.transform=e.readAffineTransform(),r.scale=e.readPoint3F()):e.readFlag()&&(r.transform=e.readAffineTransform(),r.scale=e.readPoint3F()),e.readFlag()){let t=e.readInt(2);r.state=t,3===t?r.position=0:0===t||(r.position=e.readU32())}return r}function nF(e,t,a){let r={};return r.transform=e.readMatrixF(),r.scale=e.readPoint3F(),r.shapeName=e.readString(),r}function nb(e,t,a){let r={};if(e.readFlag()){r.crc=e.readU32(),r.terrFileName=e.readString(),r.detailTextureName=e.readString(),r.squareSize=e.readU32();let t=e.readU32(),a=[];for(let r=0;r<t;r++)a.push(e.readU32());r.emptySquareRunCount=t}else if(e.readFlag()){let t=e.readU32(),a=[];for(let r=0;r<t;r++)a.push(e.readU32());r.emptySquareRunCount=t}return r}function nS(e,t,a){let r={};if(e.readFlag()){let t=[];for(let a=0;a<5;a++)t.push(e.readString());r.textures=t}if(e.readFlag()){let t=[];for(let a=0;a<19;a++)t.push(e.readF32());r.direction={x:t[0],y:t[1],z:t[2]},r.color={r:t[3],g:t[4],b:t[5],a:t[6]},r.ambient={r:t[7],g:t[8],b:t[9],a:t[10]},r.extraLightProps=t.slice(11)}return r}function nx(e,t,a){let r={};if(e.readFlag()){r.materialList=e.readString(),r.fogColor={r:e.readF32(),g:e.readF32(),b:e.readF32()};let t=e.readU32();if(t>64)throw Error(`Invalid Sky fogVolumeCount: ${t}`);r.fogVolumeCount=t,r.useSkyTextures=e.readBool(),r.renderBottomTexture=e.readBool(),r.skySolidColor={r:e.readF32(),g:e.readF32(),b:e.readF32()},r.windEffectPrecipitation=e.readBool();let a=[];for(let r=0;r<t;r++)a.push({visibleDistance:e.readF32(),minHeight:e.readF32(),maxHeight:e.readF32(),color:{r:e.readF32(),g:e.readF32(),b:e.readF32()}});r.fogVolumes=a;let n=[];for(let t=0;t<3;t++)n.push({texture:e.readString(),heightPercent:e.readF32(),speed:e.readF32()});r.cloudLayers=n,r.windVelocity=e.readPoint3F(),r.stormCurrent=e.readF32(),e.readFlag()&&(r.stormInit={startPct:e.readF32(),duration:e.readF32(),indexOrMode:e.readF32(),startTime:e.readF32(),targetPct:e.readF32()})}return e.readFlag()&&(r.stormCloudsOn=e.readBool()),e.readFlag()&&(r.stormFogOn=e.readBool()),e.readFlag()&&(r.visibleDistance=e.readF32(),r.fogDistance=e.readF32()),e.readFlag()&&(r.stormType=e.readF32(),r.stormMagnitude=e.readF32()),e.readFlag()&&(r.stormTimeline={startPct:e.readF32(),duration:e.readF32(),indexOrMode:e.readF32()}),e.readFlag()&&(r.stormCloudProfile={enabled:e.readF32(),value0:e.readF32(),value1:e.readF32(),value2:e.readF32()}),e.readFlag()&&(r.windVelocity=e.readPoint3F()),r}function nk(e,t,a){let r=rZ(e,t,a);return e.readFlag()&&(r.position=e.readPoint3F(),r.scale=e.readPoint3F(),r.strikeWidth=e.readF32(),r.chanceToHitTarget=e.readF32(),r.strikeRadius=e.readF32(),r.boltStartRadius=e.readF32(),r.color={r:e.readF32(),g:e.readF32(),b:e.readF32()},r.fadeColor={r:e.readF32(),g:e.readF32(),b:e.readF32()},r.useFog=0!==e.readInt(8),r.strikesPerMinute=e.readF32()),r}function nw(e,t,a){let r={};r.transform=e.readAffineTransform(),r.scale=e.readPoint3F(),r.surfaceName=e.readString(),r.envMapName=e.readString();let n=[];for(let t=0;t<2;t++)n.push(e.readString());return r.submergeNames=n,r.liquidType=e.readS32(),r.density=e.readF32(),r.viscosity=e.readF32(),r.waveMagnitude=e.readF32(),r.surfaceOpacity=e.readF32(),r.envMapIntensity=e.readF32(),r.removeWetEdges=0!==e.readInt(8),e.readFlag()&&(r.audioEnvironmentId=rX(e)),r}function nI(e,t,a){let r={};return e.readFlag()&&(r.area={x:e.readS32(),y:e.readS32(),w:e.readS32(),h:e.readS32()},r.flightCeiling=e.readF32(),r.flightCeilingRange=e.readF32()),r}function nC(e,t,a){let r=rZ(e,t,a);return e.readFlag()&&(r.position=e.readPoint3F()),r}function n_(e,t,a){let r=rZ(e,t,a);return e.readFlag()&&(r.position=e.readPoint3F(),r.normal=e.readPoint3F()),r}function nP(e,t,a){let r=rZ(e,t,a);return e.readFlag()&&(r.dropRadius=e.readF32(),r.dropsPerMinute=e.readF32(),r.maxDropAngle=e.readF32(),r.minDropAngle=e.readF32(),r.startVelocity=e.readF32(),r.dropHeight=e.readF32(),r.dropDir=e.readPoint3F()),r}function nD(e,t,a){let r={};return r.transform=e.readMatrixF(),r.boundsMin=e.readPoint3F(),r.boundsMax=e.readPoint3F(),r}function nM(e,t,a){let r=rZ(e,t,a);return r.transform=e.readMatrixF(),r.scale=e.readPoint3F(),e.readFlag()&&(r.emitterDatablockId=rX(e)),r}function nT(e,t,a){let r=rZ(e,t,a);if(e.readFlag()){r.percentage=e.readF32();let t=e.readS32();if(r.colorCount=t,t<0||t>3)throw Error(`Invalid precipitation colorCount: ${t}`);let a=[];for(let r=0;r<t;r++)a.push({r:e.readInt(8)/255,g:e.readInt(8)/255,b:e.readInt(8)/255,a:e.readInt(8)/255});r.colors=a,r.offsetSpeed=e.readF32(),r.minVelocity=e.readF32(),r.maxVelocity=e.readF32(),r.maxDrops=e.readS32(),r.maxRadius=e.readF32(),e.readFlag()&&(r.stormLastTime=e.readF32(),r.stormTime=e.readF32(),r.stormEndPercentage=e.readF32())}return e.readFlag()&&(r.stormPrecipitationOn=e.readBool()),e.readFlag()&&(r.stormTime=e.readF32(),r.stormEndPercentage=e.readF32()),e.readFlag()&&(r.percentageUpdate=e.readF32()),r}function nE(e,t,a){let r=rZ(e,t,a);return e.readFlag()?(r.energyPercentage=e.readFloat(7),r.initialPosition=e.readPoint3F(),r.endPos=e.readPoint3F(),r.truncated=e.readFlag(),r.hitWater=e.readFlag(),e.readFlag()&&(r.sourceObject=e.readRangedU32(0,1024),r.sourceSlot=e.readRangedU32(0,7),r.clientOwned=e.readFlag())):(e.readFlag()?(r.sourceObject=e.readRangedU32(0,1024),r.sourceSlot=e.readRangedU32(0,7),r.clientOwned=e.readFlag()):r.initialPosition=e.readPoint3F(),r.endPos=e.readPoint3F(),r.truncated=e.readFlag()),r}function nB(e,t,a){let r=rZ(e,t,a);return e.readFlag()&&(r.targetObject=e.readRangedU32(0,1024)),e.readFlag()&&(r.start=e.readPoint3F(),r.end=e.readPoint3F(),r.hitObject=e.readFlag(),e.readFlag()&&(r.sourceObject=e.readRangedU32(0,1024),r.sourceSlot=e.readRangedU32(0,7))),r}let nj=new Map,nR=new Map;function nN(e,t,a){let r=r1(e,t,a);if(r.braking=e.readFlag(),e.readFlag()){let t=4,n=r.dataBlockId,i=a.currentGhostIndex;if(void 0!==n){let e=nj.get(n);if(void 0!==e)t=e;else if(a.getDataBlockData){let e=a.getDataBlockData(n);e&&(t=function(e){if(!e)return 6;let t=e.toLowerCase();return t.includes("mpb")||t.includes("mpbase"),6}(e.shapeName),nj.set(n,t))}void 0!==i&&nR.set(i,t)}else if(void 0!==i){let e=nR.get(i);void 0!==e&&(t=e)}let o=[];for(let a=0;a<t;a++)o.push({avel:e.readF32(),dy:e.readF32(),dx:e.readF32()});r.wheels=o}return r}function nA(e,t,a){return{tickPeriodMS:e.readU32()}}function nG(e,t,a){let r={};if(e.readFlag()){r.transform=e.readMatrixF(),r.scale=e.readPoint3F();let t=e.readU32();if(t>Math.floor(e.getRemainingBits()/96))throw Error(`Invalid physicalZone point count: ${t}`);let a=[];for(let r=0;r<t;r++)a.push(e.readPoint3F());r.points=a;let n=e.readU32();if(n>Math.floor(e.getRemainingBits()/128))throw Error(`Invalid physicalZone plane count: ${n}`);let i=[];for(let t=0;t<n;t++)i.push({x:e.readF32(),y:e.readF32(),z:e.readF32(),d:e.readF32()});r.planes=i;let o=e.readU32();if(o>Math.floor(e.getRemainingBits()/128))throw Error(`Invalid physicalZone edge count: ${o}`);let s=[];for(let t=0;t<o;t++)s.push({face0:e.readU32(),face1:e.readU32(),vertex0:e.readU32(),vertex1:e.readU32()});r.edges=s,r.velocityMod=e.readF32(),r.gravityMod=e.readF32(),r.appliedForce=e.readPoint3F(),r.active=e.readFlag()}else r.active=e.readFlag();return r}function nU(e,t,a){let r={};return r.initialUpdate=e.readFlag(),e.readFlag()&&(r.transform=e.readAffineTransform()),e.readFlag()&&e.readFlag()&&(r.audioProfileId=rX(e)),e.readFlag()&&e.readFlag()&&(r.audioDescriptionId=rX(e)),e.readFlag()&&(r.filename=e.readString()),e.readFlag()&&(r.useProfileDescription=e.readFlag()),e.readFlag()&&(r.volume=e.readF32()),e.readFlag()&&(r.isLooping=e.readFlag()),e.readFlag()&&(r.is3D=e.readFlag()),e.readFlag()&&(r.minDistance=e.readF32()),e.readFlag()&&(r.maxDistance=e.readF32()),e.readFlag()&&(r.coneInsideAngle=e.readF32()),e.readFlag()&&(r.coneOutsideAngle=e.readF32()),e.readFlag()&&(r.coneOutsideVolume=e.readF32()),e.readFlag()&&(r.coneVector=e.readPoint3F()),e.readFlag()&&(r.loopCount=e.readF32()),e.readFlag()&&(r.minLoopGap=e.readF32()),e.readFlag()&&(r.maxLoopGap=e.readF32()),e.readFlag()&&(r.audioType=e.readF32()),e.readFlag()&&(r.outsideAmbient=e.readFlag()),r}function nL(e,t,a){let r=rZ(e,t,a);return e.readFlag()&&e.readFlag()&&(r.stationObject=e.readRangedU32(0,1024)),r}function nz(e,t,a){let r=rJ(e,t,a);return e.readFlag()&&(r.transform=e.readAffineTransform(),r.scale=e.readPoint3F()),r.unknownFlag=e.readFlag(),r}function nO(e,t){if(!e.readFlag())return{type:"SimDataBlockEvent",mProcess:!1};let a=e.readInt(11)+0,r=e.readInt(7)+128,n=e.readInt(11),i=e.readInt(12),o={type:"SimDataBlockEvent",mProcess:!0};o.objectId=a,o.classId=r,o.index=n,o.total=i,o._payloadBitPos=e.getCurPos();let s=t.getDataBlockParser?.(r);if(s)try{o.dataBlockData=s.unpackData(e),o.dataBlockClassName=s.name}catch{o._needsClassParser=!0}else o._needsClassParser=!0;return o}function nV(e,t){let a=e.readInt(10),r=e.readFlag(),n=r?e.readString():void 0;return{type:"NetStringEvent",id:a,hasValue:r,value:n}}function nq(e,t){return{type:"Sim2DAudioEvent",profileId:e.readInt(11)}}function nH(e,t){let a,r=e.readInt(11);if(e.readFlag()){let t=e.readFloat(8),r=e.readFloat(8),n=e.readFloat(8),i=Math.sqrt(Math.max(0,1-(t*t+r*r+n*n)));e.readFlag()&&(i=-i),a={x:t,y:r,z:n,w:i}}return{type:"Sim3DAudioEvent",profileId:r,rotation:a,position:e.readCompressedPoint(t.compressionPoint,.5)}}function nW(e,t){return{type:"SetSensorGroupEvent",sensorGroup:e.readInt(5)}}function n$(e,t){let a={type:"SetServerTargetEvent"};return e.readFlag()&&(a.targetId=e.readInt(9)),a.targetPos={x:e.readF32(),y:e.readF32(),z:e.readF32()},a}function nY(e,t){let a={type:"TargetToEvent"};return e.readFlag()&&(a.targetId=e.readInt(9)),e.readFlag()&&(a.targetPos={x:e.readF32(),y:e.readF32(),z:e.readF32()}),a.assign=e.readFlag(),a}function nK(e,t){return{type:"SetObjectActiveImageEvent",objectId:e.readRangedU32(0,1023),imageSlot:e.readRangedU32(0,8)}}function nX(e,t){return{type:"SetMissionCRCEvent",crc:e.readU32()}}function nZ(e,t){let a=e.readInt(5),r=[];for(let t=0;t<a;t++)r.push(e.unpackNetString());return{type:"RemoteCommandEvent",argc:a,argv:r,funcName:r[0]??"",args:r.slice(1)}}function nJ(e,t){let a={type:"TargetInfoEvent"};return a.targetId=e.readInt(9),e.readFlag()&&(a.nameTag=e.readFlag()?e.readInt(10):1024),e.readFlag()&&(a.skinTag=e.readFlag()?e.readInt(10):1024),e.readFlag()&&(a.skinPrefTag=e.readFlag()?e.readInt(10):1024),e.readFlag()&&(a.voiceTag=e.readFlag()?e.readInt(10):1024),e.readFlag()&&(a.typeTag=e.readFlag()?e.readInt(10):1024),e.readFlag()&&(a.sensorGroup=e.readInt(5)),e.readFlag()&&(a.dataBlockId=e.readFlag()?e.readInt(11):-2),e.readFlag()&&(a.renderFlags=e.readInt(9)),e.readFlag()&&(a.voicePitch=1.5*e.readFloat(7)+.5),a}function nQ(e,t){return{type:"TargetFreeEvent",targetId:e.readInt(9)}}function n0(e,t){let a={type:"SimTargetAudioEvent"};return a.targetId=e.readInt(9),a.fileTag=e.readInt(12),a.descriptionId=e.readRangedU32(3,1026),e.readFlag()&&(a.position=e.readCompressedPoint(t.compressionPoint,.5)),a.updateSound=e.readFlag(),a}function n1(e,t){let a={type:"SensorGroupColorEvent"};a.sensorGroup=e.readInt(5);let r=e.readU32();a.updateMask=r;let n=[];for(let t=0;t<32;t++)1<<t&r&&(e.readFlag()?n.push({index:t,r:e.readU8(),g:e.readU8(),b:e.readU8(),a:e.readU8()}):n.push({index:t,default:!0}));return a.colors=n,a}function n2(e,t){return{type:"ResetClientTargetsEvent",clientTargetsOnly:e.readFlag()}}function n3(e,t){return{type:"RemoveClientTargetTypeEvent",targetType:e.readRangedU32(0,3)}}function n5(e,t){let a={type:"SimVoiceStreamEvent"};a.streamId=e.readInt(5),a.sequence=e.readInt(6),a.codecId=e.readInt(2),a.clientId=e.readU8(),0===a.sequence&&(a.objectId=e.readInt(10)),e.readFlag()?a.size=e.readInt(5):a.size=16;let r=a.size;return r>0&&(a.audioData=e.readBitsBuffer(8*r)),a}function n4(e,t){return{type:"GhostingMessageEvent",sequence:e.readU32(),message:e.readInt(3),ghostCount:e.readInt(11)}}function n6(e,t){let a={type:"GhostAlwaysObjectEvent"};a.ghostIndex=e.readInt(10);let r=e.readFlag();if(a._hasObjectData=r,r){let r=e.readInt(7);a.classId=r;let n=t.getGhostParser?.(r);if(!n)throw Error(`No ghost parser for GhostAlwaysObjectEvent classId=${r}`);a.objectData=n.unpackUpdate(e,!0,t)}return a}function n8(e,t){let a={type:"PathManagerEvent"};if(e.readFlag()){a.messageType="NewPaths";let t=e.readU32(),r=[];for(let a=0;a<t&&a<256;a++){let t=e.readU32(),a=e.readU32(),n=[];for(let t=0;t<a&&t<1024;t++)n.push({position:e.readPoint3F(),msToNext:e.readU32()});r.push({totalTime:t,points:n})}a.paths=r}else{a.messageType="ModifyPath",a.modifiedPath=e.readU32();let t=e.readU32(),r=e.readU32(),n=[];for(let t=0;t<r&&t<1024;t++)n.push({position:e.readPoint3F(),msToNext:e.readU32()});a.path={totalTime:t,points:n}}return a}function n7(e,t){let a={type:"LightningStrikeEvent"};return e.readFlag()&&(a.sourceGhost=e.readInt(11),a.startX=e.readFloat(10),a.startY=e.readFloat(10),e.readFlag()&&(a.targetGhost=e.readInt(11))),a}function n9(e,t){let a=e.readRangedU32(0,63),r=e.readBitsBuffer(8*a);return{type:"FileChunkEvent",chunkLen:a,chunkData:r}}function ie(e,t){return{type:"DownloadMessageEvent",value:e.readU32(),message:e.readInt(3)}}function it(e,t){let a=e.readRangedU32(0,31),r=[];for(let t=0;t<a;t++)r.push(e.readString());return{type:"FileDownloadRequestEvent",fileNames:r}}function ia(e,t){return{type:"SimpleMessageEvent",message:e.readString()}}function ir(e,t){return{type:"CRCChallengeEvent",crcValue:e.readU32(),field1:e.readU32(),field2:e.readU32(),flag:e.readFlag()}}function ii(e,t){return{type:"CRCChallengeResponseEvent",crcValue:e.readU32(),field1:e.readU32(),field2:e.readU32()}}function io(e,t){return{type:"GravityEvent",gravity:e.readF32()}}function is(e,t){return{type:"FogChallengeEvent"}}function il(e){return e.readFlag()?e.readInt(11):null}function ic(e,t,a){return e.readRangedU32(0,a-t)+t}function id(e){return{r:e.readInt(8)/255,g:e.readInt(8)/255,b:e.readInt(8)/255,a:e.readInt(8)/255}}function iu(e){return 0!==e.readInt(8)}function ih(e,t,a,r){return t+e.readInt(r)/((1<<r)-1)*(a-t)}function im(e){let t={};e.readFlag()&&(t.crc=e.readU32()),t.shapeName=e.readString(),e.readFlag()&&(t.mass=e.readF32()),e.readFlag()&&(t.drag=e.readF32()),e.readFlag()&&(t.density=e.readF32()),e.readFlag()&&(t.maxEnergy=e.readF32()),e.readFlag()&&(t.cameraMaxDist=e.readF32()),e.readFlag()&&(t.cameraMinDist=e.readF32()),e.readFlag()&&(t.cameraDefaultFov=e.readF32()),e.readFlag()&&(t.cameraMinFov=e.readF32()),e.readFlag()&&(t.cameraMaxFov=e.readF32()),t.debrisShapeName=e.readString(),e.readFlag()&&(t.sensorRadius=e.readInt(10),t.sensorColor={r:e.readInt(8),g:e.readInt(8),b:e.readInt(8),a:e.readInt(8)}),e.readFlag()&&(t.heat=e.readF32()),t.cmdCategory=e.readString(),t.cmdMiniIconName=e.readString(),t.canControl=e.readFlag(),t.canObserve=e.readFlag(),t.observeThroughObject=e.readFlag(),t.firstPersonOnly=e.readFlag(),t.isInvincible=e.readFlag(),t.renderWhenDestroyed=e.readFlag(),t.debris=il(e),t.explosion=il(e),t.underwaterExplosion=il(e),t.debrisEmitter=il(e),t.inheritEnergyFromMount=e.readFlag(),t.useEyePoint=e.readFlag(),t.emap=e.readFlag(),t.shieldEffectLifetimeMS=e.readU32(),e.readFlag()&&(t.shieldEffectScale={x:e.readF32(),y:e.readF32(),z:e.readF32()});let a=[];for(let t=0;t<8;t++){if(!e.readFlag())continue;let t={};t.friendlyName=e.readString(),e.readFlag()&&(t.enemyName=e.readString()),t.renderCenter=e.readFlag(),t.renderModulated=e.readFlag(),t.renderAlways=e.readFlag(),t.renderDistance=e.readFlag(),t.renderName=e.readFlag(),a.push(t)}return a.length>0&&(t.hudImages=a),t}function ig(e){let t={};e.readFlag()&&(t.crc=e.readU32()),t.shapeName=e.readString(),t.mountPoint=e.readU32(),e.readFlag()||(t.offset=e.readAffineTransform()),t.firstPerson=e.readFlag(),t.mass=e.readF32(),t.usesEnergy=e.readFlag(),t.minEnergy=e.readF32(),t.hasFlash=e.readFlag(),t.projectile=il(e),t.muzzleFlash=il(e),t.isSeeker=e.readFlag(),t.isSeeker&&(t.seekerRadius=e.readF32(),t.maxSeekAngle=e.readF32(),t.seekerLockTime=e.readF32(),t.seekerFreeTime=e.readF32(),t.isTargetLockRequired=e.readFlag(),t.maxLockRange=e.readF32()),t.cloakable=e.readFlag(),t.lightType=e.readRangedU32(0,3),0!==t.lightType&&(t.lightRadius=e.readF32(),t.lightTime=e.readS32(),t.lightColor={r:e.readFloat(7),g:e.readFloat(7),b:e.readFloat(7),a:e.readFloat(7)}),t.shellExitDir={x:e.readF32(),y:e.readF32(),z:e.readF32()},t.shellExitVariance=e.readF32(),t.shellVelocity=e.readF32(),t.casing=il(e),t.accuFire=e.readFlag();let a=[];for(let t=0;t<31;t++){if(!e.readFlag())continue;let t={};t.name=e.readString(),t.transitionOnAmmo=e.readInt(5),t.transitionOnNoAmmo=e.readInt(5),t.transitionOnTarget=e.readInt(5),t.transitionOnNoTarget=e.readInt(5),t.transitionOnWet=e.readInt(5),t.transitionOnNotWet=e.readInt(5),t.transitionOnTriggerUp=e.readInt(5),t.transitionOnTriggerDown=e.readInt(5),t.transitionOnTimeout=e.readInt(5),t.transitionGeneric0In=e.readInt(5),t.transitionGeneric0Out=e.readInt(5),e.readFlag()&&(t.timeoutValue=e.readF32()),t.waitForTimeout=e.readFlag(),t.fire=e.readFlag(),t.ejectShell=e.readFlag(),t.scaleAnimation=e.readFlag(),t.direction=e.readFlag(),t.reload=e.readFlag(),e.readFlag()&&(t.energyDrain=e.readF32()),t.loaded=e.readInt(3),t.spin=e.readInt(3),t.recoil=e.readInt(3),e.readFlag()&&(t.sequence=e.readSignedInt(16)),e.readFlag()&&(t.sequenceVis=e.readSignedInt(16)),t.flashSequence=e.readFlag(),t.ignoreLoadedForReady=e.readFlag(),t.emitter=il(e),null!==t.emitter&&(t.emitterTime=e.readF32(),t.emitterNode=e.readS32()),t.sound=il(e),a.push(t)}return t.states=a,t}function ip(e){let t=im(e);t.renderFirstPerson=e.readFlag(),t.minLookAngle=e.readF32(),t.maxLookAngle=e.readF32(),t.maxFreelookAngle=e.readF32(),t.maxTimeScale=e.readF32(),t.maxStepHeight=e.readF32(),t.runForce=e.readF32(),t.runEnergyDrain=e.readF32(),t.minRunEnergy=e.readF32(),t.maxForwardSpeed=e.readF32(),t.maxBackwardSpeed=e.readF32(),t.maxSideSpeed=e.readF32(),t.maxUnderwaterForwardSpeed=e.readF32(),t.maxUnderwaterBackwardSpeed=e.readF32(),t.maxUnderwaterSideSpeedRef=il(e),e.readFlag()&&(t.runSurfaceAngleRef=e.readInt(11)),t.runSurfaceAngle=e.readF32(),t.recoverDelay=e.readF32(),t.recoverRunForceScale=e.readF32(),t.jumpForce=e.readF32(),t.jumpEnergyDrain=e.readF32(),t.minJumpEnergy=e.readF32(),t.minJumpSpeed=e.readF32(),t.maxJumpSpeed=e.readF32(),t.jumpSurfaceAngle=e.readF32(),t.minJetEnergy=e.readF32(),t.splashVelocity=e.readF32(),t.splashAngle=e.readF32(),t.splashFreqMod=e.readF32(),t.splashVelEpsilon=e.readF32(),t.bubbleEmitTime=e.readF32(),t.medSplashSoundVel=e.readF32(),t.hardSplashSoundVel=e.readF32(),t.exitSplashSoundVel=e.readF32(),t.jumpDelay=e.readInt(7),t.horizMaxSpeed=e.readF32(),t.horizResistSpeed=e.readF32(),t.horizResistFactor=e.readF32(),t.upMaxSpeed=e.readF32(),t.upResistSpeed=e.readF32(),t.upResistFactor=e.readF32(),t.jetEnergyDrain=e.readF32(),t.canJet=e.readF32(),t.maxJetHorizontalPercentage=e.readF32(),t.maxJetForwardSpeed=e.readF32(),t.jetForce=e.readF32(),t.minJetSpeed=e.readF32(),t.maxDamage=e.readF32(),t.minImpactDamageSpeed=e.readF32(),t.impactDamageScale=e.readF32(),t.footSplashHeight=e.readF32();let a=[];for(let t=0;t<32;t++)e.readFlag()?a.push(e.readInt(11)):a.push(null);t.sounds=a,t.boxSize={x:e.readF32(),y:e.readF32(),z:e.readF32()},t.footPuffEmitter=il(e),t.footPuffNumParts=e.readF32(),t.footPuffRadius=e.readF32(),t.decalData=il(e),t.decalOffset=e.readF32(),t.dustEmitter=il(e),t.splash=il(e);let r=[];for(let t=0;t<3;t++)r.push(il(e));return t.splashEmitters=r,t.groundImpactMinSpeed=e.readF32(),t.groundImpactShakeFreq={x:e.readF32(),y:e.readF32(),z:e.readF32()},t.groundImpactShakeAmp={x:e.readF32(),y:e.readF32(),z:e.readF32()},t.groundImpactShakeDuration=e.readF32(),t.groundImpactShakeFalloff=e.readF32(),t.boundingRadius=e.readF32(),t.moveBubbleSize=e.readF32(),t}function iy(e){let t=im(e);t.bodyRestitution=e.readF32(),t.bodyFriction=e.readF32();let a=[];for(let t=0;t<2;t++)a.push(il(e));t.impactSounds=a,t.minImpactSpeed=e.readF32(),t.softImpactSpeed=e.readF32(),t.hardImpactSpeed=e.readF32(),t.minRollSpeed=e.readF32(),t.maxSteeringAngle=e.readF32(),t.maxDrag=e.readF32(),t.minDrag=e.readF32(),t.cameraOffset=e.readF32(),t.cameraLag=e.readF32(),t.jetForce=e.readF32(),t.jetEnergyDrain=e.readF32(),t.minJetEnergy=e.readF32(),t.integration=e.readF32(),t.collisionTol=e.readF32(),t.massCenter=e.readF32(),t.exitSplashSoundVelocity=e.readF32(),t.softSplashSoundVelocity=e.readF32(),t.mediumSplashSoundVelocity=e.readF32(),t.hardSplashSoundVelocity=e.readF32();let r=[];for(let t=0;t<5;t++)r.push(il(e));t.waterSounds=r,t.dustEmitter=il(e);let n=[];for(let t=0;t<3;t++)n.push(il(e));t.damageEmitters=n;let i=[];for(let t=0;t<2;t++)i.push(il(e));return t.splashEmitters=i,t.damageEmitterOffset0={x:e.readF32(),y:e.readF32(),z:e.readF32()},t.damageEmitterOffset1={x:e.readF32(),y:e.readF32(),z:e.readF32()},t.damageLevelTolerance0=e.readF32(),t.damageLevelTolerance1=e.readF32(),t.splashFreqMod=e.readF32(),t.splashVelEpsilon=e.readF32(),t.collDamageThresholdVel=e.readF32(),t.collDamageMultiplier=e.readF32(),t}function iv(e){let t=iy(e);t.jetActivateSound=il(e),t.jetDeactivateSound=il(e);let a=[];for(let t=0;t<4;t++)a.push(il(e));return t.jetEmitters=a,t.maneuveringForce=e.readF32(),t.horizontalSurfaceForce=e.readF32(),t.verticalSurfaceForce=e.readF32(),t.autoInputDamping=e.readF32(),t.steeringForce=e.readF32(),t.steeringRollForce=e.readF32(),t.rollForce=e.readF32(),t.autoAngularForce=e.readF32(),t.rotationalDrag=e.readF32(),t.maxAutoSpeed=e.readF32(),t.autoLinearForce=e.readF32(),t.hoverHeight=e.readF32(),t.createHoverHeight=e.readF32(),t.minTrailSpeed=e.readF32(),t.vertThrustMultiple=e.readF32(),t.maxForwardSpeed=e.readF32(),t}function iF(e){let t=iy(e);t.dragForce=e.readF32(),t.mainThrustForce=e.readF32(),t.reverseThrustForce=e.readF32(),t.strafeThrustForce=e.readF32(),t.turboFactor=e.readF32(),t.stabLenMin=e.readF32(),t.stabLenMax=e.readF32(),t.stabSpringConstant=e.readF32(),t.stabDampingConstant=e.readF32(),t.gyroDrag=e.readF32(),t.normalForce=e.readF32(),t.restorativeForce=e.readF32(),t.steeringForce=e.readF32(),t.rollForce=e.readF32(),t.pitchForce=e.readF32(),t.floatingThrustFactor=e.readF32(),t.brakingForce=e.readF32(),t.dustTrailOffset={x:e.readF32(),y:e.readF32(),z:e.readF32()},t.dustTrailFreqMod=e.readF32(),t.triggerTrailHeight=e.readF32(),t.floatSound=il(e),t.thrustSound=il(e),t.turboSound=il(e);let a=[];for(let t=0;t<3;t++)a.push(il(e));return t.jetEmitters=a,t.dustTrailEmitter=il(e),t.mainThrustEmitterFactor=e.readF32(),t.strafeThrustEmitterFactor=e.readF32(),t.reverseThrustEmitterFactor=e.readF32(),t}function ib(e){let t=iy(e);return t.tireRadius=e.readF32(),t.tireStaticFriction=e.readF32(),t.tireKineticFriction=e.readF32(),t.tireRestitution=e.readF32(),t.tireLateralForce=e.readF32(),t.tireLateralDamping=e.readF32(),t.tireLateralRelaxation=e.readF32(),t.tireLongitudinalForce=e.readF32(),t.tireLongitudinalDamping=e.readF32(),t.tireEmitter=il(e),t.jetSound=il(e),t.engineSound=il(e),t.squealSound=il(e),t.wadeSound=il(e),t.spring=e.readF32(),t.springDamping=e.readF32(),t.springLength=e.readF32(),t.brakeTorque=e.readF32(),t.engineTorque=e.readF32(),t.engineBrake=e.readF32(),t.maxWheelSpeed=e.readF32(),t.steeringAngle=e.readF32(),t.steeringReturn=e.readF32(),t.steeringDamping=e.readF32(),t.powerSteeringFactor=e.readF32(),t}function iS(e){let t=im(e);return t.noIndividualDamage=e.readFlag(),t.dynamicTypeField=e.readS32(),t}function ix(e){let t=iS(e);return t.thetaMin=e.readF32(),t.thetaMax=e.readF32(),t.thetaNull=e.readF32(),t.neverUpdateControl=e.readFlag(),t.primaryAxis=e.readRangedU32(0,3),t.maxCapacitorEnergy=e.readF32(),t.capacitorRechargeRate=e.readF32(),t}function ik(e){let t=ig(e);return t.activationMS=e.readInt(8),t.deactivateDelayMS=e.readInt(8),t.degPerSecTheta=e.readRangedU32(0,1080),t.degPerSecPhi=e.readRangedU32(0,1080),t.dontFireInsideDamageRadius=e.readFlag(),t.damageRadius=e.readF32(),t.useCapacitor=e.readFlag(),t}function iw(e){let t=im(e);return t.friction=e.readFloat(10),t.elasticity=e.readFloat(10),t.sticky=e.readFlag(),e.readFlag()&&(t.gravityMod=e.readFloat(10)),e.readFlag()&&(t.maxVelocity=e.readF32()),e.readFlag()&&(t.lightType=e.readInt(2),t.lightColor={r:e.readFloat(7),g:e.readFloat(7),b:e.readFloat(7),a:e.readFloat(7)},t.lightTime=e.readS32(),t.lightRadius=e.readF32(),t.lightOnlyStatic=e.readFlag()),t}function iI(e){let t={};t.projectileShapeName=e.readString(),t.faceViewerLinkTime=e.readS32(),t.lifetime=e.readS32(),t.faceViewer=e.readFlag(),e.readFlag()&&(t.scale={x:e.readF32(),y:e.readF32(),z:e.readF32()}),t.baseEmitter=il(e),t.delayEmitter=il(e),t.bubbleEmitter=il(e),t.explosion=il(e),t.underwaterExplosion=il(e),t.splash=il(e),t.sound=il(e),t.wetFireSound=il(e),t.fireSound=il(e);let a=[];for(let t=0;t<6;t++)a.push(il(e));return t.decals=a,e.readFlag()&&(t.lightRadius=e.readFloat(8),t.lightColor={r:e.readFloat(7),g:e.readFloat(7),b:e.readFloat(7)}),e.readFlag()&&(t.underwaterLightColor={r:e.readFloat(7),g:e.readFloat(7),b:e.readFloat(7)}),t.explodeOnWaterImpact=iu(e),t.depthTolerance=e.readF32(),t}function iC(e){let t=iI(e);return t.dryVelocity=e.readF32(),t.wetVelocity=e.readF32(),t.fizzleTime=e.readU32(),t.fizzleType=e.readU32(),t.hardRetarget=e.readFlag(),t.inheritedVelocityScale=e.readRangedU32(0,90),t.lifetimeMS=e.readRangedU32(0,90),t.collideWithOwnerTimeMS=e.readU32(),t.proximityRadius=e.readU32(),t.tracerProjectile=e.readFlag(),t}function i_(e){let t=iI(e);return t.armingDelayMS=e.readS32(),t.muzzleVelocity=e.readF32(),t.grenadeElasticity=e.readF32(),t.grenadeFriction=e.readF32(),t.drag=e.readF32(),t.density=e.readF32(),t.gravityMod=e.readF32(),t.lifetimeMS=e.readS32(),t}function iP(e){let t=iI(e);return t.lifetimeMS=e.readS32(),t.muzzleVelocity=e.readF32(),t.turningSpeed=e.readF32(),t.proximityRadius=e.readF32(),t.terrainAvoidanceSpeed=e.readF32(),t.terrainScanAhead=e.readF32(),t.terrainHeightFail=e.readF32(),t.terrainAvoidanceRadius=e.readF32(),t.flareDistance=e.readF32(),t.flareAngle=e.readF32(),t.useFlechette=iu(e),t.maxVelocity=e.readF32(),t.acceleration=e.readF32(),t.flechetteDelayMs=e.readS32(),t.exhaustTimeMs=e.readS32(),t.exhaustNodeName=e.readString(),t.casingShapeName=e.readString(),t.casingDebris=il(e),t.puffEmitter=il(e),t.exhaustEmitter=il(e),t}function iD(e){let t=iI(e);t.maxRifleRange=e.readF32(),t.rifleHeadMultiplier=e.readF32(),t.beamColor=id(e),t.fadeTime=e.readF32(),t.startBeamWidth=e.readF32(),t.endBeamWidth=e.readF32(),t.pulseBeamWidth=e.readF32(),t.beamFlareAngle=e.readF32(),t.minFlareSize=e.readF32(),t.maxFlareSize=e.readF32(),t.pulseSpeed=e.readF32(),t.pulseLength=e.readF32(),t.lightColor=id(e),t.lightRadius=e.readF32();let a=[];for(let t=0;t<12;t++)a.push(e.readString());return t.textures=a,t}function iM(e){let t=iI(e);t.zapDuration=e.readF32(),t.boltLength=e.readF32(),t.numParts=e.readF32(),t.lightningFreq=e.readF32(),t.lightningDensity=e.readF32(),t.lightningAmp=e.readF32(),t.lightningWidth=e.readF32(),t.shockwave=il(e);let a=[],r=[],n=[],i=[];for(let t=0;t<2;t++)a.push(e.readF32()),r.push(e.readF32()),n.push(e.readF32()),i.push(e.readF32());t.startWidth=a,t.endWidth=r,t.boltSpeed=n,t.texWrap=i;let o=[];for(let t=0;t<4;t++)o.push(e.readString());return t.textures=o,t.emitter=il(e),t}function iT(e){let t=iI(e);return t.beamRange=e.readF32(),t.beamDrainRate=e.readF32(),t.muzzleVelocity=e.readF32(),t.proximityRadius=e.readF32(),t.startWidth=e.readF32(),t.endWidth=e.readF32(),t.mainBeamTexture=e.readString(),t.innerBeamTexture=e.readString(),t.flareTexture=e.readString(),t.hitEmitter=il(e),t}function iE(e){let t=iI(e);return t.beamRange=e.readF32(),t.beamRepairRate=e.readF32(),t.muzzleVelocity=e.readF32(),t.proximityRadius=e.readF32(),t.startWidth=e.readF32(),t.endWidth=e.readF32(),t.startBeamWidth=e.readF32(),t.endBeamWidth=e.readF32(),t.mainBeamTexture=e.readString(),t.innerBeamTexture=e.readString(),t}function iB(e){let t=iI(e);t.maxRifleRange=e.readF32(),t.beamColor=id(e),t.startBeamWidth=e.readF32(),t.pulseBeamWidth=e.readF32(),t.beamFlareAngle=e.readF32(),t.minFlareSize=e.readF32(),t.maxFlareSize=e.readF32(),t.pulseSpeed=e.readF32(),t.pulseLength=e.readF32();let a=[];for(let t=0;t<4;t++)a.push(e.readString());return t.textures=a,t}function ij(e){let t=iC(e);return t.tracerLength=e.readF32(),t.tracerAlpha=e.readF32(),t.tracerMinPixels=e.readF32(),t.crossViewFraction=iu(e),t.tracerColor=id(e),t.tracerWidth=e.readF32(),t.muzzleVelocity=e.readF32(),t.proximityRadius=iu(e),t.textureName0=e.readString(),t.textureName1=e.readString(),t}function iR(e){let t=i_(e);return t.energyDrainPerSecond=e.readF32(),t.energyMinDrain=e.readF32(),t.beamWidth=e.readF32(),t.beamRange=e.readF32(),t.numSegments=e.readF32(),t.texRepeat=e.readF32(),t.beamFlareAngle=e.readF32(),t.beamTexture=e.readString(),t.flareTexture=e.readString(),t}function iN(e){let t=iC(e);return t.numFlares=e.readF32(),t.flareColor=id(e),t.flareTexture=e.readString(),t.smokeTexture=e.readString(),t.size=e.readF32(),t.flareModTexture=e.readF32(),t.smokeSize=e.readF32(),t}function iA(e){let t=i_(e);return t.smokeDist=e.readF32(),t.noSmoke=e.readF32(),t.boomTime=e.readF32(),t.casingDist=e.readF32(),t.smokeCushion=e.readF32(),t.noSmokeCounter=e.readF32(),t.smokeTexture=e.readString(),t.bombTexture=e.readString(),t}function iG(e){let t=i_(e);return t.size=e.readF32(),t.useLensFlare=iu(e),t.flareTexture=e.readString(),t.lensFlareTexture=e.readString(),t}function iU(e){let t={};t.dtsFileName=e.readString(),t.soundProfile=il(e),t.particleEmitter=il(e),t.particleDensity=e.readInt(14),t.particleRadius=e.readF32(),t.faceViewer=e.readFlag(),e.readFlag()&&(t.explosionScale={x:e.readInt(16),y:e.readInt(16),z:e.readInt(16)}),t.playSpeed=e.readInt(14),t.debrisThetaMin=e.readRangedU32(0,180),t.debrisThetaMax=e.readRangedU32(0,180),t.debrisPhiMin=e.readRangedU32(0,360),t.debrisPhiMax=e.readRangedU32(0,360),t.debrisMinVelocity=e.readRangedU32(0,1e3),t.debrisMaxVelocity=e.readRangedU32(0,1e3),t.debrisNum=e.readInt(14),t.debrisVariance=e.readRangedU32(0,1e4),t.delayMS=e.readInt(16),t.delayVariance=e.readInt(16),t.lifetimeMS=e.readInt(16),t.lifetimeVariance=e.readInt(16),t.offset=e.readF32(),t.shakeCamera=e.readFlag(),t.hasLight=e.readFlag(),t.camShakeFreq={x:e.readF32(),y:e.readF32(),z:e.readF32()},t.camShakeAmp={x:e.readF32(),y:e.readF32(),z:e.readF32()},t.camShakeDuration=e.readF32(),t.camShakeRadius=e.readF32(),t.camShakeFalloff=e.readF32(),t.shockwave=il(e),t.debris=il(e);let a=[];for(let t=0;t<4;t++)a.push(il(e));t.emitters=a;let r=[];for(let t=0;t<5;t++)r.push(il(e));t.subExplosions=r;let n=e.readRangedU32(0,4),i=[];for(let t=0;t<n;t++)i.push(e.readFloat(8));t.times=i;let o=[];for(let t=0;t<n;t++)o.push({x:e.readRangedU32(0,16e3),y:e.readRangedU32(0,16e3),z:e.readRangedU32(0,16e3)});return t.sizes=o,t}function iL(e){let t={};return t.elasticity=e.readF32(),t.friction=e.readF32(),t.numBounces=e.readS32(),t.bounceVariance=e.readS32(),t.minSpinSpeed=e.readF32(),t.maxSpinSpeed=e.readF32(),t.render2D=iu(e),t.explodeOnMaxBounce=iu(e),t.staticOnMaxBounce=iu(e),t.snapOnMaxBounce=iu(e),t.lifetime=e.readF32(),t.lifetimeVariance=e.readF32(),t.minSpinSpeed_dup=e.readF32(),t.maxSpinSpeed_dup=e.readF32(),t.velocity=e.readF32(),t.velocityVariance=e.readF32(),t.useRadiusMass=iu(e),t.fade=iu(e),t.baseRadius=e.readF32(),t.gravModifier=e.readF32(),t.terminalVelocity=e.readF32(),t.ignoreWater=iu(e),t.shapeFileName=e.readString(),t.skinName=e.readString(),t.emitter0=il(e),t.emitter1=il(e),t.explosion=il(e),t}function iz(e){let t={};t.scale={x:e.readF32(),y:e.readF32(),z:e.readF32()},t.delayMS=e.readS32(),t.delayVariance=e.readS32(),t.lifetimeMS=e.readS32(),t.lifetimeVariance=e.readS32(),t.width=e.readF32(),t.numSegments=e.readS32(),t.velocity=e.readF32(),t.height=e.readF32(),t.acceleration=e.readF32(),t.texWrap=e.readF32(),t.texFactor=e.readF32(),t.ejectionFreq=e.readF32(),t.ejectionAngle=e.readF32(),t.ringLifetime=e.readF32(),t.startRadius=e.readF32(),t.explosion=il(e);let a=[];for(let t=0;t<3;t++)a.push(il(e));t.emitters=a;let r=[];for(let t=0;t<4;t++)r.push(id(e));t.colors=r;let n=[];for(let t=0;t<4;t++)n.push(e.readF32());return t.times=n,t.textureName=e.readString(),t.foamTexture=e.readString(),t}function iO(e){let t={};t.scale={x:e.readF32(),y:e.readF32(),z:e.readF32()},t.delayMS=e.readS32(),t.delayVariance=e.readS32(),t.lifetimeMS=e.readS32(),t.lifetimeVariance=e.readS32(),t.width=e.readF32(),t.numSegments=e.readS32(),t.numVertSegments=e.readS32(),t.velocity=e.readF32(),t.height=e.readF32(),t.verticalCurve=e.readF32(),t.acceleration=e.readF32(),t.texWrap=e.readF32(),t.is2D=iu(e),t.orientToNormal=iu(e),t.mapToTerrain=iu(e),t.renderBottom=iu(e),t.renderSquare=iu(e);let a=[];for(let t=0;t<3;t++)a.push(il(e));t.emitters=a;let r=[];for(let t=0;t<4;t++)r.push(id(e));t.colors=r;let n=[];for(let t=0;t<4;t++)n.push(e.readF32());return t.times=n,t.textureName=e.readString(),t.mapToTexture=e.readString(),t}function iV(e){let t={};t.ejectionPeriodMS=e.readInt(10),t.periodVarianceMS=e.readInt(10),t.ejectionVelocity=e.readInt(16),t.velocityVariance=e.readInt(14),e.readFlag()&&(t.ejectionOffset=e.readInt(16)),t.thetaMin=e.readRangedU32(0,180),t.thetaMax=e.readRangedU32(0,180),e.readFlag()&&(t.phiReferenceVel=e.readRangedU32(0,360)),e.readFlag()&&(t.phiVariance=e.readRangedU32(0,360)),t.overrideAdvances=e.readFlag(),t.orientParticles=e.readFlag(),t.orientOnVelocity=e.readFlag(),t.lifetimeMS=e.readInt(10),t.lifetimeVarianceMS=e.readInt(10),t.useEmitterSizes=e.readFlag(),t.useEmitterColors=e.readFlag();let a=e.readU32(),r=[];for(let t=0;t<a&&t<16;t++)r.push(il(e));return t.particles=r,t}function iq(e){let t={};t.dragCoefficient=e.readFloat(10),e.readFlag()&&(t.windCoefficient=e.readF32()),t.gravityCoefficient=e.readSignedFloat(12),t.inheritedVelFactor=e.readFloat(9),e.readFlag()&&(t.constantAcceleration=e.readF32()),t.lifetimeMS=e.readInt(10),t.lifetimeVarianceMS=e.readInt(10),e.readFlag()&&(t.spinSpeed=e.readF32()),e.readFlag()&&(t.spinRandomMin=e.readInt(11),t.spinRandomMax=e.readInt(11)),t.useInvAlpha=e.readFlag();let a=e.readInt(2)+1,r=[];for(let t=0;t<a;t++)r.push({r:e.readFloat(7),g:e.readFloat(7),b:e.readFloat(7),a:e.readFloat(7),size:e.readFloat(14),time:e.readFloat(8)});t.keys=r;let n=e.readInt(6),i=[];for(let t=0;t<n&&t<50;t++)i.push(e.readString());return t.textures=i,t}function iH(e){let t={};return t.volume=e.readFloat(6),t.isLooping=e.readFlag(),t.isLooping&&(t.loopCount=e.readS32(),t.minLoopGap=e.readS32(),t.maxLoopGap=e.readS32()),t.is3D=e.readFlag(),t.is3D&&(t.referenceDistance=e.readF32(),t.maxDistance=e.readF32(),t.coneInsideAngle=e.readInt(9),t.coneOutsideAngle=e.readInt(9),t.coneOutsideVolume=e.readFloat(6),t.coneVector=e.readNormalVector(8),t.environmentLevel=e.readF32()),t.type=e.readInt(3),t}function iW(e){let t={};return t.description=il(e),t.environment=il(e),t.sampleEnvironment=il(e),t.filename=e.readString(),t}function i$(e){let t={};return t.useRoom=e.readFlag(),t.useRoom?t.room=e.readRangedU32(0,26):(t.roomHF=ic(e,-1e4,0),t.reflections=ic(e,-1e4,1e4),t.reverb=ic(e,-1e4,2e3),t.roomRolloffFactor=ih(e,.1,10,8),t.decayTime=ih(e,.1,20,8),t.decayHFRatio=ih(e,.1,20,8),t.reflectionsDelay=ih(e,0,.3,9),t.reverbDelay=ih(e,0,.1,7),t.roomVolume=ic(e,-1e4,0),t.effectVolume=ih(e,0,1,9),t.damping=ih(e,0,2,10),t.environmentSize=ih(e,1,100,8),t.environmentDiffusion=ih(e,0,1,10),t.flags=e.readInt(6)),t.effectVolumeHF=ih(e,0,1,8),t}function iY(e){let t={};return t.direct=ic(e,-1e4,1e3),t.directHF=ic(e,-1e4,0),t.room=ic(e,-1e4,1e3),t.roomHF=ic(e,-1e4,0),t.obstruction=ih(e,0,1,9),t.obstructionLFRatio=ih(e,0,1,8),t.occlusion=ih(e,0,1,9),t.occlusionLFRatio=ih(e,0,1,8),t.occlusionRoomRatio=ih(e,0,10,9),t.roomRolloff=ih(e,0,10,9),t.airAbsorption=ih(e,0,10,9),t.outsideVolumeHF=ic(e,-1e4,0),t.flags=e.readInt(3),t}function iK(e){return{sizeX:e.readF32(),sizeY:e.readF32(),textureName:e.readString()}}function iX(e){return im(e)}function iZ(e){return{}}function iJ(e){return{tickPeriodMS:e.readS32()}}function iQ(e){let t={};return t.fadeMS=e.readS32(),t.baseTranslucency=e.readF32(),t.powerOffTranslucency=e.readF32(),t.fadeInOnly=e.readFlag(),t.triggerEnable=e.readFlag(),t.color1=id(e),t.color2=id(e),t.banRadius=e.readF32(),t.speed=e.readF32(),t.maxSpeed=e.readF32(),t.attackMS=e.readF32(),t.decayMS=e.readF32(),t.texture0=e.readString(),t.texture1=e.readString(),t.texture2=e.readString(),t.texture3=e.readString(),t.texture4=e.readString(),t}function i0(e){return{timeMultiple:e.readF32()}}function i1(e){let t=["baseImage","activeImage","inactiveImage","selectImage","hilightImage"],a={};for(let r=0;r<5;r++)a[t[r]]=e.readString();return a}function i2(e){let t={};return t.soundProfile=il(e),t.numDrops=e.readS32(),t.maxSize=e.readF32(),t.materialList=e.readString(),t.sizeX=e.readF32(),t.sizeY=e.readF32(),t.movingBoxPer=e.readF32(),t.divHeightVal=e.readF32(),t.sizeBigBox=e.readF32(),t.topBoxSpeed=e.readF32(),t.frontBoxSpeed=e.readF32(),t.topBoxDrawPer=e.readF32(),t.bottomDrawHeight=e.readF32(),t.skipIfPer=e.readF32(),t.bottomSpeedPer=e.readF32(),t.frontSpeedPer=e.readF32(),t.frontRadiusPer=e.readF32(),t}function i3(e){return{emitter:il(e)}}function i5(e){let t={},a=[];for(let t=0;t<8;t++)a.push(il(e));t.strikeSounds=a;let r=[];for(let t=0;t<8;t++)r.push(e.readString());return t.strikeTextures=r,t.thunderSound=il(e),t}function i4(e){let t={};t.glowTopHeight=e.readF32(),t.glowBottomHeight=e.readF32(),t.glowTopRadius=e.readF32(),t.glowBottomRadius=e.readF32(),t.numGlowSegments=e.readF32(),t.glowFadeTime=e.readF32(),t.armLightDelay=e.readF32(),t.armLightLifetime=e.readF32(),t.armLightFadeTime=e.readF32(),t.lifetime=e.readF32(),t.numArcSegments=e.readF32(),t.sphereColor=id(e),t.spherePhiSegments=e.readF32(),t.sphereThetaSegments=e.readF32(),t.sphereRadius=e.readF32(),t.scale={x:e.readF32(),y:e.readF32(),z:e.readF32()},t.glowTexture=e.readString();for(let a=0;a<4;a++)t[`padTexture${a}0`]=e.readString(),t[`padTexture${a}1`]=e.readString();return t.lightStartColor=e.readString(),t.lightEndColor=e.readString(),t}function i6(e){let t={};return t.glowTopRadius=e.readF32(),t.glowBottomRadius=e.readF32(),t.glowTopHeight=e.readF32(),t.glowBottomHeight=e.readF32(),t.numGlowSegments=e.readF32(),t.numGlowPanels=e.readF32(),t.topAlpha=e.readF32(),t.bottomAlpha=e.readF32(),t.glowSpeed=e.readF32(),t.scrollSpeed=e.readF32(),t.glowTexture=e.readString(),t.padTexture=e.readString(),t.lightStartColor=e.readString(),t.lightEndColor=e.readString(),t}function i8(e){return{chatText:e.readString()}}function i7(e){return im(e)}function i9(e){return{}}function oe(e){return{}}function ot(e){let t={};t.shape=e.readString();let a=e.readInt(7),r=[];for(let t=0;t<a&&t<128;t++)r.push(e.readString());return t.sequences=r,t}function oa(e){let t={};return t.minDistance=e.readF32(),t.maxDistance=e.readF32(),t.audioScale=e.readF32(),t.directional=iu(e),t.effectName=e.readString(),t}function or(e){let t={};return t.coolColor=id(e),t.hotColor=id(e),t.activateTime=e.readF32(),t.deactivateTime=e.readF32(),t.length=e.readF32(),t.width=e.readF32(),t.speed=e.readF32(),t.stretch=e.readF32(),t.yOffset=e.readF32(),e.readFlag()&&(t.texture=e.readString()),t}function on(e){let t={};return t.radius=e.readF32(),t.color=id(e),t.type=e.readF32(),t.length=e.readF32(),t.nodeName=e.readString(),t.direction={x:e.readF32(),y:e.readF32(),z:e.readF32()},t.offset={x:e.readF32(),y:e.readF32(),z:e.readF32()},e.readFlag()&&(t.texture=e.readString()),t}let oi=(0,rA.default)("t2-demo-parser"),oo=(0,rA.default)("t2-demo-parser:initial"),os=(0,rA.default)("t2-demo-parser:blocks");class ol{buffer;view;offset;registry;ghostTracker;packetParser;_loaded=!1;_header;_initialBlock;_decompressedData;_decompressedView;_blockStreamOffset=0;_blockCount;_blockCursor=0;constructor(e){this.buffer=e,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.offset=0,this.registry=new r$,this.ghostTracker=new rY,function(e){e.catalogEvent({name:"SimDataBlockEvent",unpack:nO}),e.catalogEvent({name:"NetStringEvent",unpack:nV}),e.catalogEvent({name:"Sim2DAudioEvent",unpack:nq}),e.catalogEvent({name:"Sim3DAudioEvent",unpack:nH}),e.catalogEvent({name:"SetSensorGroupEvent",unpack:nW}),e.catalogEvent({name:"SetServerTargetEvent",unpack:n$}),e.catalogEvent({name:"TargetToEvent",unpack:nY}),e.catalogEvent({name:"SetObjectActiveImageEvent",unpack:nK}),e.catalogEvent({name:"SetMissionCRCEvent",unpack:nX}),e.catalogEvent({name:"RemoteCommandEvent",unpack:nZ}),e.catalogEvent({name:"TargetInfoEvent",unpack:nJ}),e.catalogEvent({name:"TargetFreeEvent",unpack:nQ}),e.catalogEvent({name:"SimTargetAudioEvent",unpack:n0}),e.catalogEvent({name:"SensorGroupColorEvent",unpack:n1}),e.catalogEvent({name:"ResetClientTargetsEvent",unpack:n2}),e.catalogEvent({name:"RemoveClientTargetTypeEvent",unpack:n3}),e.catalogEvent({name:"SimVoiceStreamEvent",unpack:n5}),e.catalogEvent({name:"GhostingMessageEvent",unpack:n4}),e.catalogEvent({name:"GhostAlwaysObjectEvent",unpack:n6}),e.catalogEvent({name:"PathManagerEvent",unpack:n8}),e.catalogEvent({name:"LightningStrikeEvent",unpack:n7}),e.catalogEvent({name:"FileChunkEvent",unpack:n9}),e.catalogEvent({name:"DownloadMessageEvent",unpack:ie}),e.catalogEvent({name:"FileDownloadRequestEvent",unpack:it}),e.catalogEvent({name:"SimpleMessageEvent",unpack:ia}),e.catalogEvent({name:"CRCChallengeEvent",unpack:ir}),e.catalogEvent({name:"CRCChallengeResponseEvent",unpack:ii}),e.catalogEvent({name:"GravityEvent",unpack:io}),e.catalogEvent({name:"FogChallengeEvent",unpack:is})}(this.registry),function(e){e.catalogGhost({name:"AIObjective",unpackUpdate:nz}),e.catalogGhost({name:"BeaconObject",unpackUpdate:nt}),e.catalogGhost({name:"BombProjectile",unpackUpdate:ni}),e.catalogGhost({name:"Player",unpackUpdate:rQ,readPacketData:r0}),e.catalogGhost({name:"Debris",unpackUpdate:nr}),e.catalogGhost({name:"GameBase",unpackUpdate:rZ}),e.catalogGhost({name:"ShapeBase",unpackUpdate:rJ,readPacketData:r2}),e.catalogGhost({name:"Vehicle",unpackUpdate:r1,readPacketData:r2}),e.catalogGhost({name:"FlyingVehicle",unpackUpdate:r5,readPacketData:r2}),e.catalogGhost({name:"HoverVehicle",unpackUpdate:r4,readPacketData:r2}),e.catalogGhost({name:"Item",unpackUpdate:r6}),e.catalogGhost({name:"Marker",unpackUpdate:r9}),e.catalogGhost({name:"MissionMarker",unpackUpdate:na}),e.catalogGhost({name:"StaticShape",unpackUpdate:r8}),e.catalogGhost({name:"Projectile",unpackUpdate:nn}),e.catalogGhost({name:"ScopeAlwaysShape",unpackUpdate:r7}),e.catalogGhost({name:"GrenadeProjectile",unpackUpdate:no}),e.catalogGhost({name:"SimpleNetObject",unpackUpdate:ne}),e.catalogGhost({name:"SeekerProjectile",unpackUpdate:ns}),e.catalogGhost({name:"Turret",unpackUpdate:nl}),e.catalogGhost({name:"InteriorInstance",unpackUpdate:nc}),e.catalogGhost({name:"Camera",unpackUpdate:nd,readPacketData:nu}),e.catalogGhost({name:"LinearProjectile",unpackUpdate:nh}),e.catalogGhost({name:"ELFProjectile",unpackUpdate:nm}),e.catalogGhost({name:"RepairProjectile",unpackUpdate:nf}),e.catalogGhost({name:"TargetProjectile",unpackUpdate:ng}),e.catalogGhost({name:"TracerProjectile",unpackUpdate:nh}),e.catalogGhost({name:"WayPoint",unpackUpdate:np}),e.catalogGhost({name:"SpawnSphere",unpackUpdate:ny}),e.catalogGhost({name:"ForceFieldBare",unpackUpdate:nv}),e.catalogGhost({name:"TSStatic",unpackUpdate:nF}),e.catalogGhost({name:"TerrainBlock",unpackUpdate:nb}),e.catalogGhost({name:"Sun",unpackUpdate:nS}),e.catalogGhost({name:"Sky",unpackUpdate:nx}),e.catalogGhost({name:"Lightning",unpackUpdate:nk}),e.catalogGhost({name:"WaterBlock",unpackUpdate:nw}),e.catalogGhost({name:"MissionArea",unpackUpdate:nI}),e.catalogGhost({name:"Splash",unpackUpdate:nC}),e.catalogGhost({name:"Shockwave",unpackUpdate:n_}),e.catalogGhost({name:"FireballAtmosphere",unpackUpdate:nP}),e.catalogGhost({name:"VehicleBlocker",unpackUpdate:nD}),e.catalogGhost({name:"ParticleEmissionDummy",unpackUpdate:nM}),e.catalogGhost({name:"Precipitation",unpackUpdate:nT}),e.catalogGhost({name:"EnergyProjectile",unpackUpdate:no}),e.catalogGhost({name:"FlareProjectile",unpackUpdate:no}),e.catalogGhost({name:"LinearFlareProjectile",unpackUpdate:nh}),e.catalogGhost({name:"SniperProjectile",unpackUpdate:nE}),e.catalogGhost({name:"ShockLanceProjectile",unpackUpdate:nB}),e.catalogGhost({name:"WheeledVehicle",unpackUpdate:nN,readPacketData:r3}),e.catalogGhost({name:"Trigger",unpackUpdate:nA}),e.catalogGhost({name:"PhysicalZone",unpackUpdate:nG}),e.catalogGhost({name:"AudioEmitter",unpackUpdate:nU}),e.catalogGhost({name:"StationFXPersonal",unpackUpdate:nL}),e.catalogGhost({name:"StationFXVehicle",unpackUpdate:nL})}(this.registry),function(e){e.catalogDataBlock({name:"ShapeBaseData",unpackData:im}),e.catalogDataBlock({name:"ShapeBaseImageData",unpackData:ig}),e.catalogDataBlock({name:"PlayerData",unpackData:ip}),e.catalogDataBlock({name:"VehicleData",unpackData:iy}),e.catalogDataBlock({name:"FlyingVehicleData",unpackData:iv}),e.catalogDataBlock({name:"HoverVehicleData",unpackData:iF}),e.catalogDataBlock({name:"WheeledVehicleData",unpackData:ib}),e.catalogDataBlock({name:"StaticShapeData",unpackData:iS}),e.catalogDataBlock({name:"TurretData",unpackData:ix}),e.catalogDataBlock({name:"TurretImageData",unpackData:ik}),e.catalogDataBlock({name:"ItemData",unpackData:iw}),e.catalogDataBlock({name:"ProjectileData",unpackData:iI}),e.catalogDataBlock({name:"LinearProjectileData",unpackData:iC}),e.catalogDataBlock({name:"GrenadeProjectileData",unpackData:i_}),e.catalogDataBlock({name:"SeekerProjectileData",unpackData:iP}),e.catalogDataBlock({name:"SniperProjectileData",unpackData:iD}),e.catalogDataBlock({name:"ShockLanceProjectileData",unpackData:iM}),e.catalogDataBlock({name:"ELFProjectileData",unpackData:iT}),e.catalogDataBlock({name:"RepairProjectileData",unpackData:iE}),e.catalogDataBlock({name:"TargetProjectileData",unpackData:iB}),e.catalogDataBlock({name:"TracerProjectileData",unpackData:ij}),e.catalogDataBlock({name:"EnergyProjectileData",unpackData:iR}),e.catalogDataBlock({name:"LinearFlareProjectileData",unpackData:iN}),e.catalogDataBlock({name:"BombProjectileData",unpackData:iA}),e.catalogDataBlock({name:"FlareProjectileData",unpackData:iG}),e.catalogDataBlock({name:"ExplosionData",unpackData:iU}),e.catalogDataBlock({name:"DebrisData",unpackData:iL}),e.catalogDataBlock({name:"SplashData",unpackData:iz}),e.catalogDataBlock({name:"ShockwaveData",unpackData:iO}),e.catalogDataBlock({name:"ParticleEmitterData",unpackData:iV}),e.catalogDataBlock({name:"ParticleData",unpackData:iq}),e.catalogDataBlock({name:"AudioDescription",unpackData:iH}),e.catalogDataBlock({name:"AudioProfile",unpackData:iW}),e.catalogDataBlock({name:"AudioEnvironment",unpackData:i$}),e.catalogDataBlock({name:"AudioSampleEnvironment",unpackData:iY}),e.catalogDataBlock({name:"DecalData",unpackData:iK}),e.catalogDataBlock({name:"CameraData",unpackData:iX}),e.catalogDataBlock({name:"SensorData",unpackData:iZ}),e.catalogDataBlock({name:"TriggerData",unpackData:iJ}),e.catalogDataBlock({name:"ForceFieldBareData",unpackData:iQ}),e.catalogDataBlock({name:"ParticleEmissionDummyData",unpackData:i0}),e.catalogDataBlock({name:"CommanderIconData",unpackData:i1}),e.catalogDataBlock({name:"PrecipitationData",unpackData:i2}),e.catalogDataBlock({name:"FireballAtmosphereData",unpackData:i3}),e.catalogDataBlock({name:"LightningData",unpackData:i5}),e.catalogDataBlock({name:"StationFXVehicleData",unpackData:i4}),e.catalogDataBlock({name:"StationFXPersonalData",unpackData:i6}),e.catalogDataBlock({name:"CannedChatItem",unpackData:i8}),e.catalogDataBlock({name:"MissionMarkerData",unpackData:i7}),e.catalogDataBlock({name:"GameBaseData",unpackData:i9}),e.catalogDataBlock({name:"SimDataBlock",unpackData:oe}),e.catalogDataBlock({name:"TSShapeConstructor",unpackData:ot}),e.catalogDataBlock({name:"EffectProfile",unpackData:oa}),e.catalogDataBlock({name:"JetEffectData",unpackData:or}),e.catalogDataBlock({name:"RunningLightData",unpackData:on})}(this.registry);const{bound:t,missing:a}=this.registry.bindDeterministicDataBlocks(rO,128);a.length>0&&oi("DataBlock binding: %d/%d bound, missing parsers: %s",t,rO.length,a.join(", "));const{bound:r,missing:n}=this.registry.bindDeterministicGhosts(rV,0);n.length>0&&oi("Ghost binding: %d/%d bound, missing parsers: %s",r,rV.length,n.join(", "));const{bound:i,missing:o}=this.registry.bindDeterministicEvents(rq,255);o.length>0&&oi("Event binding: %d/%d bound, missing parsers: %s",i,rq.length,o.join(", ")),this.packetParser=new rW(this.registry,this.ghostTracker)}getRegistry(){return this.registry}getGhostTracker(){return this.ghostTracker}getPacketParser(){return this.packetParser}get loaded(){return this._loaded}get header(){if(!this._loaded)throw Error("must call load() first");return this._header}get initialBlock(){if(!this._loaded)throw Error("must call load() first");return this._initialBlock}get blockCount(){if(!this._loaded)throw Error("must call load() first");if(void 0===this._blockCount){let e=this._decompressedData,t=this._decompressedView,a=0,r=0;for(;r+2<=e.length;){let n=4095&t.getUint16(r,!0);if((r+=2+n)>e.length)break;a++}this._blockCount=a}return this._blockCount}get blockCursor(){if(!this._loaded)throw Error("must call load() first");return this._blockCursor}async load(){if(this._loaded)return{header:this._header,initialBlock:this._initialBlock};let e=this.readHeader();oi('header: "%s" version=0x%s length=%dms (%smin) initialBlockSize=%d',e.identString,e.protocolVersion.toString(16),e.demoLengthMs,(e.demoLengthMs/1e3/60).toFixed(1),e.initialBlockSize);let t=this.buffer.subarray(this.offset,this.offset+e.initialBlockSize),a=this.readInitialBlock(t);this.offset+=e.initialBlockSize;let r=this.buffer.subarray(this.offset);oi("compressed block stream: %d bytes",r.length);let n=await new Promise((e,t)=>{var a,n;a=(a,r)=>{a?t(a):e(r)},n||(n=a,a={}),"function"!=typeof n&&aD(7),a3(r,a,[aZ],function(e){return a1(rh(e.data[0],a2(e.data[1])))},1,n)});return oi("decompressed block stream: %d bytes",n.length),this._decompressedData=n,this._decompressedView=new DataView(n.buffer,n.byteOffset,n.byteLength),this.setupPacketParser(a),this._header=e,this._initialBlock=a,this._blockStreamOffset=0,this._blockCursor=0,this._loaded=!0,{header:e,initialBlock:a}}nextBlock(){if(!this._loaded)throw Error("must call load() first");let e=this._decompressedData,t=this._decompressedView,a=this._blockStreamOffset;if(a+2>e.length)return;let r=t.getUint16(a,!0),n=r>>12,i=4095&r;if(a+2+i>e.length)return void os("block %d: size %d would exceed decompressed data (offset=%d remaining=%d), stopping",this._blockCursor,i,a+2,e.length-a-2);let o=e.subarray(a+2,a+2+i);this._blockStreamOffset=a+2+i;let s={index:this._blockCursor,type:n,size:i,data:o};if(this._blockCursor++,0===n)try{s.parsed=this.packetParser.parsePacket(o)}catch{}else if(1===n)this.packetParser.onSendPacketTrigger();else if(2===n&&64===i)try{s.parsed=this.readRawMove(o)}catch{}else if(3===n&&8===i)try{s.parsed=this.readInfoBlock(o)}catch{}return s}reset(){if(!this._loaded)throw Error("must call load() first");this._blockStreamOffset=0,this._blockCursor=0,this._blockCount=void 0,this.setupPacketParser(this._initialBlock)}processBlocks(e){if(!this._loaded)throw Error("must call load() first");let t=0;for(let a=0;a<e&&this.nextBlock();a++)t++;return t}setupPacketParser(e){let t=new Map;for(let[a,r]of e.dataBlocks)t.set(a,r.data);let a=new rY;for(let t of e.initialGhosts){if("create"!==t.type||void 0===t.classId)continue;let e=this.registry.getGhostParser(t.classId);a.createGhost(t.index,t.classId,e?.name??`unknown_${t.classId}`)}let r=new rW(this.registry,a,{dataBlockDataMap:t,connectionProtocolState:e.connectionState,nextRecvEventSeq:e.nextRecvEventSeq});this.ghostTracker=a,this.packetParser=r}async parseFullDemo(){let e,{header:t,initialBlock:a}=await this.load(),r=[];for(;e=this.nextBlock();)r.push(e);return{header:t,initialBlock:a,blocks:r}}readHeader(){let e=this.view.getUint8(this.offset);this.offset+=1;let t=new TextDecoder("ascii").decode(this.buffer.subarray(this.offset,this.offset+e));this.offset+=e;let a=this.view.getUint32(this.offset,!0);this.offset+=4;let r=this.view.getUint32(this.offset,!0);this.offset+=4;let n=this.view.getUint32(this.offset,!0);return this.offset+=4,{identString:t,protocolVersion:a,demoLengthMs:r,initialBlockSize:n}}readInitialBlock(e){let t,a,r=new rz(e),n=new Map;for(let e=0;e<1024;e++)r.readFlag()&&n.set(e,r.readString());oo("after tagged strings bit=%d count=%d",r.getCurPos(),n.size);let i=r.readU32(),o=[],s=new Map,l=0;for(;r.readFlag();){if(l++,!r.readFlag())continue;let e=r.readInt(11),t=r.readInt(7)+128,a=r.readInt(11),n=r.readInt(12),i=r.getCurPos();o.push({objectId:e,classId:t,index:a,total:n,dataBitsStart:i});let c=this.registry.getDataBlockParser(t);if(c){let a=c.unpackData(r);s.set(e,{classId:t,className:c.name,objectId:e,data:a})}else{let e=t>=128&&t<128+rO.length?rO[t-128]:`unknown(${t})`;throw Error(`No parser for DataBlock classId ${t} (${e}) at bit ${i}`)}}oi("all %d/%d DataBlocks parsed (%d payloads), bit position after DataBlocks: %d",l,i,s.size,r.getCurPos());let c=r.readU8(),d=[];for(let e=0;e<6;e++)d.push(r.readU32());let u=[];for(let e=0;e<16;e++)u.push(r.readU32());let h=r.readU32(),m=[];for(let e=0;e<h;e++)m.push(this.readScoreEntry(r));oo("after score entries bit=%d scoreCount=%d",r.getCurPos(),h);let f=this.readDemoValues(r);oo("after demo values bit=%d demoValues=%d",r.getCurPos(),f.length);let{sensorGroupColors:g,targets:p}=this.readComplexTargetManager(r);oo("after complex target manager bit=%d targets=%d sensorGroupColors=%d",r.getCurPos(),p.length,g.length);let y=this.readConnectionProtocol(r);oo("after connection protocol bit=%d lastRecv=%d highestAck=%d lastSend=%d connected=%s",r.getCurPos(),y.lastSeqRecvd,y.highestAckedSeq,y.lastSendSeq,y.connectionEstablished);let v=r.readF32(),F=r.readF32();oo("after RTT/loss bit=%d rtt=%d loss=%d",r.getCurPos(),v,F);let b=this.readPathManager(r);oo("after path manager bit=%d entries=%d",r.getCurPos(),b.length);let S=r.readU32();oo("after notify count bit=%d notifyCount=%d",r.getCurPos(),S);let x=8*r.getBuffer().length,k=new rY,w=this.ghostTracker;this.ghostTracker=k;let I=[],C=0,_=0,P=[],D=-1,M="",T=0;try{oo("phase2 start bit=%d remaining=%d",r.getCurPos(),x-r.getCurPos()),({nextRecvEventSeq:C,events:I}=this.readEventStartBlock(r)),oo("after initial events bit=%d count=%d",r.getCurPos(),I.length);let e=this.readGhostStartBlock(r,s);if(_=e.ghostingSequence,P=e.ghosts,oo("after initial ghosts bit=%d count=%d seq=%d",r.getCurPos(),P.length,_),D=r.readS32(),oo("after control ghost index bit=%d control=%d",r.getCurPos(),D),-1!==D){let e=k.getGhost(D);if(e){let a=this.registry.getGhostParser(e.classId);a?.readPacketData&&(t=a.readPacketData(r,{compressionPoint:{x:0,y:0,z:0},ghostTracker:k}),oo("after control readPacketData bit=%d parser=%s",r.getCurPos(),a.name))}}M=r.readString(),T=r.readU32(),r.setCurPos(r.getCurPos()+7>>3<<3),this.readSimpleTargetManager(r),this.readSimpleTargetManager(r),oo('after sequential tail bit=%d mission="%s" CRC=0x%s',r.getCurPos(),M,T.toString(16))}catch(e){a=e instanceof Error?e.message:String(e)}finally{this.ghostTracker=w}let E=x-r.getCurPos(),B=M.length>0?M.split("").filter(e=>{let t=e.charCodeAt(0);return t>=32&&t<=126}).length/M.length:1,j=M.length>0&&B>=.8&&void 0===a;return oi('initial block: events=%d ghosts=%d ghostingSeq=%d controlObj=%d mission="%s" CRC=0x%s valid=%s%s',I.length,P.length,_,D,M,T.toString(16),j,a?` error=${a}`:""),{taggedStrings:n,dataBlockHeaders:o,dataBlockCount:l,dataBlocks:s,demoSetting:c,connectionFields:d,stateArray:u,scoreEntries:m,demoValues:f,sensorGroupColors:g,targetEntries:p,connectionState:y,roundTripTime:v,packetLoss:F,pathManager:b,notifyCount:S,nextRecvEventSeq:C,ghostingSequence:_,initialGhosts:P,initialEvents:I,controlObjectGhostIndex:D,controlObjectData:t,missionName:M,missionCRC:T,phase2TrailingBits:E,phase2Valid:j,phase2Error:a}}readScoreEntry(e){let t=e.readFlag()?e.readInt(16):0,a=e.readFlag()?e.readInt(16):0,r=e.readFlag()?e.readInt(16):0,n=e.readInt(6),i=e.readInt(6),o=e.readInt(6),s=e.readFlag(),l=[];for(let t=0;t<6;t++)l.push(e.readFlag());return{clientId:t,teamId:a,score:r,field0:n,field1:i,field2:o,isBot:s,triggerFlags:l}}readDemoValues(e){let t=[];for(;e.readFlag();)t.push(e.readString());return t}readComplexTargetManager(e){e.readU8(),e.readU8(),e.readU8(),e.readU8();let t=[];for(let a=0;a<32;a++)for(let r=0;r<32;r++)e.readFlag()&&t.push({group:a,targetGroup:r,r:e.readU8(),g:e.readU8(),b:e.readU8(),a:e.readU8()});let a=[];for(let t=0;t<512;t++){if(!e.readFlag())continue;let r={targetId:t,sensorGroup:0,targetData:0,damageLevel:0};e.readFlag()&&(r.sensorData=e.readU32()),e.readFlag()&&(r.voiceMapData=e.readU32()),e.readFlag()&&(r.name=e.readString()),e.readFlag()&&(r.skin=e.readString()),e.readFlag()&&(r.skinPref=e.readString()),e.readFlag()&&(r.voice=e.readString()),e.readFlag()&&(r.typeDescription=e.readString()),r.sensorGroup=e.readInt(5),r.targetData=e.readInt(9),t>=32&&e.readFlag()&&(r.dataBlockRef=e.readInt(11)),r.damageLevel=e.readFloat(7),a.push(r)}return{sensorGroupColors:t,targets:a}}readPathManager(e){let t=[],a=e.readU32();for(let r=0;r<a;r++){let a=e.readU32(),r=e.readU32(),n=[];for(let t=0;t<r;t++)n.push({field0:e.readU32(),field1:e.readU32(),field2:e.readU32(),auxField:e.readU32()});t.push({entryId:a,records:n})}return t}readSimpleTargetManager(e){e.readU8(),e.readU32(),e.readU32(),e.readU32(),e.readU32()}readConnectionProtocol(e){let t=[];for(let a=0;a<32;a++)t.push(e.readU32());let a=e.readU32(),r=e.readU32(),n=e.readU32(),i=e.readU32(),o=e.readU32();return{lastSeqRecvdAtSend:t,lastSeqRecvd:a,highestAckedSeq:r,lastSendSeq:n,ackMask:i,connectSequence:o,lastRecvAckAck:e.readU32(),connectionEstablished:e.readBool()}}readEventStartBlock(e){let t=e.readU32(),a=[];for(oo("event block: nextRecvEventSeq=%d bit=%d",t,e.getCurPos());e.readFlag();){let t,r=e.readInt(6)+255,n=e.getCurPos(),i=this.registry.getEventParser(r);if(i)try{let a={compressionPoint:{x:0,y:0,z:0},ghostTracker:this.ghostTracker,getDataBlockParser:e=>this.registry.getDataBlockParser(e)};t=i.unpack(e,a)}catch{a.push({classId:r,guaranteed:!0,dataBitsStart:n,dataBitsEnd:n});break}else{a.push({classId:r,guaranteed:!0,dataBitsStart:n,dataBitsEnd:n});break}a.push({classId:r,guaranteed:!0,dataBitsStart:n,dataBitsEnd:e.getCurPos(),parsedData:t}),oo(" event classId=%d bits=%d",r,e.getCurPos()-n)}return{nextRecvEventSeq:t,events:a}}readGhostStartBlock(e,t){let a=e.readU32(),r=[];oo("ghost block: seq=%d bit=%d",a,e.getCurPos());let n=this.registry.getGhostCatalog(),i=8*e.getBuffer().length,o=new Map;for(let[e,a]of t)o.set(e,a.data);for(;e.readFlag()&&!e.isError();){let a=e.readInt(10),s=e.readInt(7)+0,l=e.getCurPos(),c=[],d=new Set,{entry:u}=this.identifyGhostViaDataBlock(e,t,n),h=this.registry.getGhostParser(s);h&&(c.push({entry:h,method:"registry"}),d.add(h)),u&&!d.has(u)&&(c.push({entry:u,method:"datablock"}),d.add(u));let m={getDataBlockData:e=>o.get(e),getDataBlockParser:e=>this.registry.getDataBlockParser(e)},f=!1;for(let{entry:t,method:n}of c){let o="registry"===n,c=this.tryGhostParser(e,t,l,i,!1,m,o);if(!1!==c){this.ghostTracker.createGhost(a,s,t.name),oo(" ghost idx=%d classId=%d parser=%s bits=%d via=%s",a,s,t.name,e.getCurPos()-l,n),r.push({index:a,type:"create",classId:s,updateBitsStart:l,updateBitsEnd:e.getCurPos(),parsedData:c}),f=!0;break}}if(!f){oo(" ghost idx=%d classId=%d NO PARSER (stopping at bit=%d, remaining=%d)",a,s,l,i-l);break}}return oo("ghost loop ended at bit=%d remaining=%d count=%d",e.getCurPos(),i-e.getCurPos(),r.length),{ghostingSequence:a,ghosts:r}}tryGhostParser(e,t,a,r,n=!1,i,o=!1){let s=e.savePos();n||oo(" try %s: startBit=%d",t.name,a);try{let l=t.unpackUpdate(e,!0,{compressionPoint:{x:0,y:0,z:0},ghostTracker:this.ghostTracker,...i}),c=e.getCurPos()-a,d=r-e.getCurPos();if(e.isError()||!o&&c<3)return n||oo(" reject %s: bits=%d isError=%s",t.name,c,e.isError()),e.restorePos(s),!1;if(d>1e3){let a=e.getCurPos(),r=e.readFlag();if(e.setCurPos(a),!r)return n||oo(" reject %s: bits=%d misaligned (remaining=%d)",t.name,c,d),e.restorePos(s),!1}return l??{}}catch(a){return n||oo(" reject %s: error at bit=%d: %s",t.name,e.getCurPos(),a instanceof Error?a.message:String(a)),e.restorePos(s),!1}}identifyGhostViaDataBlock(e,t,a){let r;if(!t)return{entry:void 0,dbFlag:!1};let n=e.savePos(),i=!1;try{if(i=e.readFlag()){let n=e.readInt(11),i=t.get(n);if(i){let e=i.className.replace(/Data$/,"");(r=a.get(e))||oo(" identifyGhostViaDataBlock: dbId=%d className=%s ghostName=%s (no ghost parser)",n,i.className,e)}else oo(" identifyGhostViaDataBlock: dbId=%d (no DataBlock found)",n)}else oo(" identifyGhostViaDataBlock: DataBlock flag=0")}catch{}return e.restorePos(n),{entry:r,dbFlag:i}}readRawMove(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),a=t.getInt32(0,!0),r=t.getInt32(4,!0),n=t.getInt32(8,!0),i=t.getUint32(12,!0),o=t.getUint32(16,!0),s=t.getUint32(20,!0),l=t.getFloat32(24,!0),c=t.getFloat32(28,!0),d=t.getFloat32(32,!0),u=t.getFloat32(36,!0),h=t.getFloat32(40,!0),m=t.getFloat32(44,!0),f=t.getUint32(48,!0),g=t.getUint32(52,!0),p=0!==e[56],y=[];for(let t=0;t<6;t++)y.push(0!==e[57+t]);return{px:a,py:r,pz:n,pyaw:i,ppitch:o,proll:s,x:l,y:c,z:d,yaw:u,pitch:h,roll:m,id:f,sendCount:g,freeLook:p,trigger:y}}readInfoBlock(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength);return{value1:t.getUint32(0,!0),value2:t.getFloat32(4,!0)}}}let oc=Object.freeze({r:0,g:255,b:0}),od=Object.freeze({r:255,g:0,b:0}),ou=new Set(["FlyingVehicle","HoverVehicle","WheeledVehicle"]),oh=new Set(["BombProjectile","EnergyProjectile","FlareProjectile","GrenadeProjectile","LinearFlareProjectile","LinearProjectile","Projectile","SeekerProjectile","TracerProjectile"]),om=new Set(["LinearProjectile","TracerProjectile","LinearFlareProjectile","Projectile"]),of=new Set(["GrenadeProjectile","EnergyProjectile","FlareProjectile","BombProjectile"]),og=new Set(["SeekerProjectile"]),op=new Set(["StaticShape","ScopeAlwaysShape","Turret","BeaconObject","ForceFieldBare"]),oy=new Set(["TSStatic","InteriorInstance","TerrainBlock","Sky","Sun","MissionArea","PhysicalZone","MissionMarker","SpawnSphere","VehicleBlocker","Camera"]),ov=.494*Math.PI,oF=new o.Matrix4,ob=new o.Quaternion,oS=new Map([["gui/hud_new_packammo",0],["gui/hud_new_packcloak",1],["gui/hud_new_packenergy",2],["gui/hud_new_packrepair",3],["gui/hud_new_packsatchel",4],["gui/hud_new_packshield",5],["gui/hud_new_packinventory",6],["gui/hud_new_packmotionsens",7],["gui/hud_new_packradar",8],["gui/hud_new_packturretout",9],["gui/hud_new_packturretin",10],["gui/hud_new_packsensjam",11],["gui/hud_new_packturret",12],["gui/hud_satchel_unarmed",18]]);function ox(e){return null!=e&&Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.z)}function ok(e,t,a){return e<t?t:e>a?a:e}function ow(e){let t=-e/2;return[0,Math.sin(t),0,Math.cos(t)]}function oI(e){if(!Number.isFinite(e.x)||!Number.isFinite(e.y)||!Number.isFinite(e.z)||!Number.isFinite(e.w))return null;let t=-e.y,a=-e.z,r=-e.x,n=e.w,i=t*t+a*a+r*r+n*n;if(i<=1e-12)return null;let o=1/Math.sqrt(i);return[t*o,a*o,r*o,n*o]}function oC(e){let t="";for(let a=0;a<e.length;a++)e.charCodeAt(a)>=32&&(t+=e[a]);return t}let o_={2:0,3:1,4:2,5:3,6:4,7:5,8:6,11:7,12:8,14:9};function oP(e){for(let t=0;t<e.length;t++){let a=e.charCodeAt(t),r=o_[a];if(void 0!==r)return r;if(a>=32)break}}function oD(e){let t=e.indexOf("~w");return -1===t?{text:e,wavPath:null}:{text:e.substring(0,t),wavPath:e.substring(t+2)}}function oM(e){return"Player"===e?"Player":ou.has(e)?"Vehicle":"Item"===e?"Item":oh.has(e)?"Projectile":op.has(e)?"Deployable":"Ghost"}function oT(e,t){return"Player"===e?`player_${t}`:ou.has(e)?`vehicle_${t}`:"Item"===e?`item_${t}`:oh.has(e)?`projectile_${t}`:op.has(e)?`deployable_${t}`:`ghost_${t}`}function oE(e){return!!e&&"object"==typeof e&&"number"==typeof e.x&&"number"==typeof e.y&&"number"==typeof e.z&&"number"==typeof e.w}function oB(e){return!!e&&"object"==typeof e&&"number"==typeof e.x&&"number"==typeof e.y&&"number"==typeof e.z}function oj(e){if(e){for(let t of[e.shapeName,e.projectileShapeName,e.shapeFileName,e.shapeFile,e.model])if("string"==typeof t&&t.length>0)return t}}function oR(e,t){if(e)for(let a of t){let t=e[a];if("number"==typeof t&&Number.isFinite(t))return t}}function oN(e,t){if(e)for(let a of t){let t=e[a];if("string"==typeof t&&t.length>0)return t}}function oA(e){return e?"number"==typeof e.cameraMode?"camera":"number"==typeof e.rotationZ?"player":null:null}class oG{parser;initialBlock;registry;netStrings=new Map;targetNames=new Map;targetTeams=new Map;targetRenderFlags=new Map;sensorGroupColors=new Map;state;_teamScoresGen=0;_rosterGen=0;_weaponsHudGen=0;_inventoryHudGen=0;_cachedSnapshot=null;_cachedSnapshotTick=-1;_snap=null;constructor(e){this.parser=e,this.registry=e.getRegistry();const t=e.initialBlock;this.initialBlock={dataBlocks:t.dataBlocks,initialGhosts:t.initialGhosts,controlObjectGhostIndex:t.controlObjectGhostIndex,controlObjectData:t.controlObjectData,targetEntries:t.targetEntries,sensorGroupColors:t.sensorGroupColors,taggedStrings:t.taggedStrings,initialEvents:t.initialEvents,demoValues:t.demoValues},this.state={moveTicks:0,absoluteYaw:0,absolutePitch:0,lastAbsYaw:0,lastAbsPitch:0,lastControlType:"player",isPiloting:!1,lastOrbitDistance:void 0,exhausted:!1,latestFov:100,latestControl:{ghostIndex:t.controlObjectGhostIndex,data:t.controlObjectData,position:ox(t.controlObjectData?.position)?t.controlObjectData?.position:void 0},camera:null,entitiesById:new Map,entityIdByGhostIndex:new Map,lastStatus:{health:1,energy:1},nextExplosionId:0,playerSensorGroup:0,chatMessages:[],pendingAudioEvents:[],weaponsHud:{slots:new Map,activeIndex:-1},backpackHud:{packIndex:-1,active:!1,text:""},inventoryHud:{slots:new Map,activeSlot:-1},teamScores:[],playerRoster:new Map},this.reset()}reset(){for(let[e,t]of(this.parser.reset(),this._cachedSnapshot=null,this._cachedSnapshotTick=-1,this._snap=null,this.netStrings.clear(),this.targetNames.clear(),this.targetTeams.clear(),this.targetRenderFlags.clear(),this.sensorGroupColors.clear(),this.state.entitiesById.clear(),this.state.entityIdByGhostIndex.clear(),this.initialBlock.taggedStrings))this.netStrings.set(e,t);for(let e of this.initialBlock.targetEntries)e.name&&this.targetNames.set(e.targetId,oC(e.name)),this.targetTeams.set(e.targetId,e.sensorGroup),this.targetRenderFlags.set(e.targetId,e.targetData);for(let e of this.initialBlock.sensorGroupColors){let t=this.sensorGroupColors.get(e.group);t||(t=new Map,this.sensorGroupColors.set(e.group,t)),t.set(e.targetGroup,{r:e.r,g:e.g,b:e.b})}if(this.state.playerSensorGroup=0,this.state.chatMessages=[],this.state.pendingAudioEvents=[],this.state.weaponsHud={slots:new Map,activeIndex:-1},this.state.backpackHud={packIndex:-1,active:!1,text:""},this.state.inventoryHud={slots:new Map,activeSlot:-1},this.state.teamScores=[],this.state.playerRoster=new Map,this.state.moveTicks=0,this.state.absoluteYaw=0,this.state.absolutePitch=0,this.state.lastAbsYaw=0,this.state.lastAbsPitch=0,this.state.lastControlType=oA(this.initialBlock.controlObjectData)??"player",this.state.isPiloting="player"===this.state.lastControlType&&!!(this.initialBlock.controlObjectData?.pilot||this.initialBlock.controlObjectData?.controlObjectGhost!=null),this.state.lastCameraMode="camera"===this.state.lastControlType&&"number"==typeof this.initialBlock.controlObjectData?.cameraMode?this.initialBlock.controlObjectData.cameraMode:void 0,this.state.lastOrbitGhostIndex="camera"===this.state.lastControlType&&"number"==typeof this.initialBlock.controlObjectData?.orbitObjectGhostIndex?this.initialBlock.controlObjectData.orbitObjectGhostIndex:void 0,"camera"===this.state.lastControlType){let e=this.initialBlock.controlObjectData?.minOrbitDist,t=this.initialBlock.controlObjectData?.maxOrbitDist,a=this.initialBlock.controlObjectData?.curOrbitDist;"number"==typeof e&&"number"==typeof t&&Number.isFinite(e)&&Number.isFinite(t)?this.state.lastOrbitDistance=Math.max(0,t-e):"number"==typeof a&&Number.isFinite(a)?this.state.lastOrbitDistance=Math.max(0,a):this.state.lastOrbitDistance=void 0}else this.state.lastOrbitDistance=void 0;let e=this.getAbsoluteRotation(this.initialBlock.controlObjectData);for(let t of(e&&(this.state.absoluteYaw=e.yaw,this.state.absolutePitch=e.pitch,this.state.lastAbsYaw=e.yaw,this.state.lastAbsPitch=e.pitch),this.state.exhausted=!1,this.state.latestFov=100,this.state.latestControl={ghostIndex:this.initialBlock.controlObjectGhostIndex,data:this.initialBlock.controlObjectData,position:ox(this.initialBlock.controlObjectData?.position)?this.initialBlock.controlObjectData?.position:void 0},this.state.controlPlayerGhostId="player"===this.state.lastControlType&&this.initialBlock.controlObjectGhostIndex>=0?`player_${this.initialBlock.controlObjectGhostIndex}`:void 0,this.state.camera=null,this.state.lastStatus={health:1,energy:1},this.state.nextExplosionId=0,this.initialBlock.initialGhosts)){if("create"!==t.type||null==t.classId)continue;let e=this.registry.getGhostParser(t.classId)?.name??`ghost_${t.classId}`,a=oT(e,t.index),r={id:a,ghostIndex:t.index,className:e,spawnTick:0,type:oM(e),rotation:[0,0,0,1]};this.applyGhostData(r,t.parsedData),this.state.entitiesById.set(a,r),this.state.entityIdByGhostIndex.set(t.index,a)}if(0===this.state.playerSensorGroup&&"player"===this.state.lastControlType&&this.state.latestControl.ghostIndex>=0){let e=this.state.entityIdByGhostIndex.get(this.state.latestControl.ghostIndex),t=e?this.state.entitiesById.get(e):void 0;t?.sensorGroup!=null&&t.sensorGroup>0&&(this.state.playerSensorGroup=t.sensorGroup)}for(let e of this.initialBlock.initialEvents){let t=this.registry.getEventParser(e.classId)?.name;if("SetSensorGroupEvent"===t&&e.parsedData){let t=e.parsedData.sensorGroup;null!=t&&(this.state.playerSensorGroup=t)}else if("RemoteCommandEvent"===t&&e.parsedData){let t=this.resolveNetString(e.parsedData.funcName),a=e.parsedData.args;"ServerMessage"===t&&this.handleServerMessage(a),this.handleHudRemoteCommand(t,a)}}let t=function(e){let t={weaponsHud:null,backpackHud:null,inventoryHud:null,teamScores:[],playerRoster:new Map,chatMessages:[],gravity:-20};if(!e.length)return t;let a=0,r=()=>{let t=e[a++];return"<BLANK>"===t?"":t??""};if(r(),a>=e.length)return t;let n=parseInt(r(),10)||0,i=new Map;for(let e=0;e<n;e++){let e=r().split(" "),a=e[0]??"",n=parseInt(e[2],10),o=parseInt(e[4],10);isNaN(n)||isNaN(o)||t.playerRoster.set(n,{name:a,teamId:o}),!isNaN(o)&&o>0&&i.set(o,(i.get(o)??0)+1)}if(a>=e.length||(r(),a>=e.length))return t;{let e=r().split(" "),a=e[0]??"",n="1"===e[1]||"true"===e[1],i=e[2]??"",o="1"===e[4]||"true"===e[4];n&&a&&(t.backpackHud={packIndex:function(e){let t=e.toLowerCase();for(let[e,a]of oS)if(e===t)return a;return -1}(a),active:o,text:i})}if(a>=e.length)return t;let o=r().split(" "),s=parseInt(o[4],10)||0,l=parseInt(o[5],10)||0,c=parseInt(o[6],10);for(let e=0;e<s;e++)r();let d=new Map;for(let e=0;e<l;e++){let e=r().split(" "),t=parseInt(e[0],10),a=parseInt(e[1],10);isNaN(t)||d.set(t,isNaN(a)?-1:a)}if(t.weaponsHud={slots:d,activeIndex:isNaN(c)?-1:c},a>=e.length)return t;let u=r().split(" "),h=parseInt(u[4],10)||0,m=parseInt(u[5],10)||0,f=parseInt(u[6],10);for(let e=0;e<h;e++)r();{let e=new Map;for(let t=0;t<m;t++){let t=r().split(" "),a=parseInt(t[0],10),n=parseInt(t[1],10);isNaN(a)||isNaN(n)||!(n>0)||e.set(a,n)}e.size>0&&(t.inventoryHud={slots:e,activeSlot:isNaN(f)?-1:f})}if(a>=e.length)return t;let g=r().split(" "),p=g[1]??"",y=parseInt(g[2],10)||0,v=[];for(let e=0;e<y;e++)v.push(r());if("CTFGame"===p&&y>=8)for(let e=0;e<2;e++){let a=4*e,r=e+1;t.teamScores.push({teamId:r,name:v[a]??"",score:parseInt(v[a+1],10)||0,playerCount:i.get(r)??0})}else if("TR2Game"===p&&y>=4)for(let e=0;e<2;e++){let a=2*e,r=e+1;t.teamScores.push({teamId:r,name:v[a+1]??"",score:parseInt(v[a],10)||0,playerCount:i.get(r)??0})}if(a>=e.length)return t;r();for(let n=0;n<10&&!(a>=e.length);n++){let e=r();e&&t.chatMessages.push(e)}if(a<e.length){let e=parseFloat(r());Number.isFinite(e)&&(t.gravity=e)}return t}(this.initialBlock.demoValues);for(let e of(t.weaponsHud&&(this.state.weaponsHud.slots=t.weaponsHud.slots,this.state.weaponsHud.activeIndex=t.weaponsHud.activeIndex),t.backpackHud&&(this.state.backpackHud.packIndex=t.backpackHud.packIndex,this.state.backpackHud.active=t.backpackHud.active,this.state.backpackHud.text=t.backpackHud.text),t.inventoryHud&&(this.state.inventoryHud.slots=t.inventoryHud.slots,this.state.inventoryHud.activeSlot=t.inventoryHud.activeSlot),this.state.teamScores=t.teamScores,this.state.playerRoster=new Map(t.playerRoster),t.chatMessages)){let t=function(e){let t=[],a=0,r="",n=!1;for(let i=0;i<e.length;i++){let o=e.charCodeAt(i);if(16===o){n=!0;continue}if(17===o){n=!1;continue}if(n){o>=32&&(r+=e[i]);continue}let s=o_[o];void 0!==s?(r&&(t.push({text:r,colorCode:a}),r=""),a=s):15===o?(r&&(t.push({text:r,colorCode:a}),r=""),a=0):o>=32&&(r+=e[i])}return r&&t.push({text:r,colorCode:a}),t}(e);if(!t.length)continue;let a=t.map(e=>e.text).join("");if(!a.trim())continue;let r=t[0].colorCode;if(t.some(e=>3===e.colorCode||4===e.colorCode)&&a.includes(": ")){let e=a.indexOf(": ");this.state.chatMessages.push({timeSec:0,sender:a.slice(0,e),text:a.slice(e+2),kind:"chat",colorCode:r,segments:t})}else this.state.chatMessages.push({timeSec:0,sender:"",text:a,kind:"server",colorCode:r,segments:t})}this.updateCameraAndHud()}getSnapshot(){if(this._cachedSnapshot&&this._cachedSnapshotTick===this.state.moveTicks)return this._cachedSnapshot;let e=this.buildSnapshot();return this._cachedSnapshot=e,this._cachedSnapshotTick=this.state.moveTicks,e}getEffectShapes(){let e=new Set,t=t=>{let a=t.dtsFileName;a&&e.add(a);let r=t.subExplosions;if(Array.isArray(r))for(let t of r){if(null==t)continue;let a=this.getDataBlockData(t);a?.dtsFileName&&e.add(a.dtsFileName)}};for(let[,e]of this.initialBlock.dataBlocks){let a=e.data?.explosion;if(null==a)continue;let r=this.getDataBlockData(a);r&&t(r)}return[...e]}stepToTime(e,t=1/0){let a=Math.floor(1e3*(Number.isFinite(e)?Math.max(0,e):0)/32),r=!1;a<this.state.moveTicks&&(this.reset(),r=!0);let n=this.state.exhausted,i=0;for(;!this.state.exhausted&&this.state.moveTicks<a&&i<t&&this.stepOneMoveTick();)i+=1;if(0===i&&!r&&n===this.state.exhausted&&this._cachedSnapshot&&this._cachedSnapshotTick===this.state.moveTicks)return this._cachedSnapshot;let o=this.buildSnapshot();return this._cachedSnapshot=o,this._cachedSnapshotTick=this.state.moveTicks,o}stepOneMoveTick(){for(;;){let e=this.parser.nextBlock();if(!e)return this.state.exhausted=!0,!1;if(this.handleBlock(e),2===e.type)return this.state.moveTicks+=1,this.advanceProjectiles(),this.advanceItems(),this.removeExpiredExplosions(),this.updateCameraAndHud(),!0}}handleBlock(e){if(0===e.type&&this.isPacketData(e.parsed)){let t=e.parsed,a=t.gameState.controlObjectData,r=this.state.latestControl,n="number"==typeof t.gameState.controlObjectGhostIndex?t.gameState.controlObjectGhostIndex:r.ghostIndex,i=t.gameState.compressionPoint,o=ox(a?.position)?a?.position:ox(i)?i:r.position;if(this.state.latestControl={ghostIndex:n,data:a,position:o},n!==r.ghostIndex){let e=this.state.entityIdByGhostIndex.get(n),t=e?this.state.entitiesById.get(e):void 0;t?.sensorGroup!=null&&t.sensorGroup>0&&(this.state.playerSensorGroup=t.sensorGroup)}if(a){let e=oA(a);if(e&&(this.state.lastControlType=e),"player"===this.state.lastControlType)this.state.isPiloting=!!(a.pilot||null!=a.controlObjectGhost);else if(this.state.isPiloting=!1,"number"==typeof a.cameraMode)if(this.state.lastCameraMode=a.cameraMode,3===a.cameraMode){"number"==typeof a.orbitObjectGhostIndex&&(this.state.lastOrbitGhostIndex=a.orbitObjectGhostIndex);let e=a.minOrbitDist,t=a.maxOrbitDist,r=a.curOrbitDist;"number"==typeof e&&"number"==typeof t&&Number.isFinite(e)&&Number.isFinite(t)?this.state.lastOrbitDistance=Math.max(0,t-e):"number"==typeof r&&Number.isFinite(r)&&(this.state.lastOrbitDistance=Math.max(0,r))}else this.state.lastOrbitGhostIndex=void 0,this.state.lastOrbitDistance=void 0;let t=this.getAbsoluteRotation(a);t&&(this.state.absoluteYaw=t.yaw,this.state.absolutePitch=t.pitch,this.state.lastAbsYaw=t.yaw,this.state.lastAbsPitch=t.pitch)}for(let e of t.events){let t=this.registry.getEventParser(e.classId)?.name;if("NetStringEvent"===t&&e.parsedData){let t=e.parsedData.id,a=e.parsedData.value;null!=t&&"string"==typeof a&&this.netStrings.set(t,a);continue}if("TargetInfoEvent"===t&&e.parsedData){let t=e.parsedData.targetId,a=e.parsedData.nameTag;if(null!=t&&null!=a){let e=this.netStrings.get(a);e&&this.targetNames.set(t,oC(e))}let r=e.parsedData.sensorGroup;null!=t&&null!=r&&this.targetTeams.set(t,r);let n=e.parsedData.renderFlags;if(null!=t&&null!=n)for(let e of(this.targetRenderFlags.set(t,n),this.state.entitiesById.values()))e.targetId===t&&(e.targetRenderFlags=n)}else if("SetSensorGroupEvent"===t&&e.parsedData){let t=e.parsedData.sensorGroup;null!=t&&(this.state.playerSensorGroup=t)}else if("SensorGroupColorEvent"===t&&e.parsedData){let t=e.parsedData.sensorGroup,a=e.parsedData.colors;if(a){let e=this.sensorGroupColors.get(t);for(let r of(e||(e=new Map,this.sensorGroupColors.set(t,e)),a))r.default?e.delete(r.index):e.set(r.index,{r:r.r??0,g:r.g??0,b:r.b??0})}}else if("RemoteCommandEvent"===t&&e.parsedData){let t=this.resolveNetString(e.parsedData.funcName),a=e.parsedData.args,r=.032*this.state.moveTicks;if("ChatMessage"===t&&a.length>=4){let e=oP(this.resolveNetString(a[3])),t=a[4]?oC(this.resolveNetString(a[4])):"",n=this.formatRemoteArgs(a[3],a.slice(4));if(n){let i,o,s=n.indexOf(": "),{text:l,wavPath:c}=oD(s>=0?n.slice(s+2):n);if(c){let e=this.resolveNetString(a[1]);i=e?`voice/${e}/${c}.wav`:c;let t=this.resolveNetString(a[2]);if(t){let e=parseFloat(t);Number.isFinite(e)&&(o=Math.max(.5,Math.min(2,e)))}}let d=e??0;this.pushChatMessage({timeSec:r,sender:t,text:l,kind:"chat",colorCode:d,segments:[{text:t?`${t}: ${l}`:l,colorCode:d}],soundPath:i,soundPitch:o})}}else if("CannedChatMessage"===t&&a.length>=6){let e=oP(this.resolveNetString(a[1])),t=oC(this.resolveNetString(a[2])),n=oC(this.resolveNetString(a[4])),i=this.formatRemoteArgs(a[1],a.slice(2));if(i){let o,s,{wavPath:l}=oD(i),c=oD(oC(this.resolveNetString(a[3]))).text;if(l){let e=this.resolveNetString(a[5]);if(o=e?`voice/${e}/${l}.wav`:l,a[6]){let e=parseFloat(this.resolveNetString(a[6]));Number.isFinite(e)&&(s=Math.max(.5,Math.min(2,e)))}}let d=e??0,u=[];n&&u.push({text:`[${n}] `,colorCode:0}),u.push({text:t?`${t}: ${c}`:c,colorCode:d}),this.pushChatMessage({timeSec:r,sender:t,text:c,kind:"chat",colorCode:d,segments:u,soundPath:o,soundPitch:s})}}else if("ServerMessage"===t&&a.length>=2){this.handleServerMessage(a);let e=oP(this.resolveNetString(a[1])),t=this.formatRemoteArgs(a[1],a.slice(2));if(t){let{text:a,wavPath:n}=oD(t),i=e??0;this.pushChatMessage({timeSec:r,sender:"",text:a,kind:"server",colorCode:i,segments:[{text:a,colorCode:i}],soundPath:n??void 0})}}else this.handleHudRemoteCommand(t,a)}else if(("Sim3DAudioEvent"===t||"Sim2DAudioEvent"===t)&&e.parsedData){let a=e.parsedData.profileId;if("number"==typeof a){let r=.032*this.state.moveTicks,n="Sim3DAudioEvent"===t?e.parsedData.position:void 0;this.state.pendingAudioEvents.push({profileId:a,position:n,timeSec:r}),this.state.pendingAudioEvents.length>100&&this.state.pendingAudioEvents.splice(0,this.state.pendingAudioEvents.length-100)}}}for(let e of t.ghosts)this.applyPacketGhost(e);return}if(3===e.type&&this.isInfoData(e.parsed)){Number.isFinite(e.parsed.value2)&&(this.state.latestFov=e.parsed.value2);return}if(2===e.type&&this.isMoveData(e.parsed)){this.state.absoluteYaw+=e.parsed.yaw??0;let t=2*Math.PI;this.state.absoluteYaw=(this.state.absoluteYaw%t+t)%t,this.state.absolutePitch=ok(this.state.absolutePitch+(e.parsed.pitch??0),-ov,ov)}}applyPacketGhost(e){let t,a=e.index,r=this.state.entityIdByGhostIndex.get(a);if(r){let t=this.state.entitiesById.get(r);t&&"Projectile"===t.type&&!t.hasExploded&&null!=t.explosionDataBlockId&&t.position&&("delete"===e.type||"create"===e.type)&&this.spawnExplosion(t,[...t.position])}if("delete"===e.type){r&&(this.state.entitiesById.delete(r),this.state.entityIdByGhostIndex.delete(a));return}let n=this.resolveGhostClassName(a,e.classId);if(!n)return;let i=oT(n,a);r&&r!==i&&this.state.entitiesById.delete(r);let o=this.state.entitiesById.get(i);o&&"create"===e.type?(o.spawnTick=this.state.moveTicks,o.rotation=[0,0,0,1],o.hasExploded=void 0,o.explosionShape=void 0,o.explosionLifetimeTicks=void 0,o.faceViewer=void 0,o.simulatedVelocity=void 0,o.projectilePhysics=void 0,o.gravityMod=void 0,o.direction=void 0,o.velocity=void 0,o.position=void 0,o.dataBlock=void 0,o.dataBlockId=void 0,o.shapeHint=void 0,o.visual=void 0,o.targetId=void 0,o.targetRenderFlags=void 0,o.carryingFlag=void 0,o.sensorGroup=void 0,o.playerName=void 0,o.weaponShape=void 0,o.weaponImageState=void 0,o.weaponImageStates=void 0,o.weaponImageStatesDbId=void 0,o.itemPhysics=void 0,o.threads=void 0,o.headPitch=void 0,o.headYaw=void 0,o.health=void 0,o.energy=void 0,o.maxEnergy=void 0,o.damageState=void 0,o.actionAnim=void 0,o.actionAtEnd=void 0,o.explosionDataBlockId=void 0,o.maintainEmitterId=void 0,t=o):o?t=o:(t={id:i,ghostIndex:a,className:n,spawnTick:this.state.moveTicks,type:oM(n),rotation:[0,0,0,1]},this.state.entitiesById.set(i,t)),t.ghostIndex=a,t.className=n,t.type=oM(n),this.state.entityIdByGhostIndex.set(a,i),this.applyGhostData(t,e.parsedData)}resolveGhostClassName(e,t){if("number"==typeof t){let e=this.registry.getGhostParser(t)?.name;if(e)return e}let a=this.state.entityIdByGhostIndex.get(e);if(a){let e=this.state.entitiesById.get(a);if(e?.className)return e.className}let r=this.parser.getGhostTracker().getGhost(e);if(r?.className)return r.className}resolveEntityIdForGhostIndex(e){let t=this.state.entityIdByGhostIndex.get(e);if(t)return t;let a=this.parser.getGhostTracker().getGhost(e);if(a)return oT(a.className,e)}getDataBlockData(e){let t=this.initialBlock.dataBlocks.get(e);if(t?.data)return t.data;let a=this.parser.getPacketParser();return a.dataBlockDataMap?.get(e)}resolveExplosionInfo(e){let t=this.getDataBlockData(e);if(!t)return;let a=t.explosion;if(null==a)return;let r=this.getDataBlockData(a);if(!r)return;let n=r.dtsFileName||void 0,i=r.lifetimeMS??31;return{shape:n,faceViewer:!1!==r.faceViewer&&0!==r.faceViewer,lifetimeTicks:i,explosionDataBlockId:a}}applyGhostData(e,t){if(!t)return;let a=t.dataBlockId;if(null!=a){e.dataBlockId=a;let t=this.getDataBlockData(a),r=oj(t);if(e.visual=function(e,t){if(!t)return;let a=oN(t,["tracerTex0","textureName0","texture0"])??"";if(!("TracerProjectile"===e||a.length>0&&null!=oR(t,["tracerLength"]))||!a)return;let r=oN(t,["tracerTex1","textureName1","texture1"]),n=oR(t,["tracerLength"])??10,i=oR(t,["tracerWidth"]),o=oR(t,["tracerAlpha"]),s=null!=i&&(null!=oR(t,["crossViewAng"])||i<=.7)?i:o??i??.5,l=oR(t,["crossViewAng","crossViewFraction"])??("number"==typeof t.tracerWidth&&t.tracerWidth>.7?t.tracerWidth:.98);return{kind:"tracer",texture:a,crossTexture:r,tracerLength:n,tracerWidth:s,crossViewAng:l,crossSize:oR(t,["crossSize","muzzleVelocity"])??.45,renderCross:function(e,t){if(e)for(let a of t){let t=e[a];if("boolean"==typeof t)return t}}(t,["renderCross","proximityRadius"])??!0}}(e.className,t)??function(e,t){if(t){if("LinearFlareProjectile"===e){let e=oN(t,["smokeTexture","flareTexture"]);if(!e)return;let a=t.flareColor,r=oR(t,["size"])??.5;return{kind:"sprite",texture:e,color:a?{r:a.r,g:a.g,b:a.b}:{r:1,g:1,b:1},size:r}}if("FlareProjectile"===e){let e=oN(t,["flareTexture"]);if(!e)return;return{kind:"sprite",texture:e,color:{r:1,g:.9,b:.5},size:oR(t,["size"])??4}}}}(e.className,t),"string"==typeof r&&(e.shapeHint=r,e.dataBlock=r),"Player"===e.type&&"number"==typeof t?.maxEnergy&&(e.maxEnergy=t.maxEnergy),"Projectile"===e.type&&(om.has(e.className)?e.projectilePhysics="linear":of.has(e.className)?(e.projectilePhysics="ballistic",e.gravityMod=oR(t,["gravityMod"])??1):og.has(e.className)&&(e.projectilePhysics="seeker")),"Projectile"===e.type&&null==e.explosionDataBlockId){let t=this.resolveExplosionInfo(a);t&&(e.explosionShape=t.shape,e.faceViewer=t.faceViewer,e.explosionLifetimeTicks=t.lifetimeTicks,e.explosionDataBlockId=t.explosionDataBlockId)}if("Projectile"===e.type&&null==e.maintainEmitterId){let a=t?.baseEmitter;"number"==typeof a&&a>0&&(e.maintainEmitterId=a)}}if("Player"===e.type){let a=t.images;if(Array.isArray(a)&&a.length>0){let t=a.find(e=>0===e.index);if(t?.dataBlockId&&t.dataBlockId>0){let a=this.getDataBlockData(t.dataBlockId),r=oj(a);if(r){let t=a?.mountPoint;(null==t||t<=0)&&!/pack_/i.test(r)&&(e.weaponShape=r)}let n=e.weaponImageState;e.weaponImageState={dataBlockId:t.dataBlockId,triggerDown:t.triggerDown??n?.triggerDown??!1,ammo:t.ammo??n?.ammo??!0,loaded:t.loaded??n?.loaded??!0,target:t.target??n?.target??!1,wet:t.wet??n?.wet??!1,fireCount:t.fireCount??n?.fireCount??0},a&&e.weaponImageStatesDbId!==t.dataBlockId&&(e.weaponImageStates=function(e){let t=e.states;if(Array.isArray(t)&&0!==t.length)return t.map(e=>{let t=e=>null==e?-1:e-1;return{name:e.name??"",transitionOnNotLoaded:t(e.transitionOnAmmo),transitionOnLoaded:t(e.transitionOnNoAmmo),transitionOnNoAmmo:t(e.transitionOnTarget),transitionOnAmmo:t(e.transitionOnNoTarget),transitionOnNoTarget:t(e.transitionOnWet),transitionOnTarget:t(e.transitionOnNotWet),transitionOnNotWet:t(e.transitionOnTriggerUp),transitionOnWet:t(e.transitionOnTriggerDown),transitionOnTriggerUp:t(e.transitionOnTimeout),transitionOnTriggerDown:t(e.transitionGeneric0In),transitionOnTimeout:t(e.transitionGeneric0Out),timeoutValue:e.timeoutValue,waitForTimeout:e.waitForTimeout??!1,fire:e.fire??!1,sequence:e.sequence,spin:e.spin??0,direction:e.direction??!0,scaleAnimation:e.scaleAnimation??!1,loaded:e.loaded??0,soundDataBlockId:e.sound??-1}})}(a),e.weaponImageStatesDbId=t.dataBlockId)}else t&&!t.dataBlockId&&(e.weaponShape=void 0,e.weaponImageState=void 0,e.weaponImageStates=void 0);let r=a.find(e=>3===e.index);if(r){let t=!!r.dataBlockId&&r.dataBlockId>0;if(e.carryingFlag=t,null!=e.targetId&&e.targetId>=0){let a=this.targetRenderFlags.get(e.targetId)??0,r=t?2|a:-3&a;r!==a&&(this.targetRenderFlags.set(e.targetId,r),e.targetRenderFlags=r)}}}}let r=ox(t.position)?t.position:ox(t.initialPosition)?t.initialPosition:ox(t.explodePosition)?t.explodePosition:ox(t.endPoint)?t.endPoint:ox(t.transform?.position)?t.transform.position:void 0;r&&(e.position=[r.x,r.y,r.z]);let n=oB(t.direction)?t.direction:void 0;if(n&&(e.direction=[n.x,n.y,n.z]),"Player"===e.type&&"number"==typeof t.rotationZ&&(e.rotation=ow(t.rotationZ)),"Player"===e.type&&("number"==typeof t.headX&&(e.headPitch=t.headX),"number"==typeof t.headZ&&(e.headYaw=t.headZ)),oE(t.angPosition)){let a=oI(t.angPosition);a&&(e.rotation=a)}else if(oE(t.transform?.rotation)){let a=oI(t.transform.rotation);a&&(e.rotation=a)}else if("Item"===e.type&&"number"==typeof t.rotation?.angle){let a=t.rotation;e.rotation=ow((a.zSign??1)*a.angle)}else if("Projectile"===e.type){let a=t.velocity??t.direction??(ox(t.initialPosition)&&ox(t.endPos)?{x:t.endPos.x-t.initialPosition.x,y:t.endPos.y-t.initialPosition.y,z:t.endPos.z-t.initialPosition.z}:void 0);oB(a)&&(0!==a.x||0!==a.y)&&(e.rotation=ow(Math.atan2(a.x,a.y)))}if(oB(t.velocity)&&(e.velocity=[t.velocity.x,t.velocity.y,t.velocity.z],e.direction||(e.direction=[t.velocity.x,t.velocity.y,t.velocity.z])),"Item"===e.type){let a=t.atRest,n=t.warp;if(!0===a||!1===n)e.itemPhysics=void 0;else if(!1===a&&oB(t.velocity)){let a=null!=e.dataBlockId?this.getDataBlockData(e.dataBlockId):void 0;e.itemPhysics={velocity:[t.velocity.x,t.velocity.y,t.velocity.z],atRest:!1,elasticity:oR(a,["elasticity"])??.2,friction:oR(a,["friction"])??.6,gravityMod:oR(a,["gravityMod"])??1}}else r&&!oB(t.velocity)&&(e.itemPhysics=void 0)}if(e.projectilePhysics)if("linear"===e.projectilePhysics){let a=oR(null!=e.dataBlockId?this.getDataBlockData(e.dataBlockId):void 0,["dryVelocity","muzzleVelocity","bulletVelocity"])??80,r=e.direction??[0,1,0],n=r[0]*a,i=r[1]*a,o=r[2]*a,s=t.excessVel,l=t.excessDir;"number"==typeof s&&s>0&&oB(l)&&(n+=l.x*s,i+=l.y*s,o+=l.z*s),e.simulatedVelocity=[n,i,o]}else oB(t.velocity)&&(e.simulatedVelocity=[t.velocity.x,t.velocity.y,t.velocity.z]);if(e.projectilePhysics){let a=t.currTick;if("number"==typeof a&&a>0&&e.simulatedVelocity&&e.position){let t=.032*a,r=e.simulatedVelocity;if(e.position[0]+=r[0]*t,e.position[1]+=r[1]*t,e.position[2]+=r[2]*t,"ballistic"===e.projectilePhysics){let a=-9.81*(e.gravityMod??1);e.position[2]+=.5*a*t*t,r[2]+=a*t}}}let i=ox(t.explodePosition)?t.explodePosition:ox(t.explodePoint)?t.explodePoint:void 0;if("Projectile"===e.type&&!e.hasExploded&&i&&null!=e.explosionDataBlockId&&this.spawnExplosion(e,[i.x,i.y,i.z]),"number"==typeof t.damageLevel&&(e.health=ok(1-t.damageLevel,0,1)),"number"==typeof t.damageState&&(e.damageState=t.damageState),"number"==typeof t.action&&(e.actionAnim=t.action,e.actionAtEnd=!!t.actionAtEnd),Array.isArray(t.threads)){let a=t.threads;if(e.threads){let t=[...e.threads];for(let e of a){let a=t.findIndex(t=>t.index===e.index);a>=0?t[a]=e:t.push(e)}e.threads=t}else e.threads=a}if("number"==typeof t.energy&&(e.energy=ok(t.energy,0,1)),"number"==typeof t.targetId){e.targetId=t.targetId;let a=this.targetNames.get(t.targetId);a&&(e.playerName=a);let r=this.targetTeams.get(t.targetId);null!=r&&(e.sensorGroup=r,e.ghostIndex===this.state.latestControl.ghostIndex&&"player"===this.state.lastControlType&&(this.state.playerSensorGroup=r));let n=this.targetRenderFlags.get(t.targetId);null!=n&&(e.targetRenderFlags=n)}let o=t.sounds;if(Array.isArray(o)){let t=.032*this.state.moveTicks;for(let a of o)if(a.playing&&"number"==typeof a.profileId){let r=e.position;this.state.pendingAudioEvents.push({profileId:a.profileId,position:r?{x:r[0],y:r[1],z:r[2]}:void 0,timeSec:t})}}}advanceProjectiles(){for(let e of this.state.entitiesById.values()){if(!e.simulatedVelocity||!e.position)continue;let t=e.simulatedVelocity,a=e.position;"ballistic"===e.projectilePhysics&&(t[2]+=-9.81*(e.gravityMod??1)*.032),a[0]+=.032*t[0],a[1]+=.032*t[1],a[2]+=.032*t[2],(0!==t[0]||0!==t[1])&&(e.rotation=ow(Math.atan2(t[0],t[1])))}}advanceItems(){for(let a of this.state.entitiesById.values()){var e,t;let r=a.itemPhysics;if(!r||r.atRest||!a.position)continue;let n=r.velocity,i=a.position;n[2]+=-20*r.gravityMod*.032,i[0]+=.032*n[0],i[1]+=.032*n[1],i[2]+=.032*n[2];let o=(e=i[0],t=i[1],_?_(e,t):null);if(null!=o&&i[2]<o){i[2]=o;let e=Math.abs(n[2]);n[2]=e*r.elasticity;let t=e*r.friction,a=Math.sqrt(n[0]*n[0]+n[1]*n[1]);if(a>0){let e=Math.max(0,1-t/a);n[0]*=e,n[1]*=e}.15>Math.sqrt(n[0]*n[0]+n[1]*n[1]+n[2]*n[2])&&(n[0]=n[1]=n[2]=0,r.atRest=!0)}}}spawnExplosion(e,t){e.hasExploded=!0;let a=e.explosionLifetimeTicks??31,r=`fx_${this.state.nextExplosionId++}`,n={id:r,ghostIndex:-1,className:"Explosion",spawnTick:this.state.moveTicks,type:"Explosion",dataBlock:e.explosionShape,explosionDataBlockId:e.explosionDataBlockId,position:t,rotation:[0,0,0,1],isExplosion:!0,faceViewer:!1!==e.faceViewer,expiryTick:this.state.moveTicks+a};if(this.state.entitiesById.set(r,n),null!=e.explosionDataBlockId){let a=this.getDataBlockData(e.explosionDataBlockId),r=a?.subExplosions;if(Array.isArray(r))for(let e of r){if(null==e)continue;let a=this.getDataBlockData(e);if(!a)continue;let r=a.dtsFileName||void 0;if(!r)continue;let n=a.lifetimeMS??31,i=a.offset??0,o=Math.random()*Math.PI*2,s=[t[0]+Math.cos(o)*i,t[1]+Math.sin(o)*i,t[2]],l=`fx_${this.state.nextExplosionId++}`,c={id:l,ghostIndex:-1,className:"Explosion",spawnTick:this.state.moveTicks,type:"Explosion",dataBlock:r,explosionDataBlockId:e,position:s,rotation:[0,0,0,1],isExplosion:!0,faceViewer:!1!==a.faceViewer&&0!==a.faceViewer,expiryTick:this.state.moveTicks+n};this.state.entitiesById.set(l,c)}}e.position=void 0,e.simulatedVelocity=void 0}removeExpiredExplosions(){for(let[e,t]of this.state.entitiesById)t.isExplosion&&null!=t.expiryTick&&this.state.moveTicks>=t.expiryTick&&this.state.entitiesById.delete(e)}updateCameraAndHud(){let e=this.state.latestControl,t=.032*this.state.moveTicks,a=e.data,r=this.state.lastControlType;if(e.position){var n;let i,o,s,l,c=!this.state.isPiloting&&"player"===r,d=c?this.state.absoluteYaw:this.state.lastAbsYaw,u=c?this.state.absolutePitch:this.state.lastAbsPitch;if(c&&(this.state.lastAbsYaw=d,this.state.lastAbsPitch=u),this.state.camera={time:t,position:[e.position.x,e.position.y,e.position.z],rotation:(i=Math.sin(n=ok(u,-ov,ov)),o=Math.cos(n),s=Math.sin(d),l=Math.cos(d),oF.set(-s,l*i,-l*o,0,0,o,i,0,l,s*i,-s*o,0,0,0,0,1),ob.setFromRotationMatrix(oF),[ob.x,ob.y,ob.z,ob.w]),fov:this.state.latestFov,mode:"observer",yaw:d,pitch:u},"camera"===r)if(("number"==typeof a?.cameraMode?a.cameraMode:this.state.lastCameraMode)===3){this.state.camera.mode="third-person","number"==typeof this.state.lastOrbitDistance&&(this.state.camera.orbitDistance=this.state.lastOrbitDistance);let e="number"==typeof a?.orbitObjectGhostIndex?a.orbitObjectGhostIndex:this.state.lastOrbitGhostIndex;"number"==typeof e&&e>=0&&(this.state.camera.orbitTargetId=this.resolveEntityIdForGhostIndex(e))}else this.state.camera.mode="observer";else this.state.camera.mode="first-person",e.ghostIndex>=0&&(this.state.controlPlayerGhostId=`player_${e.ghostIndex}`),this.state.controlPlayerGhostId&&(this.state.camera.controlEntityId=this.state.controlPlayerGhostId);if("player"===r&&!this.state.isPiloting&&this.state.controlPlayerGhostId&&e.position){let t=this.state.entitiesById.get(this.state.controlPlayerGhostId);t&&(t.position=[e.position.x,e.position.y,e.position.z],t.rotation=ow(d),t.headPitch=ok(this.state.absolutePitch/ov,-1,1))}}else this.state.camera&&(this.state.camera={...this.state.camera,time:t,fov:this.state.latestFov});let i={health:1,energy:1};if(this.state.camera?.mode==="first-person"){let e=this.state.controlPlayerGhostId,t=e?this.state.entitiesById.get(e):void 0;i.health=t?.health??1;let r=a?.energyLevel;if("number"==typeof r){let e=t?.maxEnergy??60;e>0&&(i.energy=ok(r/e,0,1))}else i.energy=t?.energy??1}else if(this.state.camera?.mode==="third-person"&&this.state.camera.orbitTargetId){let e=this.state.entitiesById.get(this.state.camera.orbitTargetId);i.health=e?.health??1,i.energy=e?.energy??1}this.state.lastStatus=i}pushChatMessage(e){this.state.chatMessages.push(e),this.state.chatMessages.length>200&&this.state.chatMessages.splice(0,this.state.chatMessages.length-200)}handleServerMessage(e){if(e.length<2)return;let t=this.resolveNetString(e[0]);if("MsgTeamScoreIs"===t&&e.length>=4){let t=parseInt(this.resolveNetString(e[2]),10),a=parseInt(this.resolveNetString(e[3]),10);if(!isNaN(t)&&!isNaN(a)){let e=this.state.teamScores.find(e=>e.teamId===t);e&&(e.score=a,this._teamScoresGen++)}}else if("MsgCTFAddTeam"===t&&e.length>=6){let t=parseInt(this.resolveNetString(e[2]),10),a=oC(this.resolveNetString(e[3])),r=parseInt(this.resolveNetString(e[5]),10);if(!isNaN(t)){let e=t+1,n=this.state.teamScores.find(t=>t.teamId===e);n?(n.name=a,n.score=isNaN(r)?n.score:r):this.state.teamScores.push({teamId:e,name:a,score:isNaN(r)?0:r,playerCount:0}),this._teamScoresGen++}}else if("MsgClientJoin"===t&&e.length>=4){let t=parseInt(this.resolveNetString(e[2]),10),a=oC(this.resolveNetString(e[3]));if(!isNaN(t)){let e=this.state.playerRoster.get(t);this.state.playerRoster.set(t,{name:a,teamId:e?.teamId??0}),this._rosterGen++}}else if("MsgClientDrop"===t&&e.length>=3){let t=parseInt(this.resolveNetString(e[2]),10);!isNaN(t)&&(this.state.playerRoster.delete(t),this._rosterGen++)}else if("MsgClientJoinTeam"===t&&e.length>=4){let t=parseInt(this.resolveNetString(e[2]),10),a=parseInt(this.resolveNetString(e[3]),10);if(!isNaN(t)&&!isNaN(a)){let e=this.state.playerRoster.get(t);e?e.teamId=a:this.state.playerRoster.set(t,{name:"",teamId:a}),this._rosterGen++}}}handleHudRemoteCommand(e,t){if("setWeaponsHudItem"===e&&t.length>=3){let e=parseInt(t[0],10),a=parseInt(t[1],10),r="1"===t[2]||"true"===t[2];!isNaN(e)&&(r?this.state.weaponsHud.slots.set(e,isNaN(a)?-1:a):this.state.weaponsHud.slots.delete(e),this._weaponsHudGen++)}else if("setWeaponsHudAmmo"===e&&t.length>=2){let e=parseInt(t[0],10),a=parseInt(t[1],10);!isNaN(e)&&(this.state.weaponsHud.slots.set(e,isNaN(a)?-1:a),this._weaponsHudGen++)}else if("setWeaponsHudActive"===e&&t.length>=1){let e=parseInt(t[0],10);this.state.weaponsHud.activeIndex=isNaN(e)?-1:e,isNaN(e)||!(e>=0)||this.state.weaponsHud.slots.has(e)||this.state.weaponsHud.slots.set(e,-1),this._weaponsHudGen++}else if("setWeaponsHudClearAll"===e)this.state.weaponsHud.slots.clear(),this.state.weaponsHud.activeIndex=-1,this._weaponsHudGen++;else if("setBackpackHudItem"===e&&t.length>=2){let e=parseInt(t[0],10);"1"!==t[1]&&"true"!==t[1]||isNaN(e)?this.state.backpackHud.packIndex=-1:this.state.backpackHud.packIndex=e,this.state.backpackHud.active=!1,this.state.backpackHud.text=""}else if("setSatchelArmed"===e)this.state.backpackHud.active=!0;else if("setCloakIconOn"===e||"setRepairPackIconOn"===e||"setShieldIconOn"===e||"setSenJamIconOn"===e)this.state.backpackHud.active=!0;else if("setCloakIconOff"===e||"setRepairPackIconOff"===e||"setShieldIconOff"===e||"setSenJamIconOff"===e)this.state.backpackHud.active=!1;else if("updatePackText"===e&&t.length>=1)this.state.backpackHud.text=t[0]??"";else if("setInventoryHudItem"===e&&t.length>=3){let e=parseInt(t[0],10),a=parseInt(t[1],10),r="1"===t[2]||"true"===t[2];!isNaN(e)&&(r&&!isNaN(a)?this.state.inventoryHud.slots.set(e,a):this.state.inventoryHud.slots.delete(e),this._inventoryHudGen++)}else if("setInventoryHudAmount"===e&&t.length>=2){let e=parseInt(t[0],10),a=parseInt(t[1],10);!isNaN(e)&&!isNaN(a)&&(this.state.inventoryHud.slots.set(e,a),this._inventoryHudGen++)}else"setInventoryHudClearAll"===e&&(this.state.inventoryHud.slots.clear(),this.state.inventoryHud.activeSlot=-1,this._inventoryHudGen++)}buildSnapshot(){let e,t=[];for(let e of this.state.entitiesById.values()){if(!(e.spawnTick>0||!oy.has(e.className)))continue;let a=null!=e.targetId&&e.targetId>=0?this.targetRenderFlags.get(e.targetId)??e.targetRenderFlags:e.targetRenderFlags;"Player"!==e.type||e.carryingFlag||(a=null!=a?-3&a:a),t.push({id:e.id,type:e.type,visual:e.visual,direction:e.direction,ghostIndex:e.ghostIndex,className:e.className,dataBlockId:e.dataBlockId,shapeHint:e.shapeHint,dataBlock:e.dataBlock,weaponShape:e.weaponShape,playerName:e.playerName,targetRenderFlags:a,iffColor:("Player"===e.type||((a??0)&2)!=0)&&null!=e.sensorGroup?this.resolveIffColor(e.sensorGroup):void 0,position:e.position&&(e.simulatedVelocity||e.itemPhysics&&!e.itemPhysics.atRest)?[...e.position]:e.position,rotation:e.rotation,velocity:e.velocity,health:e.health,energy:e.energy,actionAnim:e.actionAnim,actionAtEnd:e.actionAtEnd,damageState:e.damageState,faceViewer:e.faceViewer,threads:e.threads,explosionDataBlockId:e.explosionDataBlockId,maintainEmitterId:e.maintainEmitterId,weaponImageState:e.weaponImageState,weaponImageStates:e.weaponImageStates,headPitch:e.headPitch,headYaw:e.headYaw})}let a=.032*this.state.moveTicks,r=this._snap,n=this.state.chatMessages.filter(e=>e.timeSec>a-15),i=this.state.pendingAudioEvents.filter(e=>e.timeSec>a-.5&&e.timeSec<=a),o=r&&r.weaponsHudGen===this._weaponsHudGen?r.weaponsHud:{slots:Array.from(this.state.weaponsHud.slots.entries()).map(([e,t])=>({index:e,ammo:t})),activeIndex:this.state.weaponsHud.activeIndex},s=r&&r.inventoryHudGen===this._inventoryHudGen?r.inventoryHud:{slots:Array.from(this.state.inventoryHud.slots.entries()).map(([e,t])=>({slot:e,count:t})),activeSlot:this.state.inventoryHud.activeSlot},l=r&&r.backpackPackIndex===this.state.backpackHud.packIndex&&r.backpackActive===this.state.backpackHud.active&&r.backpackText===this.state.backpackHud.text?r.backpackHud:this.state.backpackHud.packIndex>=0?{...this.state.backpackHud}:null;if(r&&r.teamScoresGen===this._teamScoresGen&&r.rosterGen===this._rosterGen)e=r.teamScores;else{e=this.state.teamScores.map(e=>({...e}));let t=new Map;for(let{teamId:e}of this.state.playerRoster.values())e>0&&t.set(e,(t.get(e)??0)+1);for(let a of e)a.playerCount=t.get(a.teamId)??0}return this._snap={teamScoresGen:this._teamScoresGen,rosterGen:this._rosterGen,teamScores:e,weaponsHudGen:this._weaponsHudGen,weaponsHud:o,inventoryHudGen:this._inventoryHudGen,inventoryHud:s,backpackPackIndex:this.state.backpackHud.packIndex,backpackActive:this.state.backpackHud.active,backpackText:this.state.backpackHud.text,backpackHud:l},{timeSec:a,exhausted:this.state.exhausted,camera:this.state.camera,entities:t,controlPlayerGhostId:this.state.controlPlayerGhostId,playerSensorGroup:this.state.playerSensorGroup,status:this.state.lastStatus,chatMessages:n,audioEvents:i,weaponsHud:o,backpackHud:l,inventoryHud:s,teamScores:e}}resolveIffColor(e){if(0===this.state.playerSensorGroup)return;let t=this.sensorGroupColors.get(this.state.playerSensorGroup);if(t){let a=t.get(e);if(a)return a}return e===this.state.playerSensorGroup?oc:0!==e?od:void 0}getAbsoluteRotation(e){return e?"number"==typeof e.rotationZ&&"number"==typeof e.headX?{yaw:e.rotationZ,pitch:e.headX}:"number"==typeof e.rotZ&&"number"==typeof e.rotX?{yaw:e.rotZ,pitch:e.rotX}:null:null}isPacketData(e){return!!e&&"object"==typeof e&&"gameState"in e&&"events"in e&&"ghosts"in e}isMoveData(e){return!!e&&"object"==typeof e&&"yaw"in e}isInfoData(e){return!!e&&"object"==typeof e&&"value2"in e&&"number"==typeof e.value2}resolveNetString(e){if(e.length>=2&&1===e.charCodeAt(0)){let t=parseInt(e.slice(1),10);if(Number.isFinite(t))return this.netStrings.get(t)??e}return e}formatRemoteArgs(e,t){let a=this.resolveNetString(e);for(let e=0;e<t.length;e++){let r=`%${e+1}`;a.includes(r)&&(a=a.replaceAll(r,oC(this.resolveNetString(t[e]))))}return oC(a=a.replace(/%\d+/g,""))}}async function oU(e){let t=new ol(new Uint8Array(e)),{header:a,initialBlock:r}=await t.load(),{missionName:n,gameType:i}=function(e){let t=null,a=null;for(let r=0;r<e.length;r++){if("readplayerinfo"!==e[r])continue;let n=e[r+1];if(n){if(n.startsWith("2 ")){let e=n.split(" ");e[4]&&(t=e[4]);continue}if(n.startsWith("3 ")){let e=n.split(" ");e[2]&&(a=e[2])}}}return{missionName:t,gameType:a}}(r.demoValues);return{duration:a.demoLengthMs/1e3,missionName:n??r.missionName??null,gameType:i,streamingPlayback:new oG(t)}}var oL=e.i(28903);function oz(){let e,t,i,o,s,l,c,d,u=(0,r.c)(20),h=ts(),{setRecording:m}=tm(),f=(0,n.useRef)(null),g=(0,n.useRef)(0);u[0]!==h||u[1]!==m?(e=()=>{if(h){g.current=g.current+1,m(null);return}f.current?.click()},u[0]=h,u[1]=m,u[2]=e):e=u[2];let p=e;u[3]!==m?(t=async e=>{let t=e.target.files?.[0];if(t){e.target.value="";try{let e=await t.arrayBuffer(),a=g.current+1;g.current=a;let r=await oU(e);if(g.current!==a)return;m(r)}catch(e){console.error("Failed to load demo:",e)}}},u[3]=m,u[4]=t):t=u[4];let y=t;u[5]===Symbol.for("react.memo_cache_sentinel")?(i={display:"none"},u[5]=i):i=u[5],u[6]!==y?(o=(0,a.jsx)("input",{ref:f,type:"file",accept:".rec",style:i,onChange:y}),u[6]=y,u[7]=o):o=u[7];let v=h?"Unload demo":"Load demo (.rec)",F=h?"Unload demo":"Load demo (.rec)",b=h?"true":void 0;u[8]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsx)(t8,{className:oL.default.DemoIcon}),u[8]=s):s=u[8];let S=h?"Unload demo":"Demo";return u[9]!==S?(l=(0,a.jsx)("span",{className:oL.default.ButtonLabel,children:S}),u[9]=S,u[10]=l):l=u[10],u[11]!==p||u[12]!==v||u[13]!==F||u[14]!==b||u[15]!==l?(c=(0,a.jsxs)("button",{type:"button",className:oL.default.Root,"aria-label":v,title:F,onClick:p,"data-active":b,children:[s,l]}),u[11]=p,u[12]=v,u[13]=F,u[14]=b,u[15]=l,u[16]=c):c=u[16],u[17]!==c||u[18]!==o?(d=(0,a.jsxs)(a.Fragment,{children:[o,c]}),u[17]=c,u[18]=o,u[19]=d):d=u[19],d}function oO(e){return(0,t3.GenIcon)({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"10"},child:[]},{tag:"line",attr:{x1:"12",y1:"16",x2:"12",y2:"12"},child:[]},{tag:"line",attr:{x1:"12",y1:"8",x2:"12.01",y2:"8"},child:[]}]})(e)}function oV(e){return(0,t3.GenIcon)({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"3"},child:[]},{tag:"path",attr:{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"},child:[]}]})(e)}var oq=e.i(65883);function oH(e){let t,i,o,s,l,c,d,u,h,m,f,g,p,y,F,b,S,x,k,w,I,C,_,P,D,M,T,E,B,j,R,N,A,G,U,L,z,O,V,q=(0,r.c)(92),{missionName:H,missionType:W,onChangeMission:$,onOpenMapInfo:Y,isTouch:K,cameraRef:X}=e,{fogEnabled:Z,setFogEnabled:J,fov:Q,setFov:ee,audioEnabled:et,setAudioEnabled:ea,animationEnabled:er,setAnimationEnabled:en}=(0,v.useSettings)(),{speedMultiplier:ei,setSpeedMultiplier:eo,touchMode:es,setTouchMode:el}=(0,v.useControls)(),{debugMode:ec,setDebugMode:ed}=(0,v.useDebug)(),eu=null!=ts(),[eh,em]=(0,n.useState)(!1),ef=(0,n.useRef)(null),eg=(0,n.useRef)(null),ep=(0,n.useRef)(null);q[0]!==eh?(t=()=>{eh&&ef.current?.focus()},i=[eh],q[0]=eh,q[1]=t,q[2]=i):(t=q[1],i=q[2]),(0,n.useEffect)(t,i),q[3]===Symbol.for("react.memo_cache_sentinel")?(o=e=>{let t=e.relatedTarget;t&&ep.current?.contains(t)||em(!1)},q[3]=o):o=q[3];let ey=o;q[4]===Symbol.for("react.memo_cache_sentinel")?(s=e=>{"Escape"===e.key&&(em(!1),eg.current?.focus())},q[4]=s):s=q[4];let ev=s;return q[5]!==eu||q[6]!==H||q[7]!==W||q[8]!==$?(l=(0,a.jsx)("div",{className:oq.default.MissionSelectWrapper,children:(0,a.jsx)(t1,{value:H,missionType:W,onChange:$,disabled:eu})}),q[5]=eu,q[6]=H,q[7]=W,q[8]=$,q[9]=l):l=q[9],q[10]===Symbol.for("react.memo_cache_sentinel")?(c=()=>{em(oW)},q[10]=c):c=q[10],q[11]===Symbol.for("react.memo_cache_sentinel")?(d=(0,a.jsx)(oV,{}),q[11]=d):d=q[11],q[12]!==eh?(u=(0,a.jsx)("button",{ref:eg,className:oq.default.Toggle,onClick:c,"aria-expanded":eh,"aria-controls":"settingsPanel","aria-label":"Settings",children:d}),q[12]=eh,q[13]=u):u=q[13],q[14]!==X||q[15]!==H||q[16]!==W?(h=(0,a.jsx)(t6,{missionName:H,missionType:W,cameraRef:X}),q[14]=X,q[15]=H,q[16]=W,q[17]=h):h=q[17],q[18]===Symbol.for("react.memo_cache_sentinel")?(m=(0,a.jsx)(oz,{}),q[18]=m):m=q[18],q[19]===Symbol.for("react.memo_cache_sentinel")?(f=(0,a.jsx)(oO,{}),g=(0,a.jsx)("span",{className:oq.default.ButtonLabel,children:"Show map info"}),q[19]=f,q[20]=g):(f=q[19],g=q[20]),q[21]!==Y?(p=(0,a.jsxs)("button",{type:"button",className:oq.default.MapInfoButton,"aria-label":"Show map info",onClick:Y,children:[f,g]}),q[21]=Y,q[22]=p):p=q[22],q[23]!==p||q[24]!==h?(y=(0,a.jsxs)("div",{className:oq.default.Group,children:[h,m,p]}),q[23]=p,q[24]=h,q[25]=y):y=q[25],q[26]!==J?(F=e=>{J(e.target.checked)},q[26]=J,q[27]=F):F=q[27],q[28]!==Z||q[29]!==F?(b=(0,a.jsx)("input",{id:"fogInput",type:"checkbox",checked:Z,onChange:F}),q[28]=Z,q[29]=F,q[30]=b):b=q[30],q[31]===Symbol.for("react.memo_cache_sentinel")?(S=(0,a.jsx)("label",{htmlFor:"fogInput",children:"Fog?"}),q[31]=S):S=q[31],q[32]!==b?(x=(0,a.jsxs)("div",{className:oq.default.CheckboxField,children:[b,S]}),q[32]=b,q[33]=x):x=q[33],q[34]!==ea?(k=e=>{ea(e.target.checked)},q[34]=ea,q[35]=k):k=q[35],q[36]!==et||q[37]!==k?(w=(0,a.jsx)("input",{id:"audioInput",type:"checkbox",checked:et,onChange:k}),q[36]=et,q[37]=k,q[38]=w):w=q[38],q[39]===Symbol.for("react.memo_cache_sentinel")?(I=(0,a.jsx)("label",{htmlFor:"audioInput",children:"Audio?"}),q[39]=I):I=q[39],q[40]!==w?(C=(0,a.jsxs)("div",{className:oq.default.CheckboxField,children:[w,I]}),q[40]=w,q[41]=C):C=q[41],q[42]!==x||q[43]!==C?(_=(0,a.jsxs)("div",{className:oq.default.Group,children:[x,C]}),q[42]=x,q[43]=C,q[44]=_):_=q[44],q[45]!==en?(P=e=>{en(e.target.checked)},q[45]=en,q[46]=P):P=q[46],q[47]!==er||q[48]!==P?(D=(0,a.jsx)("input",{id:"animationInput",type:"checkbox",checked:er,onChange:P}),q[47]=er,q[48]=P,q[49]=D):D=q[49],q[50]===Symbol.for("react.memo_cache_sentinel")?(M=(0,a.jsx)("label",{htmlFor:"animationInput",children:"Animation?"}),q[50]=M):M=q[50],q[51]!==D?(T=(0,a.jsxs)("div",{className:oq.default.CheckboxField,children:[D,M]}),q[51]=D,q[52]=T):T=q[52],q[53]!==ed?(E=e=>{ed(e.target.checked)},q[53]=ed,q[54]=E):E=q[54],q[55]!==ec||q[56]!==E?(B=(0,a.jsx)("input",{id:"debugInput",type:"checkbox",checked:ec,onChange:E}),q[55]=ec,q[56]=E,q[57]=B):B=q[57],q[58]===Symbol.for("react.memo_cache_sentinel")?(j=(0,a.jsx)("label",{htmlFor:"debugInput",children:"Debug?"}),q[58]=j):j=q[58],q[59]!==B?(R=(0,a.jsxs)("div",{className:oq.default.CheckboxField,children:[B,j]}),q[59]=B,q[60]=R):R=q[60],q[61]!==T||q[62]!==R?(N=(0,a.jsxs)("div",{className:oq.default.Group,children:[T,R]}),q[61]=T,q[62]=R,q[63]=N):N=q[63],q[64]!==Q||q[65]!==eu||q[66]!==ee?(A=eu?null:(0,a.jsxs)("div",{className:oq.default.Field,children:[(0,a.jsx)("label",{htmlFor:"fovInput",children:"FOV"}),(0,a.jsx)("input",{id:"fovInput",type:"range",min:75,max:120,step:5,value:Q,disabled:eu,onChange:e=>ee(parseInt(e.target.value))}),(0,a.jsx)("output",{htmlFor:"fovInput",children:Q})]}),q[64]=Q,q[65]=eu,q[66]=ee,q[67]=A):A=q[67],q[68]!==eu||q[69]!==eo||q[70]!==ei?(G=eu?null:(0,a.jsxs)("div",{className:oq.default.Field,children:[(0,a.jsx)("label",{htmlFor:"speedInput",children:"Speed"}),(0,a.jsx)("input",{id:"speedInput",type:"range",min:.1,max:5,step:.05,value:ei,disabled:eu,onChange:e=>eo(parseFloat(e.target.value))})]}),q[68]=eu,q[69]=eo,q[70]=ei,q[71]=G):G=q[71],q[72]!==A||q[73]!==G?(U=(0,a.jsxs)("div",{className:oq.default.Group,children:[A,G]}),q[72]=A,q[73]=G,q[74]=U):U=q[74],q[75]!==K||q[76]!==el||q[77]!==es?(L=K&&(0,a.jsx)("div",{className:oq.default.Group,children:(0,a.jsxs)("div",{className:oq.default.Field,children:[(0,a.jsx)("label",{htmlFor:"touchModeInput",children:"Joystick:"})," ",(0,a.jsxs)("select",{id:"touchModeInput",value:es,onChange:e=>el(e.target.value),children:[(0,a.jsx)("option",{value:"dualStick",children:"Dual Stick"}),(0,a.jsx)("option",{value:"moveLookStick",children:"Single Stick"})]})]})}),q[75]=K,q[76]=el,q[77]=es,q[78]=L):L=q[78],q[79]!==eh||q[80]!==y||q[81]!==_||q[82]!==N||q[83]!==U||q[84]!==L?(z=(0,a.jsxs)("div",{className:oq.default.Dropdown,ref:ef,id:"settingsPanel",tabIndex:-1,onKeyDown:ev,onBlur:ey,"data-open":eh,children:[y,_,N,U,L]}),q[79]=eh,q[80]=y,q[81]=_,q[82]=N,q[83]=U,q[84]=L,q[85]=z):z=q[85],q[86]!==z||q[87]!==u?(O=(0,a.jsxs)("div",{ref:ep,children:[u,z]}),q[86]=z,q[87]=u,q[88]=O):O=q[88],q[89]!==O||q[90]!==l?(V=(0,a.jsxs)("div",{id:"controls",className:oq.default.Controls,onKeyDown:oK,onPointerDown:oY,onClick:o$,children:[l,O]}),q[89]=O,q[90]=l,q[91]=V):V=q[91],V}function oW(e){return!e}function o$(e){return e.stopPropagation()}function oY(e){return e.stopPropagation()}function oK(e){return e.stopPropagation()}let oX=()=>null;var oZ=e.i(31067);let oJ=n.forwardRef(({envMap:e,resolution:t=256,frames:a=1/0,makeDefault:r,children:i,...s},l)=>{let c=(0,h.useThree)(({set:e})=>e),d=(0,h.useThree)(({camera:e})=>e),m=(0,h.useThree)(({size:e})=>e),f=n.useRef(null);n.useImperativeHandle(l,()=>f.current,[]);let g=n.useRef(null),p=function(e,t,a){let r=(0,h.useThree)(e=>e.size),i=(0,h.useThree)(e=>e.viewport),s="number"==typeof e?e:r.width*i.dpr,l=r.height*i.dpr,c=("number"==typeof e?void 0:e)||{},{samples:d=0,depth:u,...m}=c,f=null!=u?u:c.depthBuffer,g=n.useMemo(()=>{let e=new o.WebGLRenderTarget(s,l,{minFilter:o.LinearFilter,magFilter:o.LinearFilter,type:o.HalfFloatType,...m});return f&&(e.depthTexture=new o.DepthTexture(s,l,o.FloatType)),e.samples=d,e},[]);return n.useLayoutEffect(()=>{g.setSize(s,l),d&&(g.samples=d)},[d,g,s,l]),n.useEffect(()=>()=>g.dispose(),[]),g}(t);n.useLayoutEffect(()=>{s.manual||(f.current.aspect=m.width/m.height)},[m,s]),n.useLayoutEffect(()=>{f.current.updateProjectionMatrix()});let y=0,v=null,F="function"==typeof i;return(0,u.useFrame)(t=>{F&&(a===1/0||y<a)&&(g.current.visible=!1,t.gl.setRenderTarget(p),v=t.scene.background,e&&(t.scene.background=e),t.gl.render(t.scene,f.current),t.scene.background=v,t.gl.setRenderTarget(null),g.current.visible=!0,y++)}),n.useLayoutEffect(()=>{if(r)return c(()=>({camera:f.current})),()=>c(()=>({camera:d}))},[f,r,c]),n.createElement(n.Fragment,null,n.createElement("perspectiveCamera",(0,oZ.default)({ref:f},s),!F&&i),n.createElement("group",{ref:g},F&&i(p.texture)))});function oQ(){let e,t,n=(0,r.c)(3),{fov:i}=(0,v.useSettings)();return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=[0,256,0],n[0]=e):e=n[0],n[1]!==i?(t=(0,a.jsx)(oJ,{makeDefault:!0,position:e,fov:i}),n[1]=i,n[2]=t):t=n[2],t}var o0=e.i(51434),o1=e.i(86855),o2=e.i(71832),o3=n,o5=e.i(82816);class o4{states;seqIndexToName;currentStateIndex=0;delayTime=0;lastFireCount=-1;spinTimeScale=0;constructor(e,t){this.states=e,this.seqIndexToName=t,e.length>0&&(this.delayTime=e[0].timeoutValue??0)}get stateIndex(){return this.currentStateIndex}reset(){this.currentStateIndex=0,this.delayTime=this.states.length>0?this.states[0].timeoutValue??0:0,this.lastFireCount=-1}tick(e,t){if(0===this.states.length)return{sequenceName:null,isFiring:!1,spinTimeScale:0,reverse:!1,scaleAnimation:!1,timeoutValue:0,transitioned:!1,soundDataBlockIds:[],stateIndex:-1};let a=this.lastFireCount>=0&&t.fireCount!==this.lastFireCount;this.lastFireCount=t.fireCount;let r=[];if(a){let e=this.states.findIndex(e=>e.fire);if(e>=0&&e!==this.currentStateIndex){this.currentStateIndex=e,this.delayTime=this.states[e].timeoutValue??0;let t=this.states[e].soundDataBlockId;t>=0&&r.push(t)}}this.delayTime-=e;let n=a,i=this.evaluateTickTransitions(t),o=0;for(;i>=0&&o<32;){if(o++,n=!0,i===this.currentStateIndex){this.delayTime=this.states[i].timeoutValue??0;break}let e=this.states[this.currentStateIndex].spin,a=this.delayTime;this.currentStateIndex=i;let s=this.states[i].timeoutValue??0;this.delayTime=s;let l=this.states[i].soundDataBlockId;switch(l>=0&&r.push(l),this.states[i].spin){case 1:this.spinTimeScale=0;break;case 4:this.spinTimeScale=1;break;case 2:3===e&&s>0&&(this.delayTime*=1-a/s);break;case 3:2===e&&s>0&&(this.delayTime*=1-a/s)}i=this.evaluateEntryTransitions(t)}let s=this.states[this.currentStateIndex],l=s.timeoutValue??0;switch(s.spin){case 1:this.spinTimeScale=0;break;case 2:this.spinTimeScale=l>0?Math.max(0,1-this.delayTime/l):1;break;case 4:this.spinTimeScale=1;break;case 3:this.spinTimeScale=l>0?Math.max(0,this.delayTime/l):0}return{sequenceName:this.resolveSequenceName(s),isFiring:s.fire,spinTimeScale:this.spinTimeScale,reverse:!s.direction,scaleAnimation:s.scaleAnimation,timeoutValue:s.timeoutValue??0,transitioned:n,soundDataBlockIds:r,stateIndex:this.currentStateIndex}}evaluateTickTransitions(e){let t=this.states[this.currentStateIndex],a=this.delayTime<=0;if(!(a||!t.waitForTimeout))return -1;let r=this.evaluateConditions(t,e);if(-1!==r)return r;if(a){let e=t.transitionOnTimeout;if(-1!==e)return e}return -1}evaluateEntryTransitions(e){let t=this.states[this.currentStateIndex];return this.evaluateConditions(t,e)}evaluateConditions(e,t){let a=t.loaded?e.transitionOnLoaded:e.transitionOnNotLoaded;if(-1!==a)return a;let r=t.ammo?e.transitionOnAmmo:e.transitionOnNoAmmo;if(-1!==r)return r;let n=t.target?e.transitionOnTarget:e.transitionOnNoTarget;if(-1!==n)return n;let i=t.wet?e.transitionOnWet:e.transitionOnNotWet;if(-1!==i)return i;let o=t.triggerDown?e.transitionOnTriggerDown:e.transitionOnTriggerUp;return -1!==o?o:-1}resolveSequenceName(e){return null==e.sequence||e.sequence<0?null:this.seqIndexToName[e.sequence]??null}}var o6=e.i(43595),o8=e.i(29055);function o7(e,t,a){let r=e.current;if(r){(0,o8.untrackDemoSound)(r);try{r.stop()}catch{}r.disconnect(),a?.remove(r),e.current=null,t.current=-1}}function o9(e){let t,i,s,l,c,d,h,m,f,g,p,y,v,F,b,S,x,k,w,C=(0,r.c)(44),{entity:_,timeRef:P}=e,D=(0,I.useEngineStoreApi)(),M=(0,ev.useStaticShape)(_.dataBlock);C[0]!==_.dataBlock?(t=e=>{let t=_.dataBlock?.toLowerCase();return t?e.runtime.sequenceAliases.get(t):void 0},C[0]=_.dataBlock,C[1]=t):t=C[1];let T=(0,I.useEngineSelector)(t);C[2]!==M.scene?(c=o5.clone(M.scene),i=(0,o2.processShapeScene)(c),c.traverse(sn),l=new o.AnimationMixer(c),s=null,c.traverse(e=>{s||"Mount0"!==e.name||(s=e)}),C[2]=M.scene,C[3]=i,C[4]=s,C[5]=l,C[6]=c):(i=C[3],s=C[4],l=C[5],c=C[6]),C[7]!==i||C[8]!==s||C[9]!==l||C[10]!==c?(d={clonedScene:c,mixer:l,mount0:s,iflInitializers:i},C[7]=i,C[8]=s,C[9]=l,C[10]=c,C[11]=d):d=C[11];let{clonedScene:E,mixer:B,mount0:j,iflInitializers:R}=d;C[12]===Symbol.for("react.memo_cache_sentinel")?(h=new Map,C[12]=h):h=C[12];let N=(0,n.useRef)(h);C[13]===Symbol.for("react.memo_cache_sentinel")?(m={head:null,headside:null},C[13]=m):m=C[13];let A=(0,n.useRef)(m);C[14]===Symbol.for("react.memo_cache_sentinel")?(f=new Map,C[14]=f):f=C[14];let G=(0,n.useRef)(f),U=(0,n.useRef)(null);C[15]===Symbol.for("react.memo_cache_sentinel")?(g={name:"root",timeScale:1},C[15]=g):g=C[15];let L=(0,n.useRef)(g),z=(0,n.useRef)(!1);return C[16]!==M.animations||C[17]!==B||C[18]!==T?(p=()=>{let e=(0,o6.getAliasedActions)(M.animations,B,T);N.current=e;let t=e.get("root");t&&t.play(),L.current={name:"root",timeScale:1};let a={head:null,headside:null};for(let{key:e,names:t}of[{key:"head",names:["head"]},{key:"headside",names:["headside"]}]){let r=M.animations.find(e=>t.includes(e.name.toLowerCase()));if(!r)continue;let n=r.clone(),i=Math.round(30*r.duration/2);o.AnimationUtils.makeClipAdditive(n,i,r,30);let s=B.clipAction(n);s.blendMode=o.AdditiveAnimationBlendMode,s.timeScale=0,s.weight=1,s.play(),a[e]=s}A.current=a;let r=new Map,n=M.animations.find(sr),i=n?Math.round(30*n.duration/2):0;for(let e of["lookde","lookms","looksn"]){let t=M.animations.find(t=>t.name.toLowerCase()===e);if(!t)continue;let a=t.clone(),s=n??t;o.AnimationUtils.makeClipAdditive(a,i,s,30);let l=B.clipAction(a);l.blendMode=o.AdditiveAnimationBlendMode,l.timeScale=0,l.weight=0,l.play(),r.set(e,l)}G.current=r;let s=r.get("lookde");return s&&(s.weight=1,U.current="lookde"),B.update(0),()=>{B.stopAllAction(),N.current=new Map,A.current={head:null,headside:null},G.current=new Map,U.current=null}},y=[B,M.animations,T],C[16]=M.animations,C[17]=B,C[18]=T,C[19]=p,C[20]=y):(p=C[19],y=C[20]),(0,n.useEffect)(p,y),C[21]!==R||C[22]!==P?(v=()=>{let e=[];for(let{mesh:t,initialize:a}of R)a(t,()=>P.current).then(t=>e.push(t)).catch(sa);return()=>e.forEach(st)},C[21]=R,C[22]=P,C[23]=v):v=C[23],C[24]!==R?(F=[R],C[24]=R,C[25]=F):F=C[25],(0,n.useEffect)(v,F),C[26]!==D||C[27]!==_.headPitch||C[28]!==_.headYaw||C[29]!==_.keyframes||C[30]!==_.weaponShape||C[31]!==B||C[32]!==P?(b=(e,t)=>{let a=D.getState().playback,r="playing"===a.status,n=P.current,i=(0,o2.getKeyframeAtTime)(_.keyframes,n),s=i?.damageState!=null&&i.damageState>=1,l=N.current;if(s&&!z.current){z.current=!0;let e=[...l.keys()].filter(se);if(e.length>0){let t=e[Math.floor(Math.random()*e.length)],a=l.get(L.current.name.toLowerCase());a&&a.fadeOut(o2.ANIM_TRANSITION_TIME);let r=l.get(t);r.setLoop(o.LoopOnce,1),r.clampWhenFinished=!0,r.reset().fadeIn(o2.ANIM_TRANSITION_TIME).play(),L.current={name:t,timeScale:1}}}if(!s&&z.current){z.current=!1;let e=l.get(L.current.name.toLowerCase());e&&(e.stop(),e.setLoop(o.LoopRepeat,1/0),e.clampWhenFinished=!1),L.current={name:"root",timeScale:1};let t=l.get("root");t&&t.reset().play()}if(!z.current){let e=function(e,t){if(!e)return{animation:"root",timeScale:1};let[a,r,n]=e;if(n<-10)return{animation:"fall",timeScale:1};let i=-2*Math.atan2(t[1],t[3]),o=Math.cos(i),s=Math.sin(i),l=a*o+r*s,c=-a*s+r*o,d=-c,u=-l,h=Math.max(c,d,u,l);return h<.1?{animation:"root",timeScale:1}:h===c?{animation:"run",timeScale:1}:h===d?{animation:"back",timeScale:1}:h===u?{animation:"side",timeScale:1}:{animation:"side",timeScale:-1}}(i?.velocity,i?.rotation??[0,0,0,1]),t=L.current;if(e.animation!==t.name||e.timeScale!==t.timeScale){let a=l.get(t.name.toLowerCase()),n=l.get(e.animation.toLowerCase());n&&(r&&a&&a!==n?(a.fadeOut(o2.ANIM_TRANSITION_TIME),n.reset().fadeIn(o2.ANIM_TRANSITION_TIME).play()):(a&&a!==n&&a.stop(),n.reset().play()),n.timeScale=e.timeScale,L.current={name:e.animation,timeScale:e.timeScale})}}let c=function(e){if(!e)return"lookde";let t=e.toLowerCase();return t.includes("missile")?"lookms":t.includes("sniper")?"looksn":"lookde"}(_.weaponShape);if(c!==U.current){let e=G.current,t=U.current?e.get(U.current):null,a=e.get(c);a&&(t&&(t.weight=0),a.weight=+!s,U.current=c)}let{head:d,headside:u}=A.current,h=U.current?G.current.get(U.current):null,m=+!s,f=_.headPitch??0,g=_.headYaw??0,p=(f+1)/2;h&&(h.time=p*h.getClip().duration,h.weight=m),d&&(d.time=p*d.getClip().duration,d.weight=m),u&&(u.time=(g+1)/2*u.getClip().duration,u.weight=m),r?B.update(t*a.rate):B.update(0)},C[26]=D,C[27]=_.headPitch,C[28]=_.headYaw,C[29]=_.keyframes,C[30]=_.weaponShape,C[31]=B,C[32]=P,C[33]=b):b=C[33],(0,u.useFrame)(b),C[34]===Symbol.for("react.memo_cache_sentinel")?(S=[0,Math.PI/2,0],C[34]=S):S=C[34],C[35]!==E?(x=(0,a.jsx)("group",{rotation:S,children:(0,a.jsx)("primitive",{object:E})}),C[35]=E,C[36]=x):x=C[36],C[37]!==_||C[38]!==j||C[39]!==P?(k=_.weaponShape&&j&&(0,a.jsx)(sA,{fallback:null,children:(0,a.jsx)(n.Suspense,{fallback:null,children:(0,a.jsx)(si,{entity:_,mount0:j,timeRef:P})})}),C[37]=_,C[38]=j,C[39]=P,C[40]=k):k=C[40],C[41]!==x||C[42]!==k?(w=(0,a.jsxs)(a.Fragment,{children:[x,k]}),C[41]=x,C[42]=k,C[43]=w):w=C[43],w}function se(e){return e.startsWith("death")}function st(e){return e()}function sa(){}function sr(e){return"lookde"===e.name.toLowerCase()}function sn(e){if(e.isMesh&&e.material)for(let t of Array.isArray(e.material)?e.material:[e.material])t.side=o.FrontSide}function si(e){let t,a,i,s,l,d,h,m,f,g,p,y,F,b,S=(0,r.c)(40),{entity:x,mount0:k,timeRef:w}=e,C=(0,I.useEngineStoreApi)(),_=(0,ev.useStaticShape)(x.weaponShape);if(S[0]!==_.animations||S[1]!==_.scene){t=o5.clone(_.scene),a=(0,o2.processShapeScene)(t);let e=(0,o2.getPosedNodeTransform)(_.scene,_.animations,"Mountpoint");if(e){let a=e.quaternion.clone().invert(),r=e.position.clone().negate().applyQuaternion(a);t.position.copy(r),t.quaternion.copy(a)}s=new Map,t.traverse(e=>{if(!e.isMesh)return;let t=e.userData,a=(t?.vis_sequence??"").toLowerCase();if(!a)return;let r=s.get(a);r||(r=[],s.set(a,r)),r.push(e)}),i=new o.AnimationMixer(t),S[0]=_.animations,S[1]=_.scene,S[2]=t,S[3]=a,S[4]=i,S[5]=s}else t=S[2],a=S[3],i=S[4],s=S[5];let P=i,D=_.scene;S[6]!==D||S[7]!==_.animations?(l=function(e,t){let a=e.userData?.dts_sequence_names;if("string"==typeof a)try{return JSON.parse(a).map(e=>e.toLowerCase())}catch{}return t.map(e=>e.name.toLowerCase())}(D,_.animations),S[6]=D,S[7]=_.animations,S[8]=l):l=S[8];let M=l;S[9]!==t||S[10]!==a||S[11]!==P||S[12]!==M||S[13]!==s?(d={weaponClone:t,weaponMixer:P,seqIndexToName:M,visNodesBySequence:s,weaponIflInitializers:a},S[9]=t,S[10]=a,S[11]=P,S[12]=M,S[13]=s,S[14]=d):d=S[14];let{weaponClone:T,weaponMixer:E,seqIndexToName:B,visNodesBySequence:j,weaponIflInitializers:R}=d;S[15]===Symbol.for("react.memo_cache_sentinel")?(h=new Map,S[15]=h):h=S[15];let N=(0,n.useRef)(h),A=(0,n.useRef)(null);S[16]!==_.animations||S[17]!==E?(m=()=>{let e=new Map;for(let t of _.animations)e.set(t.name.toLowerCase(),E.clipAction(t));N.current=e;let t=e.get("spin");return t&&(t.setLoop(o.LoopRepeat,1/0),t.timeScale=0,t.play()),A.current=t??null,E.update(0),()=>{E.stopAllAction(),N.current=new Map,A.current=null,o7(H,W)}},f=[E,_.animations],S[16]=_.animations,S[17]=E,S[18]=m,S[19]=f):(m=S[18],f=S[19]),(0,n.useEffect)(m,f),S[20]!==w||S[21]!==R?(g=()=>{let e=[];for(let{mesh:t,initialize:a}of R)a(t,()=>w.current).then(t=>e.push(t)).catch(ss);return()=>e.forEach(so)},S[20]=w,S[21]=R,S[22]=g):g=S[22],S[23]!==R?(p=[R],S[23]=R,S[24]=p):p=S[24],(0,n.useEffect)(g,p);let{audioLoader:G,audioListener:U}=(0,o0.useAudio)(),L=(0,v.useSettings)(),z=L?.audioEnabled??!1,O=(0,n.useRef)(null),V=(0,n.useRef)(null),q=(0,n.useRef)(x.weaponImageStates),H=(0,n.useRef)(null),W=(0,n.useRef)(-1);return S[25]!==k||S[26]!==T?(y=()=>(k.add(T),()=>{k.remove(T)}),F=[T,k],S[25]=k,S[26]=T,S[27]=y,S[28]=F):(y=S[27],F=S[28]),(0,n.useEffect)(y,F),S[29]!==z||S[30]!==U||S[31]!==G||S[32]!==C||S[33]!==x.weaponImageState||S[34]!==x.weaponImageStates||S[35]!==B||S[36]!==j||S[37]!==T||S[38]!==E?(b=(e,t)=>{let a=C.getState().playback,r="playing"===a.status,n=N.current,i=x.weaponImageState,s=x.weaponImageStates;s!==q.current&&(q.current=s,s&&s.length>0?O.current=new o4(s,B):O.current=null,V.current=null,o7(H,W,T)),!O.current&&s&&s.length>0&&(O.current=new o4(s,B));let l=O.current;if(l&&i&&r){let e=t*a.rate,r=l.tick(e,i);if(function(e,t,a,r){let n=e.sequenceName,i=a.current;if(n===i&&!e.transitioned)return;if(n!==i){if(i){let e=r.get(i);if(e)for(let t of e)t.visible=!1}if(n){let e=r.get(n);if(e)for(let t of e)t.visible=!0}}if(!n){if(i){let e=t.get(i);e&&e.fadeOut(o2.ANIM_TRANSITION_TIME),a.current=null}return}let s=t.get(n);if(s&&(e.transitioned||n!==i)){let r=i?t.get(i):null;if(e.isFiring||e.timeoutValue>0?(s.setLoop(o.LoopOnce,1),s.clampWhenFinished=!0):(s.setLoop(o.LoopRepeat,1/0),s.clampWhenFinished=!1),e.scaleAnimation&&e.timeoutValue>0){let t=s.getClip().duration;s.timeScale=t>0?t/e.timeoutValue:1}else s.timeScale=e.reverse?-1:1;r&&r!==s?(r.fadeOut(o2.ANIM_TRANSITION_TIME),s.reset().fadeIn(o2.ANIM_TRANSITION_TIME).play()):s.reset().play(),a.current=n}}(r,n,V,j),H.current&&r.stateIndex!==W.current&&o7(H,W,T),z&&G&&U&&r.soundDataBlockIds.length>0){let e=a.recording?.streamingPlayback.getDataBlockData.bind(a.recording.streamingPlayback);if(e)for(let t of r.soundDataBlockIds){let r=(0,o8.resolveAudioProfile)(t,e);if(r)if(r.isLooping){if(!H.current)try{let e=(0,c.audioToUrl)(r.filename);(0,o8.getCachedAudioBuffer)(e,G,e=>{if(H.current)return;let t=l.stateIndex,n=new o.PositionalAudio(U);n.setBuffer(e),n.setDistanceModel("inverse"),n.setRefDistance(r.refDist),n.setMaxDistance(r.maxDist),n.setRolloffFactor(1),n.setVolume(r.volume),n.setPlaybackRate(a.rate),n.setLoop(!0),T.add(n),(0,o8.trackDemoSound)(n),n.play(),H.current=n,W.current=t})}catch{}}else(0,o8.playOneShotSound)(r,U,G,void 0,T)}}A.current&&(A.current.timeScale=r.spinTimeScale)}r?E.update(t*a.rate):E.update(0)},S[29]=z,S[30]=U,S[31]=G,S[32]=C,S[33]=x.weaponImageState,S[34]=x.weaponImageStates,S[35]=B,S[36]=j,S[37]=T,S[38]=E,S[39]=b):b=S[39],(0,u.useFrame)(b),null}function so(e){return e()}function ss(){}function sl(e){let t,a,i=(0,r.c)(7),{shapeName:o,eyeOffsetRef:s}=e,l=(0,ev.useStaticShape)(o);return i[0]!==s||i[1]!==l.animations||i[2]!==l.scene?(t=()=>{let e=(0,o2.getPosedNodeTransform)(l.scene,l.animations,"Eye");e?s.current.set(e.position.z,e.position.y,-e.position.x):s.current.set(0,o2.DEFAULT_EYE_HEIGHT,0)},i[0]=s,i[1]=l.animations,i[2]=l.scene,i[3]=t):t=i[3],i[4]!==s||i[5]!==l?(a=[l,s],i[4]=s,i[5]=l,i[6]=a):a=i[6],(0,n.useEffect)(t,a),null}var sc=e.i(71505);function sd(e){let t,n,i,o=(0,r.c)(8),{shapeName:s,entityId:l,threads:c}=e,d="number"==typeof l?l:0;o[0]!==d?(t={_class:"player",_className:"Player",_id:d},o[0]=d,o[1]=t):t=o[1];let u=t;return o[2]!==c?(n=(0,a.jsx)(ev.ShapeRenderer,{loadingColor:"#00ff88",demoThreads:c}),o[2]=c,o[3]=n):n=o[3],o[4]!==s||o[5]!==n||o[6]!==u?(i=(0,a.jsx)(eF.ShapeInfoProvider,{object:u,shapeName:s,type:"StaticShape",children:n}),o[4]=s,o[5]=n,o[6]=u,o[7]=i):i=o[7],i}function su({shapeName:e,playerShapeName:t}){let r=(0,ev.useStaticShape)(t),i=(0,ev.useStaticShape)(e),o=(0,n.useMemo)(()=>{let t,a,n=function(e){if(!e)return"lookde";let t=e.toLowerCase();return t.includes("missile")?"lookms":t.includes("sniper")?"looksn":"lookde"}(e),o=(0,o2.getPosedNodeTransform)(r.scene,r.animations,"Mount0",[n]);if(!o)return{position:void 0,quaternion:void 0};let s=(0,o2.getPosedNodeTransform)(i.scene,i.animations,"Mountpoint");if(s){let e=s.quaternion.clone().invert(),r=s.position.clone().negate().applyQuaternion(e);a=o.quaternion.clone().multiply(e),t=r.clone().applyQuaternion(o.quaternion).add(o.position)}else t=o.position.clone(),a=o.quaternion.clone();return{position:t.applyQuaternion(o2._r90),quaternion:o2._r90.clone().multiply(a).multiply(o2._r90inv)}},[r,i]),s=(0,n.useMemo)(()=>({_class:"weapon",_className:"Weapon",_id:0}),[]);return(0,a.jsx)(eF.ShapeInfoProvider,{object:s,shapeName:e,type:"Item",children:(0,a.jsx)("group",{position:o.position,quaternion:o.quaternion,children:(0,a.jsx)(ev.ShapeRenderer,{loadingColor:"#4488ff"})})})}function sh({entity:e,playback:t}){let r=(0,ev.useStaticShape)(e.dataBlock),i=(0,n.useRef)(null),s=(0,n.useRef)((0,I.demoEffectNow)()),l=(0,n.useRef)(Math.random()*Math.PI*2),c=(0,n.useRef)([]),d=(0,n.useMemo)(()=>{if(e.explosionDataBlockId)return t.getDataBlockData(e.explosionDataBlockId)},[e.explosionDataBlockId,t]),h=(0,n.useMemo)(()=>d?function(e){let t=e.sizes,a=e.times;if(!Array.isArray(t)||0===t.length)return{times:[0,1],sizes:[[1,1,1],[1,1,1]]};let r=t.map(e=>[e.x/100,e.y/100,e.z/100]);return{times:Array.isArray(a)?a:r.map((e,t)=>t/Math.max(r.length-1,1)),sizes:r}}(d):void 0,[d]),m=(0,n.useMemo)(()=>{let e=d?.explosionScale;return e?[e.x/100,e.y/100,e.z/100]:[1,1,1]},[d]),f=32*(d?.lifetimeMS??31),g=!1!==e.faceViewer,{scene:p,mixer:y,visNodes:v,iflInfos:F,materials:b}=(0,n.useMemo)(()=>{let e=o5.clone(r.scene),t=[];e.traverse(e=>{if(!e.isMesh||!e.material)return;let a=Array.isArray(e.material)?e.material[0]:e.material;if(!a?.userData)return;let r=new Set(a.userData.flag_names??[]),n=a.userData.resource_path;if(r.has("IflMaterial")&&n){let a=e.userData;t.push({mesh:e,iflPath:`textures/${n}.ifl`,sequenceName:a?.ifl_sequence?String(a.ifl_sequence).toLowerCase():void 0,duration:a?.ifl_duration?Number(a.ifl_duration):void 0,cyclic:a?.ifl_sequence?!!a.ifl_cyclic:void 0,toolBegin:a?.ifl_tool_begin!=null?Number(a.ifl_tool_begin):void 0})}}),(0,o2.processShapeScene)(e);let a=[];for(let t of(e.traverse(e=>{if(!e.isMesh)return;let t=e.userData;if(!t)return;let r=t.vis_keyframes,n=t.vis_duration,i=(t.vis_sequence??"").toLowerCase();i&&Array.isArray(r)&&!(r.length<=1)&&n&&!(n<=0)&&"ambient"===i&&a.push({mesh:e,keyframes:r,duration:n,cyclic:!!t.vis_cyclic})}),a))t.mesh.visible=!0,t.mesh.material&&!Array.isArray(t.mesh.material)&&(t.mesh.material.transparent=!0,t.mesh.material.depthWrite=!1);for(let e of t)e.mesh.userData?.vis_sequence||(e.mesh.visible=!0);let n=new Map;for(let e of r.animations)n.set(e.name.toLowerCase(),e);let i=n.get("ambient"),s=null;if(i){let t=(s=new o.AnimationMixer(e)).clipAction(i);t.setLoop(o.LoopOnce,1),t.clampWhenFinished=!0,t.timeScale=(d?.playSpeed??20)/20,t.play()}let l=[];return e.traverse(e=>{e.isMesh&&(Array.isArray(e.material)?l.push(...e.material):e.material&&l.push(e.material))}),e.traverse(e=>{e.frustumCulled=!1}),{scene:e,mixer:s,visNodes:a,iflInfos:t,materials:l}},[r,d]);return(0,n.useEffect)(()=>{for(let e of(c.current=[],F))(0,sc.loadIflAtlas)(e.iflPath).then(t=>{let a=Array.isArray(e.mesh.material)?e.mesh.material[0]:e.mesh.material;a&&(a.map=t.texture,a.needsUpdate=!0),c.current.push({atlas:t,info:e})}).catch(()=>{})},[F]),(0,u.useFrame)((e,t)=>{let a=i.current;if(!a)return;let r=I.engineStore.getState().playback,n="playing"===r.status?t*r.rate:0,o=(0,I.demoEffectNow)()-s.current,d=Math.min(o/f,1),u=o/1e3;y&&y.update(n);let p=d>.8?1-(d-.8)/.2:1;for(let{mesh:e,keyframes:t,duration:a,cyclic:r}of v){let n=e.material;if(!n||Array.isArray(n))continue;let i=u/a,o=r?i%1:Math.min(i,1),s=t.length,l=o*s,c=Math.floor(l)%s,d=(c+1)%s,h=l-Math.floor(l);n.opacity=(t[c]+(t[d]-t[c])*h)*p}if(p<1)for(let e of b)"opacity"in e&&(e.transparent=!0,e.opacity*=p);for(let{atlas:e,info:t}of c.current){let a;a=t.sequenceName&&t.duration?(t.cyclic?u/t.duration%1:Math.min(u/t.duration,1))*t.duration+(t.toolBegin??0):u,(0,sc.updateAtlasFrame)(e,(0,sc.getFrameIndexForTime)(e,a))}if(h){let e=function(e,t){let{times:a,sizes:r}=e;if(0===a.length)return[1,1,1];if(t<=a[0])return r[0];if(t>=a[a.length-1])return r[r.length-1];for(let e=0;e<a.length-1;e++)if(t>=a[e]&&t<=a[e+1]){let n=(t-a[e])/(a[e+1]-a[e]);return[r[e][0]+(r[e+1][0]-r[e][0])*n,r[e][1]+(r[e+1][1]-r[e][1])*n,r[e][2]+(r[e+1][2]-r[e][2])*n]}return r[r.length-1]}(h,d);a.scale.set(e[0]*m[0],e[1]*m[1],e[2]*m[2])}g&&(a.lookAt(e.camera.position),a.rotateZ(l.current))}),(0,a.jsx)("group",{ref:i,children:(0,a.jsx)("group",{rotation:[0,Math.PI,0],children:(0,a.jsx)("primitive",{object:p})})})}let sm=new o.Vector3,sf=new o.Vector3,sg=new o.Vector3,sp=new o.Vector3,sy=new o.Vector3,sv=new o.Vector3,sF=new o.Vector3(0,1,0);function sb(e){let t,n,i,s,l,d=(0,r.c)(14),{visual:u}=e;d[0]!==u.texture?(t=(0,c.textureToUrl)(u.texture),d[0]=u.texture,d[1]=t):t=d[1];let h=t,m=(0,g.useTexture)(h,sS),f=Array.isArray(m)?m[0]:m;d[2]!==u.color.b||d[3]!==u.color.g||d[4]!==u.color.r?(n=new o.Color().setRGB(u.color.r,u.color.g,u.color.b,o.SRGBColorSpace),d[2]=u.color.b,d[3]=u.color.g,d[4]=u.color.r,d[5]=n):n=d[5];let p=n;return d[6]!==u.size?(i=[u.size,u.size,1],d[6]=u.size,d[7]=i):i=d[7],d[8]!==p||d[9]!==f?(s=(0,a.jsx)("spriteMaterial",{map:f,color:p,transparent:!0,blending:o.AdditiveBlending,depthWrite:!1,toneMapped:!1}),d[8]=p,d[9]=f,d[10]=s):s=d[10],d[11]!==i||d[12]!==s?(l=(0,a.jsx)("sprite",{scale:i,children:s}),d[11]=i,d[12]=s,d[13]=l):l=d[13],l}function sS(e){let t=Array.isArray(e)?e[0]:e;(0,o2.setupEffectTexture)(t)}function sx(e){let t,i,s,l,d,h,m,f,p,y,v,F,b=(0,r.c)(28),{entity:S,visual:x}=e,k=(0,n.useRef)(null),w=(0,n.useRef)(null),I=(0,n.useRef)(null);b[0]===Symbol.for("react.memo_cache_sentinel")?(t=new o.Quaternion,b[0]=t):t=b[0];let C=(0,n.useRef)(t);b[1]!==x.texture?(i=(0,c.textureToUrl)(x.texture),b[1]=x.texture,b[2]=i):i=b[2];let _=x.crossTexture??x.texture;b[3]!==_?(s=(0,c.textureToUrl)(_),b[3]=_,b[4]=s):s=b[4],b[5]!==i||b[6]!==s?(l=[i,s],b[5]=i,b[6]=s,b[7]=l):l=b[7];let P=l,D=(0,g.useTexture)(P,sk);b[8]!==D?(d=Array.isArray(D)?D:[D,D],b[8]=D,b[9]=d):d=b[9];let[M,T]=d;return b[10]!==S||b[11]!==x.crossSize||b[12]!==x.crossViewAng||b[13]!==x.renderCross||b[14]!==x.tracerLength||b[15]!==x.tracerWidth?(h=e=>{let{camera:t}=e,a=k.current,r=w.current;if(!a||!r)return;let n=S.keyframes[0],i=n?.position,o=S.direction??n?.velocity;if(!i||!o||((0,o2.torqueVecToThree)(o,sm),1e-8>sm.lengthSq())){a.visible=!1,I.current&&(I.current.visible=!1);return}sm.normalize(),a.visible=!0,(0,o2.torqueVecToThree)(i,sv),sf.copy(sv).sub(t.position),sg.crossVectors(sf,sm),1e-8>sg.lengthSq()&&(sg.crossVectors(sF,sm),1e-8>sg.lengthSq()&&sg.set(1,0,0)),sg.normalize().multiplyScalar(x.tracerWidth);let s=.5*x.tracerLength;sp.copy(sm).multiplyScalar(-s),sy.copy(sm).multiplyScalar(s);let l=r.array;l[0]=sp.x+sg.x,l[1]=sp.y+sg.y,l[2]=sp.z+sg.z,l[3]=sp.x-sg.x,l[4]=sp.y-sg.y,l[5]=sp.z-sg.z,l[6]=sy.x-sg.x,l[7]=sy.y-sg.y,l[8]=sy.z-sg.z,l[9]=sy.x+sg.x,l[10]=sy.y+sg.y,l[11]=sy.z+sg.z,r.needsUpdate=!0;let c=I.current;if(!c)return;if(!x.renderCross){c.visible=!1;return}sf.normalize();let d=sm.dot(sf);if(d>-x.crossViewAng&&d<x.crossViewAng){c.visible=!1;return}c.visible=!0,(0,o2.setQuaternionFromDir)(sm,C.current),c.quaternion.copy(C.current),c.scale.setScalar(x.crossSize)},b[10]=S,b[11]=x.crossSize,b[12]=x.crossViewAng,b[13]=x.renderCross,b[14]=x.tracerLength,b[15]=x.tracerWidth,b[16]=h):h=b[16],(0,u.useFrame)(h),b[17]===Symbol.for("react.memo_cache_sentinel")?(m=(0,a.jsx)("bufferAttribute",{ref:w,attach:"attributes-position",args:[new Float32Array(12),3]}),b[17]=m):m=b[17],b[18]===Symbol.for("react.memo_cache_sentinel")?(f=(0,a.jsx)("bufferAttribute",{attach:"attributes-uv",args:[new Float32Array([0,0,0,1,1,1,1,0]),2]}),b[18]=f):f=b[18],b[19]===Symbol.for("react.memo_cache_sentinel")?(p=(0,a.jsxs)("bufferGeometry",{children:[m,f,(0,a.jsx)("bufferAttribute",{attach:"index",args:[new Uint16Array([0,1,2,0,2,3]),1]})]}),b[19]=p):p=b[19],b[20]!==M?(y=(0,a.jsxs)("mesh",{ref:k,children:[p,(0,a.jsx)("meshBasicMaterial",{map:M,transparent:!0,blending:o.AdditiveBlending,side:o.DoubleSide,depthWrite:!1,toneMapped:!1})]}),b[20]=M,b[21]=y):y=b[21],b[22]!==T||b[23]!==x.renderCross?(v=x.renderCross?(0,a.jsxs)("mesh",{ref:I,children:[(0,a.jsxs)("bufferGeometry",{children:[(0,a.jsx)("bufferAttribute",{attach:"attributes-position",args:[new Float32Array([-.5,0,-.5,.5,0,-.5,.5,0,.5,-.5,0,.5]),3]}),(0,a.jsx)("bufferAttribute",{attach:"attributes-uv",args:[new Float32Array([0,0,0,1,1,1,1,0]),2]}),(0,a.jsx)("bufferAttribute",{attach:"index",args:[new Uint16Array([0,1,2,0,2,3]),1]})]}),(0,a.jsx)("meshBasicMaterial",{map:T,transparent:!0,blending:o.AdditiveBlending,side:o.DoubleSide,depthWrite:!1,toneMapped:!1})]}):null,b[22]=T,b[23]=x.renderCross,b[24]=v):v=b[24],b[25]!==y||b[26]!==v?(F=(0,a.jsxs)(a.Fragment,{children:[y,v]}),b[25]=y,b[26]=v,b[27]=F):F=b[27],F}function sk(e){for(let t of Array.isArray(e)?e:[e])(0,o2.setupEffectTexture)(t)}var sw=e.i(60099),sI=e.i(29418);let sC=(0,c.textureToUrl)("gui/hud_alliedtriangle"),s_=(0,c.textureToUrl)("gui/hud_enemytriangle"),sP=new o.Vector3;function sD(e){let t,i,s,l,c,d,m=(0,r.c)(22),{entity:f,timeRef:g}=e,p=(0,ev.useStaticShape)(f.dataBlock),{camera:y}=(0,h.useThree)(),v=(0,n.useRef)(null),F=(0,n.useRef)(null),b=(0,n.useRef)(null),S=(0,n.useRef)(null),x=(0,n.useRef)(null),[k,w]=(0,n.useState)(!0);e:{if(f.playerName){t=f.playerName;break e}if("string"==typeof f.id){let e;if(m[0]!==f.id){let t;m[2]===Symbol.for("react.memo_cache_sentinel")?(t=/^player_/,m[2]=t):t=m[2],e=f.id.replace(t,"Player "),m[0]=f.id,m[1]=e}else e=m[1];t=e;break e}t=`Player ${f.id}`}let I=t;m[3]!==p.scene?(i=new o.Box3().setFromObject(p.scene),m[3]=p.scene,m[4]=i):i=m[4];let C=i.max.y+.1;m[5]!==f.keyframes?(s=f.keyframes.some(sM),m[5]=f.keyframes,m[6]=s):s=m[6];let _=s;m[7]!==y||m[8]!==f.iffColor||m[9]!==f.keyframes||m[10]!==_||m[11]!==k||m[12]!==g?(l=()=>{let e=v.current;if(!e)return;e.getWorldPosition(sP);let t=y.position.distanceTo(sP),a=y.matrixWorld.elements,r=!(-((sP.x-a[12])*a[8])+-((sP.y-a[13])*a[9])+-((sP.z-a[14])*a[10])<0)&&t<150;if(k!==r&&w(r),!r)return;let n=(0,o2.getKeyframeAtTime)(f.keyframes,g.current),i=n?.health??1;if(n?.damageState!=null&&n.damageState>=1){F.current&&(F.current.style.opacity="0"),b.current&&(b.current.style.opacity="0");return}let o=Math.max(0,Math.min(1,1-t/150)).toString();if(F.current&&(F.current.style.opacity=o),b.current&&(b.current.style.opacity=o),x.current&&f.iffColor){let e=f.iffColor.r>f.iffColor.g?s_:sC;x.current.src!==e&&(x.current.src=e)}S.current&&_&&(S.current.style.width=`${Math.max(0,Math.min(100,100*i))}%`,S.current.style.background=f.iffColor?`rgb(${f.iffColor.r}, ${f.iffColor.g}, ${f.iffColor.b})`:"")},m[7]=y,m[8]=f.iffColor,m[9]=f.keyframes,m[10]=_,m[11]=k,m[12]=g,m[13]=l):l=m[13],(0,u.useFrame)(l);let P=f.iffColor&&f.iffColor.r>f.iffColor.g?s_:sC;return m[14]!==I||m[15]!==_||m[16]!==C||m[17]!==P||m[18]!==k?(c=k&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(sw.Html,{position:[0,C,0],center:!0,children:(0,a.jsx)("div",{ref:F,className:sI.default.Top,children:(0,a.jsx)("img",{ref:x,className:sI.default.IffArrow,src:P,alt:""})})}),(0,a.jsx)(sw.Html,{position:[0,-.2,0],center:!0,children:(0,a.jsxs)("div",{ref:b,className:sI.default.Bottom,children:[(0,a.jsx)("div",{className:sI.default.Name,children:I}),_&&(0,a.jsx)("div",{className:sI.default.HealthBar,children:(0,a.jsx)("div",{ref:S,className:sI.default.HealthFill})})]})})]}),m[14]=I,m[15]=_,m[16]=C,m[17]=P,m[18]=k,m[19]=c):c=m[19],m[20]!==c?(d=(0,a.jsx)("group",{ref:v,children:c}),m[20]=c,m[21]=d):d=m[21],d}function sM(e){return null!=e.health}var sT=e.i(78779);let sE=(0,c.textureToUrl)("commander/MiniIcons/com_flag_grey"),sB=new o.Vector3;function sj(e){let t,i,o,s,l,c=(0,r.c)(9),{entity:d}=e,m=(0,n.useRef)(null),f=(0,n.useRef)(null),g=(0,n.useRef)(null),{camera:p}=(0,h.useThree)();c[0]!==p||c[1]!==d.iffColor?(t=()=>{if(f.current&&d.iffColor){let{r:e,g:t,b:a}=d.iffColor;f.current.style.backgroundColor=`rgb(${e},${t},${a})`}if(g.current&&m.current){m.current.getWorldPosition(sB);let e=p.position.distanceTo(sB);g.current.textContent=e.toFixed(1)}},c[0]=p,c[1]=d.iffColor,c[2]=t):t=c[2],(0,u.useFrame)(t);let y=d.iffColor?`rgb(${d.iffColor.r},${d.iffColor.g},${d.iffColor.b})`:"rgb(200,200,200)";c[3]===Symbol.for("react.memo_cache_sentinel")?(i=[0,1.5,0],c[3]=i):i=c[3],c[4]===Symbol.for("react.memo_cache_sentinel")?(o=(0,a.jsx)("span",{ref:g,className:sT.default.Distance}),c[4]=o):o=c[4],c[5]!==y?(s={backgroundColor:y,"--flag-icon-url":`url(${sE})`},c[5]=y,c[6]=s):s=c[6];let v=s;return c[7]!==v?(l=(0,a.jsx)("group",{ref:m,children:(0,a.jsx)(sw.Html,{position:i,center:!0,children:(0,a.jsxs)("div",{className:sT.default.Root,children:[o,(0,a.jsx)("div",{ref:f,className:sT.default.Icon,style:v})]})})}),c[7]=v,c[8]=l):l=c[8],l}let sR=(0,o3.memo)(function(e){let t,n,i,o,s,l,c,d,u,h=(0,r.c)(100),{entity:m,timeRef:f,playback:g}=e,p=(0,v.useDebug)(),y=p?.debugMode??!1,F=(0,I.useEngineSelector)(sG),b=String(m.id);if(m.visual?.kind==="tracer"){let e,t,r,n,i;return h[0]===Symbol.for("react.memo_cache_sentinel")?(e={demoVisualKind:"tracer"},h[0]=e):e=h[0],h[1]!==m?(t=(0,a.jsx)(o3.Suspense,{fallback:null,children:(0,a.jsx)(sx,{entity:m,visual:m.visual})}),h[1]=m,h[2]=t):t=h[2],h[3]!==y||h[4]!==m?(r=y?(0,a.jsx)(sN,{entity:m}):null,h[3]=y,h[4]=m,h[5]=r):r=h[5],h[6]!==t||h[7]!==r?(n=(0,a.jsxs)("group",{name:"model",userData:e,children:[t,r]}),h[6]=t,h[7]=r,h[8]=n):n=h[8],h[9]!==b||h[10]!==n?(i=(0,a.jsx)("group",{name:b,children:n}),h[9]=b,h[10]=n,h[11]=i):i=h[11],i}if(m.visual?.kind==="sprite"){let e,t,r,n,i;return h[12]===Symbol.for("react.memo_cache_sentinel")?(e={demoVisualKind:"sprite"},h[12]=e):e=h[12],h[13]!==m.visual?(t=(0,a.jsx)(o3.Suspense,{fallback:null,children:(0,a.jsx)(sb,{visual:m.visual})}),h[13]=m.visual,h[14]=t):t=h[14],h[15]!==y||h[16]!==m?(r=y?(0,a.jsx)(sN,{entity:m}):null,h[15]=y,h[16]=m,h[17]=r):r=h[17],h[18]!==t||h[19]!==r?(n=(0,a.jsxs)("group",{name:"model",userData:e,children:[t,r]}),h[18]=t,h[19]=r,h[20]=n):n=h[20],h[21]!==b||h[22]!==n?(i=(0,a.jsx)("group",{name:b,children:n}),h[21]=b,h[22]=n,h[23]=i):i=h[23],i}if(!m.dataBlock){let e,t,r,n,i,o,s,l=((m.targetRenderFlags??0)&2)!=0;return h[24]===Symbol.for("react.memo_cache_sentinel")?(e=(0,a.jsx)("sphereGeometry",{args:[.3,6,4]}),h[24]=e):e=h[24],h[25]!==m.type?(t=(0,o2.entityTypeColor)(m.type),h[25]=m.type,h[26]=t):t=h[26],h[27]!==t?(r=(0,a.jsxs)("mesh",{children:[e,(0,a.jsx)("meshBasicMaterial",{color:t,wireframe:!0})]}),h[27]=t,h[28]=r):r=h[28],h[29]!==y||h[30]!==m?(n=y?(0,a.jsx)(sN,{entity:m}):null,h[29]=y,h[30]=m,h[31]=n):n=h[31],h[32]!==r||h[33]!==n?(i=(0,a.jsxs)("group",{name:"model",children:[r,n]}),h[32]=r,h[33]=n,h[34]=i):i=h[34],h[35]!==m||h[36]!==l||h[37]!==f?(o=l&&(0,a.jsx)(o3.Suspense,{fallback:null,children:(0,a.jsx)(sj,{entity:m,timeRef:f})}),h[35]=m,h[36]=l,h[37]=f,h[38]=o):o=h[38],h[39]!==b||h[40]!==i||h[41]!==o?(s=(0,a.jsxs)("group",{name:b,children:[i,o]}),h[39]=b,h[40]=i,h[41]=o,h[42]=s):s=h[42],s}h[43]===Symbol.for("react.memo_cache_sentinel")?(t=(0,a.jsx)("sphereGeometry",{args:[.5,8,6]}),h[43]=t):t=h[43],h[44]!==m.type?(n=(0,o2.entityTypeColor)(m.type),h[44]=m.type,h[45]=n):n=h[45],h[46]!==n?(i=(0,a.jsxs)("mesh",{children:[t,(0,a.jsx)("meshBasicMaterial",{color:n,wireframe:!0})]}),h[46]=n,h[47]=i):i=h[47];let S=i;if("Player"===m.type){let e,t,r,n,i,o,s,l=m.id===F,c=((m.targetRenderFlags??0)&2)!=0;return h[48]!==m||h[49]!==f?(e=(0,a.jsx)(o9,{entity:m,timeRef:f}),h[48]=m,h[49]=f,h[50]=e):e=h[50],h[51]!==S||h[52]!==e?(t=(0,a.jsx)(o3.Suspense,{fallback:S,children:e}),h[51]=S,h[52]=e,h[53]=t):t=h[53],h[54]!==S||h[55]!==t?(r=(0,a.jsx)(sA,{fallback:S,children:t}),h[54]=S,h[55]=t,h[56]=r):r=h[56],h[57]!==m||h[58]!==l||h[59]!==f?(n=!l&&(0,a.jsx)(o3.Suspense,{fallback:null,children:(0,a.jsx)(sD,{entity:m,timeRef:f})}),h[57]=m,h[58]=l,h[59]=f,h[60]=n):n=h[60],h[61]!==m||h[62]!==c||h[63]!==f?(i=c&&(0,a.jsx)(o3.Suspense,{fallback:null,children:(0,a.jsx)(sj,{entity:m,timeRef:f})}),h[61]=m,h[62]=c,h[63]=f,h[64]=i):i=h[64],h[65]!==r||h[66]!==n||h[67]!==i?(o=(0,a.jsxs)("group",{name:"model",children:[r,n,i]}),h[65]=r,h[66]=n,h[67]=i,h[68]=o):o=h[68],h[69]!==b||h[70]!==o?(s=(0,a.jsx)("group",{name:b,children:o}),h[69]=b,h[70]=o,h[71]=s):s=h[71],s}if("Explosion"===m.type&&m.dataBlock&&g){let e,t;return h[72]!==g||h[73]!==m?(e=(0,a.jsx)("group",{name:"model",children:(0,a.jsx)(sA,{fallback:null,children:(0,a.jsx)(o3.Suspense,{fallback:null,children:(0,a.jsx)(sh,{entity:m,playback:g})})})}),h[72]=g,h[73]=m,h[74]=e):e=h[74],h[75]!==b||h[76]!==e?(t=(0,a.jsx)("group",{name:b,children:e}),h[75]=b,h[76]=e,h[77]=t):t=h[77],t}let x=((m.targetRenderFlags??0)&2)!=0;return h[78]!==m.dataBlock||h[79]!==m.id||h[80]!==m.threads?(o=(0,a.jsx)(sd,{shapeName:m.dataBlock,entityId:m.id,threads:m.threads}),h[78]=m.dataBlock,h[79]=m.id,h[80]=m.threads,h[81]=o):o=h[81],h[82]!==S||h[83]!==o?(s=(0,a.jsx)(o3.Suspense,{fallback:S,children:o}),h[82]=S,h[83]=o,h[84]=s):s=h[84],h[85]!==S||h[86]!==s?(l=(0,a.jsx)("group",{name:"model",children:(0,a.jsx)(sA,{fallback:S,children:s})}),h[85]=S,h[86]=s,h[87]=l):l=h[87],h[88]!==m.dataBlock||h[89]!==m.weaponShape?(c=m.weaponShape&&(0,a.jsx)("group",{name:"weapon",children:(0,a.jsx)(sA,{fallback:null,children:(0,a.jsx)(o3.Suspense,{fallback:null,children:(0,a.jsx)(su,{shapeName:m.weaponShape,playerShapeName:m.dataBlock})})})}),h[88]=m.dataBlock,h[89]=m.weaponShape,h[90]=c):c=h[90],h[91]!==m||h[92]!==x||h[93]!==f?(d=x&&(0,a.jsx)(o3.Suspense,{fallback:null,children:(0,a.jsx)(sj,{entity:m,timeRef:f})}),h[91]=m,h[92]=x,h[93]=f,h[94]=d):d=h[94],h[95]!==b||h[96]!==l||h[97]!==c||h[98]!==d?(u=(0,a.jsxs)("group",{name:b,children:[l,c,d]}),h[95]=b,h[96]=l,h[97]=c,h[98]=d,h[99]=u):u=h[99],u});function sN(e){let t,n,i=(0,r.c)(9),{entity:o}=e,s=String(o.id);i[0]!==o.className||i[1]!==o.dataBlockId||i[2]!==o.ghostIndex||i[3]!==o.shapeHint||i[4]!==o.type||i[5]!==s?((t=[]).push(`${s} (${o.type})`),o.className&&t.push(`class ${o.className}`),"number"==typeof o.ghostIndex&&t.push(`ghost ${o.ghostIndex}`),"number"==typeof o.dataBlockId&&t.push(`db ${o.dataBlockId}`),t.push(o.shapeHint?`shapeHint ${o.shapeHint}`:"shapeHint <none resolved>"),i[0]=o.className,i[1]=o.dataBlockId,i[2]=o.ghostIndex,i[3]=o.shapeHint,i[4]=o.type,i[5]=s,i[6]=t):t=i[6];let l=t.join(" | ");return i[7]!==l?(n=(0,a.jsx)(z.FloatingLabel,{color:"#ff6688",children:l}),i[7]=l,i[8]=n):n=i[8],n}class sA extends o3.Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,t){console.warn("[demo] Shape load failed:",e.message,t.componentStack)}render(){return this.state.hasError?this.props.fallback:this.props.children}}function sG(e){return e.playback.streamSnapshot?.controlPlayerGhostId}let sU=Math.PI/180,sL=Math.PI/18e4;function sz(e,t,a){let r=e[t];return"number"==typeof r&&Number.isFinite(r)?r:a}function sO(e,t,a){let r=e[t];return"boolean"==typeof r?r:"number"==typeof r?0!==r:a}function sV(e,t){let a,r=e.particles;if(Array.isArray(r)){for(let e of r)if("number"==typeof e&&(a=t(e)))break}return a?{ejectionPeriodMS:sz(e,"ejectionPeriodMS",100),periodVarianceMS:sz(e,"periodVarianceMS",0),ejectionVelocity:.01*sz(e,"ejectionVelocity",200),velocityVariance:.01*sz(e,"velocityVariance",100),ejectionOffset:.01*sz(e,"ejectionOffset",0),thetaMin:sz(e,"thetaMin",0),thetaMax:sz(e,"thetaMax",90),phiReferenceVel:sz(e,"phiReferenceVel",0),phiVariance:sz(e,"phiVariance",360),overrideAdvances:sO(e,"overrideAdvances",!1),orientParticles:sO(e,"orientParticles",!1),orientOnVelocity:sO(e,"orientOnVelocity",!0),lifetimeMS:sz(e,"lifetimeMS",0)<<5,lifetimeVarianceMS:sz(e,"lifetimeVarianceMS",0)<<5,particles:function(e){let t=e.keys,a=[];if(Array.isArray(t)&&t.length>0)for(let e=0;e<t.length&&e<4;e++){let r=t[e];a.push({r:r.r??1,g:r.g??1,b:r.b??1,a:r.a??1,size:(r.size??.02)*50,time:0===e?0:r.time??1})}0===a.length&&a.push({r:1,g:1,b:1,a:1,size:1,time:0}),a.length<2&&a.push({...a[0],time:1});let r="";if("string"==typeof e.textureName&&e.textureName)r=e.textureName;else{let t=e.textures;Array.isArray(t)&&t.length>0&&t[0]&&(r=t[0])}return{dragCoefficient:5*sz(e,"dragCoefficient",0),windCoefficient:sz(e,"windCoefficient",1),gravityCoefficient:10*sz(e,"gravityCoefficient",0),inheritedVelFactor:sz(e,"inheritedVelFactor",0),constantAcceleration:sz(e,"constantAcceleration",0),lifetimeMS:sz(e,"lifetimeMS",31)<<5,lifetimeVarianceMS:sz(e,"lifetimeVarianceMS",0)<<5,spinSpeed:sz(e,"spinSpeed",0),spinRandomMin:sz(e,"spinRandomMin",1e3)+-1e3,spinRandomMax:sz(e,"spinRandomMax",1e3)+-1e3,useInvAlpha:sO(e,"useInvAlpha",!1),keys:a,textureName:r}}(a)}:null}function sq(e,t){return e+(2*Math.random()-1)*t}function sH(e,t,a,r,n,i,o){let s=Math.cos(o),l=Math.sin(o),c=e*r+t*n+a*i;return[e*s+(n*a-i*t)*l+r*c*(1-s),t*s+(i*e-r*a)*l+n*c*(1-s),a*s+(r*t-n*e)*l+i*c*(1-s)]}class sW{data;particles=[];maxParticles;internalClock=0;nextParticleTime=0;emitterAge=0;emitterLifetime;emitterDead=!1;constructor(e,t=256,a){this.data=e,this.maxParticles=t;let r=a??e.lifetimeMS;!a&&e.lifetimeVarianceMS>0&&(r+=Math.round(sq(0,e.lifetimeVarianceMS))),this.emitterLifetime=r}emitBurst(e,t,a=[0,0,1]){for(let r=0;r<t&&this.particles.length<this.maxParticles;r++)this.addParticle(e,a)}emitPeriodic(e,t,a=[0,0,1]){if(this.emitterDead)return;let r=t;for(;r>0;){if(this.nextParticleTime>0){let e=Math.min(r,this.nextParticleTime);this.nextParticleTime-=e,r-=e,this.internalClock+=e;continue}if(this.particles.length<this.maxParticles&&(this.addParticle(e,a),!this.data.overrideAdvances&&r>0)){let e=this.particles[this.particles.length-1];e.currentAge+=r,e.currentAge>=e.totalLifetime&&this.particles.pop()}let t=this.data.ejectionPeriodMS;this.data.periodVarianceMS>0&&(t+=Math.round(sq(0,this.data.periodVarianceMS))),this.nextParticleTime=Math.max(1,t)}}update(e){this.emitterAge+=e,this.emitterLifetime>0&&this.emitterAge>this.emitterLifetime&&(this.emitterDead=!0);let t=e/1e3,a=this.data.particles;for(let r=this.particles.length-1;r>=0;r--){let n=this.particles[r];if(n.currentAge+=e,n.currentAge>=n.totalLifetime){this.particles[r]=this.particles[this.particles.length-1],this.particles.pop();continue}let i=a.dragCoefficient,o=a.gravityCoefficient,s=n.acc[0]-n.vel[0]*i,l=n.acc[1]-n.vel[1]*i,c=n.acc[2]-n.vel[2]*i+-9.81*o;n.vel[0]+=s*t,n.vel[1]+=l*t,n.vel[2]+=c*t,n.pos[0]+=n.vel[0]*t,n.pos[1]+=n.vel[1]*t,n.pos[2]+=n.vel[2]*t;let d=n.currentAge/n.totalLifetime,u=function(e,t){for(let a=1;a<e.length;a++)if(e[a].time>=t){let r=e[a-1],n=e[a],i=n.time-r.time,o=i>0?(t-r.time)/i:0;return{r:r.r+(n.r-r.r)*o,g:r.g+(n.g-r.g)*o,b:r.b+(n.b-r.b)*o,a:r.a+(n.a-r.a)*o,size:r.size+(n.size-r.size)*o}}let a=e[e.length-1];return{r:a.r,g:a.g,b:a.b,a:a.a,size:a.size}}(a.keys,d);n.r=u.r,n.g=u.g,n.b=u.b,n.a=u.a,n.size=u.size,n.currentSpin=n.spinSpeed*n.currentAge*sL}}isDead(){return this.emitterDead&&0===this.particles.length}kill(){this.emitterDead=!0}addParticle(e,t){var a,r,n,i;let o,s,l,c,d=this.data,u=d.particles,h=t[0],m=t[1],f=t[2],g=(a=h,r=m,.9>Math.abs(n=f)?(o=r,s=-a,l=0):(o=-n,s=0,l=a),(c=Math.sqrt(o*o+s*s+l*l))<1e-8?[1,0,0]:[o/c,s/c,l/c]),p=(d.thetaMin+Math.random()*(d.thetaMax-d.thetaMin))*sU,y=(this.internalClock/1e3*d.phiReferenceVel+Math.random()*d.phiVariance)*sU;[h,m,f]=sH(h,m,f,g[0],g[1],g[2],p),[h,m,f]=sH(h,m,f,t[0],t[1],t[2],y);let v=Math.sqrt(h*h+m*m+f*f);v>1e-8&&(h/=v,m/=v,f/=v);let F=sq(d.ejectionVelocity,d.velocityVariance),b=[e[0]+h*d.ejectionOffset,e[1]+m*d.ejectionOffset,e[2]+f*d.ejectionOffset],S=[h*F,m*F,f*F],x=u.constantAcceleration,k=[S[0]*x,S[1]*x,S[2]*x],w=u.lifetimeMS;u.lifetimeVarianceMS>0&&(w+=Math.round(sq(0,u.lifetimeVarianceMS))),w=Math.max(1,w);let I=u.spinSpeed+((i=u.spinRandomMin)+Math.random()*(u.spinRandomMax-i)),C=u.keys[0];this.particles.push({pos:b,vel:S,acc:k,orientDir:[h,m,f],currentAge:0,totalLifetime:w,dataIndex:0,spinSpeed:I,currentSpin:0,r:C.r,g:C.g,b:C.b,a:C.a,size:C.size})}}let s$=`
|
||
// 'position' is auto-declared by Three.js for ShaderMaterial.
|
||
attribute vec4 particleColor;
|
||
attribute float particleSize;
|
||
attribute float particleSpin;
|
||
attribute vec2 quadCorner; // (-0.5,-0.5) to (0.5,0.5)
|
||
attribute vec3 orientDir;
|
||
|
||
uniform bool uOrientParticles;
|
||
// cameraPosition is a built-in Three.js uniform.
|
||
|
||
varying vec2 vUv;
|
||
varying vec4 vColor;
|
||
|
||
void main() {
|
||
vUv = quadCorner + 0.5; // [0,1] range
|
||
vColor = particleColor;
|
||
|
||
if (uOrientParticles) {
|
||
if (length(orientDir) < 0.0001) {
|
||
// V12: don't render oriented particles with zero velocity.
|
||
gl_Position = vec4(0.0, 0.0, 0.0, 0.0);
|
||
return;
|
||
}
|
||
// V12 oriented particle: quad aligned along direction, facing camera.
|
||
vec3 worldPos = (modelMatrix * vec4(position, 1.0)).xyz;
|
||
vec3 dir = normalize(orientDir);
|
||
vec3 dirFromCam = worldPos - cameraPosition;
|
||
vec3 crossDir = normalize(cross(dirFromCam, dir));
|
||
|
||
// V12 maps U along dir (velocity) — match by using quadCorner.x for dir.
|
||
vec3 offset = dir * quadCorner.x + crossDir * quadCorner.y;
|
||
worldPos += offset * particleSize;
|
||
|
||
gl_Position = projectionMatrix * viewMatrix * vec4(worldPos, 1.0);
|
||
} else {
|
||
// Standard camera-facing billboard.
|
||
vec3 viewPos = (modelViewMatrix * vec4(position, 1.0)).xyz;
|
||
|
||
// Apply spin rotation to quad corner.
|
||
float c = cos(particleSpin);
|
||
float s = sin(particleSpin);
|
||
vec2 rotated = vec2(
|
||
c * quadCorner.x - s * quadCorner.y,
|
||
s * quadCorner.x + c * quadCorner.y
|
||
);
|
||
|
||
// Offset in view space (camera-facing billboard).
|
||
viewPos.xy += rotated * particleSize;
|
||
|
||
gl_Position = projectionMatrix * vec4(viewPos, 1.0);
|
||
}
|
||
}
|
||
`,sY=`
|
||
uniform sampler2D particleTexture;
|
||
uniform bool hasTexture;
|
||
uniform float debugOpacity;
|
||
|
||
varying vec2 vUv;
|
||
varying vec4 vColor;
|
||
|
||
void main() {
|
||
if (hasTexture) {
|
||
vec4 texColor = texture2D(particleTexture, vUv);
|
||
gl_FragColor = texColor * vColor;
|
||
} else {
|
||
gl_FragColor = vColor;
|
||
}
|
||
gl_FragColor.a *= debugOpacity;
|
||
}
|
||
`,sK=new Float32Array([-.5,-.5,.5,-.5,.5,.5,-.5,.5]),sX=new Map,sZ=new Set,sJ=new o.DataTexture(new Uint8Array([255,255,255,255]),1,1,o.RGBAFormat,o.UnsignedByteType);function sQ(e){if(!e)return sJ;let t=sX.get(e);if(t)return t;try{let t=(0,c.textureToUrl)(e),a=(0,f.loadTexture)(t,e=>{(0,o2.setupEffectTexture)(e),sZ.add(e)});return(0,o2.setupEffectTexture)(a),sX.set(e,a),a}catch{return sJ}}sJ.needsUpdate=!0;let s0=new o.SphereGeometry(1,6,6),s1=new o.MeshBasicMaterial({color:0xff0000,wireframe:!0}),s2=new o.BoxGeometry(.3,.3,.3),s3=new o.MeshBasicMaterial({color:65280,wireframe:!0}),s5=new o.SphereGeometry(1,12,8),s4=`
|
||
attribute vec4 vertexColor;
|
||
attribute vec2 texCoord;
|
||
varying vec4 vColor;
|
||
varying vec2 vUV;
|
||
void main() {
|
||
vColor = vertexColor;
|
||
vUV = texCoord;
|
||
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
||
}
|
||
`,s6=`
|
||
uniform sampler2D uTexture;
|
||
varying vec4 vColor;
|
||
varying vec2 vUV;
|
||
void main() {
|
||
vec4 tex = texture2D(uTexture, vUV);
|
||
gl_FragColor = vec4(vColor.rgb * tex.rgb, vColor.a * tex.a);
|
||
}
|
||
`;function s8(e){let t=(e+1)*2,a=new Float32Array(3*t),r=new Float32Array(2*t),n=new Float32Array(4*t),i=new Uint16Array(6*e);for(let t=0;t<e;t++){let e=2*t,a=6*t;i[a]=e,i[a+1]=e+1,i[a+2]=e+2,i[a+3]=e+1,i[a+4]=e+3,i[a+5]=e+2}let s=new o.BufferGeometry,l=new o.BufferAttribute(a,3);l.setUsage(35048),s.setAttribute("position",l);let c=new o.BufferAttribute(r,2);c.setUsage(35048),s.setAttribute("texCoord",c);let d=new o.BufferAttribute(n,4);return d.setUsage(35048),s.setAttribute("vertexColor",d),s.setIndex(new o.BufferAttribute(i,1)),s}function s7(e,t,a,r,n){let i=e.getAttribute("position").array,o=e.getAttribute("texCoord").array,s=e.getAttribute("vertexColor").array,l=Math.max(a-.5*t.width,0),c=a+.5*t.width,d=t.numSegments,u=r[0],h=r[1],m=r[2],f=r[3];for(let e=0;e<=d;e++){let a=e/d*Math.PI*2,r=Math.cos(a),g=Math.sin(a),p=2*e,y=p+1,v=3*p;i[v]=r*c,i[v+1]=n?0:t.height,i[v+2]=g*c;let F=3*y;i[F]=r*l,i[F+1]=0,i[F+2]=g*l;let b=e/d*t.texWrap,S=2*p;o[S]=b,o[S+1]=.05;let x=2*y;o[x]=b,o[x+1]=.95;let k=4*p;s[k]=u,s[k+1]=h,s[k+2]=m,s[k+3]=f;let w=4*y;s[w]=u,s[w+1]=h,s[w+2]=m,s[w+3]=f}e.getAttribute("position").needsUpdate=!0,e.getAttribute("texCoord").needsUpdate=!0,e.getAttribute("vertexColor").needsUpdate=!0,e.computeBoundingSphere()}function s9(e){let t=new o.BufferGeometry,a=4*e,r=new Float32Array(2*a);for(let t=0;t<e;t++)r.set(sK,8*t);let n=new Uint16Array(6*e);for(let t=0;t<e;t++){let e=4*t,a=6*t;n[a]=e,n[a+1]=e+1,n[a+2]=e+2,n[a+3]=e,n[a+4]=e+2,n[a+5]=e+3}let i=new Float32Array(3*a),s=new Float32Array(4*a),l=new Float32Array(a),c=new Float32Array(a),d=new Float32Array(3*a);return t.setIndex(new o.Uint16BufferAttribute(n,1)),t.setAttribute("quadCorner",new o.Float32BufferAttribute(r,2)),t.setAttribute("position",new o.Float32BufferAttribute(i,3)),t.setAttribute("particleColor",new o.Float32BufferAttribute(s,4)),t.setAttribute("particleSize",new o.Float32BufferAttribute(l,1)),t.setAttribute("particleSpin",new o.Float32BufferAttribute(c,1)),t.setAttribute("orientDir",new o.Float32BufferAttribute(d,3)),t.setDrawRange(0,0),t}function le(e,t,a=!1){let r=sZ.has(e);return new o.ShaderMaterial({vertexShader:s$,fragmentShader:sY,uniforms:{particleTexture:{value:r?e:sJ},hasTexture:{value:!0},debugOpacity:{value:1},uOrientParticles:{value:a}},transparent:!0,depthWrite:!1,depthTest:!0,side:o.DoubleSide,blending:t?o.NormalBlending:o.AdditiveBlending})}function lt(e){let t,i,s,l,d,m,f,g,p,y,F,b=(0,r.c)(18),{playback:S,snapshotRef:x}=e,{debugMode:k}=(0,v.useDebug)(),{audioEnabled:w}=(0,v.useSettings)(),{audioLoader:C,audioListener:_}=(0,o0.useAudio)(),P=(0,h.useThree)(ln),D=(0,n.useRef)(null);b[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],b[0]=t):t=b[0];let M=(0,n.useRef)(t);b[1]===Symbol.for("react.memo_cache_sentinel")?(i=new Set,b[1]=i):i=b[1];let T=(0,n.useRef)(i);b[2]===Symbol.for("react.memo_cache_sentinel")?(s=new Set,b[2]=s):s=b[2];let E=(0,n.useRef)(s);b[3]===Symbol.for("react.memo_cache_sentinel")?(l=new Map,b[3]=l):l=b[3];let B=(0,n.useRef)(l);b[4]===Symbol.for("react.memo_cache_sentinel")?(d=new Set,b[4]=d):d=b[4];let j=(0,n.useRef)(d);b[5]===Symbol.for("react.memo_cache_sentinel")?(m=[],b[5]=m):m=b[5];let R=(0,n.useRef)(m);b[6]===Symbol.for("react.memo_cache_sentinel")?(f=[],b[6]=f):f=b[6];let N=(0,n.useRef)(f);return b[7]!==w||b[8]!==_||b[9]!==C||b[10]!==k||b[11]!==P||b[12]!==S||b[13]!==x?(g=(e,t)=>{let a=D.current,r=x.current;if(!a||!r)return;let n=I.engineStore.getState().playback,i="playing"===n.status,s=i?t*n.rate:0,l=1e3*s,d=S.getDataBlockData.bind(S);for(let e of r.entities){if("Explosion"!==e.type||!e.explosionDataBlockId||!e.position||T.current.has(e.id))continue;T.current.add(e.id);let t=function(e,t){let a=t(e);if(!a)return null;let r=[],n=[],i=a.particleEmitter;if("number"==typeof i){let e=t(i);if(e){let n=sV(e,t);if(n){let e=a.particleDensity??10;r.push({data:n,density:e})}}}let o=a.emitters;if(Array.isArray(o))for(let e of o){if("number"!=typeof e)continue;let a=t(e);if(!a)continue;let r=sV(a,t);r&&n.push(r)}return 0===r.length&&0===n.length?null:{burstEmitters:r,streamingEmitters:n,lifetimeMS:32*(a.lifetimeMS??31)}}(e.explosionDataBlockId,d);if(!t)continue;let r=[...e.position];for(let e of t.burstEmitters){let t=new sW(e.data,256);t.emitBurst(r,e.density);let n=sQ(e.data.particles.textureName),i=s9(256),s=le(n,e.data.particles.useInvAlpha,e.data.orientParticles),l=new o.Mesh(i,s);l.frustumCulled=!1,a.add(l),M.current.push({emitter:t,mesh:l,geometry:i,material:s,targetTexture:n,origin:r,isBurst:!0,hasBurst:!0})}for(let e of t.streamingEmitters){let n=new sW(e,256,t.lifetimeMS),i=sQ(e.particles.textureName),s=s9(256),l=le(i,e.particles.useInvAlpha,e.orientParticles),c=new o.Mesh(s,l);c.frustumCulled=!1,a.add(c),M.current.push({emitter:n,mesh:c,geometry:s,material:l,targetTexture:i,origin:r,isBurst:!1,hasBurst:!1})}let n=d(e.explosionDataBlockId);if(k){let i=n?function(e){let t=e.sizes;if(Array.isArray(t)&&t.length>0){let e=0;for(let a of t)e=Math.max(e,a.x,a.y,a.z);if(e>0)return e/1e3}let a=e.particleRadius;return"number"==typeof a&&a>0?a:5}(n):5,s=function(e){if(!e)return 0xff00ff;let t=e.toLowerCase();return t.includes("disc")?4491519:t.includes("grenade")?0xff8800:t.includes("mortar")?0xff4400:t.includes("plasma")?4521796:t.includes("laser")?0xff2222:t.includes("blaster")?0xffff00:t.includes("missile")?0xff6600:t.includes("bomb")?0xff0000:t.includes("mine")?0xff8844:t.includes("concussion")?0xffaa00:t.includes("shocklance")?8930559:t.includes("chaingun")||t.includes("bullet")?0xcccccc:0xff00ff}(e.dataBlock),l=new o.MeshBasicMaterial({color:s,wireframe:!0,transparent:!0,opacity:1,depthWrite:!1}),c=new o.Mesh(s5,l);c.frustumCulled=!1,c.scale.setScalar(i),c.position.set(r[1],r[2],r[0]),a.add(c);let{sprite:d,material:u}=function(e,t){let a=document.createElement("canvas"),r=a.getContext("2d");r.font="bold 32px monospace",a.width=Math.ceil(r.measureText(e).width)+16,a.height=48,r.font="bold 32px monospace",r.fillStyle=`#${t.toString(16).padStart(6,"0")}`,r.textBaseline="middle",r.fillText(e,8,a.height/2);let n=new o.CanvasTexture(a),i=new o.SpriteMaterial({map:n,transparent:!0,depthTest:!1,depthWrite:!1}),s=new o.Sprite(i),l=a.width/a.height;return s.scale.set(2*l,2,1),{sprite:s,material:i}}(`${e.id}: ${e.dataBlock??`expId:${e.explosionDataBlockId}`}`,s);d.position.set(r[1],r[2]+i+2,r[0]),d.frustumCulled=!1,a.add(d),R.current.push({entityId:e.id,mesh:c,material:l,label:d,labelMaterial:u,creationTime:(0,I.demoEffectNow)(),lifetimeMS:Math.max(t.lifetimeMS,3e3),targetRadius:i})}let i=n?.shockwave;if("number"==typeof i){let t=function(e,t){let a=t(e);if(!a)return null;let r=a.colors??[],n=a.times??[0,.5,1,1];return{width:a.width??1,numSegments:Math.max(a.numSegments??16,4),velocity:a.velocity??0,height:a.height??0,verticalCurve:a.verticalCurve??0,acceleration:a.acceleration??0,texWrap:a.texWrap??1,lifetimeMS:a.lifetimeMS??500,is2D:!!a.is2D,renderSquare:!!a.renderSquare,renderBottom:!!a.renderBottom,mapToTerrain:!!a.mapToTerrain,colors:r,times:n,textureName:a.textureName??"",mapToTexture:a.mapToTexture??""}}(i,d);if(t){let n=sQ(t.textureName),i=s8(t.numSegments),s=new o.ShaderMaterial({vertexShader:s4,fragmentShader:s6,uniforms:{uTexture:{value:n}},transparent:!0,depthWrite:!1,blending:o.AdditiveBlending,side:o.DoubleSide}),l=new o.Mesh(i,s);l.frustumCulled=!1,l.position.set(r[1],r[2],r[0]),a.add(l);let c=null,d=null;t.renderBottom&&(d=s8(t.numSegments),(c=new o.Mesh(d,s)).frustumCulled=!1,c.position.set(r[1],r[2],r[0]),c.scale.y=-1,a.add(c));let u=Math.abs(t.velocity)>1e-10?t.velocity:0;N.current.push({entityId:e.id,mesh:l,bottomMesh:c,geometry:i,bottomGeometry:d,material:s,creationTime:(0,I.demoEffectNow)(),lifetimeMS:t.lifetimeMS,data:t,radius:0,velocity:u})}}}let u=new Set;for(let e of r.entities){if(u.add(e.id),!e.maintainEmitterId||E.current.has(e.id))continue;E.current.add(e.id);let t=d(e.maintainEmitterId);if(!t)continue;let r=sV(t,d);if(!r)continue;let n=e.position?[...e.position]:[0,0,0],i=new sW(r,256),s=sQ(r.particles.textureName),l=s9(256),c=le(s,r.particles.useInvAlpha,r.orientParticles),h=new o.Mesh(l,c);h.frustumCulled=!1,a.add(h),M.current.push({emitter:i,mesh:h,geometry:l,material:c,targetTexture:s,origin:n,isBurst:!1,hasBurst:!1,followEntityId:e.id})}for(let e of M.current)e.followEntityId&&!u.has(e.followEntityId)&&e.emitter.kill();for(let e of E.current)u.has(e)||E.current.delete(e);let h=M.current;for(let e=h.length-1;e>=0;e--){let t=h[e];if(t.shaderChecked||(!function(e,t,a){let r=e.properties.get(t).currentProgram;if(!r)return;let n=r.program,i=e.getContext();i.getProgramParameter(n,i.LINK_STATUS)||console.error(`[ParticleFX] Shader LINK ERROR (${a}):`,i.getProgramInfoLog(n))}(P,t.material,t.isBurst?"burst":"stream"),t.shaderChecked=!0),t.followEntityId){let e=r.entities.find(e=>e.id===t.followEntityId);e?.position&&(t.origin[0]=e.position[0],t.origin[1]=e.position[1],t.origin[2]=e.position[2]),e?.direction&&(t.emitAxis=e.direction)}if(t.isBurst||t.emitter.emitPeriodic(t.origin,l,t.emitAxis),t.emitter.update(l),sZ.has(t.targetTexture)&&t.material.uniforms.particleTexture.value!==t.targetTexture&&(t.material.uniforms.particleTexture.value=t.targetTexture),t.material.uniforms.debugOpacity.value=k?.2:1,!function(e){let t=e.emitter.particles,a=e.geometry,r=a.getAttribute("position"),n=a.getAttribute("particleColor"),i=a.getAttribute("particleSize"),o=a.getAttribute("particleSpin"),s=a.getAttribute("orientDir"),l=r.array,c=n.array,d=i.array,u=o.array,h=s.array,m=Math.min(t.length,256),f=e.emitter.data.orientOnVelocity;for(let e=0;e<m;e++){let a=t[e],r=a.pos[1],n=a.pos[2],i=a.pos[0],o=f?a.vel:a.orientDir,s=o[1],m=o[2],g=o[0],p=a.r,y=a.g,v=a.b,F=a.a;for(let t=0;t<4;t++){let o=4*e+t,f=3*o;l[f]=r,l[f+1]=n,l[f+2]=i;let b=4*o;c[b]=p,c[b+1]=y,c[b+2]=v,c[b+3]=F;let S=3*o;h[S]=s,h[S+1]=m,h[S+2]=g,d[o]=a.size,u[o]=a.currentSpin}}for(let e=m;e<256;e++)for(let t=0;t<4;t++)d[4*e+t]=0;r.needsUpdate=!0,n.needsUpdate=!0,i.needsUpdate=!0,o.needsUpdate=!0,s.needsUpdate=!0,a.setDrawRange(0,6*m)}(t),k){t.debugOriginMesh||(t.debugOriginMesh=new o.Mesh(s0,s1),t.debugOriginMesh.frustumCulled=!1,a.add(t.debugOriginMesh)),t.debugOriginMesh.position.set(t.origin[1],t.origin[2],t.origin[0]),t.debugParticleMeshes||(t.debugParticleMeshes=[]);let e=Math.min(t.emitter.particles.length,8);for(;t.debugParticleMeshes.length<e;){let e=new o.Mesh(s2,s3);e.frustumCulled=!1,a.add(e),t.debugParticleMeshes.push(e)}for(let e=0;e<t.debugParticleMeshes.length;e++){let a=t.debugParticleMeshes[e];if(e<t.emitter.particles.length){let r=t.emitter.particles[e];a.position.set(r.pos[1],r.pos[2],r.pos[0]),a.visible=!0}else a.visible=!1}}else if(t.debugOriginMesh&&(a.remove(t.debugOriginMesh),t.debugOriginMesh=void 0),t.debugParticleMeshes){for(let e of t.debugParticleMeshes)a.remove(e);t.debugParticleMeshes=void 0}if(t.emitter.isDead()){if(a.remove(t.mesh),t.geometry.dispose(),t.material.dispose(),t.debugOriginMesh&&a.remove(t.debugOriginMesh),t.debugParticleMeshes)for(let e of t.debugParticleMeshes)a.remove(e);h.splice(e,1)}}let m=R.current,f=(0,I.demoEffectNow)();for(let e=m.length-1;e>=0;e--){let t=m[e],r=Math.min((f-t.creationTime)/t.lifetimeMS,1),n=Math.min(r/.1,1);t.mesh.scale.setScalar(t.targetRadius*n),t.material.opacity=1-r,t.labelMaterial.opacity=1-r,r>=1&&(a.remove(t.mesh),a.remove(t.label),t.material.dispose(),t.labelMaterial.dispose(),m.splice(e,1))}let g=N.current;for(let t=g.length-1;t>=0;t--){let r=g[t],n=Math.min((f-r.creationTime)/r.lifetimeMS,1);r.velocity=r.velocity+r.data.acceleration*s,r.radius=r.radius+r.velocity*s;let i=function(e,t){let{colors:a,times:r}=e;if(0===a.length)return[1,1,1,1];let n=0;for(let e=0;e<r.length-1;e++)t>=r[e]&&(n=e);let i=Math.min(n+1,a.length-1),o=r[n]??0,s=(r[i]??1)-o,l=s>0?Math.min((t-o)/s,1):0,c=a[n]??a[0],d=a[i]??a[0];return[c.r+(d.r-c.r)*l,c.g+(d.g-c.g)*l,c.b+(d.b-c.b)*l,c.a+(d.a-c.a)*l]}(r.data,n);s7(r.geometry,r.data,r.radius,i,r.data.is2D),r.bottomGeometry&&s7(r.bottomGeometry,r.data,r.radius,i,r.data.is2D),r.data.is2D&&r.mesh.lookAt(e.camera.position),n>=1&&(a.remove(r.mesh),r.bottomMesh&&a.remove(r.bottomMesh),r.geometry.dispose(),r.bottomGeometry?.dispose(),r.material.dispose(),g.splice(t,1))}if(i&&w&&C&&_&&D.current){for(let e of r.entities){if("Explosion"!==e.type||!e.explosionDataBlockId||!e.position)continue;let t=`snd:${e.id}`;if(j.current.has(t))continue;j.current.add(t);let a=d(e.explosionDataBlockId);if(!a)continue;let r=a.soundProfile;if("number"!=typeof r)continue;let n=(0,o8.resolveAudioProfile)(r,d);if(!n)continue;let i=new o.Vector3(e.position[1],e.position[2],e.position[0]);(0,o8.playOneShotSound)(n,_,C,i,D.current)}let e=B.current;for(let t of r.entities){if("Projectile"!==t.type||!t.dataBlockId||!t.position)continue;if(e.has(t.id)){e.get(t.id).position.set(t.position[1],t.position[2],t.position[0]);continue}if(e.size>=20)continue;let a=d(t.dataBlockId);if(!a)continue;let r=a.sound;if("number"!=typeof r)continue;let i=(0,o8.resolveAudioProfile)(r,d);if(i&&i.isLooping&&i.is3D)try{let a=(0,c.audioToUrl)(i.filename);(0,o8.getCachedAudioBuffer)(a,C,a=>{if(!u.has(t.id)||e.has(t.id))return;let r=D.current;if(!r)return;let s=new o.PositionalAudio(_);s.setBuffer(a),s.setDistanceModel("inverse"),s.setRefDistance(i.refDist),s.setMaxDistance(i.maxDist),s.setRolloffFactor(1),s.setVolume(i.volume),s.setPlaybackRate(n.rate),s.setLoop(!0),s.position.set(t.position[1],t.position[2],t.position[0]),r.add(s),(0,o8.trackDemoSound)(s),s.play(),e.set(t.id,s)})}catch{}}for(let[t,a]of e)if(!u.has(t)){(0,o8.untrackDemoSound)(a);try{a.stop()}catch{}a.disconnect(),D.current?.remove(a),e.delete(t)}for(let e of r.audioEvents){let t=`${e.timeSec}:${e.profileId}:${e.position?.x??""}`;if(j.current.has(t))continue;j.current.add(t);let a=(0,o8.resolveAudioProfile)(e.profileId,d);if(!a)continue;let r=e.position?new o.Vector3(e.position.y,e.position.z,e.position.x):void 0;(0,o8.playOneShotSound)(a,_,C,r,D.current)}}if(T.current.size>500){let e=new Set(r.entities.map(lr));for(let t of T.current)e.has(t)||T.current.delete(t)}if(j.current.size>500){let e=new Set(r.entities.map(la));for(let t of j.current)t.startsWith("snd:")&&e.has(t.slice(4))||j.current.delete(t)}},b[7]=w,b[8]=_,b[9]=C,b[10]=k,b[11]=P,b[12]=S,b[13]=x,b[14]=g):g=b[14],(0,u.useFrame)(g),b[15]===Symbol.for("react.memo_cache_sentinel")?(y=()=>()=>{let e=D.current;for(let t of M.current){if(e&&(e.remove(t.mesh),t.debugOriginMesh&&e.remove(t.debugOriginMesh),t.debugParticleMeshes))for(let a of t.debugParticleMeshes)e.remove(a);t.geometry.dispose(),t.material.dispose()}for(let t of(M.current=[],R.current))e&&(e.remove(t.mesh),e.remove(t.label)),t.material.dispose(),t.labelMaterial.dispose();for(let t of(R.current=[],N.current))e&&(e.remove(t.mesh),t.bottomMesh&&e.remove(t.bottomMesh)),t.geometry.dispose(),t.bottomGeometry?.dispose(),t.material.dispose();for(let[,t]of(N.current=[],T.current.clear(),E.current.clear(),B.current)){(0,o8.untrackDemoSound)(t);try{t.stop()}catch{}t.disconnect(),e&&e.remove(t)}B.current.clear(),j.current.clear()},p=[],b[15]=p,b[16]=y):(p=b[15],y=b[16]),(0,n.useEffect)(y,p),b[17]===Symbol.for("react.memo_cache_sentinel")?(F=(0,a.jsx)("group",{ref:D}),b[17]=F):F=b[17],F}function la(e){return e.id}function lr(e){return e.id}function ln(e){return e.gl}let li=new WeakMap;function lo(e){let t=li.get(e);return t||(t=new Map(e.entities.map(e=>[e.id,e])),li.set(e,t)),t}let ls=new o.Vector3,ll=new o.Quaternion,lc=new o.Quaternion,ld=new o.Quaternion(0,1,0,0),lu=new o.Vector3,lh=new o.Vector3,lm=new o.Vector3;function lf(e){let t,i,s,l,d,h,m,f,g,p,y,v,F=(0,r.c)(25),{recording:b}=e,S=(0,I.useEngineStoreApi)(),x=(0,n.useRef)(null),k=(0,n.useRef)(0),w=(0,n.useRef)(0),C=(0,n.useRef)(null),_=(0,n.useRef)(null);F[0]===Symbol.for("react.memo_cache_sentinel")?(t=new o.Vector3(0,o2.DEFAULT_EYE_HEIGHT,0),F[0]=t):t=F[0];let P=(0,n.useRef)(t),D=(0,n.useRef)(b.streamingPlayback??null),M=(0,n.useRef)(null);F[1]===Symbol.for("react.memo_cache_sentinel")?(i=new Map,F[1]=i):i=F[1];let T=(0,n.useRef)(i),E=(0,n.useRef)(null);F[2]===Symbol.for("react.memo_cache_sentinel")?(s=[],F[2]=s):s=F[2];let[B,j]=(0,n.useState)(s),[R,N]=(0,n.useState)(null);F[3]===Symbol.for("react.memo_cache_sentinel")?(l=e=>{if(e===E.current)return;E.current=e;let t=T.current,a=new Map,r=!1;for(let n of e.entities){let i=t.get(n.id);i&&i.type===n.type&&i.dataBlock===n.dataBlock&&i.weaponShape===n.weaponShape&&i.className===n.className&&i.ghostIndex===n.ghostIndex&&i.dataBlockId===n.dataBlockId&&i.shapeHint===n.shapeHint?(i.playerName!==n.playerName||i.iffColor!==n.iffColor||i.targetRenderFlags!==n.targetRenderFlags||i.threads!==n.threads||i.weaponImageState!==n.weaponImageState||i.weaponImageStates!==n.weaponImageStates||i.headPitch!==n.headPitch||i.headYaw!==n.headYaw||i.direction!==n.direction||i.visual!==n.visual)&&(i={...i,playerName:n.playerName,iffColor:n.iffColor,targetRenderFlags:n.targetRenderFlags,threads:n.threads,weaponImageState:n.weaponImageState,weaponImageStates:n.weaponImageStates,headPitch:n.headPitch,headYaw:n.headYaw,direction:n.direction,visual:n.visual},r=!0):((i=(0,o2.buildStreamDemoEntity)(n.id,n.type,n.dataBlock,n.visual,n.direction,n.weaponShape,n.playerName,n.className,n.ghostIndex,n.dataBlockId,n.shapeHint,n.explosionDataBlockId,n.faceViewer)).playerName=n.playerName,i.iffColor=n.iffColor,i.targetRenderFlags=n.targetRenderFlags,i.threads=n.threads,i.weaponImageState=n.weaponImageState,i.weaponImageStates=n.weaponImageStates,i.headPitch=n.headPitch,i.headYaw=n.headYaw,i.direction=n.direction,i.visual=n.visual,i.explosionDataBlockId=n.explosionDataBlockId,i.faceViewer=n.faceViewer,i.spawnTime=e.timeSec,r=!0),0===i.keyframes.length&&i.keyframes.push({time:e.timeSec,position:n.position??[0,0,0],rotation:n.rotation??[0,0,0,1]});let o=i.keyframes[0];o.time=e.timeSec,n.position&&(o.position=n.position),n.rotation&&(o.rotation=n.rotation),o.velocity=n.velocity,o.health=n.health,o.energy=n.energy,o.actionAnim=n.actionAnim,o.actionAtEnd=n.actionAtEnd,o.damageState=n.damageState,a.set(n.id,i)}for(let[n,i]of t)if(!a.has(n)){if("Explosion"===i.type&&i.dataBlock&&null!=i.spawnTime&&e.timeSec-i.spawnTime<5){a.set(n,i);continue}r=!0}a.size!==t.size&&(r=!0),T.current=a,r&&j(Array.from(a.values()));let n=null;if(e.camera?.mode==="first-person"&&e.camera.controlEntityId){let t=a.get(e.camera.controlEntityId);t?.dataBlock&&(n=t.dataBlock)}N(e=>e===n?e:n)},F[3]=l):l=F[3];let A=l;return F[4]!==S||F[5]!==b.streamingPlayback?(d=()=>{D.current=b.streamingPlayback??null,T.current=new Map,E.current=null,M.current=null,k.current=0,w.current=0,C.current=null,_.current=null;let e=D.current;if(!e)return void S.getState().setPlaybackStreamSnapshot(null);for(let t of(e.reset(),e.getEffectShapes()))L.useGLTF.preload((0,c.shapeToUrl)(t));let t=e.getSnapshot();return k.current=t.timeSec,w.current=t.timeSec,C.current=t,_.current=t,A(t),S.getState().setPlaybackStreamSnapshot(t),M.current=t,()=>{S.getState().setPlaybackStreamSnapshot(null)}},F[4]=S,F[5]=b.streamingPlayback,F[6]=d):d=F[6],F[7]!==S||F[8]!==b?(h=[b,S,A],F[7]=S,F[8]=b,F[9]=h):h=F[9],(0,n.useEffect)(d,h),F[10]!==S?(m=(e,t)=>{let a=D.current;if(!a)return;let r=S.getState(),n=r.playback,i="playing"===n.status,o=n.timeMs/1e3,s=!i&&Math.abs(o-w.current)>5e-4,l=i&&Math.abs(o-k.current)>.05,c=s||l;c&&(w.current=o),i&&((0,I.advanceEffectClock)(t,n.rate),w.current=w.current+t*n.rate);let d=Math.max(1,Math.ceil(1e3*t*Math.max(n.rate,.01)/32)+2),u=w.current+o2.STREAM_TICK_SEC,h=a.stepToTime(u,i&&!c?d:1/0),m=_.current;!m||h.timeSec<m.timeSec||h.timeSec-m.timeSec>1.5*o2.STREAM_TICK_SEC?(C.current=h,_.current=h):h.timeSec!==m.timeSec&&(C.current=m,_.current=h);let f=_.current??h,g=C.current??f,p=f.timeSec-o2.STREAM_TICK_SEC,y=Math.max(0,Math.min(1,(w.current-p)/o2.STREAM_TICK_SEC));k.current=w.current,h.exhausted&&i&&(w.current=Math.min(w.current,h.timeSec)),A(f);let v=M.current;(!v||f.timeSec!==v.timeSec||f.exhausted!==v.exhausted||f.status.health!==v.status.health||f.status.energy!==v.status.energy||f.camera?.mode!==v.camera?.mode||f.camera?.controlEntityId!==v.camera?.controlEntityId||f.camera?.orbitTargetId!==v.camera?.orbitTargetId||f.chatMessages.length!==v.chatMessages.length||f.teamScores.length!==v.teamScores.length||f.teamScores.some((e,t)=>e.score!==v.teamScores[t]?.score||e.playerCount!==v.teamScores[t]?.playerCount))&&(M.current=f,r.setPlaybackStreamSnapshot(f));let F=f.camera,b=F&&g.camera&&g.camera.mode===F.mode&&g.camera.controlEntityId===F.controlEntityId&&g.camera.orbitTargetId===F.orbitTargetId?g.camera:null;if(F){if(b){let t=b.position[0],a=b.position[1],r=b.position[2],n=F.position[0],i=F.position[1],o=F.position[2];e.camera.position.set(a+(i-a)*y,r+(o-r)*y,t+(n-t)*y),ll.set(...b.rotation),lc.set(...F.rotation),ll.slerp(lc,y),e.camera.quaternion.copy(ll)}else e.camera.position.set(F.position[1],F.position[2],F.position[0]),e.camera.quaternion.set(...F.rotation);if(Number.isFinite(F.fov)&&"isPerspectiveCamera"in e.camera&&e.camera.isPerspectiveCamera){let t=e.camera,a=b&&Number.isFinite(b.fov)?b.fov+(F.fov-b.fov)*y:F.fov,r=(0,o2.torqueHorizontalFovToThreeVerticalFov)(a,t.aspect);Math.abs(t.fov-r)>.01&&(t.fov=r,t.updateProjectionMatrix())}}let E=lo(f),B=lo(g),j=T.current,R=x.current;if(R)for(let t of R.children){let a=E.get(t.name);if(!a){let e=j.get(t.name);if(e?.keyframes[0]?.position){let a=e.keyframes[0];t.visible=!0,t.position.set(a.position[1],a.position[2],a.position[0]);continue}}if(!a?.position){t.visible=!1;continue}t.visible=!0;let r=B.get(t.name);if(r?.position){let e=r.position[0],n=r.position[1],i=r.position[2],o=a.position[0],s=a.position[1],l=a.position[2],c=e+(o-e)*y,d=n+(s-n)*y,u=i+(l-i)*y;t.position.set(d,u,c)}else t.position.set(a.position[1],a.position[2],a.position[0]);a.faceViewer?t.quaternion.copy(e.camera.quaternion).multiply(ld):a.visual?.kind==="tracer"?t.quaternion.identity():a.rotation&&(r?.rotation?(ll.set(...r.rotation),lc.set(...a.rotation),ll.slerp(lc,y),t.quaternion.copy(ll)):t.quaternion.set(...a.rotation))}let N=F?.mode;if("third-person"===N&&R&&F?.orbitTargetId){let t=R.children.find(e=>e.name===F.orbitTargetId);if(t){let a=E.get(F.orbitTargetId);lh.copy(t.position),a?.type==="Player"&&(lh.y=lh.y+1);let r=!1;if("number"==typeof F.yaw&&"number"==typeof F.pitch){let e=Math.sin(F.pitch),t=Math.cos(F.pitch),a=Math.sin(F.yaw),n=Math.cos(F.yaw);lu.set(-t,-a*e,-n*e),r=lu.lengthSq()>1e-8}if(r||(lu.copy(e.camera.position).sub(lh),r=lu.lengthSq()>1e-8),r){lu.normalize();let t=Math.max(.1,F.orbitDistance??4);lm.copy(lh).addScaledVector(lu,t),e.camera.position.copy(lm),e.camera.lookAt(lh)}}}if("first-person"===N&&R&&F?.controlEntityId){let t=R.children.find(e=>e.name===F.controlEntityId);t?(ls.copy(P.current).applyQuaternion(t.quaternion),e.camera.position.add(ls)):e.camera.position.y=e.camera.position.y+P.current.y}i&&h.exhausted&&r.setPlaybackStatus("paused");let G=1e3*w.current;Math.abs(G-n.timeMs)>.5&&r.setPlaybackTime(G)},F[10]=S,F[11]=m):m=F[11],(0,u.useFrame)(m),F[12]!==B||F[13]!==b.streamingPlayback?(f=B.map(e=>(0,a.jsx)(sR,{entity:e,timeRef:k,playback:b.streamingPlayback},e.id)),F[12]=B,F[13]=b.streamingPlayback,F[14]=f):f=F[14],F[15]!==f?(g=(0,a.jsx)("group",{ref:x,children:f}),F[15]=f,F[16]=g):g=F[16],F[17]!==b.streamingPlayback?(p=(0,a.jsx)(lt,{playback:b.streamingPlayback,snapshotRef:_}),F[17]=b.streamingPlayback,F[18]=p):p=F[18],F[19]!==R?(y=R&&(0,a.jsx)(n.Suspense,{fallback:null,children:(0,a.jsx)(sl,{shapeName:R,eyeOffsetRef:P})}),F[19]=R,F[20]=y):y=F[20],F[21]!==p||F[22]!==y||F[23]!==g?(v=(0,a.jsxs)(eE.TickProvider,{children:[g,p,y]}),F[21]=p,F[22]=y,F[23]=g,F[24]=v):v=F[24],v}function lg(){let e,t=(0,r.c)(2),n=ts();return n?(t[0]!==n?(e=(0,a.jsx)(lf,{recording:n}),t[0]=n,t[1]=e):e=t[1],e):null}var lp=e.i(21629);let ly=[.25,.5,1,2,4];function lv(e){let t=Math.floor(e/60),a=Math.floor(e%60);return`${t}:${a.toString().padStart(2,"0")}`}function lF(){let e,t,i,o,s,l,c,d,u,h,m,f,g=(0,r.c)(33),p=ts(),y=(0,I.useEngineSelector)(tc),v=(0,I.useEngineSelector)(td),F=(0,I.useEngineSelector)(tu),b=(0,I.useEngineSelector)(th),{play:S,pause:x,seek:k,setSpeed:w}=tm();g[0]!==y||g[1]!==x||g[2]!==S||g[3]!==p?(e=()=>{if(!p)return;let e=e=>{if("Space"!==e.code)return;let t=e.target;"INPUT"===t.tagName||"TEXTAREA"===t.tagName||"SELECT"===t.tagName||"BUTTON"===t.tagName||t.isContentEditable||(e.preventDefault(),y?x():S())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},t=[p,y,S,x],g[0]=y,g[1]=x,g[2]=S,g[3]=p,g[4]=e,g[5]=t):(e=g[4],t=g[5]),(0,n.useEffect)(e,t),g[6]!==k?(i=e=>{k(parseFloat(e.target.value))},g[6]=k,g[7]=i):i=g[7];let C=i;g[8]!==w?(o=e=>{w(parseFloat(e.target.value))},g[8]=w,g[9]=o):o=g[9];let _=o;if(!p)return null;let P=y?x:S,D=y?"Pause":"Play",M=y?"❚❚":"▶";g[10]!==P||g[11]!==D||g[12]!==M?(s=(0,a.jsx)("button",{className:lp.default.PlayPause,onClick:P,"aria-label":D,children:M}),g[10]=P,g[11]=D,g[12]=M,g[13]=s):s=g[13],g[14]!==v?(l=lv(v),g[14]=v,g[15]=l):l=g[15],g[16]!==F?(c=lv(F),g[16]=F,g[17]=c):c=g[17];let T=`${l} / ${c}`;return g[18]!==T?(d=(0,a.jsx)("span",{className:lp.default.Time,children:T}),g[18]=T,g[19]=d):d=g[19],g[20]!==v||g[21]!==F||g[22]!==C?(u=(0,a.jsx)("input",{className:lp.default.Seek,type:"range",min:0,max:F,step:.01,value:v,onChange:C}),g[20]=v,g[21]=F,g[22]=C,g[23]=u):u=g[23],g[24]===Symbol.for("react.memo_cache_sentinel")?(h=ly.map(lb),g[24]=h):h=g[24],g[25]!==_||g[26]!==b?(m=(0,a.jsx)("select",{className:lp.default.Speed,value:b,onChange:_,children:h}),g[25]=_,g[26]=b,g[27]=m):m=g[27],g[28]!==d||g[29]!==u||g[30]!==m||g[31]!==s?(f=(0,a.jsxs)("div",{className:lp.default.Root,onKeyDown:lk,onPointerDown:lx,onClick:lS,children:[s,d,u,m]}),g[28]=d,g[29]=u,g[30]=m,g[31]=s,g[32]=f):f=g[32],f}function lb(e){return(0,a.jsxs)("option",{value:e,children:[e,"x"]},e)}function lS(e){return e.stopPropagation()}function lx(e){return e.stopPropagation()}function lk(e){return e.stopPropagation()}var lw=e.i(75840);let lI=(0,c.textureToUrl)("gui/hud_new_compass"),lC=(0,c.textureToUrl)("gui/hud_new_NSEW");function l_(e){let t,n,i=(0,r.c)(3),{yaw:o}=e;if(null==o)return null;let s=180*o/Math.PI;i[0]===Symbol.for("react.memo_cache_sentinel")?(t=(0,a.jsx)("img",{src:lI,alt:"",className:lw.default.CompassRing}),i[0]=t):t=i[0];let l=`rotate(${-s}deg)`;return i[1]!==l?(n=(0,a.jsxs)("div",{className:lw.default.Compass,children:[t,(0,a.jsx)("img",{src:lC,alt:"",className:lw.default.CompassNSEW,style:{transform:l}})]}),i[1]=l,i[2]=n):n=i[2],n}function lP(e){let t,n=(0,r.c)(2),{value:i}=e,o=Math.max(0,Math.min(100,100*i)),s=`${o}%`;return n[0]!==s?(t=(0,a.jsx)("div",{className:lw.default.BarTrack,children:(0,a.jsx)("div",{className:lw.default.BarFillHealth,style:{width:s}})}),n[0]=s,n[1]=t):t=n[1],t}function lD(e){let t,n=(0,r.c)(2),{value:i}=e,o=Math.max(0,Math.min(100,100*i)),s=`${o}%`;return n[0]!==s?(t=(0,a.jsx)("div",{className:lw.default.BarTrack,children:(0,a.jsx)("div",{className:lw.default.BarFillEnergy,style:{width:s}})}),n[0]=s,n[1]=t):t=n[1],t}let lM={weapon_sniper:"gui/hud_ret_sniper",weapon_shocklance:"gui/hud_ret_shocklance",weapon_targeting:"gui/hud_ret_targlaser"};function lT(){let e,t=(0,r.c)(5),n=(0,I.useEngineSelector)(lE);if(void 0===n)return null;let i=lM[!n?"":n.replace(/\.dts$/i,"").toLowerCase()];if(i){let e,r;return t[0]!==i?(e=(0,c.textureToUrl)(i),t[0]=i,t[1]=e):e=t[1],t[2]!==e?(r=(0,a.jsx)("div",{className:lw.default.Reticle,children:(0,a.jsx)("img",{src:e,alt:"",className:lw.default.ReticleImage})}),t[2]=e,t[3]=r):r=t[3],r}return t[4]===Symbol.for("react.memo_cache_sentinel")?(e=(0,a.jsx)("div",{className:lw.default.Reticle,children:(0,a.jsx)("div",{className:lw.default.ReticleDot})}),t[4]=e):e=t[4],e}function lE(e){let t=e.playback.streamSnapshot;if(!t||t.camera?.mode!=="first-person")return;let a=t.controlPlayerGhostId;if(a)return t.entities.find(e=>e.id===a)?.weaponShape}let lB={0:{icon:"gui/hud_blaster",label:"Blaster"},1:{icon:"gui/hud_plasma",label:"Plasma"},2:{icon:"gui/hud_chaingun",label:"Chaingun"},3:{icon:"gui/hud_disc",label:"Spinfusor"},4:{icon:"gui/hud_grenlaunch",label:"GL"},5:{icon:"gui/hud_sniper",label:"Laser Rifle"},6:{icon:"gui/hud_elfgun",label:"ELF Gun"},7:{icon:"gui/hud_new_mortar",label:"Mortar"},8:{icon:"gui/hud_missiles",label:"Missile"},9:{icon:"gui/hud_targetlaser",label:"Targeting"},10:{icon:"gui/hud_shocklance",label:"Shocklance"},11:{icon:"gui/hud_disc",label:"Spinfusor"},12:{icon:"gui/hud_grenlaunch",label:"GL"},13:{icon:"gui/hud_chaingun",label:"Chaingun"},14:{icon:"gui/hud_targetlaser",label:"Targeting"},15:{icon:"gui/hud_targetlaser",label:"Targeting"},16:{icon:"gui/hud_shocklance",label:"Shocklance"},17:{icon:"gui/hud_new_mortar",label:"Mortar"}},lj=new Map(Object.entries(lB).map(([e,t])=>[Number(e),(0,c.textureToUrl)(t.icon)])),lR=new Set([9,14,15]),lN=(0,c.textureToUrl)("gui/hud_infinity");function lA(e){let t,n,i,o,s=(0,r.c)(12),{slot:l,isSelected:c}=e,d=lB[l.index];if(!d)return null;let u=l.ammo<0,h=`${lw.default.PackInvItem} ${c?lw.default.PackInvItemActive:lw.default.PackInvItemDim}`;return s[0]!==l.index?(t=lj.get(l.index),s[0]=l.index,s[1]=t):t=s[1],s[2]!==d.label||s[3]!==t?(n=(0,a.jsx)("img",{src:t,alt:d.label,className:lw.default.PackInvIcon}),s[2]=d.label,s[3]=t,s[4]=n):n=s[4],s[5]!==u||s[6]!==l.ammo?(i=u?(0,a.jsx)("img",{src:lN,alt:"\\u221E",className:lw.default.PackInvInfinity}):(0,a.jsx)("span",{className:lw.default.PackInvCount,children:l.ammo}),s[5]=u,s[6]=l.ammo,s[7]=i):i=s[7],s[8]!==h||s[9]!==n||s[10]!==i?(o=(0,a.jsxs)("div",{className:h,children:[n,i]}),s[8]=h,s[9]=n,s[10]=i,s[11]=o):o=s[11],o}function lG(){let e,t,n,i,o,s,l=(0,r.c)(15),c=(0,I.useEngineSelector)(lU);if(!c||!c.slots.length)return null;if(l[0]!==c.slots){for(let a of(t=[],e=[],c.slots))lR.has(a.index)?e.push(a):t.push(a);l[0]=c.slots,l[1]=e,l[2]=t}else e=l[1],t=l[2];return l[3]!==t||l[4]!==c?(n=t.map(e=>(0,a.jsx)(lA,{slot:e,isSelected:e.index===c.activeIndex},e.index)),l[3]=t,l[4]=c,l[5]=n):n=l[5],l[6]!==e.length?(i=e.length>0&&(0,a.jsx)("div",{className:lw.default.WeaponSeparator}),l[6]=e.length,l[7]=i):i=l[7],l[8]!==e||l[9]!==c?(o=e.map(e=>(0,a.jsx)(lA,{slot:e,isSelected:e.index===c.activeIndex},e.index)),l[8]=e,l[9]=c,l[10]=o):o=l[10],l[11]!==n||l[12]!==i||l[13]!==o?(s=(0,a.jsxs)("div",{className:lw.default.WeaponHUD,children:[n,i,o]}),l[11]=n,l[12]=i,l[13]=o,l[14]=s):s=l[14],s}function lU(e){return e.playback.streamSnapshot?.weaponsHud}let lL={1:"Storm",2:"Inferno",3:"Starwolf",4:"Diamond Sword",5:"Blood Eagle",6:"Phoenix"};function lz(){let e,t,n,i=(0,r.c)(11),o=(0,I.useEngineSelector)(lV),s=(0,I.useEngineSelector)(lO);if(!o?.length)return null;if(i[0]!==s||i[1]!==o){let r,n;i[4]!==s?(r=(e,t)=>{if(s){if(e.teamId===s)return -1;if(t.teamId===s)return 1}return e.teamId-t.teamId},i[4]=s,i[5]=r):r=i[5];let l=[...o].sort(r);e=lw.default.TeamScores,i[6]!==s?(n=e=>{let t=s>0&&e.teamId===s,r=e.name||(lL[e.teamId]??`Team ${e.teamId}`);return(0,a.jsxs)("div",{className:lw.default.TeamRow,children:[(0,a.jsx)("span",{className:t?lw.default.TeamNameFriendly:lw.default.TeamNameEnemy,children:r}),(0,a.jsx)("span",{className:lw.default.TeamScore,children:e.score}),(0,a.jsxs)("span",{className:lw.default.TeamCount,children:["(",e.playerCount,")"]})]},e.teamId)},i[6]=s,i[7]=n):n=i[7],t=l.map(n),i[0]=s,i[1]=o,i[2]=e,i[3]=t}else e=i[2],t=i[3];return i[8]!==e||i[9]!==t?(n=(0,a.jsx)("div",{className:e,children:t}),i[8]=e,i[9]=t,i[10]=n):n=i[10],n}function lO(e){return e.playback.streamSnapshot?.playerSensorGroup}function lV(e){return e.playback.streamSnapshot?.teamScores}let lq={0:lw.default.ChatColor0,1:lw.default.ChatColor1,2:lw.default.ChatColor2,3:lw.default.ChatColor3,4:lw.default.ChatColor4,5:lw.default.ChatColor5,6:lw.default.ChatColor6,7:lw.default.ChatColor7,8:lw.default.ChatColor8,9:lw.default.ChatColor9};function lH(){let e,t,n,i,o=(0,r.c)(13),s=(0,I.useEngineSelector)(lY),l=(0,I.useEngineSelector)(l$);if(!s||!s.length||null==l)return null;let c=l-7.5;if(o[0]!==c||o[1]!==s||o[2]!==l){n=Symbol.for("react.early_return_sentinel");e:{let r,i;o[6]!==c?(r=e=>e.timeSec>c&&""!==e.text.trim(),o[6]=c,o[7]=r):r=o[7];let d=s.filter(r);if(!d.length){n=null;break e}e=lw.default.ChatWindow,o[8]!==l?(i=(e,t)=>{let r=l-e.timeSec,n=r<=6?1:Math.max(0,1-(r-6)/1.5);return(0,a.jsx)("div",{className:lw.default.ChatMessage,style:{opacity:n},children:e.segments?e.segments.map(lW):(0,a.jsxs)("span",{className:null!=e.colorCode&&lq[e.colorCode]?lq[e.colorCode]:lq[0],children:[e.sender?`${e.sender}: `:"",e.text]})},`${e.timeSec}-${t}`)},o[8]=l,o[9]=i):i=o[9],t=d.map(i)}o[0]=c,o[1]=s,o[2]=l,o[3]=e,o[4]=t,o[5]=n}else e=o[3],t=o[4],n=o[5];return n!==Symbol.for("react.early_return_sentinel")?n:(o[10]!==e||o[11]!==t?(i=(0,a.jsx)("div",{className:e,children:t}),o[10]=e,o[11]=t,o[12]=i):i=o[12],i)}function lW(e,t){return(0,a.jsx)("span",{className:lq[e.colorCode]??lq[0],children:e.text},t)}function l$(e){return e.playback.streamSnapshot?.timeSec}function lY(e){return e.playback.streamSnapshot?.chatMessages}let lK=new Map(Object.entries({0:"gui/hud_new_packammo",1:"gui/hud_new_packcloak",2:"gui/hud_new_packenergy",3:"gui/hud_new_packrepair",4:"gui/hud_new_packsatchel",5:"gui/hud_new_packshield",6:"gui/hud_new_packinventory",7:"gui/hud_new_packmotionsens",8:"gui/hud_new_packradar",9:"gui/hud_new_packturretout",10:"gui/hud_new_packturretin",11:"gui/hud_new_packsensjam",12:"gui/hud_new_packturret",13:"gui/hud_new_packturret",14:"gui/hud_new_packturret",15:"gui/hud_new_packturret",16:"gui/hud_new_packturret",17:"gui/hud_new_packturret",18:"gui/hud_satchel_unarmed",19:"gui/hud_new_packenergy"}).map(([e,t])=>[Number(e),(0,c.textureToUrl)(t)])),lX=new Map(Object.entries({1:"gui/hud_new_packcloak_armed",3:"gui/hud_new_packrepair_armed",4:"gui/hud_satchel_armed",5:"gui/hud_new_packshield_armed",11:"gui/hud_new_packsensjam_armed"}).map(([e,t])=>[Number(e),(0,c.textureToUrl)(t)])),lZ={0:{icon:"gui/hud_handgren",label:"Grenade"},1:{icon:"gui/hud_mine",label:"Mine"},2:{icon:"gui/hud_beacon",label:"Beacon"},3:{icon:"gui/hud_medpack",label:"Repair Kit"}},lJ=new Map(Object.entries(lZ).map(([e,t])=>[Number(e),(0,c.textureToUrl)(t.icon)]));function lQ(){let e,t,n,i,o,s,l,c=(0,r.c)(25),d=(0,I.useEngineSelector)(l2),u=(0,I.useEngineSelector)(l1),h=d&&d.packIndex>=0;if(h){let t,a;c[0]!==d.active||c[1]!==d.packIndex?(t=d.active?lX.get(d.packIndex):void 0,c[0]=d.active,c[1]=d.packIndex,c[2]=t):t=c[2];let r=t;c[3]!==r||c[4]!==d.packIndex?(a=r??lK.get(d.packIndex),c[3]=r,c[4]=d.packIndex,c[5]=a):a=c[5],e=a}if(c[6]!==u){if(t=new Map,u)for(let e of u.slots)t.set(e.slot,e.count);c[6]=u,c[7]=t}else t=c[7];if(c[8]!==d||c[9]!==t||c[10]!==h||c[11]!==e){s=Symbol.for("react.early_return_sentinel");e:{let r,l=Object.keys(lZ).map(Number).sort(l0);if(!h&&!t.size){s=null;break e}n=lw.default.PackInventoryHUD,c[16]!==d||c[17]!==e?(i=e&&(0,a.jsxs)("div",{className:`${lw.default.PackInvItem} ${d.active?lw.default.PackInvItemActive:""}`,children:[(0,a.jsx)("img",{src:e,alt:"",className:lw.default.PackInvIcon}),(0,a.jsx)("span",{className:lw.default.PackInvCount,children:d.text||" "})]}),c[16]=d,c[17]=e,c[18]=i):i=c[18],c[19]!==t?(r=e=>{let r=lZ[e],n=lJ.get(e);return r&&n?(0,a.jsxs)("div",{className:lw.default.PackInvItem,children:[(0,a.jsx)("img",{src:n,alt:r.label,className:lw.default.PackInvIcon}),(0,a.jsx)("span",{className:lw.default.PackInvCount,children:t.get(e)??0})]},e):null},c[19]=t,c[20]=r):r=c[20],o=l.map(r)}c[8]=d,c[9]=t,c[10]=h,c[11]=e,c[12]=n,c[13]=i,c[14]=o,c[15]=s}else n=c[12],i=c[13],o=c[14],s=c[15];return s!==Symbol.for("react.early_return_sentinel")?s:(c[21]!==n||c[22]!==i||c[23]!==o?(l=(0,a.jsxs)("div",{className:n,children:[i,o]}),c[21]=n,c[22]=i,c[23]=o,c[24]=l):l=c[24],l)}function l0(e,t){return e-t}function l1(e){return e.playback.streamSnapshot?.inventoryHud}function l2(e){return e.playback.streamSnapshot?.backpackHud}function l3(){let e,t,n,i,o,s,l,c,d,u,h,m=(0,r.c)(19),f=ts(),g=(0,I.useEngineSelector)(l5);if(!f)return null;let p=g?.status;if(!p)return null;m[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,a.jsx)(lH,{}),m[0]=e):e=m[0],m[1]!==p.health?(t=(0,a.jsx)(lP,{value:p.health}),m[1]=p.health,m[2]=t):t=m[2],m[3]!==p.energy?(n=(0,a.jsx)(lD,{value:p.energy}),m[3]=p.energy,m[4]=n):n=m[4],m[5]!==t||m[6]!==n?(i=(0,a.jsxs)("div",{className:lw.default.Bars,children:[t,n]}),m[5]=t,m[6]=n,m[7]=i):i=m[7];let y=g?.camera?.yaw;return m[8]!==y?(o=(0,a.jsx)(l_,{yaw:y}),m[8]=y,m[9]=o):o=m[9],m[10]!==i||m[11]!==o?(s=(0,a.jsxs)("div",{className:lw.default.TopRight,children:[i,o]}),m[10]=i,m[11]=o,m[12]=s):s=m[12],m[13]===Symbol.for("react.memo_cache_sentinel")?(c=(0,a.jsx)(lG,{}),d=(0,a.jsx)(lQ,{}),u=(0,a.jsx)(lz,{}),l=(0,a.jsx)(lT,{}),m[13]=l,m[14]=c,m[15]=d,m[16]=u):(l=m[13],c=m[14],d=m[15],u=m[16]),m[17]!==s?(h=(0,a.jsxs)("div",{className:lw.default.PlayerHUD,children:[e,s,c,d,u,l]}),m[17]=s,m[18]=h):h=m[18],h}function l5(e){return e.playback.streamSnapshot}function l4(){let{audioLoader:e,audioListener:t}=(0,o0.useAudio)(),a=(0,v.useSettings)(),r=a?.audioEnabled??!1,i=(0,I.useEngineSelector)(e=>e.playback.streamSnapshot?.chatMessages),s=(0,I.useEngineSelector)(e=>e.playback.streamSnapshot?.timeSec),l=(0,n.useRef)(new WeakSet),d=(0,n.useRef)(new Map);return(0,n.useEffect)(()=>{if(!r||!e||!t||!i?.length||null==s)return;let a=l.current,n=d.current;for(let r of i){if(!a.has(r)){if((a.add(r),r.soundPath)&&!(Math.abs(s-r.timeSec)>2))try{let a=(0,c.audioToUrl)(r.soundPath),i=r.soundPitch??1,s=I.engineStore.getState().playback.rate,l=r.sender;(0,o8.getCachedAudioBuffer)(a,e,e=>{if(l){let e=n.get(l);if(e){try{e.stop()}catch{}(0,o8.untrackDemoSound)(e),e.disconnect(),n.delete(l)}}let a=new o.Audio(t);a.setBuffer(e),a.setPlaybackRate(i*s),(0,o8.trackDemoSound)(a,i),l&&n.set(l,a),a.play(),a.source.onended=()=>{(0,o8.untrackDemoSound)(a),a.disconnect(),l&&n.get(l)===a&&n.delete(l)}})}catch{}}}},[r,e,t,i,s]),null}var l6=e.i(38847),l8=e.i(3011);let l7=(0,n.lazy)(()=>e.A(59197).then(e=>({default:e.MapInfoDialog}))),l9=new eW.QueryClient,ce={toneMapping:o.NoToneMapping,outputColorSpace:o.SRGBColorSpace},ct=(0,l6.createParser)({parse(e){let[t,a]=e.split("~"),r=a,n=(0,eG.getMissionInfo)(t).missionTypes;return a&&n.includes(a)||(r=n[0]),{missionName:t,missionType:r}},serialize:({missionName:e,missionType:t})=>1===(0,eG.getMissionInfo)(e).missionTypes.length?e:`${e}~${t}`,eq:(e,t)=>e.missionName===t.missionName&&e.missionType===t.missionType}).withDefault({missionName:"RiverDance",missionType:"CTF"});function ca(){let e,t,s,l,c,d,u,h,m,f,g,p,y,F,b,S,x,k,w,I,C,_,P,D,M,T,E,B,j,R,N,A,G,U,L,z,O,V,q,H=(0,r.c)(69),[W,$]=(0,l6.useQueryState)("mission",ct),[Y,K]=(0,l6.useQueryState)("fog",l6.parseAsBoolean);H[0]!==K?(e=()=>{K(null)},H[0]=K,H[1]=e):e=H[1];let X=e;H[2]!==X||H[3]!==$?(t=e=>{window.location.hash="",X(),$(e)},H[2]=X,H[3]=$,H[4]=t):t=H[4];let Z=t,J=(z=(0,r.c)(2),O=(0,n.useRef)(null),z[0]===Symbol.for("react.memo_cache_sentinel")?(U=e=>{let t=window.matchMedia("(pointer: coarse)");return t.addEventListener("change",e),O.current=t,()=>{t.removeEventListener("change",e)}},z[0]=U):U=z[0],V=U,z[1]===Symbol.for("react.memo_cache_sentinel")?(L=()=>O.current?.matches??null,z[1]=L):L=z[1],q=L,(0,n.useSyncExternalStore)(V,q,oX)),{missionName:Q,missionType:ee}=W,[et,ea]=(0,n.useState)(!1),[er,en]=(0,n.useState)(0),[ei,eo]=(0,n.useState)(!0),es=er<1;H[5]!==es?(s=()=>{if(es)eo(!0);else{let e=setTimeout(()=>eo(!1),500);return()=>clearTimeout(e)}},l=[es],H[5]=es,H[6]=s,H[7]=l):(s=H[6],l=H[7]),(0,n.useEffect)(s,l),H[8]!==Z?(c=()=>(window.setMissionName=e=>{let t=(0,eG.getMissionInfo)(e).missionTypes;Z({missionName:e,missionType:t[0]})},window.getMissionList=eG.getMissionList,window.getMissionInfo=eG.getMissionInfo,cr),d=[Z],H[8]=Z,H[9]=c,H[10]=d):(c=H[9],d=H[10]),(0,n.useEffect)(c,d),H[11]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{let e=e=>{if("KeyI"!==e.code||e.metaKey||e.ctrlKey||e.altKey)return;let t=e.target;"INPUT"===t.tagName||"TEXTAREA"===t.tagName||t.isContentEditable||ea(!0)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},h=[],H[11]=u,H[12]=h):(u=H[11],h=H[12]),(0,n.useEffect)(u,h),H[13]===Symbol.for("react.memo_cache_sentinel")?(m=(e,t)=>{en(void 0===t?0:t)},H[13]=m):m=H[13];let el=m,ec=(0,n.useRef)(null);H[14]===Symbol.for("react.memo_cache_sentinel")?(f={angle:0,force:0},H[14]=f):f=H[14];let ed=(0,n.useRef)(f),eu=(0,n.useRef)(null);H[15]===Symbol.for("react.memo_cache_sentinel")?(g={angle:0,force:0},H[15]=g):g=H[15];let eh=(0,n.useRef)(g),em=(0,n.useRef)(null);H[16]!==es||H[17]!==er||H[18]!==ei?(p=ei&&(0,a.jsxs)("div",{id:"loadingIndicator",className:l8.default.LoadingIndicator,"data-complete":!es,children:[(0,a.jsx)("div",{className:l8.default.Spinner}),(0,a.jsx)("div",{className:l8.default.Progress,children:(0,a.jsx)("div",{className:l8.default.ProgressBar,style:{width:`${100*er}%`}})}),(0,a.jsxs)("div",{className:l8.default.ProgressText,children:[Math.round(100*er),"%"]})]}),H[16]=es,H[17]=er,H[18]=ei,H[19]=p):p=H[19],H[20]===Symbol.for("react.memo_cache_sentinel")?(y={type:o.PCFShadowMap},F=e=>{ec.current=e.camera},H[20]=y,H[21]=F):(y=H[20],F=H[21]);let ef=`${Q}~${ee}`;return H[22]!==Q||H[23]!==ee||H[24]!==ef?(b=(0,a.jsx)(eH,{name:Q,missionType:ee,onLoadingChange:el},ef),H[22]=Q,H[23]=ee,H[24]=ef,H[25]=b):b=H[25],H[26]===Symbol.for("react.memo_cache_sentinel")?(S=(0,a.jsx)(oQ,{}),x=(0,a.jsx)(o1.DebugElements,{}),k=(0,a.jsx)(lg,{}),w=(0,a.jsx)(l4,{}),H[26]=S,H[27]=x,H[28]=k,H[29]=w):(S=H[26],x=H[27],k=H[28],w=H[29]),H[30]!==J?(I=(0,a.jsx)(co,{isTouch:J,joystickStateRef:ed,joystickZoneRef:eu,lookJoystickStateRef:eh,lookJoystickZoneRef:em}),H[30]=J,H[31]=I):I=H[31],H[32]!==b||H[33]!==I?(C=(0,a.jsx)(i.Canvas,{frameloop:"always",gl:ce,shadows:y,onCreated:F,children:(0,a.jsx)(ew,{children:(0,a.jsxs)(o0.AudioProvider,{children:[b,S,x,k,w,I]})})}),H[32]=b,H[33]=I,H[34]=C):C=H[34],H[35]!==p||H[36]!==C?(_=(0,a.jsxs)("div",{id:"canvasContainer",className:l8.default.CanvasContainer,children:[p,C]}),H[35]=p,H[36]=C,H[37]=_):_=H[37],H[38]===Symbol.for("react.memo_cache_sentinel")?(P=(0,a.jsx)(l3,{}),H[38]=P):P=H[38],H[39]!==J?(D=J&&(0,a.jsx)(tB,{joystickState:ed,joystickZone:eu,lookJoystickState:eh,lookJoystickZone:em}),H[39]=J,H[40]=D):D=H[40],H[41]!==J?(M=!1===J&&(0,a.jsx)(tF,{}),H[41]=J,H[42]=M):M=H[42],H[43]===Symbol.for("react.memo_cache_sentinel")?(T=()=>ea(!0),H[43]=T):T=H[43],H[44]!==Z||H[45]!==J||H[46]!==Q||H[47]!==ee?(E=(0,a.jsx)(oH,{missionName:Q,missionType:ee,onChangeMission:Z,onOpenMapInfo:T,cameraRef:ec,isTouch:J}),H[44]=Z,H[45]=J,H[46]=Q,H[47]=ee,H[48]=E):E=H[48],H[49]!==et||H[50]!==Q||H[51]!==ee?(B=et&&(0,a.jsx)(n.Suspense,{fallback:null,children:(0,a.jsx)(l7,{open:et,onClose:()=>ea(!1),missionName:Q,missionType:ee??""})}),H[49]=et,H[50]=Q,H[51]=ee,H[52]=B):B=H[52],H[53]!==Z||H[54]!==W?(j=(0,a.jsx)(ci,{changeMission:Z,currentMission:W}),H[53]=Z,H[54]=W,H[55]=j):j=H[55],H[56]===Symbol.for("react.memo_cache_sentinel")?(R=(0,a.jsx)(lF,{}),N=(0,a.jsx)(cs,{}),H[56]=R,H[57]=N):(R=H[56],N=H[57]),H[58]!==_||H[59]!==D||H[60]!==M||H[61]!==E||H[62]!==B||H[63]!==j?(A=(0,a.jsxs)(eJ,{map:ta,children:[_,P,D,M,E,B,j,R,N]}),H[58]=_,H[59]=D,H[60]=M,H[61]=E,H[62]=B,H[63]=j,H[64]=A):A=H[64],H[65]!==X||H[66]!==Y||H[67]!==A?(G=(0,a.jsx)(e$.QueryClientProvider,{client:l9,children:(0,a.jsx)("main",{children:(0,a.jsx)(to,{children:(0,a.jsx)(v.SettingsProvider,{fogEnabledOverride:Y,onClearFogEnabledOverride:X,children:A})})})}),H[65]=X,H[66]=Y,H[67]=A,H[68]=G):G=H[68],G}function cr(){delete window.setMissionName,delete window.getMissionList,delete window.getMissionInfo}let cn={"Capture the Flag":"CTF","Capture and Hold":"CnH",Deathmatch:"DM","Team Deathmatch":"TDM",Siege:"Siege",Bounty:"Bounty",Rabbit:"Rabbit"};function ci(e){let t,a,i=(0,r.c)(5),{changeMission:o,currentMission:s}=e,l=ts();return i[0]!==o||i[1]!==s||i[2]!==l?(t=()=>{if(!l?.missionName)return;let e=(0,eG.findMissionByDemoName)(l.missionName);if(!e)return void console.warn(`Demo mission "${l.missionName}" not found in manifest`);let t=(0,eG.getMissionInfo)(e),a=l.gameType?cn[l.gameType]:void 0,r=a&&t.missionTypes.includes(a)?a:t.missionTypes[0];(s.missionName!==e||s.missionType!==r)&&o({missionName:e,missionType:r})},a=[l,o,s],i[0]=o,i[1]=s,i[2]=l,i[3]=t,i[4]=a):(t=i[3],a=i[4]),(0,n.useEffect)(t,a),null}function co(e){let t,n=(0,r.c)(6),{isTouch:i,joystickStateRef:o,joystickZoneRef:s,lookJoystickStateRef:l,lookJoystickZoneRef:c}=e;if(ts()||null===i)return null;if(i){let e;return n[0]!==o||n[1]!==s||n[2]!==l||n[3]!==c?(e=(0,a.jsx)(tj,{joystickState:o,joystickZone:s,lookJoystickState:l,lookJoystickZone:c}),n[0]=o,n[1]=s,n[2]=l,n[3]=c,n[4]=e):e=n[4],e}return n[5]===Symbol.for("react.memo_cache_sentinel")?(t=(0,a.jsx)(tr,{}),n[5]=t):t=n[5],t}function cs(){let e,t,a=(0,r.c)(3),{setRecording:i}=tm();return a[0]!==i?(e=()=>(window.loadDemoRecording=i,cl),t=[i],a[0]=i,a[1]=e,a[2]=t):(e=a[1],t=a[2]),(0,n.useEffect)(e,t),null}function cl(){delete window.loadDemoRecording}function cc(){let e,t=(0,r.c)(1);return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,a.jsx)(n.Suspense,{children:(0,a.jsx)(ca,{})}),t[0]=e):e=t[0],e}e.s(["default",()=>cc],31713)}]); |