diff --git a/README.md b/README.md index d224036b..f0d38e93 100644 --- a/README.md +++ b/README.md @@ -616,7 +616,7 @@ git diff --exit-code -- src/intelstream/hands/static `npm run build` typechecks, writes exactly `index.html`, `assets/hands.js`, and `assets/hands.css` into `src/intelstream/hands/static`, and runs the scanner. Those generated files are committed so production Python installations do not require Node. Change TypeScript/CSS in `web/hands`, rebuild, inspect the output, commit source and generated files together, and require the final `git diff --exit-code` after a clean rebuild. Never hand-edit the generated bundle. -The fixed three-file deployment contract embeds the mesh-only Boxer rig and its five source textures (re-encoded as JPEG by the generator) in `hands.js`; the resulting production script is about 2.89 MB (about 1.45 MB gzip). This startup-cost tradeoff keeps the Activity self-contained and avoids runtime asset requests. `scripts/hands_pose_strip.js` renders a pose frozen at a list of times into one frame strip for motion review. `npm run dev` also serves `?model-lab=1&pose=&cam=&trauma=` as a pose lab for reviewing the runtime animation and injury shading without a match (poses include punches, guards, slips, knockdown, seated, celebrate and wave_off), and `?fixture=1` with `&finisher=head|hand`, `&phase=rest`, `&pin=1|corner`, `&blood=reduced|off` or `&platform=mobile` for presentation review. Both take the engine's injuries: `&injuries=` carried from the start, `&inflict=` happening one after another, `&bloodvol=<0..1000>`, and `&fatality=` (the fixture runs FINISH HIM, the kill, its replay and the result card). The lab also takes `&dead=`, `&dazed=1` and `&vomit=1`; the fixture takes `&death=` and `&injuries1=` for the other fighter. +The fixed three-file deployment contract embeds the mesh-only Boxer rig and its five source textures (re-encoded as JPEG by the generator) in `hands.js`; the resulting production script is about 2.94 MB (about 1.46 MB gzip). This startup-cost tradeoff keeps the Activity self-contained and avoids runtime asset requests. `scripts/hands_pose_strip.js` renders a pose frozen at a list of times into one frame strip for motion review. `npm run dev` also serves `?model-lab=1&pose=&cam=&trauma=` as a pose lab for reviewing the runtime animation and injury shading without a match (poses include punches, guards, slips, knockdown, seated, celebrate and wave_off), and `?fixture=1` with `&finisher=head|hand`, `&phase=rest`, `&pin=1|corner`, `&blood=reduced|off` or `&platform=mobile` for presentation review. Both take the engine's injuries: `&injuries=` carried from the start, `&inflict=` happening one after another, `&bloodvol=<0..1000>`, and `&fatality=` (the fixture runs FINISH HIM, the kill, its replay and the result card). The lab also takes `&dead=`, `&dazed=1` and `&vomit=1`; the fixture takes `&death=` and `&injuries1=` for the other fighter. For judging how the boxers stand and move, both take `&gap=`; the fixture takes `&calm=1` (both standing in their stances, nothing scripted) or `&calm=walk` (circling), `&guard=high|low`, `&styles=,`, `&wear=1` (bodies marked by the fight from the start) and `&referee=count|break`; the lab takes `&speed=` for the walks, `&xray=` to play a bone break's cut-in and `&wear=`. For a standalone presentation fixture, run `npm --prefix web/hands run dev` and open the printed URL with `?fixture=1`. For the real two-process localhost flow, terminal one runs the Python bot/Hands server with valid Discord credentials: diff --git a/src/intelstream/hands/static/assets/hands.js b/src/intelstream/hands/static/assets/hands.js index 561f0ba3..6194898e 100644 --- a/src/intelstream/hands/static/assets/hands.js +++ b/src/intelstream/hands/static/assets/hands.js @@ -1,18 +1,8 @@ -var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var n={format:2,tick_rate:30,ring:{half_width:500,half_height:500,fighter_radius:38},limits:{max_stamina:1e3,max_conditioning:1e3,max_guard:700,max_poise:600},action_buffer_ticks:8,facing:{scale:1e3,turn_degrees_per_second:110},movement:{max_speed:10,blend_percent:75,recovery_speed_percent:60},evasion:{ticks:7,stamina:15},combos:{recovery_cancel_percent:50,chains:[[`jab`,`straight`],[`jab`,`hook`],[`straight`,`hook`],[`hook`,`uppercut`],[`uppercut`,`hook`]]},knockdown:{referee_walk_speed:9,count_ticks:20,mandatory_count:5,box_pause_ticks:20,get_up_stun_ticks:12,get_up_stamina:600,get_up_base:30,get_up_per_knockdown:16,get_up_trauma_divisor:28},countdown:{opening_ticks:90},tired:{startup_ticks:1,recovery_ticks:2,impact_percent:70},foul:{separation:45},hitstop_ms:{hit:78,block:45,power:140},fatigue_scaling:{startup_formula:`max(2, startup * 100 // fatigue - lead_jab_bonus)`,recovery_formula:`max(3, recovery * 100 // fatigue)`,lead_jab_bonus:1,rear_straight_impact_bonus:8},punches:{jab:{startup:3,active:2,recovery:4,reach:150,lateral_arc:42,impact:34,stamina_cost:25,whiff_cost:9,guard_damage:44,poise_damage:35,combo_window:7,startup_vulnerability:1,recovery_vulnerability:2},straight:{startup:4,active:2,recovery:6,reach:168,lateral_arc:38,impact:52,stamina_cost:39,whiff_cost:14,guard_damage:66,poise_damage:58,combo_window:8,startup_vulnerability:2,recovery_vulnerability:3},hook:{startup:5,active:2,recovery:7,reach:126,lateral_arc:92,impact:64,stamina_cost:47,whiff_cost:18,guard_damage:82,poise_damage:72,combo_window:9,startup_vulnerability:3,recovery_vulnerability:4},uppercut:{startup:5,active:2,recovery:8,reach:108,lateral_arc:54,impact:72,stamina_cost:53,whiff_cost:22,guard_damage:88,poise_damage:84,combo_window:10,startup_vulnerability:3,recovery_vulnerability:5}},variants:{body:{startup_add:1,reach_min:80,reach_sub:14,lateral_arc_add:8,impact_mul_num:92,impact_mul_den:100,stamina_cost_add:2,whiff_cost_add:2,poise_damage_mul_num:72,poise_damage_mul_den:100},power:{startup_add:3,active_add:1,recovery_add:3,reach_add:5,impact_mul_num:185,impact_mul_den:100,stamina_cost_mul_num:140,stamina_cost_mul_den:100,whiff_cost_mul_num:150,whiff_cost_mul_den:100,guard_damage_mul_num:220,guard_damage_mul_den:100,poise_damage_mul_num:175,poise_damage_mul_den:100,startup_vulnerability_add:1,recovery_vulnerability_add:1}},hurtboxes:{head:{radius:.13,length:.16,joint:`head`,offset_y:.12},torso:{radius:.21,length:.34,joint:`chest`,offset_y:.16}},corners:{reach:733},rest:{corner_offset:365,walk_speed:10},clinch:{hold_distance:60,draw_speed:6},referee:{radius:34,health:450,walk_speed:6,standoff:62,count_standoff:90,stagger_base_ticks:6,stagger_damage_divisor:8,stagger_max_ticks:30,down_ticks:150,bleed_health_divisor:60},corner:{cut:{worse_cut:250,other_cut:100,bleeding_kept_percent:30},swelling:{swelling:250,eyes:200},breath:{conditioning:180,body:150},balanced:{worse_cut:80,bleeding_kept_percent:75,swelling:80,eyes:60}},blind_side:{eye_threshold:700,impact_percent:120},parry:{stagger_ticks:16},body:{wind_percent:90,collapse_body_trauma:650,collapse_stamina:350,collapse_minimum_damage:40,collapse_delay_ticks:10,collapse_cooldown_ticks:300},styles:{balanced:{},boxer:{recovery_ticks:{jab:-1},reach_percent:102,impact_percent:98,poise_damage_percent:98},slugger:{impact_percent:108,poise_damage_percent:108,poise_taken_percent:95,stamina_cost_percent:115,recovery_ticks:{hook:1,uppercut:1},move_speed_percent:96},swarmer:{move_speed_percent:103,startup_ticks:{hook:-1,uppercut:-1},body_damage_percent:110,conditioning_loss_percent:85,impact_percent:96,poise_damage_percent:96,evasion_ticks:1},counter_puncher:{counter_bonus_percent:38,counter_window_ticks:3,evasion_ticks:1,perfect_block_ticks:1,impact_percent:96,poise_damage_percent:96}},stun:{flinch_minimum_damage:36,flinch_base_ticks:4,flinch_damage_divisor:16,rocked_counter_damage:50,rocked_power_damage:70,rocked_hurt_poise:180,rocked_base_ticks:12,rocked_damage_divisor:6,rocked_max_ticks:28,chain_max_ticks:36,immunity_ticks:18,rocked_immunity_ticks:8,moving_speed_percent:75},guard:{block_poise_percent:35,perfect_block_poise_percent:0,leak_base_percent:80,leak_minimum_percent:25,block_minimum:60,perfect_rearm_ticks:6,damage_percent:100,stamina_regen_percent:50,held_drain:3,break_stun_ticks:24,rearm:250},trauma:{head_per_damage_percent:60,eye_per_damage_percent:70,cut_per_damage_percent:80,jab_cut_percent:40,jab_swelling_percent:50,swelling_per_damage_percent:33,poise_ceiling_per_head_percent:30,poise_ceiling_floor:220,body_per_damage_percent:100,poise_regen_every_ticks:2,poise_damage_percent:85,cut_opens_eye:120,bleeding_cut_divisor:30},hitbox:{glove_radius:.11},injuries:{blood:{volume:1e3,bleeding_divisor:160,rest_percent:50,stages:[{below:600,stamina_regen_percent:75},{below:350,stamina_regen_percent:50},{below:150,stamina_regen_percent:25}]},kinds:{broken_nose:{drain:1,stamina_regen_percent:75,bleeding_floor:150},broken_jaw:{drain:1,poise_taken_percent:125},jaw_torn:{drain:5,poise_taken_percent:150,bleeding_floor:300},eye_out:{drain:2},ear_torn:{drain:1,poise_regen_ticks_add:1},face_flayed:{drain:4,vision_penalty:8},skull_fractured:{drain:4,poise_ceiling_percent:60},shoulder_dislocated:{drain:0,startup_add:2,impact_percent:50,guard_leak_add:20},arm_broken:{drain:3,startup_add:2,impact_percent:30,guard_leak_add:25},forearm_severed:{drain:12,impact_percent:20,reach_sub:45,guard_leak_add:35},arm_torn:{drain:20,guard_leak_add:50},ribs_broken:{drain:0,body_taken_percent:135,max_stamina_sub:60},liver_ruptured:{drain:6,stamina_regen_percent:60},disemboweled:{drain:12,move_speed_percent:75,max_stamina_sub:150,body_taken_percent:150},knee_blown:{drain:0,move_speed_percent:80}},triggers:{nose_wear:800,jaw_break_wear:320,jaw_tear_wear:640,ear_wear:280,eye_out_trauma:850,eye_out_damage:55,flay_cut:550,flay_damage:60,skull_head_trauma:1050,skull_damage:90,brain_death_wear:220,shoulder_wear:280,shoulder_whiff_wear:40,shoulder_parried_wear:90,arm_break_wear:1100,arm_guard_break_wear:300,arm_tear_damage:80,ribs_wear:260,liver_wear:260,gut_body_trauma:800,gut_damage:90,gutted_damage:90,knee_knockdowns:2},vomit:{every_ticks:240,stun_ticks:10},finish:{ticks:105},fatalities:{head:{jab:`eyes_out`,straight:`head_burst`,hook:`decapitation`,uppercut:`spine_rip`},body:{jab:`heart_punch`,straight:`gutting`,hook:`bisection`,uppercut:`total_gib`}}}},r=n.punches,i=n.variants,a=n.tick_rate;n.action_buffer_ticks;var o=n.hitstop_ms,s=n.hurtboxes,c=n.hitbox.glove_radius;n.fatigue_scaling;var l=n.rest.corner_offset,u=n.ring.half_width,d=n.ring.half_height,f=n.ring.fighter_radius,p=n.blind_side.eye_threshold,m=n.guard.block_minimum,h=n.guard.rearm,g=n.movement.max_speed,_=n.movement.blend_percent,v=n.movement.recovery_speed_percent,y=n.evasion.ticks,b=n.evasion.stamina,x=n.corner,S=n.corners.reach,C=n.combos.recovery_cancel_percent,w=new Set(n.combos.chains.map(([e,t])=>`${e}:${t}`));function T(e,t){return w.has(`${e}:${t}`)}function E(e){return e.startup+e.active+Math.floor(e.recovery*C/100)}function D(e,t,n,r,i,a=`balanced`){return t&&!i&&T(e,n.class)&&r>=ue(a,n.class,n.target,n.power)}function O(e){return r[e].combo_window}var k=n.stun.rocked_base_ticks,A=n.stun.rocked_max_ticks,j=n.knockdown,ee=j.count_ticks,M=1400,te=3,ne=j.get_up_base,re=j.get_up_base+te*j.get_up_per_knockdown+Math.floor(M/j.get_up_trauma_divisor),ie=n.stun.moving_speed_percent,N=n.tired.startup_ticks,ae=n.tired.recovery_ticks;function oe(e,t,n){let a=r[e],o=a.startup,s=a.active,c=a.recovery,l=a.reach,u=a.lateral_arc;if(t===`body`){let e=i.body;o+=e.startup_add??0,c+=e.recovery_add??0,l=Math.max(e.reach_min??0,l-(e.reach_sub??0)),u+=e.lateral_arc_add??0}if(n===`power`){let e=i.power;o+=e.startup_add??0,s+=e.active_add??0,c+=e.recovery_add??0,l+=e.reach_add??0}return{startup:o,active:s,recovery:c,reach:l,lateralArc:u}}function se(e,t,n){let a=r[e].stamina_cost;return t===`body`&&(a+=i.body.stamina_cost_add??0),n===`power`&&(a=Math.floor(a*(i.power.stamina_cost_mul_num??1)/(i.power.stamina_cost_mul_den??1))),a}var ce=n.styles,le=new Map;function P(e){let t=le.get(e);if(t!==void 0)return t;let n=ce[e]??{},r={startupTicks:n.startup_ticks??{},recoveryTicks:n.recovery_ticks??{},staminaCostPercent:n.stamina_cost_percent??100,conditioningLossPercent:n.conditioning_loss_percent??100,moveSpeedPercent:n.move_speed_percent??100,evasionTicks:n.evasion_ticks??0};return le.set(e,r),r}function ue(e,t,n,r){return Math.floor(se(t,n,r)*P(e).staminaCostPercent/100)}function de(e){return e.startup+e.active+e.recovery}var fe=[`broken_nose`,`broken_jaw`,`jaw_torn`,`eye_left_out`,`eye_right_out`,`ear_left_torn`,`ear_right_torn`,`face_left_flayed`,`face_right_flayed`,`skull_fractured`,`shoulder_left_dislocated`,`shoulder_right_dislocated`,`arm_left_broken`,`arm_right_broken`,`forearm_left_severed`,`forearm_right_severed`,`arm_left_torn`,`arm_right_torn`,`ribs_left_broken`,`ribs_right_broken`,`liver_ruptured`,`disemboweled`,`knee_left_blown`,`knee_right_blown`];function pe(e){return fe.includes(e)}var me=[`eyes_out`,`head_burst`,`decapitation`,`spine_rip`,`heart_punch`,`gutting`,`bisection`,`total_gib`],he=[`nose`,`mouth`,`eye_left`,`eye_right`,`ear_left`,`ear_right`,`skull`,`neck`,`shoulder_left`,`shoulder_right`,`elbow_left`,`elbow_right`,`chest`,`ribs_left`,`ribs_right`,`liver`,`belly`,`waist`,`crotch`,`knee_left`,`knee_right`],ge=n.injuries,_e=ge.kinds,ve=ge.blood.volume,ye=ge.blood.stages.map(e=>e.below),be=ge.finish.ticks,xe=(e,t)=>Array.isArray(e)?e.includes(t):e.has(t);function Se(e){return e.includes(`_left_`)?`left`:e.includes(`_right_`)?`right`:null}function F(e){return e.replace(`_left_`,`_`).replace(`_right_`,`_`)}var Ce={broken_nose:`BROKEN NOSE`,broken_jaw:`BROKEN JAW`,jaw_torn:`JAW TORN OFF`,eye_out:`EYE OUT`,ear_torn:`EAR TORN OFF`,face_flayed:`CHEEK FLAYED`,skull_fractured:`SKULL SPLIT OPEN`,shoulder_dislocated:`SHOULDER OUT`,arm_broken:`ARM SNAPPED`,forearm_severed:`FOREARM SEVERED`,arm_torn:`ARM TORN OFF`,ribs_broken:`RIBS CAVED IN`,liver_ruptured:`LIVER RUPTURED`,disemboweled:`DISEMBOWELED`,knee_blown:`KNEE BLOWN OUT`};function we(e){let t=Se(e),n=Ce[F(e)];return t===null?n:`${t.toUpperCase()} ${n}`}var Te={eyes_out:`EYES PUNCHED OUT`,head_burst:`HEAD EXPLODED`,decapitation:`DECAPITATED`,spine_rip:`SPINE RIPPED OUT`,heart_punch:`HEART PUNCHED OUT`,gutting:`GUTTED`,bisection:`TORN IN HALF`,total_gib:`BLOWN TO PIECES`};function I(e){return Te[e]}function Ee(e,t){return ge.fatalities[e][t]}function De(e){if(e===`bled_out`||e===`brain`||e===`gutted`)return e;let t=e.startsWith(`fatality:`)?e.slice(9):null;return t!==null&&me.includes(t)?e:null}function Oe(e){return e.startsWith(`fatality:`)?e.slice(9):null}function ke(e){let t=Oe(e);return t===null?e===`bled_out`?`BLED TO DEATH`:e===`brain`?`BRAIN DESTROYED`:`GUTTED`:I(t)}function Ae(e,t){return xe(e,`arm_${t}_torn`)?`torn`:xe(e,`forearm_${t}_severed`)?`severed`:xe(e,`arm_${t}_broken`)?`broken`:xe(e,`shoulder_${t}_dislocated`)?`dislocated`:`whole`}var je={dislocated:`shoulder_dislocated`,broken:`arm_broken`,severed:`forearm_severed`,torn:`arm_torn`};function Me(e,t){if(Ae(e,t)!==`torn`)return t;let n=t===`left`?`right`:`left`;return Ae(e,n)===`torn`?null:n}function Ne(e){return Ae(e,`left`)===`torn`&&Ae(e,`right`)===`torn`}function Pe(e,t){let n=Ae(e,t);return n===`whole`?0:_e[je[n]].startup_add??0}var Fe=Object.fromEntries(fe.map(e=>[e,_e[F(e)].move_speed_percent??100]));function Ie(e,t){let n=e;for(let e of t){let t=Fe[e];t!==100&&(n=Math.floor(n*t/100))}return n}function Le(e){let t=0;for(let n of ye)e0?`-${e.draws}`:``}`}var ze=e=>e.wins+e.losses+e.draws===0;function Be(e){return ze(e)?`PRO DEBUT`:`${Re(e)} (${e.knockouts} KO)`}var Ve=class extends Error{name=`ProtocolError`},He=2147483647,Ue=new TextEncoder;function We(e){let t=0,n=()=>{for(;/\s/u.test(e[t]??``);)t+=1},r=()=>{let n=t;if(e[t++]!==`"`)throw new Ve(`invalid JSON`);for(;t{n();let a=e[t];if(a===`{`){t+=1,n();let a=new Set;if(e[t]===`}`){t+=1;return}for(;;){n();let o=r();if(a.has(o))throw new Ve(`duplicate field ${o}`);if(a.add(o),n(),e[t++]!==`:`)throw new Ve(`invalid JSON`);i(),n();let s=e[t++];if(s===`}`)return;if(s!==`,`)throw new Ve(`invalid JSON`)}}if(a===`[`){if(t+=1,n(),e[t]===`]`){t+=1;return}for(;;){i(),n();let r=e[t++];if(r===`]`)return;if(r!==`,`)throw new Ve(`invalid JSON`)}}if(a===`"`){r();return}let o=e.slice(t),s=/^(?:-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?|true|false|null)/u.exec(o);if(!s)throw new Ve(`invalid JSON`);t+=s[0].length};if(i(),n(),t!==e.length)throw new Ve(`invalid JSON`)}function Ge(e){let t,n;if(typeof e==`string`?(t=Ue.encode(e),n=e):(t=e instanceof Uint8Array?e:new Uint8Array(e),n=new TextDecoder(`utf-8`,{fatal:!0}).decode(t)),t.byteLength>65536)throw new Ve(`server frame too large`);try{return We(n),JSON.parse(n)}catch(e){throw e instanceof Ve?e:new Ve(`invalid JSON`)}}function Ke(e,t){if(typeof e!=`object`||!e||Array.isArray(e)||Object.getPrototypeOf(e)!==Object.prototype)throw new Ve(`${t} must be an object`);return e}function qe(e,t,n=[]){let r=new Set([...t,...n]),i=Object.keys(e);if(t.some(t=>!Object.hasOwn(e,t))||i.some(e=>!r.has(e)))throw new Ve(`schema mismatch`)}function L(e,t,n=0,r=He){if(!Number.isSafeInteger(e)||er)throw new Ve(`${t} must be a bounded integer`);return e}function Je(e,t){if(typeof e!=`boolean`)throw new Ve(`${t} must be boolean`);return e}function Ye(e,t,n=255,r=1){if(typeof e!=`string`||e.lengthn||/[\u0000-\u001f\u007f]/u.test(e))throw new Ve(`${t} must be a bounded string`);return e}function Xe(e,t,n=255){return e===null?null:Ye(e,t,n)}function Ze(e,t,n){if(typeof e!=`string`||!t.includes(e))throw new Ve(`invalid ${n}`);return e}function Qe(e,t,n){if(!Array.isArray(e)||e.length>n)throw new Ve(`${t} must be a bounded array`);return e}var $e=[`left`,`right`],et=[`jab`,`straight`,`hook`,`uppercut`],tt=[`head`,`body`],nt=[`normal`,`power`],rt=[`orthodox`,`southpaw`],it=[`balanced`,`boxer`,`slugger`,`swarmer`,`counter_puncher`],at=[`none`,`guard_high`,`guard_low`,`slip_left`,`slip_right`,`weave`,`pull`],ot=[`none`,`guard_high`,`guard_low`],st=[`slip_left`,`slip_right`,`weave`,`pull`,`clinch`,`switch_stance`,`get_up_left`,`get_up_right`,`taunt`,`corner_cut`,`corner_swelling`,`corner_breath`],ct=[`cut`,`swelling`,`breath`,`balanced`],lt=[`low_blow`,`headbutt`],ut=[`countdown`,`fight`,`knockdown`,`foul_recovery`,`referee_down`,`finish`,`rest`,`complete`],dt=[`ko`,`flash_ko`,`tko`,`death`,`disqualification`,`decision`,`draw`,`forfeit`];function ft(e){let t=Ke(e,`record`);return qe(t,[`wins`,`losses`,`draws`,`knockouts`]),{wins:L(t.wins,`record.wins`),losses:L(t.losses,`record.losses`),draws:L(t.draws,`record.draws`),knockouts:L(t.knockouts,`record.knockouts`)}}function pt(e){let t=Ke(e,`player`);qe(t,[`id`,`name`,`avatar`,`rating`,`connected`],[`cpu`,`record`,`style`]);let n=t.style===void 0?{}:{style:Ze(t.style,it,`player style`)},r=t.cpu===void 0?{}:{cpu:Je(t.cpu,`cpu`)},i=t.record===void 0?{}:{record:ft(t.record)};return{id:Ye(t.id,`player.id`),name:Ye(t.name,`player.name`,80),avatar:Xe(t.avatar,`player.avatar`,128),rating:L(t.rating,`rating`),connected:Je(t.connected,`connected`),...r,...i,...n}}function mt(e,t,n=1){let r=Qe(e,`players`,2).map(pt);if(r.lengthe.id)).size!==r.length)throw new Ve(`players must be present and distinct`);return r}function ht(e){let t=Ke(e,`trauma`);return qe(t,[`head`,`body`,`left_eye`,`right_eye`,`left_cut`,`right_cut`,`swelling`,`bleeding`]),{head:L(t.head,`head`,0,1400),body:L(t.body,`body`,0,1200),left_eye:L(t.left_eye,`left_eye`,0,1e3),right_eye:L(t.right_eye,`right_eye`,0,1e3),left_cut:L(t.left_cut,`left_cut`,0,1e3),right_cut:L(t.right_cut,`right_cut`,0,1e3),swelling:L(t.swelling,`swelling`,0,1e3),bleeding:L(t.bleeding,`bleeding`,0,1e3)}}var gt=g;function _t(e,t){return Math.max(-gt,Math.min(gt,L(e,t,-2147483647,He)))}function vt(e){let t=Qe(e,`injuries`,fe.length).map(e=>Ze(e,fe,`injury`));for(let e=1;ee===null)&&[n,r,i,a].some(e=>e!==null))throw new Ve(`partial punch action`);let o=t.action_id===null?null:Ye(t.action_id,`action_id`,32),s=t.action_key===null?null:Ye(t.action_key,`action_key`,64);if([o,s].some(e=>e===null)!==[o,s].every(e=>e===null))throw new Ve(`partial action instance`);if(o!==null&&n===null)throw new Ve(`action instance without class`);let c=t.get_up_prompt===null?null:Ze(t.get_up_prompt,[`get_up_left`,`get_up_right`],`get-up prompt`),l=L(t.maximum_stamina,`maximum_stamina`,330,1e3),u=L(t.stamina,`stamina`,0,l),d=L(t.get_up_required,`get_up_required`,0,re),f=L(t.facing,`facing`,-1,1);if(f===0)throw new Ve(`invalid facing`);let p=L(t.facing_x,`facing_x`,-1e3,1e3),m=L(t.facing_y,`facing_y`,-1e3,1e3);if(p===0&&m===0)throw new Ve(`invalid facing vector`);if(d!==0&&dQe(e,`round scores`,15).map(e=>L(e,`score`,6,10)),r=n(t.player_one),i=n(t.player_two);if(r.length!==i.length)throw new Ve(`scorecard round mismatch`);return{judge:Ye(t.judge,`judge`,80),player_one:r,player_two:i}}function St(e){let t=Qe(e,`scorecards`,3).map(xt);if(t.length!==3)throw new Ve(`exactly three scorecards required`);return t}function Ct(e,t){if(t===`draw`!=(e===null))throw new Ve(`incoherent finish result`)}function wt(e){let t=Ke(e,`result`);qe(t,[`match_id`,`activity_instance_id`,`guild_id`,`player_one_id`,`player_two_id`,`winner_id`,`finish_method`,`round_number`,`tick`,`scorecards`,`player_one_knockdowns`,`player_two_knockdowns`,`player_one_damage`,`player_two_damage`]);let n=Ye(t.player_one_id,`player_one_id`),r=Ye(t.player_two_id,`player_two_id`);if(n===r)throw new Ve(`result players must be distinct`);let i=Xe(t.winner_id,`winner_id`);if(i!==null&&i!==n&&i!==r)throw new Ve(`invalid winner`);let a=Ze(t.finish_method,dt,`finish method`);return Ct(i,a),{match_id:Ye(t.match_id,`match_id`),activity_instance_id:Ye(t.activity_instance_id,`activity_instance_id`),guild_id:Ye(t.guild_id,`guild_id`),player_one_id:n,player_two_id:r,winner_id:i,finish_method:a,round_number:L(t.round_number,`round`,1,15),tick:L(t.tick,`tick`),scorecards:St(t.scorecards),player_one_knockdowns:L(t.player_one_knockdowns,`knockdowns`,0,3),player_two_knockdowns:L(t.player_two_knockdowns,`knockdowns`,0,3),player_one_damage:L(t.player_one_damage,`damage`),player_two_damage:L(t.player_two_damage,`damage`)}}function Tt(e){let t=Ke(e,`referee`);return qe(t,[`x`,`y`,`facing_x`,`facing_y`,`velocity_x`,`velocity_y`,`stunned_ticks`,`alive`,`trauma`]),{x:L(t.x,`referee.x`,-462,462),y:L(t.y,`referee.y`,-462,462),facing_x:L(t.facing_x,`referee.facing_x`,-1e3,1e3),facing_y:L(t.facing_y,`referee.facing_y`,-1e3,1e3),velocity_x:_t(t.velocity_x,`referee.velocity_x`),velocity_y:_t(t.velocity_y,`referee.velocity_y`),stunned_ticks:L(t.stunned_ticks,`referee.stunned_ticks`,0,90),alive:Je(t.alive,`referee.alive`),trauma:ht(t.trauma)}}function Et(e){let t=Ke(e,`snapshot`);qe(t,[`tick`,`phase`,`round_number`,`phase_ticks_remaining`,`fighters`,`referee`,`events`,`result`,`checksum`]);let n=Qe(t.fighters,`fighters`,2).map(yt);if(n.length!==2||n[0]?.player_id===n[1]?.player_id)throw new Ve(`snapshot requires two distinct fighters`);let r=Ye(t.checksum,`checksum`,64);if(!/^[a-f0-9]{64}$/u.test(r))throw new Ve(`invalid checksum`);return{tick:L(t.tick,`tick`),phase:Ze(t.phase,ut,`phase`),round_number:L(t.round_number,`round`,1,15),phase_ticks_remaining:L(t.phase_ticks_remaining,`phase ticks`),fighters:[n[0],n[1]],referee:Tt(t.referee),events:Qe(t.events,`events`,256).map(bt),result:t.result===null?null:wt(t.result),checksum:r}}function Dt(e){let t=Ke(Ge(e),`envelope`);if(t.version!==6)throw new Ve(`unsupported protocol version`);let n=Ye(t.type,`type`,32);if(n===`welcome`){let e=Ze(t.role,[`fighter`,`spectator`],`connection role`),r=Ye(t.player_id,`player_id`),i=t.reconnect_ticket===void 0?{}:{reconnect_ticket:Ye(t.reconnect_ticket,`reconnect_ticket`,4096)};if(e===`fighter`){qe(t,[`version`,`type`,`role`,`player_id`,`seat`,`rating`,`players`,`server_tick`,`next_sequence`],[`reconnect_ticket`]);let a=mt(t.players);if(!a.some(e=>e.id===r))throw new Ve(`welcome fighter is absent`);return{version:6,type:n,role:e,player_id:r,seat:L(t.seat,`seat`,1,2),rating:L(t.rating,`rating`),players:a,server_tick:L(t.server_tick,`server_tick`),next_sequence:L(t.next_sequence,`next_sequence`),...i}}qe(t,[`version`,`type`,`role`,`player_id`,`players`,`server_tick`],[`reconnect_ticket`]);let a=mt(t.players,void 0,0);if(a.some(e=>e.id===r))throw new Ve(`spectator cannot be a fighter`);return{version:6,type:n,role:e,player_id:r,players:a,server_tick:L(t.server_tick,`server_tick`),...i}}if(n===`ticket`)return qe(t,[`version`,`type`,`reconnect_ticket`,`refresh_id`]),{version:6,type:n,reconnect_ticket:Ye(t.reconnect_ticket,`reconnect_ticket`,4096),refresh_id:Ye(t.refresh_id,`refresh_id`,128,16)};if(n===`waiting`){if(qe(t,[`version`,`type`,`open_seats`]),t.open_seats!==1&&t.open_seats!==2)throw new Ve(`invalid open seats`);return{version:6,type:n,open_seats:t.open_seats}}if(n===`select`){qe(t,[`version`,`type`,`deadline_ms`,`players`,`ready`]);let e=mt(t.players,2),r=Qe(t.ready,`ready`,2).map(e=>Ye(e,`ready player id`));if(new Set(r).size!==r.length||r.some(t=>!e.some(e=>e.id===t)))throw new Ve(`invalid ready fighters`);return{version:6,type:n,deadline_ms:L(t.deadline_ms,`deadline_ms`,0,6e4),players:[e[0],e[1]],ready:r}}if(n===`ready`){qe(t,[`version`,`type`,`players`]);let e=mt(t.players,2);return{version:6,type:n,players:[e[0],e[1]]}}if(n===`paused`)return qe(t,[`version`,`type`,`player_id`,`grace_ms`]),{version:6,type:n,player_id:Ye(t.player_id,`player_id`),grace_ms:L(t.grace_ms,`grace_ms`,0,6e4)};if(n===`resumed`)return qe(t,[`version`,`type`,`player_id`]),{version:6,type:n,player_id:Ye(t.player_id,`player_id`)};if(n===`snapshot`)return qe(t,[`version`,`type`,`payload`]),{version:6,type:n,payload:Et(t.payload)};if(n===`error`)return qe(t,[`version`,`type`,`code`]),{version:6,type:n,code:Ye(t.code,`error code`,80)};if(n===`final`)return kt(t,n);throw new Ve(`unsupported server message type`)}function Ot(e,t){let n=Object.entries(Ke(e,`punches`));if(n.length!==2||n.some(([e])=>!t.includes(e)))throw new Ve(`punches must count both fighters`);let r=Object.create(null);for(let[e,t]of n){let n=Ke(t,`punch totals`);qe(n,[`thrown`,`landed`,`jabs_thrown`,`jabs_landed`]);let i=L(n.thrown,`thrown`),a=L(n.landed,`landed`,0,i),o=L(n.jabs_thrown,`jabs_thrown`,0,i);r[e]={thrown:i,landed:a,jabs_thrown:o,jabs_landed:L(n.jabs_landed,`jabs_landed`,0,Math.min(a,o))}}return r}function kt(e,t){qe(e,[`version`,`type`,`match_id`,`winner_id`,`method`,`round`,`scorecards`,`ratings`],[`punches`]);let n=Ke(e.ratings,`ratings`),r=Object.entries(n);if(r.length!==2)throw new Ve(`final requires two ratings`);let i=Object.create(null);for(let[e,t]of r){Ye(e,`rating player id`);let n=Ke(t,`rating`);qe(n,[`before`,`after`]),i[e]={before:L(n.before,`before`),after:L(n.after,`after`)}}let a=Xe(e.winner_id,`winner_id`);if(a!==null&&!Object.hasOwn(i,a))throw new Ve(`winner absent from ratings`);let o=Ze(e.method,dt,`finish method`);Ct(a,o);let s=e.punches===void 0?{}:{punches:Ot(e.punches,Object.keys(i))};return{version:6,type:t,match_id:Ye(e.match_id,`match_id`),winner_id:a,method:o,round:L(e.round,`round`,1,15),scorecards:St(e.scorecards),ratings:i,...s}}function At(e,t,n){return JSON.stringify({version:6,type:`input`,sequence:L(e,`sequence`),client_tick:L(t,`client tick`),move:{x:Math.max(-1e3,Math.min(1e3,Math.round(Number.isFinite(n.moveX)?n.moveX:0))),y:Math.max(-1e3,Math.min(1e3,Math.round(Number.isFinite(n.moveY)?n.moveY:0)))},defense:Ze(n.defense,ot,`held defense`),actions:n.actions.slice(0,4).map(e=>{let t=e.id===void 0?{}:{id:e.id.slice(0,32)};return e.kind===`punch`?{kind:`punch`,hand:Ze(e.hand,$e,`hand`),class:Ze(e.class,et,`class`),target:Ze(e.target,tt,`target`),power:Ze(e.power,nt,`power`),...t}:e.kind===`foul`?{kind:`foul`,foul:Ze(e.foul,lt,`foul`),...t}:{kind:Ze(e.kind,st,`action`),...t}})})}function jt(e,t){return JSON.stringify({version:6,type:`style`,style:Ze(e,it,`fighter style`),ready:t===!0})}var Mt=[`rookie`,`contender`,`champion`];function Nt(e){return JSON.stringify({version:6,type:`cpu`,level:Ze(e,Mt,`computer level`)})}function Pt(e){let t=Ke(e,`bootstrap`);if(qe(t,[`client_id`,`state`,`protocol`,`simulation`]),t.protocol!==6)throw new Ve(`unsupported protocol version`);let n=Ke(t.simulation,`simulation`);return qe(n,[`tick_rate`,`ring_half_width`,`ring_half_height`]),{client_id:Ye(t.client_id,`client_id`,36),state:Ye(t.state,`state`,128),protocol:6,simulation:{tick_rate:L(n.tick_rate,`tick rate`,1,120),ring_half_width:L(n.ring_half_width,`ring width`,1),ring_half_height:L(n.ring_half_height,`ring height`,1)}}}function Ft(e){let t=Ke(e,`token response`);qe(t,[`access_token`,`ticket`,`player`]);let n=Ke(t.player,`player`);return qe(n,[`id`,`name`,`avatar`,`rating`]),{access_token:Ye(t.access_token,`access token`,4096),ticket:Ye(t.ticket,`ticket`,4096),player:{id:Ye(n.id,`id`),name:Ye(n.name,`name`,80),avatar:Xe(n.avatar,`avatar`,128),rating:L(n.rating,`rating`)}}}var It=[`Power`,`Hand speed`,`Footwork`,`Reach`,`Stamina`,`Defence`],Lt=[{style:`balanced`,name:`Balanced`,tag:`BALANCED`,detail:`Even at everything, no holes to exploit.`,stats:[3,3,3,3,3,3]},{style:`boxer`,name:`Boxer`,tag:`BOXER`,detail:`Snappy jab and long reach, lighter hands.`,stats:[2,4,3,4,3,3]},{style:`slugger`,name:`Slugger`,tag:`SLUGGER`,detail:`Heavy hands, hard chin, slow feet, tires sooner.`,stats:[5,2,2,3,2,4]},{style:`swarmer`,name:`Swarmer`,tag:`SWARMER`,detail:`Quick feet and head, digs to the body, never stops.`,stats:[2,4,4,3,4,3]},{style:`counter_puncher`,name:`Counter-puncher`,tag:`COUNTER`,detail:`Slips and parries, makes every miss cost.`,stats:[2,3,3,3,3,5]}],Rt=e=>Lt.find(t=>t.style===e)??Lt[0];function zt(e){return e===void 0||e===`balanced`?null:Rt(e).tag}function Bt(e){return e===void 0||e===`balanced`?null:`the ${Rt(e).name.toLowerCase()}`}var Vt=`hands.style.v1`;function Ht(e=Wt()){try{let t=e?.getItem(Vt);return it.find(e=>e===t)??`balanced`}catch{return`balanced`}}function Ut(e,t=Wt()){try{t?.setItem(Vt,e)}catch{}}function Wt(){try{return window.localStorage}catch{return null}}var Gt=400,Kt={Digit1:0,Digit2:1,Digit3:2,Digit4:3,Digit5:4,Numpad1:0,Numpad2:1,Numpad3:2,Numpad4:3,Numpad5:4},qt=.6;function Jt(){try{return[...navigator.getGamepads?.()??[]].find(e=>e!==null&&e.connected&&e.mapping===`standard`)??null}catch{return null}}function Yt(e){let t=new Set;if(e===null)return t;let n=t=>e.buttons[t]?.pressed===!0,r=e.axes[0]??0,i=e.axes[1]??0;return(n(12)||n(14)||r<-.6||i<-.6)&&t.add(`previous`),(n(13)||n(15)||r>qt||i>qt)&&t.add(`next`),n(0)&&t.add(`settle`),t}var Xt=class{send;now;element;buttons=new Map;clock;status;visible=!1;choosing=!1;highlighted;settled=!1;deadlineAt=0;timer=null;padFrame=0;padHeld=new Set;context=null;keydown=e=>{if(!this.visible||!this.choosing||e.repeat||e.ctrlKey||e.metaKey||e.altKey)return;let t=e.target;if(t instanceof HTMLElement&&t!==document.body&&!this.element.contains(t))return;let n=Kt[e.code];n===void 0?e.code===`ArrowRight`||e.code===`ArrowDown`?(e.preventDefault(),this.move(this.neighbour(1))):e.code===`ArrowLeft`||e.code===`ArrowUp`?(e.preventDefault(),this.move(this.neighbour(-1))):e.code!==`Enter`&&e.code!==`Space`||t instanceof HTMLButtonElement||(e.preventDefault(),this.pick(this.highlighted,!0)):(e.preventDefault(),this.pick(Lt[n].style,!0))};constructor(e,t,n=()=>performance.now(),r=Ht()){this.send=t,this.now=n,this.highlighted=r;let i=document.createElement(`section`);i.className=`style-picker`,i.dataset.stylePicker=``,i.hidden=!0,i.setAttribute(`aria-label`,`Pick how your fighter boxes`);let a=document.createElement(`header`),o=document.createElement(`p`);o.className=`style-title`,o.textContent=`CHOOSE YOUR STYLE`,this.clock=document.createElement(`p`),this.clock.className=`style-clock`,a.append(o,this.clock);let s=document.createElement(`div`);s.className=`style-cards`;for(let[e,t]of Lt.entries()){let n=document.createElement(`button`);n.type=`button`,n.dataset.style=t.style,n.setAttribute(`aria-pressed`,`false`);let r=document.createElement(`kbd`);r.textContent=String(e+1);let i=document.createElement(`strong`);i.textContent=t.name;let a=document.createElement(`span`);a.textContent=t.detail;let o=document.createElement(`ul`);o.className=`style-stats`;for(let[e,n]of t.stats.entries()){let t=document.createElement(`li`);t.setAttribute(`aria-label`,`${It[e]} ${n} of 5`);let r=document.createElement(`small`);r.textContent=It[e];let i=document.createElement(`i`);i.dataset.value=String(n),t.append(r,i),o.append(t)}n.append(r,i,a,o),n.addEventListener(`click`,()=>this.pick(t.style,!0)),s.append(n),this.buttons.set(t.style,n)}this.status=document.createElement(`p`),this.status.className=`style-status`,this.status.setAttribute(`role`,`status`),i.append(a,s,this.status),e.append(i),this.element=i,window.addEventListener(`keydown`,this.keydown)}update(e,t,n){if(e===null){this.setVisible(!1),this.context=null,this.settled=!1;return}let r=this.context===null||!this.choosing&&n===`fighter`;this.context?.select!==e&&(this.deadlineAt=this.now()+e.deadline_ms-Gt),this.context={select:e,viewerId:t},this.choosing=n===`fighter`&&t!==null,this.settled=this.choosing&&(this.settled||e.ready.includes(t));let i=e.players.find(e=>e.id===t)?.style;this.settled&&i!==void 0&&(this.highlighted=i),r&&this.choosing&&!this.settled&&this.send(this.highlighted,!1),this.setVisible(!0),this.render()}pick(e,t){!this.choosing||this.settled||this.closed||(this.highlighted=e,this.send(e,t)&&(t&&(this.settled=!0),this.render()))}get closed(){return this.now()>=this.deadlineAt}neighbour(e){return Lt[(Lt.findIndex(e=>e.style===this.highlighted)+e+Lt.length)%Lt.length].style}move(e){this.pick(e,!1),this.settled||this.buttons.get(this.highlighted)?.focus()}render(){let e=this.context;if(e===null)return;let{select:t,viewerId:n}=e;for(let e of Lt){let t=this.buttons.get(e.style),n=this.choosing&&e.style===this.highlighted;t.disabled=!this.choosing||this.settled||this.closed,t.setAttribute(`aria-pressed`,String(n)),t.toggleAttribute(`data-chosen`,n),t.tabIndex=e.style===this.highlighted?0:-1}let r=`${Math.max(0,Math.ceil((this.deadlineAt-this.now())/1e3))}s`;this.clock.textContent!==r&&(this.clock.textContent=r);let i=t.players.filter(e=>e.id!==n&&(!e.connected||t.ready.includes(e.id))).map(e=>e.connected?`${e.name} is ready.`:`Waiting for ${e.name} to reconnect.`).join(` `),a=this.choosing?this.settled?i.length>0?`Ready as ${Rt(this.highlighted).name}. ${i}`:`Ready as ${Rt(this.highlighted).name}. Waiting for your opponent.`:i.length>0?`${i} Tap a style or press Enter to settle on yours.`:`Tap a style, or use the arrow keys and Enter.`:i.length>0?`The fighters are choosing. ${i}`:`The fighters are choosing their styles.`;this.status.textContent!==a&&(this.status.textContent=a)}setVisible(e){this.visible!==e&&(this.visible=e,this.element.hidden=!e,e?(this.timer=window.setInterval(()=>this.render(),250),this.padHeld=Yt(Jt()),this.padFrame=requestAnimationFrame(()=>this.pollPad())):(this.timer!==null&&window.clearInterval(this.timer),this.timer=null,cancelAnimationFrame(this.padFrame)))}pollPad(){if(!this.visible)return;let e=Yt(Jt());for(let t of e)this.padHeld.has(t)||(t===`settle`?this.pick(this.highlighted,!0):this.move(this.neighbour(t===`next`?1:-1)));this.padHeld=e,this.padFrame=requestAnimationFrame(()=>this.pollPad())}destroy(){this.setVisible(!1),window.removeEventListener(`keydown`,this.keydown),this.element.remove()}},Zt=/^[0-9]{17,20}$/u,Qt=/^[A-Za-z0-9_]{1,128}$/u,$t=`https://cdn.discordapp.com/avatars/`,en=128,tn=8;function nn(e){return e.avatar===null||!Zt.test(e.id)||!Qt.test(e.avatar)?null:new URL(`${e.id}/${e.avatar}.png?size=${en}`,$t).href}function rn(e){let t=Array.from(e).find(e=>/[\p{L}\p{N}]/u.test(e));return t===void 0?`?`:t.toUpperCase()}var an=class{create;pictures=new Map;addresses=new Map;constructor(e=()=>new Image){this.create=e}get(e){if(e===void 0)return null;let t=this.addresses.get(e.id);(t===void 0||t.avatar!==e.avatar)&&(this.addresses.size>=tn&&this.addresses.clear(),t={avatar:e.avatar,url:nn(e)},this.addresses.set(e.id,t));let n=t.url;if(n===null)return null;let r=this.pictures.get(n);if(r!==void 0)return r.ready?r.image:null;if(this.pictures.size>=tn){let e=this.pictures.entries().next().value;e!==void 0&&this.drop(e[0],e[1])}let i={image:this.create(),ready:!1};return this.pictures.set(n,i),i.image.crossOrigin=`anonymous`,i.image.referrerPolicy=`no-referrer`,i.image.decoding=`async`,i.image.onload=()=>{i.ready=i.image.naturalWidth>0},i.image.onerror=()=>{i.ready=!1},i.image.src=n,null}dispose(){for(let[e,t]of[...this.pictures])this.drop(e,t);this.addresses.clear()}drop(e,t){t.image.onload=null,t.image.onerror=null,t.ready=!1,this.pictures.delete(e)}},on=`POWER ARMED`,sn=1e3,cn=e=>e.reduce((e,t)=>e+t,0),ln=(e,t,n)=>{if(e.measureText(t).width<=n)return t;let r=t;for(;r.length>1&&e.measureText(`${r}…`).width>n;)r=r.slice(0,-1);return`${r}…`},un=(e,t,n,r)=>{for(let i=n;i>r;--i)if(e(i)<=t)return i;return r},dn=`#ff7066`;function fn(e,t,n,r,i,a){let o=i.spentBelow!==void 0&&i.value0&&(e.globalAlpha=i.alarm*.6,e.fillStyle=`#ff4632`,e.fillRect(t-1,n-1,r+2,11),e.globalAlpha=1),o){e.beginPath();for(let i=-9;i.5?`#ffffff`:`#ff9a90`,e.fillText(r,t,n-4)}}function mn(e,t,n,r,i,a,o){let s=()=>{e.beginPath(),e.arc(t,n,r,0,Math.PI*2),e.closePath()};e.save(),s(),e.fillStyle=`#0b1220`,e.fill(),i===null?(e.globalAlpha=.4,e.fillStyle=o,e.fill(),e.globalAlpha=1,e.fillStyle=`#f5f8ff`,e.textAlign=`center`,e.font=`800 ${Math.round(r*1.1)}px Inter, system-ui, sans-serif`,e.fillText(rn(a),t,n+r*.39)):(e.save(),e.clip(),e.drawImage(i,t-r,n-r,r*2,r*2),e.restore()),s(),e.lineWidth=Math.max(1.5,r/9),e.strokeStyle=o,e.stroke(),e.restore()}function hn(e,t=[]){let n=e.left_eye>=p&&!t.includes(`eye_left_out`),r=e.right_eye>=p&&!t.includes(`eye_right_out`);return n&&r?`BOTH EYES SHUT`:n?`LEFT EYE SHUT`:r?`RIGHT EYE SHUT`:null}var gn={cut:`closing the cut`,swelling:`icing the swelling`,breath:`catching breath`,balanced:`a little of everything`};function _n(e){let t=e.flatMap((e,t)=>e.corner_choice===null?[]:[`${t===0?`Blue`:`Red`}: ${gn[e.corner_choice]}`]);return t.length===0?null:t.join(` · `)}function vn(e,t,n,r){e.save(),e.font=`900 12px Inter, system-ui, sans-serif`;let i=e.measureText(on).width+16,a=r?t-i:t;e.shadowColor=`rgba(255,120,30,0.9)`,e.shadowBlur=12;let o=e.createLinearGradient(0,n,0,n+18);o.addColorStop(0,`#ffd36b`),o.addColorStop(1,`#ff6a1a`),e.fillStyle=o,e.fillRect(a,n,i,18),e.shadowBlur=0,e.fillStyle=`#2a0c00`,e.textAlign=`left`,e.fillText(on,a+8,n+13),e.restore()}function yn(e,t,n,r,i){e.save(),e.font=`800 9px Inter, system-ui, sans-serif`;let a=e.measureText(r).width+12,o=i?t-a:t;e.fillStyle=`rgba(150,22,18,0.92)`,e.fillRect(o,n,a,14),e.fillStyle=`#ffe8e3`,e.textAlign=`left`,e.fillText(r,o+6,n+10),e.restore()}var bn={arm_torn:0,disemboweled:1,forearm_severed:2,skull_fractured:3,jaw_torn:4,face_flayed:5,eye_out:6,ear_torn:7,arm_broken:8,knee_blown:9,ribs_broken:10,broken_jaw:11,broken_nose:12,liver_ruptured:13,shoulder_dislocated:14},xn=8,Sn=e=>bn[F(e)],Cn={wide:4,compact:3};function wn(e){return e.filter(t=>t!==`broken_jaw`||!e.includes(`jaw_torn`)).sort((e,t)=>Sn(e)-Sn(t))}function Tn(e,t){let n=e.slice(0,t).map(we);return e.length>t&&n.push(`+${e.length-t}`),n}var En=14,Dn=3,On=`800 9px Inter, system-ui, sans-serif`,kn={grave:`#c4160f`,plain:`rgba(122,18,14,0.92)`,count:`rgba(52,8,8,0.92)`},An={grave:`#ffffff`,plain:`#ffe8e3`,count:`#ffb1a8`};function jn(e,t,n,r,i,a){e.fillStyle=kn[a],e.fillRect(t,n,r,En),e.fillStyle=An[a],e.fillText(i,t+6,n+10)}function Mn(e,t,n,r,i,a,o){if(i.length===0)return n;let s=wn(i),c=Math.min(a,s.length),l=Tn(s,a).map(e=>({label:e,width:0,offset:0,row:0}));e.save(),e.font=On,e.textAlign=`left`;let u=0,d=0;for(let t of l)t.label=ln(e,t.label,r-12),t.width=e.measureText(t.label).width+12,d>0&&d+Dn+t.width>r&&(u+=1,d=0),t.offset=d===0?0:d+Dn,t.row=u,d=t.offset+t.width;let f=n-(u+1)*17+Dn;return l.forEach((n,r)=>{let i=r>=c?`count`:Sn(s[r])r)break;jn(e,o?t-p-f:t+p,n,f,d,a===null||Sn(a)>=xn?`plain`:`grave`),l=p+f,u+=1}if(u>0&&u0?`${t.knockdowns} KD`:null,c=[s,t.warnings>0?`${t.warnings} WARNING${t.warnings===1?``:`S`}`:null,t.deductions>0?`−${t.deductions} PT${t.deductions===1?``:`S`}`:null,r>0?`${r} INJUR${r===1?`Y`:`IES`}`:null],l=[s,t.warnings>0?`W${t.warnings}`:null,t.deductions>0?`−${t.deductions}`:null,r>0?`${r} INJ`:null],u=(...e)=>e.filter(e=>e!==null).join(` · `),d=n?[u(i,...l),u(...l)]:[u(i,a,o,...c),u(i,o,...c),u(i,...c),u(i,...l),u(...l)];return d.filter((e,t)=>e!==``&&d.indexOf(e)===t)}var Un=168;function Wn(e,t,n,r,i,a,o,s,c,l,u=!1){e.save(),e.beginPath(),s?(e.moveTo(t+14,n),e.lineTo(t+r,n),e.lineTo(t+r-14,n+62),e.lineTo(t,n+62)):(e.moveTo(t,n),e.lineTo(t+r-14,n),e.lineTo(t+r,n+62),e.lineTo(t+14,n+62)),e.closePath(),e.fillStyle=`rgba(3,6,12,0.82)`,e.fill(),e.strokeStyle=`rgba(190,200,220,0.22)`,e.lineWidth=1,e.stroke(),e.fillStyle=c,e.fillRect(s?t+r-5:t,n+4,5,54);let d=l===void 0?20:51;l!==void 0&&mn(e,s?t+r-11-16:t+11+16,n+4+16,16,l,i,c);let f=s?t+r-d:t+d;e.textAlign=s?`right`:`left`,e.fillStyle=`#f5f8ff`;let p=i.toUpperCase(),m=r-d-24;e.font=`800 ${un(t=>(e.font=`800 ${t}px Inter, system-ui, sans-serif`,e.measureText(p).width),m,16,11)}px Inter, system-ui, sans-serif`,e.fillText(ln(e,p,m),f,n+21);let h=r-d-14;if(u)e.fillStyle=`#ffb347`,e.font=`900 10px Inter, system-ui, sans-serif`,e.fillText(ln(e,on,h),f,n+35);else{e.fillStyle=`#93a3bd`;let t=(t,n)=>(e.font=`600 ${n}px Inter, system-ui, sans-serif`,e.measureText(t).width),r=a.find(e=>t(e,8)<=h)??a.at(-1)??``;e.font=`600 ${un(e=>t(r,e),h,10,8)}px Inter, system-ui, sans-serif`,e.fillText(ln(e,r,h),f,n+35)}let g=(r-52)/o.length,_=o.length*g+(o.length-1)*12,v=s?t+r-20-_:t+20;o.forEach((t,r)=>{fn(e,v+(g+12)*r,n+48,g,t,s)}),e.restore()}function Gn(e,t,n,r,i,a){let o=Un;e.save(),e.beginPath(),e.moveTo(t-o/2+12,n),e.lineTo(t+o/2-12,n),e.lineTo(t+o/2,n+29),e.lineTo(t+o/2-12,n+58),e.lineTo(t-o/2+12,n+58),e.lineTo(t-o/2,n+29),e.closePath(),e.fillStyle=`rgba(4,6,12,0.88)`,e.fill();let s=e.createLinearGradient(t-o/2,n,t+o/2,n+58);s.addColorStop(0,`#8a6a26`),s.addColorStop(.5,`#f6d57a`),s.addColorStop(1,`#8a6a26`),e.strokeStyle=s,e.lineWidth=2,e.stroke(),e.textAlign=`center`,e.fillStyle=`#ffffff`,e.font=`800 22px ui-monospace, monospace`,e.fillText(r,t,n+27),e.fillStyle=`#f6d57a`,e.font=`800 12px Inter, system-ui, sans-serif`,e.fillText(i,t,n+44),a!==`FIGHT`&&(e.fillStyle=`#93a3bd`,e.font=`700 9px Inter, system-ui, sans-serif`,e.fillText(a,t,n+55)),e.restore()}var Kn=78,qn=50,Jn=.22,Yn=e=>e<480?qn:Kn,Xn=(e,t)=>Math.max(e<640?112:56,t*.1)+Yn(t)/2-t/2,Zn={upright:{bottom:118,height:274,moves:0,grid:118},landscape:{bottom:118,height:196,moves:102,grid:118},short:{bottom:112,height:154,moves:86,grid:92},shortHeight:350,reach:216,movesReach:134},Qn=(e,t)=>e<=t?Zn.upright:t<=Zn.shortHeight?Zn.short:Zn.landscape;function $n(e,t,n){let r=Qn(e,t);return n<=t-r.bottom-r.height?0:Zn.reach+(r.moves>0&&n>t-r.bottom-r.moves?Zn.movesReach:0)}var er=160;function tr(e,t,n=!1){let r=Yn(t),i=t/2+Xn(e,t)-r/2,a=Math.min(320,e-24),o=e/2+a/2;if(n&&e<=t)$n(e,t,i+r+8)>0&&(r=qn);else if(n){let n=e<640?Math.min(e/2-Un/2-8,e-$n(e,t,56+r)):0,s=n-12>=er;s&&(i=56);let c=s?n:e-$n(e,t,i+r);o>c&&(a=Math.min(a,c-12),o=c)}return{x:o-a,y:i,width:a,height:r}}var nr={width:380,height:150},rr=112;function ir(e,t,n=!1){let r=Qn(e,t),i=t-r.bottom-r.grid,a=e<=t,o=n&&a?Math.min(t-rr,i-8):t-rr,s=Math.max(56,Math.min(Math.max(t*.24,hr(t,e<640)+34),o-nr.height)),c=Math.min(nr.width,e-24),l=e/2+c/2;if(n&&!a&&s+nr.height>i){let t=e-Zn.reach;l>t&&(c=Math.min(c,t-12),l=t)}return{x:l-c,y:s,width:c,height:nr.height}}function ar(e,t,n,r){let i=t.height===qn,a=t.x+t.width/2;e.fillStyle=`rgba(3,6,12,0.88)`,e.fillRect(t.x,t.y,t.width,t.height),e.strokeStyle=`rgba(246,213,122,0.45)`,e.lineWidth=1.5,e.strokeRect(t.x+2,t.y+2,t.width-4,t.height-4),e.textAlign=`center`,e.fillStyle=`#ffd77a`,Ir(e,n,a,t.y+(i?22:34),t.width-24,800,i?17:22,12),e.fillStyle=`#c8d3e6`,e.font=`600 ${i?11:12}px Inter, system-ui, sans-serif`,e.fillText(ln(e,r,t.width-24),a,t.y+(i?39:58))}var or=class{fightTicks=null;round=0;ticks(e){return e.round_number!==this.round&&(this.round=e.round_number,this.fightTicks=null),e.phase===`fight`&&(this.fightTicks=e.phase_ticks_remaining),(e.phase===`knockdown`||e.phase===`foul_recovery`||e.phase===`referee_down`||e.phase===`finish`||e.phase===`complete`)&&this.fightTicks!==null?this.fightTicks:e.phase_ticks_remaining}},sr=()=>({thrown:0,landed:0,jabsThrown:0,jabsLanded:0});function cr(e,t){return e.action_id!==null&&t.some(t=>(t.kind===`block`||t.kind===`perfect_block`)&&t.tick===e.tick&&t.action_id===e.action_id&&t.actor_id===e.target_id)}var lr=class{stats=new Map;totals=new Map;record(e,t=[]){if(e.kind===`bell`)e.detail===`round_start`&&this.stats.clear();else if(e.actor_id!==null){if(e.kind===`punch_start`){let t=+(e.detail.split(`:`)[1]===`jab`);for(let n of[this.entry(this.stats,e.actor_id),this.entry(this.totals,e.actor_id)])n.thrown+=1,n.jabsThrown+=t}else if((e.kind===`hit`||e.kind===`counter_hit`)&&!cr(e,t)){let t=+(e.detail.split(`:`)[0]===`jab`);for(let n of[this.entry(this.stats,e.actor_id),this.entry(this.totals,e.actor_id)])n.landed+=1,n.jabsLanded+=t}}}get(e){return this.stats.get(e)??sr()}total(e){return this.totals.get(e)??sr()}entry(e,t){let n=e.get(t);return n===void 0&&(n=sr(),e.set(t,n)),n}};function ur(e){let t=e.method.replaceAll(`_`,` `).toUpperCase();if(e.method!==`decision`&&e.method!==`draw`)return t;let n=0,r=0,i=0;for(let t of e.scorecards){let e=cn(t.player_one),a=cn(t.player_two);e>a?n+=1:a>e?r+=1:i+=1}let a=e.scorecards.length;return a===0?t:e.method===`draw`?i===a?`UNANIMOUS DRAW`:n===r?`SPLIT DRAW`:`MAJORITY DRAW`:Math.max(n,r)===a?`UNANIMOUS DECISION`:i>0?`MAJORITY DECISION`:`SPLIT DECISION`}var dr=new Set([`ko`,`flash_ko`,`tko`,`death`]),fr=3.6,pr=2.4;function mr(e){return e===null?0:dr.has(e.method)?fr:e.method===`disqualification`?pr:0}var hr=(e,t)=>Math.max(e*.16,(t?112:56)+40),gr=(e,t)=>e!==null&&e>=(t?100:120),_r=`FINISH HIM!`,vr=`Impact, "Arial Black", Inter, system-ui, sans-serif`,yr=2.2,br=.82,xr={name:15,nameGap:24,bar:10,foot:42},Sr={name:11,nameGap:15,bar:6,foot:26},Cr=28,wr=160;function Tr(e,t,n=!1){let r=e<640?118:60,i=Math.round(Math.min(120,t*.17,(e-32)/5)),a=(e,t,n,r,i)=>{let a=i+Math.round(e*br);return{centre:n,maxWidth:r,size:e,baseline:a,bottom:a+(t?Sr:xr).foot,dense:t}};if(!n)return a(i,!1,e/2,e-32,r);let o=Qn(e,t),s=t-o.bottom-o.height;for(let n of[!1,!0]){let c=null;for(let l of o.moves>0?[s,t-o.bottom-o.moves]:[s]){let o=Math.min(i,Math.floor((l-r-(n?Sr:xr).foot)/br));if(o=wr&&(c={...s,maxWidth:e-2*u})}if(c!==null)return c}let c=tr(e,t,!0);return a(Math.max(12,Math.min(i,Math.floor((c.height-Sr.foot-4)/br))),!0,c.x+c.width/2,c.width,c.y+2)}function Er(e,t=null){let[n,r]=e;return t!==null&&(n.player_id===t||r.player_id===t)?n.player_id===t?n:r:n.poise===0==(r.poise===0)?n.knockdowns===r.knockdowns?n.stunned_ticks===r.stunned_ticks?null:n.stunned_ticks>r.stunned_ticks?n:r:n.knockdowns>r.knockdowns?n:r:n.poise===0?n:r}var Dr=[`jab`,`straight`,`hook`,`uppercut`],Or=Dr.map(e=>e.toUpperCase()),kr=[`head`,`body`].map(e=>({target:e.toUpperCase(),fatalities:Dr.map(t=>I(Ee(e,t)))})),Ar=14,jr=.4,Mr=[0,0,0,0];function Nr(e,t,n,r,i){e.save(),e.textAlign=`left`;for(let a of[!1,!0])for(let o=10;o>=8;--o){let s=o+5,c=(a?3:2)*s+6;if(n+c>i)continue;e.font=`700 ${o}px Inter, system-ui, sans-serif`;let l=o*.4,u=Math.max(...kr.map(t=>e.measureText(t.target).width))+10,d=12+u+42;for(let[t,n]of Or.entries()){let r=e.measureText(n).width,i=a?r:0;for(let n of kr)i=Math.max(i,e.measureText(n.fatalities[t]).width+(a?0:r+l));Mr[t]=i,d+=i}if(d>r)continue;let f=t-d/2;e.fillStyle=`rgba(3,6,12,0.78)`,e.fillRect(f,n,d,c);let p=n+2+o;if(a){e.fillStyle=`#f6d57a`;let t=f+6+u;for(let[n,r]of Or.entries())e.fillText(r,t,p),t+=Mr[n]+Ar;p+=s}for(let t of kr){e.fillStyle=dn,e.fillText(t.target,f+6,p);let n=f+6+u;for(let[r,i]of t.fatalities.entries()){let t=Or[r];a||(e.fillStyle=`#f6d57a`,e.fillText(t,n,p)),e.fillStyle=`#f5f8ff`,e.fillText(i,a?n:n+e.measureText(t).width+l,p),n+=Mr[r]+Ar}p+=s}e.restore();return}e.restore()}function Pr(e,t,n,r,i,a){let o=i===null?0:.5-.5*Math.cos(i*yr*Math.PI*2),s=t.dense?Sr:xr;e.save(),e.textAlign=`center`,e.font=`italic 900 ${t.size}px ${vr}`;let c=e.measureText(_r).width,l=Math.min(t.size,t.size*t.maxWidth/(c*1.1)),u=l*(1+.08*o);e.font=`italic 900 ${u}px ${vr}`,e.lineJoin=`round`,e.lineWidth=Math.max(3,u*.12),e.strokeStyle=`rgba(10,0,0,0.92)`,e.shadowColor=`rgba(255,24,12,0.9)`,e.shadowBlur=14+24*o,e.strokeText(_r,t.centre,t.baseline),e.shadowBlur=0;let d=e.createLinearGradient(0,t.baseline-u*.8,0,t.baseline);d.addColorStop(0,`#ff5540`),d.addColorStop(.5,`#d8160d`),d.addColorStop(1,`#7d0705`),e.fillStyle=d,e.fillText(_r,t.centre,t.baseline),e.font=`800 ${s.name}px Inter, system-ui, sans-serif`,e.lineWidth=t.dense?3:4;let f=`ONE MORE PUNCH KILLS`;if(n!==null){let r=e.measureText(`${n} IS DEAD ON HIS FEET`).width<=t.maxWidth?` IS DEAD ON HIS FEET`:` IS DONE FOR`;f=`${ln(e,n,Math.max(0,t.maxWidth-e.measureText(r).width))}${r}`}e.strokeText(f,t.centre,t.baseline+s.nameGap),e.fillStyle=`#ffe8e3`,e.fillText(f,t.centre,t.baseline+s.nameGap);let p=Math.min(420,t.maxWidth),m=t.bottom-s.bar-2,h=p*Math.max(0,Math.min(1,r));e.fillStyle=`rgba(2,4,9,0.85)`,e.fillRect(t.centre-p/2-1,m-1,p+2,s.bar+2),e.fillStyle=`#e0180f`,e.fillRect(t.centre-h/2,m,h,s.bar),e.strokeStyle=`rgba(255,112,102,0.85)`,e.lineWidth=1,e.strokeRect(t.centre-p/2-1.5,m-1.5,p+3,s.bar+3),e.restore(),a!==null&&Nr(e,t.centre,t.bottom+8,Math.min(t.maxWidth,c*l/t.size),a)}function Fr(e,t,n,r,i,a,o,s,c=30,l=null,u=null,d=null,f=null,p=null,g=null,_=null,v=!1,y=!1,b=null,x=null,S=!0){e.save();let C=Vn(t,n);e.scale(C,C),t/=C,n/=C,e.textBaseline=`alphabetic`;let w=e=>{let t=i[e.player_id];return t===void 0||g===null?null:g(t)},T=t<640,E=T?(t-56)/2:Math.min(300,t*.38,t/2-Un/2-8-24),D=n-84,O=S?r.tick/c:null,k=zn(t,n,v,r.phase===`rest`&&r.fighters.some(e=>e.player_id===a));o===null&&r.fighters.forEach((o,s)=>{let c=s===1,l=c?t-24-E:24,u=i[o.player_id],d=[{label:`${T?`STA`:`STAMINA`} ${Math.round(o.stamina)}`,value:o.stamina,maximum:o.maximum_stamina,from:`#ffe08a`,to:`#d9a53a`},{label:`${T?`HP`:`HEALTH`} ${Math.round(o.conditioning)}`,value:o.conditioning,maximum:sn,from:`#ff8a7a`,to:`#b02a20`},{label:o.guard_broken?`GUARD BROKEN`:`GUARD`,value:o.guard,maximum:700,from:`#9ec7ff`,to:`#3d6fb8`,spentBelow:o.guard_broken?h:m},{label:`POISE ${Math.round(o.poise)}`,value:o.poise,maximum:600,from:`#e8c890`,to:`#8a6a34`}],f=s===0?`#3d6fb8`:`#b02a20`,p=D-12,g=hn(o.trauma,o.injuries),_=Bn(o.blood_volume,O),b=r.phase===`fight`||r.phase===`countdown`||r.phase===`finish`&&Er(r.fighters,x)?.player_id!==o.player_id,S=y&&o.player_id===a&&b,C=k?3:2,A=Math.min(64,(E-28-C*12)/C),j=A+12,ee=c?l+E+4-C*j:l+20,M=c?l+E-8:ee,te=ee+(c?C-2:0)*j,ne=0;if(k){let n=A<40,r=n&&_.label===`BLEEDING OUT`;fn(e,te,p,A,n?{...d[2],label:r?``:`GUARD`}:d[2],c),fn(e,te+j,p,A,n?{...d[3],label:r?``:`POISE`}:d[3],c),fn(e,c?ee:ee+2*j,p,A,n?{..._,label:r?``:`BLOOD`}:_,c),r&&pn(e,M,p,In,c,!1,_.alarm);let i=c?ee-12:ee+3*j;ne=Nn(e,i,p-5,c?i-t/2-4:t/2-4-i,g,o.injuries,c)}else{fn(e,te,p,A,d[2],c),fn(e,te+j,p,A,d[3],c);let t=2*A+12;fn(e,ee,p-Ln,t,_,c);let n=p-Ln-Rn;g!==null&&(n-=18,yn(e,M,n,g,c)),n=Mn(e,M,n-4,T?E-24:t,o.injuries,T?Cn.compact:Cn.wide,c),S&&vn(e,M,n-18,c)}Wn(e,l,D,E,u?.name??`Fighter`,Hn(u,o,T,ne),d.slice(0,2),c,f,T?void 0:w(o),k&&S),T&&!(v&&t>n)&&mn(e,t/2+(c?1:-1)*112,83,20,w(o),u?.name??`Fighter`,f)});let A=Math.floor((p??r.phase_ticks_remaining)/c),j=`${Math.floor(A/60)}:${String(A%60).padStart(2,`0`)}`,ee=r.phase===`knockdown`&&u===null&&r.fighters.some(e=>e.player_id===a&&e.is_downed)?ir(t,n,v):null,M=ee!==null&&T&&ee.y<112;o===null&&!M&&Gn(e,t/2,T?54:n-84,j,`ROUND ${r.round_number}`,r.phase===`complete`?`FINAL`:r.phase.replace(`_`,` `).toUpperCase());let te=d===null?0:Math.round(d);if(te>=100&&!T&&o===null&&!(v&&u!==null)&&r.fighters.some(e=>e.player_id===a)&&(e.save(),e.textAlign=v?`left`:`right`,e.font=`700 11px ui-monospace, monospace`,e.fillStyle=te<200?`rgba(240,200,110,0.9)`:`rgba(255,110,100,0.95)`,e.fillText(`SLOW CONNECTION ${te} ms`,v?24:t-24,76),e.restore()),u!==null){let t=T?120:64;e.save(),e.fillStyle=`rgba(3,6,12,0.82)`,e.fillRect(24,t,196,34),e.fillStyle=`#ff3b3b`,e.beginPath(),e.arc(42,t+17,6,0,Math.PI*2),e.fill(),e.fillStyle=`#f6f7fb`,e.font=`800 14px Inter, system-ui, sans-serif`,e.textAlign=`left`,e.fillText(u,56,t+22),e.restore()}f!==null&&r.phase===`fight`&&(e.save(),e.textAlign=`center`,e.font=`900 46px Inter, system-ui, sans-serif`,e.lineWidth=6,e.strokeStyle=`rgba(0,0,0,0.75)`,e.strokeText(f,t/2,n*Jn),e.fillStyle=`#f6d57a`,e.fillText(f,t/2,n*Jn),e.restore()),r.phase===`countdown`&&ar(e,tr(t,n,v),`ROUND ${r.round_number}`,`Touch gloves. Protect yourself at all times.`);let ne=hr(n,T);if(r.phase===`knockdown`&&u===null){let n=r.fighters.find(e=>e.is_downed),a=n??r.fighters.find(e=>e.player_id===_),o=a===void 0?null:(i[a.player_id]?.name??`Fighter`).toUpperCase();e.save(),e.textAlign=`center`,e.font=`900 44px Inter, system-ui, sans-serif`,e.lineWidth=6,e.strokeStyle=`rgba(0,0,0,0.75)`,(ee===null||ee.y>=ne+6)&&(e.strokeText(`KNOCKDOWN`,t/2,ne),e.fillStyle=`#ff4d4d`,e.fillText(`KNOCKDOWN`,t/2,ne)),e.font=`700 15px Inter, system-ui, sans-serif`,e.fillStyle=`#e6ecf7`;let s=n===void 0?` BEAT THE COUNT`:` IS DOWN`,c=o===null?`STANDING EIGHT`:`${ln(e,o,Math.min(t*.5,t-32-e.measureText(s).width))}${s}`;(ee===null||ee.y>=ne+30)&&e.fillText(c,t/2,ne+24),e.restore()}if(r.phase===`knockdown`&&u===null){let i=r.fighters.find(e=>e.player_id===a),o=Math.max(...r.fighters.map(e=>e.get_up_count));if(i?.is_downed!==!0)o>=1&&(e.save(),e.textAlign=`center`,e.font=`900 36px Inter, system-ui, sans-serif`,e.lineWidth=5,e.strokeStyle=`rgba(0,0,0,0.75)`,e.strokeText(`COUNT ${o}`,t/2,ne+64),e.fillStyle=`#ffd77a`,e.fillText(`COUNT ${o}`,t/2,ne+64),e.restore());else{let{x:a,y:s,width:c,height:l}=ee??ir(t,n,v),u=a+c/2;e.fillStyle=`rgba(3,6,12,0.88)`,e.fillRect(a,s,c,l),e.strokeStyle=`rgba(246,213,122,0.5)`,e.lineWidth=2,e.strokeRect(a+2,s+2,c-4,l-4),e.textAlign=`center`,e.fillStyle=`#ffd77a`,e.font=`800 30px Inter, system-ui, sans-serif`,e.fillText(o>=1?`COUNT ${o}`:`GET UP!`,u,s+40);let d=i?.is_downed===!0?i.get_up_prompt:null;if(d!=null&&i!==void 0){let t=r.tick>=i.get_up_window_start_tick&&r.tick<=i.get_up_window_end_tick,n=d===`get_up_left`?`←`:`→`;t?(e.fillStyle=`#ffe9a8`,e.font=`900 64px Inter, system-ui, sans-serif`,e.fillText(n,u-90,s+106),e.fillStyle=`#7dffa8`,e.font=`900 34px Inter, system-ui, sans-serif`,e.fillText(`NOW!`,u+62,s+100)):(e.fillStyle=`#8fa3c8`,e.font=`800 30px Inter, system-ui, sans-serif`,e.fillText(`GET READY ${n}`,u,s+98));let o=c-60,l=Math.max(0,Math.min(1,i.get_up_meter/Math.max(1,i.get_up_required)));e.fillStyle=`rgba(2,4,9,0.9)`,e.fillRect(a+30,s+120,o,16);let f=e.createLinearGradient(a+30,0,a+30+o,0);f.addColorStop(0,`#7dffa8`),f.addColorStop(1,`#2ea860`),e.fillStyle=f,e.fillRect(a+30,s+120,o*l,16),e.strokeStyle=`rgba(210,220,235,0.5)`,e.lineWidth=1,e.strokeRect(a+29.5,s+119.5,o+1,17)}else e.fillStyle=`#c8d3e6`,e.font=`600 14px Inter, system-ui, sans-serif`,e.fillText(ln(e,`Waiting for your rhythm instruction…`,c-24),u,s+100)}}if(r.phase===`finish`&&o===null&&u===null){let o=Er(r.fighters,x),s=Tr(t,n,v),c=o!==null&&o.player_id!==a&&r.fighters.some(e=>e.player_id===a);Pr(e,s,o===null?null:(i[o.player_id]?.name??`Fighter`).toUpperCase(),r.phase_ticks_remaining/be,O,c&&!v?n*jr:null)}if(r.phase===`foul_recovery`){let a=r.fighters.find(e=>e.is_foul_recovery_target);ar(e,tr(t,n,v),`FOUL RECOVERY`,`${i[a?.player_id??``]?.name??`Fighter`} is recovering`)}if(r.phase===`rest`){let i=r.fighters.map((e,t)=>({corner:t===0?`Blue`:`Red`,stats:l?.get(e.player_id)??sr()})).filter(({stats:e})=>e.thrown>0||e.landed>0).map(({corner:e,stats:t})=>`${e} ${t.landed} of ${t.thrown}`).join(` · `),a=_n(r.fighters);ar(e,tr(t,n,v),`CORNERS · RECOVER`,a??(i.length>0?`Landed this round: ${i}`:`Conditioning governs recovery`))}if(s>0){let r=Math.min(320,t-24),i=Yn(n);ar(e,v?tr(t,n,!0):{x:t/2-r/2,y:n/2-i/2,width:r,height:i},`OPPONENT RECONNECTING · ${Math.ceil(s/1e3)}s`,`The bout is paused`)}if(o!==null){let a=r.fighters.map(e=>l?.total(e.player_id)??sr());Kr(e,t,n,zr(o,r.fighters,i,a,b),!0,[w(r.fighters[0]),w(r.fighters[1])])}e.restore()}function Ir(e,t,n,r,i,a,o,s,c=`Inter, system-ui, sans-serif`){e.font=`${a} ${un(n=>(e.font=`${a} ${n}px ${c}`,e.measureText(t).width),i,o,s)}px ${c}`,e.fillText(ln(e,t,i),n,r)}var Lr={ko:`KNOCKOUT`,flash_ko:`FLASH KNOCKOUT`,tko:`TECHNICAL KNOCKOUT`,disqualification:`DISQUALIFICATION`,forfeit:`FORFEIT`},Rr=(e,t)=>e>t?0:t>e?1:null;function zr(e,t,n,r,i=null){let a=t.map(e=>n[e.player_id]?.name??`Fighter`),o=e.winner_id===null?null:t[0].player_id===e.winner_id?0:t[1].player_id===e.winner_id?1:null,s=e.method===`draw`&&i!==null,c=[],l=[];if(e.method===`decision`||e.method===`draw`&&!s)for(let t of e.scorecards){let e=cn(t.player_one),n=cn(t.player_two);l.push({label:t.judge.toUpperCase(),values:[String(e),String(n)],lead:Rr(e,n)})}let u=[t[1].knockdowns,t[0].knockdowns];(u[0]>0||u[1]>0)&&c.push({label:`KNOCKDOWNS`,values:[String(u[0]),String(u[1])],lead:Rr(u[0],u[1])});let[d,f]=t.map(t=>e.punches?.[t.player_id]),p=e=>({thrown:e.thrown,landed:e.landed,jabsThrown:e.jabs_thrown,jabsLanded:e.jabs_landed}),m=d!==void 0&&f!==void 0?[p(d),p(f)]:r;if(m[0].thrown>0||m[1].thrown>0){let e=(e,t)=>t>0?`${Math.min(e,t)}/${t} (${Math.round(Math.min(e,t)/t*100)}%)`:`0/0`,t=m.map(e=>({landed:e.landed-e.jabsLanded,thrown:e.thrown-e.jabsThrown}));c.push({label:`TOTAL PUNCHES`,values:[e(m[0].landed,m[0].thrown),e(m[1].landed,m[1].thrown)],lead:Rr(m[0].landed,m[1].landed)}),c.push({label:`JABS`,values:[e(m[0].jabsLanded,m[0].jabsThrown),e(m[1].jabsLanded,m[1].jabsThrown)],lead:Rr(m[0].jabsLanded,m[1].jabsLanded)}),c.push({label:`POWER PUNCHES`,values:[e(t[0].landed,t[0].thrown),e(t[1].landed,t[1].thrown)],lead:Rr(t[0].landed,t[1].landed)})}let[h,g]=t.map(t=>e.ratings[t.player_id]);if(t.some(e=>n[e.player_id]?.cpu===!0))c.push({label:`RATING`,values:[`Unrated`,`Unrated`],lead:null});else if(h!==void 0&&g!==void 0){let e=e=>`${e.after} (${e.after>=e.before?`+`:`−`}${Math.abs(e.after-e.before)})`;c.push({label:`RATING`,values:[e(h),e(g)],lead:null,news:[h.after>=h.before,g.after>=g.before]})}return{headline:e.method===`death`?i!==null&&Oe(i)!==null?`FATALITY`:`DEATH`:s?`DOUBLE DEATH`:Lr[e.method]??ur(e),detail:i!==null&&(e.method===`death`||s)?`${ke(i)} · ROUND ${e.round}`:`ROUND ${e.round}`,verdict:s?`NO SURVIVORS`:o===null?e.winner_id===null?`DRAW`:`${(n[e.winner_id]?.name??`Winner`).toUpperCase()} WINS`:`${a[o].toUpperCase()} WINS`,deadly:e.method===`death`||s,winnerSeat:o,names:a,judges:l,rows:c}}var Br=[`#4f86d9`,`#d9483c`],Vr=14;function Hr(e,t,n,r){let i=Vn(e,t),a=Gr(e/i,t/i,n,r);return i===1?a:{...a,x:a.x*i,y:a.y*i,width:a.width*i,height:a.height*i,rowHeight:a.rowHeight*i,verdictHeight:a.verdictHeight*i,judgesHeight:a.judgesHeight*i}}var Ur=new Set([`KNOCKDOWNS`,`TOTAL PUNCHES`,`RATING`]),Wr=(e,t)=>t?e.rows.filter(e=>Ur.has(e.label)):e.rows;function Gr(e,t,n,r){let i=t<480,a=e>=900||e>=640&&i,o=Math.min(e-24,a?980:720),s=r?62:Vr,c=i?72:112,l=n.judges.length===0?0:i?36:52,u=c+l,d=Wr(n,i).length+1,f=t-(e<640?118:70)-14-Vr-s-(a?0:u),p=Math.max(16,Math.min(i?20:28,f/d)),m=Vr+(a?Math.max(u,d*p):u+d*p)+s;return{x:(e-o)/2,y:t-14-m,width:o,height:m,wide:a,dense:i,rowHeight:p,verdictHeight:c,judgesHeight:l}}function Kr(e,t,n,r,i,a){let o=Gr(t,n,r,i),{x:s,y:c}=o;e.fillStyle=`rgba(3,6,12,0.9)`,e.fillRect(s,c,o.width,o.height),e.strokeStyle=r.deadly?`rgba(224,36,26,0.8)`:`rgba(246,213,122,0.55)`,e.lineWidth=2,e.strokeRect(s+1,c+1,o.width-2,o.height-2),e.textAlign=`center`;let l=(o.wide?o.width*.42:o.width)-32,u=o.wide?s+o.width*.21+4:t/2,d=c+Vr,f=o.verdictHeight/112;e.fillStyle=r.deadly?`#ff3a2c`:`#f6d57a`,Ir(e,r.headline,u,d+34*f,l,800,(o.wide||t>=640?32:28)*f,14),e.fillStyle=`#aebbd0`,Ir(e,r.detail,u,d+56*f,l,700,13*f,9),e.fillStyle=r.winnerSeat===null?`#f6f7fb`:Br[r.winnerSeat],Ir(e,r.verdict,u,d+92*f,l,800,25*f,12);let p=l/Math.max(1,r.judges.length),m=d+o.verdictHeight;r.judges.forEach((t,n)=>{let r=u-l/2+p*(n+.5);e.fillStyle=`rgba(255,255,255,0.06)`,e.fillRect(r-p/2+3,m,p-6,o.judgesHeight-8),e.fillStyle=`#8fa3c8`,Ir(e,t.label,r,m+o.judgesHeight*.3,p-14,700,10,7),e.fillStyle=`#f6f7fb`,Ir(e,`${t.values[0]} – ${t.values[1]}`,r,m+o.judgesHeight*.7,p-14,800,o.dense?14:17,10)});let h=o.wide?s+o.width*.42:s+12,g=s+o.width-12-h,_=o.wide?d:m+o.judgesHeight,v=g*.36,y=(g-v)/2,b=[h+y/2,h+g-y/2],x=o.rowHeight,S=Math.min(16,x*.6),C=_+x*.7;e.fillStyle=`rgba(255,255,255,0.06)`,e.fillRect(h,_,g,x);let w=Math.max(6,x/2-2);for(let t of[0,1]){let n=t===0?-1:1;e.fillStyle=Br[t],e.fillRect(t===0?h:h+g-4,_,4,x),mn(e,b[t]+n*(y/2-10-w),_+x/2,w,a[t],r.names[t],Br[t]),e.textAlign=`center`,e.fillStyle=`#f6f7fb`,Ir(e,r.names[t],b[t]-n*(w+3+v/4),C,y+v/2-22-w*2,800,S,9)}for(let t of Wr(r,o.dense)){C+=x,e.fillStyle=`#8fa3c8`,Ir(e,t.label,h+g/2,C,v,700,Math.min(12,S),8);for(let n of[0,1])e.fillStyle=t.news===void 0?t.lead===n?`#f6f7fb`:`#aebbd0`:t.news[n]?`#55df9b`:`#ff7b74`,Ir(e,t.values[n],b[n],C,y-16,t.lead===n?800:600,S,9)}}var qr=6,Jr=150;function Yr(){return typeof window<`u`&&typeof window.speechSynthesis==`object`&&window.speechSynthesis!==null&&typeof window.SpeechSynthesisUtterance==`function`}function Xr(e){let t=e.filter(e=>e.localService&&e.lang.toLowerCase().startsWith(`en`));return t.find(e=>e.default)??t[0]??null}var Zr=class{settings;synthesis;Utterance;queue=[];speaking=null;destroyed=!1;grave=!1;voice=null;voicesListed=!1;onVoicesChanged=null;cutoff=null;pendingShout=null;cutOff=null;shoutTimer=null;voicesChanged=()=>{this.listVoices(),this.voice===null&&this.cancel(),this.onVoicesChanged?.()};visibility=()=>{document.hidden&&this.cancel()};constructor(e,t=Yr()?window.speechSynthesis:null,n=Yr()?window.SpeechSynthesisUtterance:null){this.settings=e,this.synthesis=t,this.Utterance=n,this.listVoices(),t?.addEventListener?.(`voiceschanged`,this.voicesChanged),document.addEventListener(`visibilitychange`,this.visibility)}get supported(){return this.synthesis!==null&&this.Utterance!==null}get hasVoice(){return this.supported&&(this.voice!==null||!this.voicesListed)}speak(e){if(!this.supported||this.destroyed||document.hidden)return;let t=this.settings();!t.announcer||t.volume<=0||(this.voice===null&&this.listVoices(),this.voice!==null&&(this.queue.push(...e),this.queue.length>qr&&this.queue.splice(0,this.queue.length-qr),this.speaking===null&&this.pendingShout===null&&this.next()))}shout(e){let t=this.speaking??this.cutOff;if(this.cancel(),t===null){this.grave=!0,this.speak([e]),this.grave=!1;return}let n=()=>{this.pendingShout===n&&(this.clearShout(),t.onend=null,t.onerror=null,this.queue.unshift(e),this.grave=!0,this.next(),this.grave=!1)};this.pendingShout=n,this.cutOff=t,t.onend=n,t.onerror=n,this.shoutTimer=window.setTimeout(n,Jr)}settingsChanged(){let e=this.settings();(!e.announcer||e.volume<=0)&&this.cancel()}finishLine(e){this.queue.length=0,this.clearCutoff();let t=this.speaking;t!==null&&(this.cutoff=window.setTimeout(()=>{this.cutoff=null,this.speaking===t&&this.cancel()},e))}cancel(){this.queue.length=0,this.clearCutoff(),this.clearShout();let e=this.speaking;this.speaking=null,e!==null&&(e.onend=null,e.onerror=null,this.synthesis?.cancel())}destroy(){this.destroyed=!0,this.synthesis?.removeEventListener?.(`voiceschanged`,this.voicesChanged),document.removeEventListener(`visibilitychange`,this.visibility),this.onVoicesChanged=null,this.cancel()}clearCutoff(){this.cutoff!==null&&window.clearTimeout(this.cutoff),this.cutoff=null}clearShout(){this.shoutTimer!==null&&window.clearTimeout(this.shoutTimer),this.shoutTimer=null,this.pendingShout=null,this.cutOff=null}listVoices(){let e=this.synthesis?.getVoices()??[];e.length>0&&(this.voicesListed=!0),this.voice=Xr(e)}next(){let e=this.synthesis,t=this.Utterance,n=this.voice,r=this.queue.shift();if(e===null||t===null||r===void 0)return;let i=this.settings();if(!i.announcer||i.volume<=0||n===null||document.hidden){this.queue.length=0;return}let a=new t(r);a.volume=Math.min(1,i.volume),a.rate=this.grave?.8:.96,a.pitch=this.grave?.3:.82,a.voice=n,a.lang=n.lang;let o=()=>{this.speaking===a&&(this.speaking=null,this.clearCutoff(),this.next())};a.onend=o,a.onerror=o,this.speaking=a,e.speak(a)}},Qr=[{name:`decapitation`,sampleRate:12e3,frames:7920,wav:`UklGRgQ+AABXQVZFZm10IBAAAAABAAEA4C4AAMBdAAACABAAZGF0YeA9AAAGAGAAd/9r/1b/Dv+d/kH+Of69/vL/gAGaAhUD9wKOAmICHwPSBLYGQ/pC+4r72/rQ+Sr5sPle+7X+MQM2BmQHHwfgBSEFpAU+CKkLYA649Q331faL9fnzlfMw9ST5+/5iBV4JDAtaCuYIVgdWB0kKSw/iE2HuFvGL8lnxVO/g7TXt4+6L8wT7agMsCvAN0g4gDb0K4QjzCOEMBhO+GHQdcuis667sVOsZ6dTmDeaH54Hr4fE9+0wECgylELYRuBDhDU0LfAnWCb8OABXvG6QiDyiLKwjk3uUl5fziMuAc3v/cvtx23kbj2Op98xH8EQYQD/ETiBVzFgkUHxCYDc0MWAtYC4sPrhWTHE4kpitIMV41DDlm11XZV9pG2ZPXOtVN0yrRjc/wzkXPstA51HDae+DX6I/xjfq1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/x4ARQBjAG4AYwBSADoAIAAMAAQABwA=`}],$r={head_burst:`decapitation`,eye_left:`jaw_dislocation`,eye_right:`jaw_dislocation`,ribs_left:`shoulder_left`,ribs_right:`shoulder_right`},ei={broken_nose:`crack`,broken_jaw:`crack`,skull_fractured:`crack`,shoulder_dislocated:`crack`,arm_broken:`crack`,ribs_broken:`crack`,knee_blown:`crack`,jaw_torn:`rip`,ear_torn:`rip`,face_flayed:`rip`,arm_torn:`rip`,eye_out:`squelch`,liver_ruptured:`squelch`,disemboweled:`squelch`,forearm_severed:`chop`},ti={eyes_out:[`squelch`,`squelch`],head_burst:[`crack`,`squelch`],decapitation:[`crack`,`chop`],spine_rip:[`rip`,`crack`],heart_punch:[`crack`,`squelch`],gutting:[`squelch`,`rip`],bisection:[`rip`,`squelch`],total_gib:[`crack`,`squelch`,`chop`]},ni=[0,.05,.12,.16,.27,.41,.6],ri=[.045,.07,.115,.14,.2],ii=1.9,ai={duration:1.1,first:[330,420],second:[760,880],gain:.16},oi={duration:1.2,first:[520,360],second:[980,720],gain:.13},si={duration:1.3,first:[300,280],second:[640,600],gain:.11,delay:.75},ci=2.5,li=20,ui=.05,di=.022,fi=2e4,pi=650,mi=[`pointerdown`,`pointerup`,`touchend`,`click`,`keydown`],hi={jab:{from:520,to:1500,duration:.09},straight:{from:420,to:1150,duration:.12},hook:{from:300,to:880,duration:.14},uppercut:{from:240,to:820,duration:.15}};function gi(e){return Math.round(14+(1-Math.max(0,Math.min(1,e)))*22)}var _i=class{settings;context=null;master=null;noiseBuffer=null;injuryBuffers=new Map;crowdGain=null;unlocked=!1;unlockPromise=null;crowdStarted=!1;destroyed=!1;timers=new Set;lastBreathTick=-300;lastHeartbeatTick=-300;clapperRound=0;murmurGain=null;murmurLevel=0;lastOohAt=-1/0;lastChantAt=-1/0;muffle=null;rockedLevel=0;lastRockedBeat=-300;lastTick=-1;unlockListener=()=>{let e=this.context;e!==null&&e.state!==`running`&&e.resume().catch(()=>void 0),this.unlock().catch(()=>void 0)};visibility=()=>{let e=this.context;if(e===null)return;let t=document.hidden?e.suspend():this.unlocked?e.resume():null;t!==null&&t.catch(()=>void 0)};constructor(e){this.settings=e;for(let e of mi)window.addEventListener(e,this.unlockListener);document.addEventListener(`visibilitychange`,this.visibility)}unlock(){return this.destroyed||this.unlocked?Promise.resolve():(this.unlockPromise===null&&(this.unlockPromise=this.performUnlock().finally(()=>{this.unlockPromise=null})),this.unlockPromise)}async performUnlock(){let e=this.context;if(e===null){e=new AudioContext;let t=e.createGain();t.gain.value=Math.min(.8,Math.max(0,this.settings().volume));let n=e.createBiquadFilter();n.type=`lowpass`,n.frequency.value=fi,n.Q.value=.7,t.connect(n).connect(e.destination),this.context=e,this.master=t,this.muffle=n}if(e.state===`suspended`&&await e.resume(),this.destroyed||this.context!==e)return;let t=await this.decodeInjuryBuffers(e);if(!(this.destroyed||this.context!==e)){this.injuryBuffers=t,this.unlocked=!0;for(let e of mi)window.removeEventListener(e,this.unlockListener);this.crowdStarted||(this.crowdStarted=!0,this.crowdBed())}}setVolume(){this.master!==null&&(this.master.gain.value=Math.min(.8,Math.max(0,this.settings().volume)))}event(e,t=!1){if(this.unlocked)switch(e.kind){case`punch_start`:this.whoosh(e.detail.split(`:`)[1]??`jab`,t);break;case`whiff`:this.noise({duration:.11,frequency:850,sweepTo:320,gain:.07,type:`bandpass`,q:1.1});break;case`hit`:case`counter_hit`:{let n=e.detail.endsWith(`body`),r=Math.min(1,e.amount/260),i=Math.min(.36,.14+r*.2)*(e.kind===`counter_hit`?1.25:1);this.impact(i,n,r,t),(e.kind===`counter_hit`||r>.7||t)&&this.crowdSwell(.35+r*.4),(e.kind===`counter_hit`&&e.amount>=50||e.amount>=90)&&this.ooh(Math.min(1,e.amount/160));break}case`referee_hit`:{let t=Math.min(1,e.amount/260);this.impact(Math.min(.36,.16+t*.2),e.detail.endsWith(`body`),t),this.ooh(.7+t*.3),this.crowdSwell(.5+t*.3);break}case`referee_down`:this.impact(.36,!1,1),this.crowdRoar(1),this.ooh(1);break;case`block`:this.noise({duration:.045,frequency:1200,sweepTo:600,gain:.14,type:`bandpass`,q:1.1}),this.noise({duration:.09,frequency:260,gain:.08}),this.tone({from:160,to:110,duration:.06,type:`triangle`,gain:.05}),t&&this.tone({from:96,to:44,duration:.2,type:`sine`,gain:.2});break;case`perfect_block`:this.noise({duration:.05,frequency:1800,sweepTo:900,gain:.16,type:`bandpass`,q:1.6}),this.tone({from:280,to:210,duration:.06,type:`triangle`,gain:.06});break;case`guard_break`:this.impact(.3,!1,.9),this.tone({from:230,to:78,duration:.2,type:`sawtooth`,gain:.08}),this.crowdSwell(.5),this.ooh(.6);break;case`stun`:this.tone({from:96,to:74,duration:.22,type:`sine`,gain:.1}),this.crowdSwell(.3);break;case`parry`:this.noise({duration:.06,frequency:2400,sweepTo:1100,gain:.18,type:`bandpass`,q:1.8}),this.tone({from:330,to:180,duration:.09,type:`triangle`,gain:.07}),this.crowdSwell(.35);break;case`body_collapse`:this.tone({from:118,to:52,duration:.42,type:`sine`,gain:.16}),this.noise({duration:.26,frequency:420,sweepTo:180,gain:.05,type:`bandpass`,q:.9}),this.crowdSwell(.6);break;case`eye_shut`:this.crowdSwell(.25);break;case`corner`:this.noise({duration:.22,frequency:2600,sweepTo:1500,gain:.05,type:`bandpass`,q:.8});break;case`knockdown`:this.impact(.34,!1,1),this.tone({from:60,to:28,duration:.42,type:`sine`,gain:.3}),this.noise({duration:.3,frequency:140,gain:.24}),this.crowdRoar(1),this.hush();break;case`bell`:{let t=e.detail===`round_start`?3:1;for(let e=0;e10*r||this.clapperRound===t||(this.clapperRound=t,!this.unlocked))return;this.noise({duration:.05,frequency:2600,gain:.42,type:`bandpass`,q:1.4}),this.noise({duration:.09,frequency:700,gain:.18,type:`bandpass`,q:.8});let i=window.setTimeout(()=>{this.timers.delete(i),this.noise({duration:.05,frequency:2400,gain:.4,type:`bandpass`,q:1.4}),this.noise({duration:.09,frequency:660,gain:.16,type:`bandpass`,q:.8})},120);this.timers.add(i)}chant(){let e=this.context;if(!(!this.unlocked||e===null||e.currentTime-this.lastChantAtthis.murmurLevel;this.murmurLevel=r,n.gain.setTargetAtTime(r*ui,t.currentTime,i?.3:.8)}rocked(e,t){this.follow(t);let n=this.context,r=this.muffle;if(!this.unlocked||n===null||r===null)return;let i=Math.max(0,Math.min(1,e));if(Math.abs(i-this.rockedLevel)>=.02||i===0&&this.rockedLevel!==0){let e=i>this.rockedLevel;this.rockedLevel=i,r.frequency.setTargetAtTime(fi*(pi/fi)**+i,n.currentTime,e?.05:.9)}i>.15&&t-this.lastRockedBeat>=gi(i)&&(this.lastRockedBeat=t,this.tone({from:58,to:40,duration:.12,type:`sine`,gain:.09+i*.08}),this.tone({from:50,to:36,duration:.14,type:`sine`,gain:.07+i*.06,delay:.16}))}snapshot(e,t,n,r){if(this.follow(e),!this.unlocked)return;let i=1-t/Math.max(1,n);i>.55&&e-this.lastBreathTick>=75&&(this.lastBreathTick=e,this.noise({duration:.18,frequency:420,gain:.045+i*.04})),(i>.72||r>500)&&this.rockedLevel<=.15&&e-this.lastHeartbeatTick>=24&&(this.lastHeartbeatTick=e,this.tone({from:52,duration:.09,type:`sine`,gain:.055}))}result(e){if(this.openMuffle(),!this.unlocked)return;this.crowdSwell(1),this.tone({from:e.winner_id===null?280:520,duration:.45,type:`triangle`,gain:.18});let t=window.setTimeout(()=>{this.timers.delete(t),this.tone({from:650,duration:.5,type:`triangle`,gain:.14})},160);this.timers.add(t)}injury(e){let t=this.context,n=this.master,r=this.injuryBuffers.get($r[e]??e),i=this.settings();if(!this.unlocked||t===null||n===null||i.blood!==`full`||i.reducedMotion||(this.tearing(),r===void 0))return;let a=t.createBufferSource(),o=t.createGain();a.buffer=r,o.gain.value=.2,a.connect(o).connect(n),a.start()}tearing(){this.noise({duration:.09,frequency:2600,sweepTo:700,gain:.22,type:`bandpass`,q:1.6}),this.noise({duration:.4,frequency:900,sweepTo:150,gain:.28,type:`lowpass`,q:6,offset:.35});for(let[e,t]of[.3,.9,1.5].entries())this.noise({duration:.2,frequency:480-e*60,sweepTo:170,gain:.13-e*.03,type:`bandpass`,q:4,delay:t,offset:.2+t})}gore(e){let t=this.settings();if(!this.unlocked||t.volume<=0)return;let n=t.blood===`full`&&!t.reducedMotion;switch(e.kind){case`injury`:{let t=ei[F(e.injury)];n?this.wound(t,0):this.impact(.3,!1,.9),this.ooh(1),this.crowdSwell(.8),t!==`crack`&&this.crowdVoice({...oi,delay:.45});break}case`vomit`:n&&this.retch(),this.crowdVoice({...oi,gain:.09,delay:.5});break;case`finish_him`:this.omen(),this.crowdRoar(1);break;case`fatality`:this.sting(),n&&ti[e.fatality].forEach((e,t)=>this.wound(e,t*.2)),this.crowdRoar(1),this.ooh(1);break;case`death`:Oe(e.cause)===null?(this.flatline(0),this.hush(!0)):this.flatline(ii)}}wound(e,t){e===`crack`?this.crack(t):e===`rip`?this.rip(t):e===`squelch`?this.squelch(t):this.chop(t)}crack(e){this.noise({duration:.03,frequency:3400,sweepTo:1800,gain:.34,type:`bandpass`,q:2.2,delay:e}),this.tone({from:190,to:70,duration:.09,type:`triangle`,gain:.22,delay:e});for(let[t,n]of ri.entries())this.noise({duration:.018,frequency:2800-t*260,gain:.2-t*.03,type:`highpass`,q:1.4,delay:e+n,offset:.17*(t+1)})}rip(e){this.noise({duration:.5,frequency:420,sweepTo:2600,gain:.3,type:`bandpass`,q:3.2,delay:e,offset:.4}),this.noise({duration:.45,frequency:180,sweepTo:520,gain:.2,type:`lowpass`,q:5,delay:e+.03,offset:.7});for(let t=0;t<6;t+=1)this.noise({duration:.035,frequency:900+t*280,gain:.16,type:`bandpass`,q:6,delay:e+.05+t*.07,offset:.09*t});this.noise({duration:.12,frequency:700,sweepTo:160,gain:.24,type:`lowpass`,q:4,delay:e+.52,offset:.55})}squelch(e){this.noise({duration:.3,frequency:1100,sweepTo:140,gain:.32,type:`lowpass`,q:9,delay:e,offset:.25}),this.noise({duration:.22,frequency:300,sweepTo:900,gain:.18,type:`bandpass`,q:7,delay:e+.1,offset:.6}),this.tone({from:150,to:60,duration:.12,type:`sine`,gain:.16,delay:e}),this.spatter(e+.25)}spatter(e){for(let[t,n]of ni.entries())this.noise({duration:.03,frequency:1500+t%3*600,sweepTo:500,gain:.14-t*.012,type:`bandpass`,q:3,delay:e+n,offset:.13*t})}chop(e){this.tone({from:120,to:38,duration:.2,type:`sine`,gain:.32,delay:e}),this.noise({duration:.05,frequency:2200,sweepTo:500,gain:.3,type:`bandpass`,q:1.2,delay:e}),this.noise({duration:.16,frequency:600,sweepTo:150,gain:.26,type:`lowpass`,q:5,delay:e+.02,offset:.3});for(let[t,n]of[.3,.75,1.2,1.65].entries())this.noise({duration:.22,frequency:520-t*60,sweepTo:170,gain:.15-t*.03,type:`bandpass`,q:4,delay:e+n,offset:.2+n})}retch(){for(let[e,t]of[0,.45].entries())this.tone({from:150-e*25,to:80,duration:.3,type:`sawtooth`,gain:.09,delay:t}),this.crowdVoice({duration:.36,first:[650,360],second:[1150,780],gain:.22,delay:t});this.noise({duration:.45,frequency:2400,sweepTo:300,gain:.24,type:`lowpass`,q:3,delay:.9,offset:.5}),this.spatter(1.05)}drum(e){this.tone({from:95,to:30,duration:.7,type:`sine`,gain:.35,delay:e}),this.noise({duration:.2,frequency:160,gain:.3,delay:e}),this.noise({duration:.03,frequency:1800,sweepTo:600,gain:.18,type:`bandpass`,q:1,delay:e})}omen(){this.drum(0),this.held({frequency:27.5,duration:1.4,gain:.3,attack:1.1,type:`sine`,delay:.1}),this.held({frequency:55,duration:1.4,gain:.12,attack:1.2,type:`sawtooth`,delay:.1}),this.held({frequency:58.3,duration:1.4,gain:.1,attack:1.2,type:`sawtooth`,delay:.1}),this.drum(1.5)}sting(){this.drum(0);for(let[e,t]of[196,185,147,110].entries())this.tone({from:t,to:t*.97,duration:.5,type:`sawtooth`,gain:.14,delay:e*.2}),this.tone({from:t/2,duration:.5,type:`square`,gain:.1,delay:e*.2});this.tone({from:73.4,to:69,duration:1.4,type:`sawtooth`,gain:.2,delay:.8}),this.tone({from:36.7,to:34.5,duration:1.4,type:`sine`,gain:.32,delay:.8}),this.drum(.8)}flatline(e){for(let t of[0,.38])this.held({frequency:880,duration:.09,gain:.1,attack:.005,type:`sine`,delay:e+t});this.held({frequency:880,duration:2.6,gain:.1,attack:.01,type:`sine`,delay:e+.76})}held(e){let t=this.context,n=this.master;if(t===null||n===null)return;let r=t.currentTime+(e.delay??0),i=Math.min(3,e.duration),a=Math.min(.35,e.gain),o=t.createOscillator(),s=t.createGain();o.type=e.type,o.frequency.setValueAtTime(Math.max(20,e.frequency),r),s.gain.setValueAtTime(1e-4,r),s.gain.exponentialRampToValueAtTime(a,r+Math.min(i-.03,e.attack)),s.gain.setValueAtTime(a,r+i-.03),s.gain.exponentialRampToValueAtTime(1e-4,r+i),o.connect(s).connect(n),o.start(r),o.stop(r+i+.03)}async decodeInjuryBuffers(e){let t=await Promise.all(Qr.map(async t=>{let n=atob(t.wav),r=new Uint8Array(n.length);for(let e=0;evoid 0)}},vi=class extends Error{code;reloadRequired;name=`ClientError`;constructor(e,t=!1){super(e),this.code=e,this.reloadRequired=t}};async function yi(e,t){if(!e.ok)throw new vi(e.status===429?`rate_limited`:t);if(!(e.headers.get(`content-type`)??``).toLowerCase().startsWith(`application/json`))throw new vi(t);try{return Ge(await e.text())}catch{throw new vi(t)}}function bi(e=window.location.search){let t=new URLSearchParams(e).getAll(`instance_id`);if(t.length!==1||!/^[A-Za-z0-9_-]{1,255}$/u.test(t[0]??``))throw new vi(`invalid_launch`);return t[0]}function xi(e){if(typeof e==`object`&&e&&`protocol`in e&&e.protocol!==6)throw new vi(`client_outdated`,!0)}async function Si(e,t){let n=new URL(`/api/hands/bootstrap`,window.location.origin);try{let r=await yi(await fetch(n,{method:`POST`,credentials:`same-origin`,cache:`no-store`,headers:{"Content-Type":`application/json`},body:JSON.stringify({instance_id:e}),...t===void 0?{}:{signal:t}}),`bootstrap_failed`);return xi(r),Pt(r)}catch(e){throw e instanceof vi?e:e instanceof Ve?new vi(`invalid_bootstrap`):new vi(`bootstrap_failed`)}}async function Ci(e,t,n){try{return Ft(await yi(await fetch(new URL(`/api/hands/token`,window.location.origin),{method:`POST`,credentials:`same-origin`,cache:`no-store`,headers:{"Content-Type":`application/json`},body:JSON.stringify({code:e,state:t}),...n===void 0?{}:{signal:n}}),`token_failed`))}catch(e){throw e instanceof vi?e:e instanceof Ve?new vi(`invalid_token_response`):new vi(`token_failed`)}}function wi(e){return e instanceof vi?e.code:e instanceof Ve?`protocol_error`:`unexpected_error`}var Ti=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};function Ei(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}var Di={exports:{}},Oi;function ki(){return Oi||(Oi=1,(function(e){var t=Object.prototype.hasOwnProperty,n=`~`;function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function i(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function a(e,t,r,a,o){if(typeof r!=`function`)throw TypeError(`The listener must be a function`);var s=new i(r,a||e,o),c=n?n+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function o(e,t){--e._eventsCount===0?e._events=new r:delete e._events[t]}function s(){this._events=new r,this._eventsCount=0}s.prototype.eventNames=function(){var e=[],r,i;if(this._eventsCount===0)return e;for(i in r=this._events)t.call(r,i)&&e.push(n?i.slice(1):i);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(r)):e},s.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,a=r.length,o=Array(a);ie;function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(ji||={});var Mi;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(Mi||={});var R=ji.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),Ni=e=>{switch(typeof e){case`undefined`:return R.undefined;case`string`:return R.string;case`number`:return isNaN(e)?R.nan:R.number;case`boolean`:return R.boolean;case`function`:return R.function;case`bigint`:return R.bigint;case`symbol`:return R.symbol;case`object`:return Array.isArray(e)?R.array:e===null?R.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?R.promise:typeof Map<`u`&&e instanceof Map?R.map:typeof Set<`u`&&e instanceof Set?R.set:typeof Date<`u`&&e instanceof Date?R.date:R.object;default:return R.unknown}},z=ji.arrayToEnum([`invalid_type`,`invalid_literal`,`custom`,`invalid_union`,`invalid_union_discriminator`,`invalid_enum_value`,`unrecognized_keys`,`invalid_arguments`,`invalid_return_type`,`invalid_date`,`invalid_string`,`too_small`,`too_big`,`invalid_intersection_types`,`not_multiple_of`,`not_finite`]),Pi=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,`$1:`),Fi=class e extends Error{constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}get errors(){return this.issues}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;re.message){let t={},n=[];for(let r of this.issues)r.path.length>0?(t[r.path[0]]=t[r.path[0]]||[],t[r.path[0]].push(e(r))):n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};Fi.create=e=>new Fi(e);var Ii=(e,t)=>{let n;switch(e.code){case z.invalid_type:n=e.received===R.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case z.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,ji.jsonStringifyReplacer)}`;break;case z.unrecognized_keys:n=`Unrecognized key(s) in object: ${ji.joinValues(e.keys,`, `)}`;break;case z.invalid_union:n=`Invalid input`;break;case z.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${ji.joinValues(e.options)}`;break;case z.invalid_enum_value:n=`Invalid enum value. Expected ${ji.joinValues(e.options)}, received '${e.received}'`;break;case z.invalid_arguments:n=`Invalid function arguments`;break;case z.invalid_return_type:n=`Invalid function return type`;break;case z.invalid_date:n=`Invalid date`;break;case z.invalid_string:typeof e.validation==`object`?`includes`in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==`number`&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):`startsWith`in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:`endsWith`in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:ji.assertNever(e.validation):n=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case z.too_small:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at least`:`more than`} ${e.minimum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at least`:`over`} ${e.minimum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${e.minimum}`:e.type===`date`?`Date must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(e.minimum))}`:`Invalid input`;break;case z.too_big:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at most`:`less than`} ${e.maximum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at most`:`under`} ${e.maximum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`bigint`?`BigInt must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`date`?`Date must be ${e.exact?`exactly`:e.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(e.maximum))}`:`Invalid input`;break;case z.custom:n=`Invalid input`;break;case z.invalid_intersection_types:n=`Intersection results could not be merged`;break;case z.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case z.not_finite:n=`Number must be finite`;break;default:n=t.defaultError,ji.assertNever(e)}return{message:n}},Li=Ii;function Ri(e){Li=e}function zi(){return Li}var Bi=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}},Vi=[];function B(e,t){let n=zi(),r=Bi({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===Ii?void 0:Ii].filter(e=>!!e)});e.common.issues.push(r)}var Hi=class e{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return Ui;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return Ui;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}},Ui=Object.freeze({status:`aborted`}),Wi=e=>({status:`dirty`,value:e}),Gi=e=>({status:`valid`,value:e}),Ki=e=>e.status===`aborted`,qi=e=>e.status===`dirty`,Ji=e=>e.status===`valid`,Yi=e=>typeof Promise<`u`&&e instanceof Promise;function Xi(e,t,n,r){if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return t.get(e)}function Zi(e,t,n,r,i){if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return t.set(e,n),n}var Qi;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(Qi||={});var $i,ea,ta=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},na=(e,t)=>{if(Ji(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){if(this._error)return this._error;let t=new Fi(e.common.issues);return this._error=t,this._error}}};function ra(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var ia=class{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return Ni(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Ni(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Hi,ctx:{common:e.parent.common,data:e.data,parsedType:Ni(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(Yi(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ni(e)};return na(n,this._parseSync({data:e,path:n.path,parent:n}))}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ni(e)},r=this._parse({data:e,path:n.path,parent:n});return na(n,await(Yi(r)?r:Promise.resolve(r)))}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let i=e(t),a=()=>r.addIssue({code:z.custom,...n(t)});return typeof Promise<`u`&&i instanceof Promise?i.then(e=>e?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new to({schema:this,typeName:mo.ZodEffects,effect:{type:`refinement`,refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return no.create(this,this._def)}nullable(){return ro.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ia.create(this,this._def)}promise(){return eo.create(this,this._def)}or(e){return za.create([this,e],this._def)}and(e){return Ua.create(this,e,this._def)}transform(e){return new to({...ra(this._def),schema:this,typeName:mo.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new io({...ra(this._def),innerType:this,defaultValue:t,typeName:mo.ZodDefault})}brand(){return new co({typeName:mo.ZodBranded,type:this,...ra(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new ao({...ra(this._def),innerType:this,catchValue:t,typeName:mo.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return lo.create(this,e)}readonly(){return uo.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},aa=/^c[^\s-]{8,}$/i,oa=/^[0-9a-z]+$/,sa=/^[0-9A-HJKMNP-TV-Z]{26}$/,ca=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,la=/^[a-z0-9_-]{21}$/i,ua=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,da=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,fa=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,pa,ma=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ha=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ga=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,_a=`((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`,va=RegExp(`^${_a}$`);function ya(e){let t=`([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;return e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`),t}function ba(e){return RegExp(`^${ya(e)}$`)}function xa(e){let t=`${_a}T${ya(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function Sa(e,t){return!((t!==`v4`&&t||!ma.test(e))&&(t!==`v6`&&t||!ha.test(e)))}var Ca=class e extends ia{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==R.string){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:R.string,received:t.parsedType}),Ui}let t=new Hi,n;for(let r of this._def.checks)if(r.kind===`min`)e.data.lengthr.value&&(n=this._getOrReturnCtx(e,n),B(n,{code:z.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`length`){let i=e.data.length>r.value,a=e.data.lengthe.test(t),{validation:t,code:z.invalid_string,...Qi.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...Qi.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...Qi.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...Qi.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...Qi.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...Qi.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...Qi.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...Qi.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...Qi.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...Qi.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...Qi.errToObj(e)})}datetime(e){return typeof e==`string`?this._addCheck({kind:`datetime`,precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:`datetime`,precision:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...Qi.errToObj(e?.message)})}date(e){return this._addCheck({kind:`date`,message:e})}time(e){return typeof e==`string`?this._addCheck({kind:`time`,precision:null,message:e}):this._addCheck({kind:`time`,precision:e?.precision===void 0?null:e?.precision,...Qi.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...Qi.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...Qi.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...Qi.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...Qi.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...Qi.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...Qi.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...Qi.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...Qi.errToObj(t)})}nonempty(e){return this.min(1,Qi.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toUpperCase`}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind===`datetime`)}get isDate(){return!!this._def.checks.find(e=>e.kind===`date`)}get isTime(){return!!this._def.checks.find(e=>e.kind===`time`)}get isDuration(){return!!this._def.checks.find(e=>e.kind===`duration`)}get isEmail(){return!!this._def.checks.find(e=>e.kind===`email`)}get isURL(){return!!this._def.checks.find(e=>e.kind===`url`)}get isEmoji(){return!!this._def.checks.find(e=>e.kind===`emoji`)}get isUUID(){return!!this._def.checks.find(e=>e.kind===`uuid`)}get isNANOID(){return!!this._def.checks.find(e=>e.kind===`nanoid`)}get isCUID(){return!!this._def.checks.find(e=>e.kind===`cuid`)}get isCUID2(){return!!this._def.checks.find(e=>e.kind===`cuid2`)}get isULID(){return!!this._def.checks.find(e=>e.kind===`ulid`)}get isIP(){return!!this._def.checks.find(e=>e.kind===`ip`)}get isBase64(){return!!this._def.checks.find(e=>e.kind===`base64`)}get minLength(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.valuenew Ca({checks:[],typeName:mo.ZodString,coerce:e?.coerce??!1,...ra(e)});function wa(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return parseInt(e.toFixed(i).replace(`.`,``))%parseInt(t.toFixed(i).replace(`.`,``))/10**i}var Ta=class e extends ia{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==R.number){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:R.number,received:t.parsedType}),Ui}let t,n=new Hi;for(let r of this._def.checks)r.kind===`int`?ji.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),B(t,{code:z.invalid_type,expected:`integer`,received:`float`,message:r.message}),n.dirty()):r.kind===`min`?(r.inclusive?e.datar.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),B(t,{code:z.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`multipleOf`?wa(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),B(t,{code:z.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),B(t,{code:z.not_finite,message:r.message}),n.dirty()):ji.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,Qi.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,Qi.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,Qi.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,Qi.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:Qi.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:Qi.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:Qi.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:Qi.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:Qi.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:Qi.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:Qi.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:Qi.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:Qi.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:Qi.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.valuee.kind===`int`||e.kind===`multipleOf`&&ji.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.valuenew Ta({checks:[],typeName:mo.ZodNumber,coerce:e?.coerce||!1,...ra(e)});var Ea=class e extends ia{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==R.bigint){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:R.bigint,received:t.parsedType}),Ui}let t,n=new Hi;for(let r of this._def.checks)r.kind===`min`?(r.inclusive?e.datar.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),B(t,{code:z.too_big,type:`bigint`,maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`multipleOf`?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),B(t,{code:z.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):ji.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,Qi.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,Qi.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,Qi.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,Qi.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:Qi.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:Qi.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:Qi.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:Qi.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:Qi.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:Qi.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.valuenew Ea({checks:[],typeName:mo.ZodBigInt,coerce:e?.coerce??!1,...ra(e)});var Da=class extends ia{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==R.boolean){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:R.boolean,received:t.parsedType}),Ui}return Gi(e.data)}};Da.create=e=>new Da({typeName:mo.ZodBoolean,coerce:e?.coerce||!1,...ra(e)});var Oa=class e extends ia{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==R.date){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:R.date,received:t.parsedType}),Ui}if(isNaN(e.data.getTime()))return B(this._getOrReturnCtx(e),{code:z.invalid_date}),Ui;let t=new Hi,n;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()r.value&&(n=this._getOrReturnCtx(e,n),B(n,{code:z.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),t.dirty()):ji.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:Qi.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:Qi.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.valuenew Oa({checks:[],coerce:e?.coerce||!1,typeName:mo.ZodDate,...ra(e)});var ka=class extends ia{_parse(e){if(this._getType(e)!==R.symbol){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:R.symbol,received:t.parsedType}),Ui}return Gi(e.data)}};ka.create=e=>new ka({typeName:mo.ZodSymbol,...ra(e)});var Aa=class extends ia{_parse(e){if(this._getType(e)!==R.undefined){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:R.undefined,received:t.parsedType}),Ui}return Gi(e.data)}};Aa.create=e=>new Aa({typeName:mo.ZodUndefined,...ra(e)});var ja=class extends ia{_parse(e){if(this._getType(e)!==R.null){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:R.null,received:t.parsedType}),Ui}return Gi(e.data)}};ja.create=e=>new ja({typeName:mo.ZodNull,...ra(e)});var Ma=class extends ia{constructor(){super(...arguments),this._any=!0}_parse(e){return Gi(e.data)}};Ma.create=e=>new Ma({typeName:mo.ZodAny,...ra(e)});var Na=class extends ia{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Gi(e.data)}};Na.create=e=>new Na({typeName:mo.ZodUnknown,...ra(e)});var Pa=class extends ia{_parse(e){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:R.never,received:t.parsedType}),Ui}};Pa.create=e=>new Pa({typeName:mo.ZodNever,...ra(e)});var Fa=class extends ia{_parse(e){if(this._getType(e)!==R.undefined){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:R.void,received:t.parsedType}),Ui}return Gi(e.data)}};Fa.create=e=>new Fa({typeName:mo.ZodVoid,...ra(e)});var Ia=class e extends ia{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==R.array)return B(t,{code:z.invalid_type,expected:R.array,received:t.parsedType}),Ui;if(r.exactLength!==null){let e=t.data.length>r.exactLength.value,i=t.data.lengthr.maxLength.value&&(B(t,{code:z.too_big,maximum:r.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new ta(t,e,t.path,n)))).then(e=>Hi.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new ta(t,e,t.path,n)));return Hi.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:Qi.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:Qi.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:Qi.toString(n)}})}nonempty(e){return this.min(1,e)}};Ia.create=(e,t)=>new Ia({type:e,minLength:null,maxLength:null,exactLength:null,typeName:mo.ZodArray,...ra(t)});function La(e){if(e instanceof Ra){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=no.create(La(r))}return new Ra({...e._def,shape:()=>t})}return e instanceof Ia?new Ia({...e._def,type:La(e.element)}):e instanceof no?no.create(La(e.unwrap())):e instanceof ro?ro.create(La(e.unwrap())):e instanceof Wa?Wa.create(e.items.map(e=>La(e))):e}var Ra=class e extends ia{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=ji.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==R.object){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:R.object,received:t.parsedType}),Ui}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof Pa&&this._def.unknownKeys===`strip`))for(let e in n.data)i.includes(e)||a.push(e);let o=[];for(let e of i){let t=r[e],i=n.data[e];o.push({key:{status:`valid`,value:e},value:t._parse(new ta(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof Pa){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of a)o.push({key:{status:`valid`,value:e},value:{status:`valid`,value:n.data[e]}});else if(e===`strict`)a.length>0&&(B(n,{code:z.unrecognized_keys,keys:a}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of a){let r=n.data[t];o.push({key:{status:`valid`,value:t},value:e._parse(new ta(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of o){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>Hi.mergeObjectSync(t,e)):Hi.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return Qi.errToObj,new e({...this._def,unknownKeys:`strict`,...t===void 0?{}:{errorMap:(e,n)=>{var r;let i=(r=this._def).errorMap?.call(r,e,n).message??n.defaultError;return e.code===`unrecognized_keys`?{message:Qi.errToObj(t).message??i}:{message:i}}}})}strip(){return new e({...this._def,unknownKeys:`strip`})}passthrough(){return new e({...this._def,unknownKeys:`passthrough`})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:mo.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};return ji.objectKeys(t).forEach(e=>{t[e]&&this.shape[e]&&(n[e]=this.shape[e])}),new e({...this._def,shape:()=>n})}omit(t){let n={};return ji.objectKeys(this.shape).forEach(e=>{t[e]||(n[e]=this.shape[e])}),new e({...this._def,shape:()=>n})}deepPartial(){return La(this)}partial(t){let n={};return ji.objectKeys(this.shape).forEach(e=>{let r=this.shape[e];t&&!t[e]?n[e]=r:n[e]=r.optional()}),new e({...this._def,shape:()=>n})}required(t){let n={};return ji.objectKeys(this.shape).forEach(e=>{if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof no;)t=t._def.innerType;n[e]=t}}),new e({...this._def,shape:()=>n})}keyof(){return Za(ji.objectKeys(this.shape))}};Ra.create=(e,t)=>new Ra({shape:()=>e,unknownKeys:`strip`,catchall:Pa.create(),typeName:mo.ZodObject,...ra(t)}),Ra.strictCreate=(e,t)=>new Ra({shape:()=>e,unknownKeys:`strict`,catchall:Pa.create(),typeName:mo.ZodObject,...ra(t)}),Ra.lazycreate=(e,t)=>new Ra({shape:e,unknownKeys:`strip`,catchall:Pa.create(),typeName:mo.ZodObject,...ra(t)});var za=class extends ia{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new Fi(e.ctx.common.issues));return B(t,{code:z.invalid_union,unionErrors:n}),Ui}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(r);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=r.map(e=>new Fi(e));return B(t,{code:z.invalid_union,unionErrors:i}),Ui}}get options(){return this._def.options}};za.create=(e,t)=>new za({options:e,typeName:mo.ZodUnion,...ra(t)});var Ba=e=>e instanceof Ya?Ba(e.schema):e instanceof to?Ba(e.innerType()):e instanceof Xa?[e.value]:e instanceof Qa?e.options:e instanceof $a?ji.objectValues(e.enum):e instanceof io?Ba(e._def.innerType):e instanceof Aa?[void 0]:e instanceof ja?[null]:e instanceof no?[void 0,...Ba(e.unwrap())]:e instanceof ro?[null,...Ba(e.unwrap())]:e instanceof co||e instanceof uo?Ba(e.unwrap()):e instanceof ao?Ba(e._def.innerType):[],Va=class e extends ia{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==R.object)return B(t,{code:z.invalid_type,expected:R.object,received:t.parsedType}),Ui;let n=this.discriminator,r=t.data[n],i=this.optionsMap.get(r);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(B(t,{code:z.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),Ui)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=new Map;for(let e of n){let n=Ba(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:mo.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...ra(r)})}};function Ha(e,t){let n=Ni(e),r=Ni(t);if(e===t)return{valid:!0,data:e};if(n===R.object&&r===R.object){let n=ji.objectKeys(t),r=ji.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Ha(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}if(n===R.array&&r===R.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let r=0;r{if(Ki(e)||Ki(r))return Ui;let i=Ha(e.value,r.value);return i.valid?((qi(e)||qi(r))&&t.dirty(),{status:t.value,value:i.data}):(B(n,{code:z.invalid_intersection_types}),Ui)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Ua.create=(e,t,n)=>new Ua({left:e,right:t,typeName:mo.ZodIntersection,...ra(n)});var Wa=class e extends ia{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==R.array)return B(n,{code:z.invalid_type,expected:R.array,received:n.parsedType}),Ui;if(n.data.lengththis._def.items.length&&(B(n,{code:z.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let r=[...n.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new ta(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>Hi.mergeArray(t,e)):Hi.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Wa.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new Wa({items:e,typeName:mo.ZodTuple,rest:null,...ra(t)})};var Ga=class e extends ia{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==R.object)return B(n,{code:z.invalid_type,expected:R.object,received:n.parsedType}),Ui;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new ta(n,e,n.path,e)),value:a._parse(new ta(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?Hi.mergeObjectAsync(t,r):Hi.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof ia?new e({keyType:t,valueType:n,typeName:mo.ZodRecord,...ra(r)}):new e({keyType:Ca.create(),valueType:t,typeName:mo.ZodRecord,...ra(n)})}},Ka=class extends ia{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==R.map)return B(n,{code:z.invalid_type,expected:R.map,received:n.parsedType}),Ui;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new ta(n,e,n.path,[a,`key`])),value:i._parse(new ta(n,t,n.path,[a,`value`]))}));if(n.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of a){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return Ui;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}{let e=new Map;for(let n of a){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return Ui;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};Ka.create=(e,t,n)=>new Ka({valueType:t,keyType:e,typeName:mo.ZodMap,...ra(n)});var qa=class e extends ia{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==R.set)return B(n,{code:z.invalid_type,expected:R.set,received:n.parsedType}),Ui;let r=this._def;r.minSize!==null&&n.data.sizer.maxSize.value&&(B(n,{code:z.too_big,maximum:r.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());let i=this._def.valueType;function a(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return Ui;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let o=[...n.data.values()].map((e,t)=>i._parse(new ta(n,e,n.path,t)));return n.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(t,n){return new e({...this._def,minSize:{value:t,message:Qi.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:Qi.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};qa.create=(e,t)=>new qa({valueType:e,minSize:null,maxSize:null,typeName:mo.ZodSet,...ra(t)});var Ja=class e extends ia{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==R.function)return B(t,{code:z.invalid_type,expected:R.function,received:t.parsedType}),Ui;function n(e,n){return Bi({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,zi(),Ii].filter(e=>!!e),issueData:{code:z.invalid_arguments,argumentsError:n}})}function r(e,n){return Bi({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,zi(),Ii].filter(e=>!!e),issueData:{code:z.invalid_return_type,returnTypeError:n}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof eo){let e=this;return Gi(async function(...t){let o=new Fi([]),s=await e._def.args.parseAsync(t,i).catch(e=>{throw o.addIssue(n(t,e)),o}),c=await Reflect.apply(a,this,s);return await e._def.returns._def.type.parseAsync(c,i).catch(e=>{throw o.addIssue(r(c,e)),o})})}{let e=this;return Gi(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new Fi([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new Fi([r(s,c.error)]);return c.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:Wa.create(t).rest(Na.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,r){return new e({args:t||Wa.create([]).rest(Na.create()),returns:n||Na.create(),typeName:mo.ZodFunction,...ra(r)})}},Ya=class extends ia{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};Ya.create=(e,t)=>new Ya({getter:e,typeName:mo.ZodLazy,...ra(t)});var Xa=class extends ia{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return B(t,{received:t.data,code:z.invalid_literal,expected:this._def.value}),Ui}return{status:`valid`,value:e.data}}get value(){return this._def.value}};Xa.create=(e,t)=>new Xa({value:e,typeName:mo.ZodLiteral,...ra(t)});function Za(e,t){return new Qa({values:e,typeName:mo.ZodEnum,...ra(t)})}var Qa=class e extends ia{constructor(){super(...arguments),$i.set(this,void 0)}_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return B(t,{expected:ji.joinValues(n),received:t.parsedType,code:z.invalid_type}),Ui}if(Xi(this,$i)||Zi(this,$i,new Set(this._def.values)),!Xi(this,$i).has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return B(t,{received:t.data,code:z.invalid_enum_value,options:n}),Ui}return Gi(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(e=>!t.includes(e)),{...this._def,...n})}};$i=new WeakMap,Qa.create=Za;var $a=class extends ia{constructor(){super(...arguments),ea.set(this,void 0)}_parse(e){let t=ji.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==R.string&&n.parsedType!==R.number){let e=ji.objectValues(t);return B(n,{expected:ji.joinValues(e),received:n.parsedType,code:z.invalid_type}),Ui}if(Xi(this,ea)||Zi(this,ea,new Set(ji.getValidEnumValues(this._def.values))),!Xi(this,ea).has(e.data)){let e=ji.objectValues(t);return B(n,{received:n.data,code:z.invalid_enum_value,options:e}),Ui}return Gi(e.data)}get enum(){return this._def.values}};ea=new WeakMap,$a.create=(e,t)=>new $a({values:e,typeName:mo.ZodNativeEnum,...ra(t)});var eo=class extends ia{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==R.promise&&t.common.async===!1?(B(t,{code:z.invalid_type,expected:R.promise,received:t.parsedType}),Ui):Gi((t.parsedType===R.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};eo.create=(e,t)=>new eo({type:e,typeName:mo.ZodPromise,...ra(t)});var to=class extends ia{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===mo.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:e=>{B(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),r.type===`preprocess`){let e=r.transform(n.data,i);if(n.common.async)return Promise.resolve(e).then(async e=>{if(t.value===`aborted`)return Ui;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?Ui:r.status===`dirty`||t.value===`dirty`?Wi(r.value):r});{if(t.value===`aborted`)return Ui;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?Ui:r.status===`dirty`||t.value===`dirty`?Wi(r.value):r}}if(r.type===`refinement`){let e=e=>{let t=r.refinement(e,i);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(n.common.async===!1){let r=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return r.status===`aborted`?Ui:(r.status===`dirty`&&t.dirty(),e(r.value),{status:t.value,value:r.value})}return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>n.status===`aborted`?Ui:(n.status===`dirty`&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if(r.type===`transform`){if(n.common.async===!1){let e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Ji(e))return e;let a=r.transform(e.value,i);if(a instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:t.value,value:a}}return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>Ji(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):e)}ji.assertNever(r)}};to.create=(e,t,n)=>new to({schema:e,typeName:mo.ZodEffects,effect:t,...ra(n)}),to.createWithPreprocess=(e,t,n)=>new to({schema:t,effect:{type:`preprocess`,transform:e},typeName:mo.ZodEffects,...ra(n)});var no=class extends ia{_parse(e){return this._getType(e)===R.undefined?Gi(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};no.create=(e,t)=>new no({innerType:e,typeName:mo.ZodOptional,...ra(t)});var ro=class extends ia{_parse(e){return this._getType(e)===R.null?Gi(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};ro.create=(e,t)=>new ro({innerType:e,typeName:mo.ZodNullable,...ra(t)});var io=class extends ia{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===R.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};io.create=(e,t)=>new io({innerType:e,typeName:mo.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...ra(t)});var ao=class extends ia{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Yi(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new Fi(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new Fi(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};ao.create=(e,t)=>new ao({innerType:e,typeName:mo.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...ra(t)});var oo=class extends ia{_parse(e){if(this._getType(e)!==R.nan){let t=this._getOrReturnCtx(e);return B(t,{code:z.invalid_type,expected:R.nan,received:t.parsedType}),Ui}return{status:`valid`,value:e.data}}};oo.create=e=>new oo({typeName:mo.ZodNaN,...ra(e)});var so=Symbol(`zod_brand`),co=class extends ia{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},lo=class e extends ia{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?Ui:e.status===`dirty`?(t.dirty(),Wi(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?Ui:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:mo.ZodPipeline})}},uo=class extends ia{_parse(e){let t=this._def.innerType._parse(e),n=e=>(Ji(e)&&(e.value=Object.freeze(e.value)),e);return Yi(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};uo.create=(e,t)=>new uo({innerType:e,typeName:mo.ZodReadonly,...ra(t)});function fo(e,t={},n){return e?Ma.create().superRefine((r,i)=>{if(!e(r)){let e=typeof t==`function`?t(r):typeof t==`string`?{message:t}:t,a=e.fatal??n??!0,o=typeof e==`string`?{message:e}:e;i.addIssue({code:`custom`,...o,fatal:a})}}):Ma.create()}var po={object:Ra.lazycreate},mo;(function(e){e.ZodString=`ZodString`,e.ZodNumber=`ZodNumber`,e.ZodNaN=`ZodNaN`,e.ZodBigInt=`ZodBigInt`,e.ZodBoolean=`ZodBoolean`,e.ZodDate=`ZodDate`,e.ZodSymbol=`ZodSymbol`,e.ZodUndefined=`ZodUndefined`,e.ZodNull=`ZodNull`,e.ZodAny=`ZodAny`,e.ZodUnknown=`ZodUnknown`,e.ZodNever=`ZodNever`,e.ZodVoid=`ZodVoid`,e.ZodArray=`ZodArray`,e.ZodObject=`ZodObject`,e.ZodUnion=`ZodUnion`,e.ZodDiscriminatedUnion=`ZodDiscriminatedUnion`,e.ZodIntersection=`ZodIntersection`,e.ZodTuple=`ZodTuple`,e.ZodRecord=`ZodRecord`,e.ZodMap=`ZodMap`,e.ZodSet=`ZodSet`,e.ZodFunction=`ZodFunction`,e.ZodLazy=`ZodLazy`,e.ZodLiteral=`ZodLiteral`,e.ZodEnum=`ZodEnum`,e.ZodEffects=`ZodEffects`,e.ZodNativeEnum=`ZodNativeEnum`,e.ZodOptional=`ZodOptional`,e.ZodNullable=`ZodNullable`,e.ZodDefault=`ZodDefault`,e.ZodCatch=`ZodCatch`,e.ZodPromise=`ZodPromise`,e.ZodBranded=`ZodBranded`,e.ZodPipeline=`ZodPipeline`,e.ZodReadonly=`ZodReadonly`})(mo||={});var ho=(e,t={message:`Input not instance of ${e.name}`})=>fo(t=>t instanceof e,t),V=Ca.create,go=Ta.create,_o=oo.create,vo=Ea.create,yo=Da.create,bo=Oa.create,xo=ka.create,So=Aa.create,Co=ja.create,wo=Ma.create,To=Na.create,Eo=Pa.create,Do=Fa.create,Oo=Ia.create,H=Ra.create,ko=Ra.strictCreate,Ao=za.create,jo=Va.create,Mo=Ua.create,No=Wa.create,Po=Ga.create,Fo=Ka.create,Io=qa.create,Lo=Ja.create,Ro=Ya.create,zo=Xa.create,Bo=Qa.create,Vo=$a.create,Ho=eo.create,Uo=to.create,Wo=no.create,Go=ro.create,Ko=to.createWithPreprocess,qo=lo.create,U=Object.freeze({__proto__:null,defaultErrorMap:Ii,setErrorMap:Ri,getErrorMap:zi,makeIssue:Bi,EMPTY_PATH:Vi,addIssueToContext:B,ParseStatus:Hi,INVALID:Ui,DIRTY:Wi,OK:Gi,isAborted:Ki,isDirty:qi,isValid:Ji,isAsync:Yi,get util(){return ji},get objectUtil(){return Mi},ZodParsedType:R,getParsedType:Ni,ZodType:ia,datetimeRegex:xa,ZodString:Ca,ZodNumber:Ta,ZodBigInt:Ea,ZodBoolean:Da,ZodDate:Oa,ZodSymbol:ka,ZodUndefined:Aa,ZodNull:ja,ZodAny:Ma,ZodUnknown:Na,ZodNever:Pa,ZodVoid:Fa,ZodArray:Ia,ZodObject:Ra,ZodUnion:za,ZodDiscriminatedUnion:Va,ZodIntersection:Ua,ZodTuple:Wa,ZodRecord:Ga,ZodMap:Ka,ZodSet:qa,ZodFunction:Ja,ZodLazy:Ya,ZodLiteral:Xa,ZodEnum:Qa,ZodNativeEnum:$a,ZodPromise:eo,ZodEffects:to,ZodTransformer:to,ZodOptional:no,ZodNullable:ro,ZodDefault:io,ZodCatch:ao,ZodNaN:oo,BRAND:so,ZodBranded:co,ZodPipeline:lo,ZodReadonly:uo,custom:fo,Schema:ia,ZodSchema:ia,late:po,get ZodFirstPartyTypeKind(){return mo},coerce:{string:(e=>Ca.create({...e,coerce:!0})),number:(e=>Ta.create({...e,coerce:!0})),boolean:(e=>Da.create({...e,coerce:!0})),bigint:(e=>Ea.create({...e,coerce:!0})),date:(e=>Oa.create({...e,coerce:!0}))},any:wo,array:Oo,bigint:vo,boolean:yo,date:bo,discriminatedUnion:jo,effect:Uo,enum:Bo,function:Lo,instanceof:ho,intersection:Mo,lazy:Ro,literal:zo,map:Fo,nan:_o,nativeEnum:Vo,never:Eo,null:Co,nullable:Go,number:go,object:H,oboolean:()=>yo().optional(),onumber:()=>go().optional(),optional:Wo,ostring:()=>V().optional(),pipeline:qo,preprocess:Ko,promise:Ho,record:Po,set:Io,strictObject:ko,string:V,symbol:xo,transformer:Uo,tuple:No,undefined:So,union:Ao,unknown:To,void:Do,NEVER:Ui,ZodIssueCode:z,quotelessJson:Pi,ZodError:Fi}),Jo={exports:{}},Yo;function Xo(){return Yo||(Yo=1,(function(e){var t=(function(e){var n=1e7,r=9007199254740992,i=f(r),a=`0123456789abcdefghijklmnopqrstuvwxyz`,o=typeof BigInt==`function`;function s(e,t,n,r){return e===void 0?s[0]:t===void 0||+t==10&&!n?F(e):ge(e,t,n,r)}function c(e,t){this.value=e,this.sign=t,this.isSmall=!1}c.prototype=Object.create(s.prototype);function l(e){this.value=e,this.sign=e<0,this.isSmall=!0}l.prototype=Object.create(s.prototype);function u(e){this.value=e}u.prototype=Object.create(s.prototype);function d(e){return-r0?Math.floor(e):Math.ceil(e)}function _(e,t){for(var r=e.length,i=t.length,a=Array(r),o=0,s=n,c,l=0;l=s),a[l]=c-o*s;for(;l0&&a.push(o),a}function v(e,t){return e.length>=t.length?_(e,t):_(t,e)}function y(e,t){for(var r=e.length,i=Array(r),a=n,o,s=0;s0;)i[s++]=t%a,t=Math.floor(t/a);return i}c.prototype.add=function(e){var t=F(e);if(this.sign!==t.sign)return this.subtract(t.negate());var n=this.value,r=t.value;return t.isSmall?new c(y(n,Math.abs(r)),this.sign):new c(v(n,r),this.sign)},c.prototype.plus=c.prototype.add,l.prototype.add=function(e){var t=F(e),n=this.value;if(n<0!==t.sign)return this.subtract(t.negate());var r=t.value;if(t.isSmall){if(d(n+r))return new l(n+r);r=f(Math.abs(r))}return new c(y(r,Math.abs(n)),n<0)},l.prototype.plus=l.prototype.add,u.prototype.add=function(e){return new u(this.value+F(e).value)},u.prototype.plus=u.prototype.add;function b(e,t){for(var r=e.length,i=t.length,a=Array(r),o=0,s=n,c=0,l;c=0?r=b(e,t):(r=b(t,e),n=!n),r=p(r),typeof r==`number`?(n&&(r=-r),new l(r)):new c(r,n)}function S(e,t,r){for(var i=e.length,a=Array(i),o=-t,s=n,u=0,d;u=0)},l.prototype.minus=l.prototype.subtract,u.prototype.subtract=function(e){return new u(this.value-F(e).value)},u.prototype.minus=u.prototype.subtract,c.prototype.negate=function(){return new c(this.value,!this.sign)},l.prototype.negate=function(){var e=this.sign,t=new l(-this.value);return t.sign=!e,t},u.prototype.negate=function(){return new u(-this.value)},c.prototype.abs=function(){return new c(this.value,!1)},l.prototype.abs=function(){return new l(Math.abs(this.value))},u.prototype.abs=function(){return new u(this.value>=0?this.value:-this.value)};function C(e,t){for(var r=e.length,i=t.length,a=h(r+i),o=n,s,c,l=0,u,d;l0;)i[c++]=o%a,o=Math.floor(o/a);return i}function T(e,t){for(var n=[];t-->0;)n.push(0);return n.concat(e)}function E(e,t){var n=Math.max(e.length,t.length);if(n<=30)return C(e,t);n=Math.ceil(n/2);var r=e.slice(n),i=e.slice(0,n),a=t.slice(n),o=t.slice(0,n),s=E(i,o),c=E(r,a),l=v(v(s,T(b(b(E(v(i,r),v(o,a)),s),c),n)),T(c,2*n));return m(l),l}function D(e,t){return-.012*e-.012*t+15e-6*e*t>0}c.prototype.multiply=function(e){var t=F(e),r=this.value,i=t.value,a=this.sign!==t.sign,o;if(t.isSmall){if(i===0)return s[0];if(i===1)return this;if(i===-1)return this.negate();if(o=Math.abs(i),o=0;f--){for(d=a-1,l[f+i]!==s&&(d=Math.floor((l[f+i]*a+l[f+i-1])/s)),m=0,g=0,v=u.length,_=0;_i&&(u=(u+1)*s),c=Math.ceil(u/d);do{if(f=w(t,c),te(f,o)<=0)break;c--}while(c);a.push(c),o=b(o,f)}return a.reverse(),[p(a),p(o)]}function ee(e,t){var r=e.length,i=h(r),a=n,o,s,c=0,l;for(o=r-1;o>=0;--o)l=c*a+e[o],s=g(l/t),c=l-s*t,i[o]=s|0;return[i,c|0]}function M(e,t){var r,i=F(t);if(o)return[new u(e.value/i.value),new u(e.value%i.value)];var a=e.value,d=i.value,m;if(d===0)throw Error(`Cannot divide by zero`);if(e.isSmall)return i.isSmall?[new l(g(a/d)),new l(a%d)]:[s[0],e];if(i.isSmall){if(d===1)return[e,s[0]];if(d==-1)return[e.negate(),s[0]];var h=Math.abs(d);if(ht.length?1:-1;for(var n=e.length-1;n>=0;n--)if(e[n]!==t[n])return e[n]>t[n]?1:-1;return 0}c.prototype.compareAbs=function(e){var t=F(e),n=this.value,r=t.value;return t.isSmall?1:te(n,r)},l.prototype.compareAbs=function(e){var t=F(e),n=Math.abs(this.value),r=t.value;return t.isSmall?(r=Math.abs(r),n===r?0:n>r?1:-1):-1},u.prototype.compareAbs=function(e){var t=this.value,n=F(e).value;return t=t>=0?t:-t,n=n>=0?n:-n,t===n?0:t>n?1:-1},c.prototype.compare=function(e){if(e===1/0)return-1;if(e===-1/0)return 1;var t=F(e),n=this.value,r=t.value;return this.sign===t.sign?t.isSmall?this.sign?-1:1:te(n,r)*(this.sign?-1:1):t.sign?1:-1},c.prototype.compareTo=c.prototype.compare,l.prototype.compare=function(e){if(e===1/0)return-1;if(e===-1/0)return 1;var t=F(e),n=this.value,r=t.value;return t.isSmall?n==r?0:n>r?1:-1:n<0===t.sign?n<0?1:-1:n<0?-1:1},l.prototype.compareTo=l.prototype.compare,u.prototype.compare=function(e){if(e===1/0)return-1;if(e===-1/0)return 1;var t=this.value,n=F(e).value;return t===n?0:t>n?1:-1},u.prototype.compareTo=u.prototype.compare,c.prototype.equals=function(e){return this.compare(e)===0},u.prototype.eq=u.prototype.equals=l.prototype.eq=l.prototype.equals=c.prototype.eq=c.prototype.equals,c.prototype.notEquals=function(e){return this.compare(e)!==0},u.prototype.neq=u.prototype.notEquals=l.prototype.neq=l.prototype.notEquals=c.prototype.neq=c.prototype.notEquals,c.prototype.greater=function(e){return this.compare(e)>0},u.prototype.gt=u.prototype.greater=l.prototype.gt=l.prototype.greater=c.prototype.gt=c.prototype.greater,c.prototype.lesser=function(e){return this.compare(e)<0},u.prototype.lt=u.prototype.lesser=l.prototype.lt=l.prototype.lesser=c.prototype.lt=c.prototype.lesser,c.prototype.greaterOrEquals=function(e){return this.compare(e)>=0},u.prototype.geq=u.prototype.greaterOrEquals=l.prototype.geq=l.prototype.greaterOrEquals=c.prototype.geq=c.prototype.greaterOrEquals,c.prototype.lesserOrEquals=function(e){return this.compare(e)<=0},u.prototype.leq=u.prototype.lesserOrEquals=l.prototype.leq=l.prototype.lesserOrEquals=c.prototype.leq=c.prototype.lesserOrEquals,c.prototype.isEven=function(){return!(this.value[0]&1)},l.prototype.isEven=function(){return!(this.value&1)},u.prototype.isEven=function(){return(this.value&BigInt(1))===BigInt(0)},c.prototype.isOdd=function(){return(this.value[0]&1)==1},l.prototype.isOdd=function(){return(this.value&1)==1},u.prototype.isOdd=function(){return(this.value&BigInt(1))===BigInt(1)},c.prototype.isPositive=function(){return!this.sign},l.prototype.isPositive=function(){return this.value>0},u.prototype.isPositive=l.prototype.isPositive,c.prototype.isNegative=function(){return this.sign},l.prototype.isNegative=function(){return this.value<0},u.prototype.isNegative=l.prototype.isNegative,c.prototype.isUnit=function(){return!1},l.prototype.isUnit=function(){return Math.abs(this.value)===1},u.prototype.isUnit=function(){return this.abs().value===BigInt(1)},c.prototype.isZero=function(){return!1},l.prototype.isZero=function(){return this.value===0},u.prototype.isZero=function(){return this.value===BigInt(0)},c.prototype.isDivisibleBy=function(e){var t=F(e);return t.isZero()?!1:t.isUnit()?!0:t.compareAbs(2)===0?this.isEven():this.mod(t).isZero()},u.prototype.isDivisibleBy=l.prototype.isDivisibleBy=c.prototype.isDivisibleBy;function ne(e){var t=e.abs();if(t.isUnit())return!1;if(t.equals(2)||t.equals(3)||t.equals(5))return!0;if(t.isEven()||t.isDivisibleBy(3)||t.isDivisibleBy(5))return!1;if(t.lesser(49))return!0}function re(e,n){for(var r=e.prev(),i=r,a=0,o,s,c;i.isEven();)i=i.divide(2),a++;next:for(s=0;s-r?new l(e-1):new c(i,!0)},u.prototype.prev=function(){return new u(this.value-BigInt(1))};for(var ie=[1];2*ie[ie.length-1]<=n;)ie.push(2*ie[ie.length-1]);var N=ie.length,ae=ie[N-1];function oe(e){return Math.abs(e)<=n}c.prototype.shiftLeft=function(e){var t=F(e).toJSNumber();if(!oe(t))throw Error(String(t)+` is too large for shifting.`);if(t<0)return this.shiftRight(-t);var n=this;if(n.isZero())return n;for(;t>=N;)n=n.multiply(ae),t-=N-1;return n.multiply(ie[t])},u.prototype.shiftLeft=l.prototype.shiftLeft=c.prototype.shiftLeft,c.prototype.shiftRight=function(e){var t,n=F(e).toJSNumber();if(!oe(n))throw Error(String(n)+` is too large for shifting.`);if(n<0)return this.shiftLeft(-n);for(var r=this;n>=N;){if(r.isZero()||r.isNegative()&&r.isUnit())return r;t=M(r,ae),r=t[1].isNegative()?t[0].prev():t[0],n-=N-1}return t=M(r,ie[n]),t[1].isNegative()?t[0].prev():t[0]},u.prototype.shiftRight=l.prototype.shiftRight=c.prototype.shiftRight;function se(e,n,r){n=F(n);for(var i=e.isNegative(),a=n.isNegative(),o=i?e.not():e,s=a?n.not():n,c=0,l=0,u=null,d=null,f=[];!o.isZero()||!s.isZero();)u=M(o,ae),c=u[1].toJSNumber(),i&&(c=ae-1-c),d=M(s,ae),l=d[1].toJSNumber(),a&&(l=ae-1-l),o=u[0],s=d[0],f.push(r(c,l));for(var p=r(+!!i,+!!a)===0?t(0):t(-1),m=f.length-1;m>=0;--m)p=p.multiply(ae).add(t(f[m]));return p}c.prototype.not=function(){return this.negate().prev()},u.prototype.not=l.prototype.not=c.prototype.not,c.prototype.and=function(e){return se(this,e,function(e,t){return e&t})},u.prototype.and=l.prototype.and=c.prototype.and,c.prototype.or=function(e){return se(this,e,function(e,t){return e|t})},u.prototype.or=l.prototype.or=c.prototype.or,c.prototype.xor=function(e){return se(this,e,function(e,t){return e^t})},u.prototype.xor=l.prototype.xor=c.prototype.xor;var ce=1<<30,le=(n&-n)*(n&-n)|ce;function P(e){var t=e.value,r=typeof t==`number`?t|ce:typeof t==`bigint`?t|BigInt(ce):t[0]+t[1]*n|le;return r&-r}function ue(e,n){if(n.compareTo(e)<=0){var r=ue(e,n.square(n)),i=r.p,a=r.e,o=i.multiply(n);return o.compareTo(e)<=0?{p:o,e:a*2+1}:{p:i,e:a*2}}return{p:t(1),e:0}}c.prototype.bitLength=function(){var e=this;return e.compareTo(t(0))<0&&(e=e.negate().subtract(t(1))),e.compareTo(t(0))===0?t(0):t(ue(e,t(2)).e).add(t(1))},u.prototype.bitLength=l.prototype.bitLength=c.prototype.bitLength;function de(e,t){return e=F(e),t=F(t),e.greater(t)?e:t}function fe(e,t){return e=F(e),t=F(t),e.lesser(t)?e:t}function pe(e,t){if(e=F(e).abs(),t=F(t).abs(),e.equals(t))return e;if(e.isZero())return t;if(t.isZero())return e;for(var n=s[1],r,i;e.isEven()&&t.isEven();)r=fe(P(e),P(t)),e=e.divide(r),t=t.divide(r),n=n.multiply(r);for(;e.isEven();)e=e.divide(P(e));do{for(;t.isEven();)t=t.divide(P(t));e.greater(t)&&(i=t,t=e,e=i),t=t.subtract(e)}while(!t.isZero());return n.isUnit()?e:e.multiply(n)}function me(e,t){return e=F(e).abs(),t=F(t).abs(),e.divide(pe(e,t)).multiply(t)}function he(e,t,r){e=F(e),t=F(t);var i=r||Math.random,a=fe(e,t),o=de(e,t).subtract(a).add(1);if(o.isSmall)return a.add(Math.floor(i()*o));for(var c=ye(o,n).value,l=[],u=!0,d=0;d=s){if(l===`1`&&s===1)continue;throw Error(l+` is not a valid digit in base `+t+`.`)}}t=F(t);var u=[],d=e[0]===`-`;for(o=+!!d;o`&&o=0;a--)r=r.add(e[a].times(i)),i=i.times(t);return n?r.negate():r}function ve(e,t){return t||=a,e`}function ye(e,n){if(n=t(n),n.isZero()){if(e.isZero())return{value:[0],isNegative:!1};throw Error(`Cannot convert nonzero numbers to base 0.`)}if(n.equals(-1)){if(e.isZero())return{value:[0],isNegative:!1};if(e.isNegative())return{value:[].concat.apply([],Array.apply(null,Array(-e.toJSNumber())).map(Array.prototype.valueOf,[1,0])),isNegative:!1};var r=Array.apply(null,Array(e.toJSNumber()-1)).map(Array.prototype.valueOf,[0,1]);return r.unshift([1]),{value:[].concat.apply([],r),isNegative:!1}}var i=!1;if(e.isNegative()&&n.isPositive()&&(i=!0,e=e.abs()),n.isUnit())return e.isZero()?{value:[0],isNegative:!1}:{value:Array.apply(null,Array(e.toJSNumber())).map(Number.prototype.valueOf,1),isNegative:i};for(var a=[],o=e,s;o.isNegative()||o.compareAbs(n)>=0;){s=o.divmod(n),o=s.quotient;var c=s.remainder;c.isNegative()&&(c=n.minus(c).abs(),o=o.next()),a.push(c.toJSNumber())}return a.push(o.toJSNumber()),{value:a.reverse(),isNegative:i}}function be(e,t,n){var r=ye(e,t);return(r.isNegative?`-`:``)+r.value.map(function(e){return ve(e,n)}).join(``)}c.prototype.toArray=function(e){return ye(this,e)},l.prototype.toArray=function(e){return ye(this,e)},u.prototype.toArray=function(e){return ye(this,e)},c.prototype.toString=function(t,n){if(t===e&&(t=10),t!==10||n)return be(this,t,n);for(var r=this.value,i=r.length,a=String(r[--i]),o=`0000000`,s;--i>=0;)s=String(r[i]),a+=o.slice(s.length)+s;return(this.sign?`-`:``)+a},l.prototype.toString=function(t,n){return t===e&&(t=10),t!=10||n?be(this,t,n):String(this.value)},u.prototype.toString=l.prototype.toString,u.prototype.toJSON=c.prototype.toJSON=l.prototype.toJSON=function(){return this.toString()},c.prototype.valueOf=function(){return parseInt(this.toString(),10)},c.prototype.toJSNumber=c.prototype.valueOf,l.prototype.valueOf=function(){return this.value},l.prototype.toJSNumber=l.prototype.valueOf,u.prototype.valueOf=u.prototype.toJSNumber=function(){return parseInt(this.toString(),10)};function xe(e){if(d(+e)){var t=+e;if(t===g(t))return o?new u(BigInt(t)):new l(t);throw Error(`Invalid integer: `+e)}var n=e[0]===`-`;n&&(e=e.slice(1));var r=e.split(/e/i);if(r.length>2)throw Error(`Invalid integer: `+r.join(`e`));if(r.length===2){var i=r[1];if(i[0]===`+`&&(i=i.slice(1)),i=+i,i!==g(i)||!d(i))throw Error(`Invalid integer: `+i+` is not a valid exponent.`);var a=r[0],s=a.indexOf(`.`);if(s>=0&&(i-=a.length-s-1,a=a.slice(0,s)+a.slice(s+1)),i<0)throw Error(`Cannot include negative exponent part for integers`);a+=Array(i+1).join(`0`),e=a}if(!/^([0-9][0-9]*)$/.test(e))throw Error(`Invalid integer: `+e);if(o)return new u(BigInt(n?`-`+e:e));for(var f=[],p=e.length,h=7,_=p-h;p>0;)f.push(+e.slice(_,p)),_-=h,_<0&&(_=0),p-=h;return m(f),new c(f,n)}function Se(e){if(o)return new u(BigInt(e));if(d(e)){if(e!==g(e))throw Error(e+` is not an integer.`);return new l(e)}return xe(e.toString())}function F(e){return typeof e==`number`?Se(e):typeof e==`string`?xe(e):typeof e==`bigint`?new u(e):e}for(var Ce=0;Ce<1e3;Ce++)s[Ce]=F(Ce),Ce>0&&(s[-Ce]=F(-Ce));return s.one=s[1],s.zero=s[0],s.minusOne=s[-1],s.max=de,s.min=fe,s.gcd=pe,s.lcm=me,s.isInstance=function(e){return e instanceof c||e instanceof l||e instanceof u},s.randBetween=he,s.fromArray=function(e,t,n){return _e(e.map(F),F(t||10),n)},s})();e.hasOwnProperty(`exports`)&&(e.exports=t)})(Jo)),Jo.exports}var Zo=Ei(Xo()),Qo=64,$o=16,es=Qo/$o;function ts(){try{return!0}catch{return!1}}function ns(e,t,n){let r=0;for(let i=0;ie&t[n]))}or({parts:t}){return new e(this.parts.map((e,n)=>e|t[n]))}xor({parts:t}){return new e(this.parts.map((e,n)=>e^t[n]))}not(){return new e(this.parts.map(e=>~e))}equals({parts:e}){return this.parts.every((t,n)=>t===e[n])}toString(){if(this.str!=null)return this.str;let e=Array(Qo/4);return this.parts.forEach((t,n)=>{let r=rs(t.toString());for(let t=0;t<4;t++)e[t+n*4]=r[3-t]||0}),this.str=Zo.fromArray(e,16).toString()}toJSON(){return this.toString()}},os=ts();os&&BigInt.prototype.toJSON==null&&(BigInt.prototype.toJSON=function(){return this.toString()});var ss={},cs=os?function(e){return BigInt(e)}:function(e){return e instanceof as?e:(typeof e==`number`&&(e=e.toString()),ss[e]??(ss[e]=as.fromString(e)),ss[e])},ls=cs(0),us=os?function(e=ls,t=ls){return e&t}:function(e=ls,t=ls){return e.and(t)},ds=os?function(e=ls,t=ls){return e|t}:function(e=ls,t=ls){return e.or(t)},fs=os?function(e=ls,t=ls){return e^t}:function(e=ls,t=ls){return e.xor(t)},ps=os?function(e=ls){return~e}:function(e=ls){return e.not()},ms=os?function(e,t){return e===t}:function(e,t){return e==null||t==null?e==t:e.equals(t)};function hs(...e){let t=e[0];for(let n=1;n{let[n]=Object.entries(e).find(([,e])=>e===t)??[];return t!=null&&n===void 0?e.UNHANDLED:t},V().or(go()))}function Es(e){let t=fo().transform(t=>{let n=e.safeParse(t);return n.success?n.data:e._def.defaultValue()});return t.overlayType=e,t}var Ds=U.object({image_url:U.string()}).describe(`Response for "INITIATE_IMAGE_UPLOAD" Command`),Os=U.object({mediaUrl:U.string().max(1024)}).describe(`Request for "OPEN_SHARE_MOMENT_DIALOG" Command`),ks=U.object({access_token:U.union([U.string(),U.null()]).optional()}).describe(`Request for "AUTHENTICATE" Command`),As=U.object({access_token:U.string(),user:U.object({username:U.string(),discriminator:U.string(),id:U.string(),avatar:U.union([U.string(),U.null()]).optional(),public_flags:U.number(),global_name:U.union([U.string(),U.null()]).optional()}),scopes:U.array(Es(U.enum(`identify,identify.premium,email,connections,guilds,guilds.join,guilds.members.read,guilds.channels.read,gdm.join,bot,rpc,rpc.notifications.read,rpc.voice.read,rpc.voice.write,rpc.video.read,rpc.video.write,rpc.screenshare.read,rpc.screenshare.write,rpc.activities.write,webhook.incoming,messages.read,applications.builds.upload,applications.builds.read,applications.commands,applications.commands.permissions.update,applications.commands.update,applications.store.update,applications.entitlements,activities.read,activities.write,activities.invites.write,relationships.read,relationships.write,voice,dm_channels.read,role_connections.write,presences.read,presences.write,openid,dm_channels.messages.read,dm_channels.messages.write,gateway.connect,account.global_name.update,payment_sources.country_code,sdk.social_layer_presence,sdk.social_layer,lobbies.write,application_identities.write`.split(`,`)).or(U.literal(-1)).default(-1))),expires:U.string(),application:U.object({description:U.string(),icon:U.union([U.string(),U.null()]).optional(),id:U.string(),rpc_origins:U.array(U.string()).optional(),name:U.string()})}).describe(`Response for "AUTHENTICATE" Command`),js=U.object({participants:U.array(U.object({id:U.string(),username:U.string(),global_name:U.union([U.string(),U.null()]).optional(),discriminator:U.string(),avatar:U.union([U.string(),U.null()]).optional(),flags:U.number(),bot:U.boolean(),avatar_decoration_data:U.union([U.object({asset:U.union([U.string(),U.null()]).optional(),skuId:U.string().optional(),expiresAt:U.number().optional()}),U.null()]).optional(),premium_type:U.union([U.number(),U.null()]).optional(),nickname:U.string().optional()}))}).describe(`Response for "GET_ACTIVITY_INSTANCE_CONNECTED_PARTICIPANTS" Command`),Ms=U.object({command:U.string(),options:U.array(U.object({name:U.string(),value:U.string()})).optional(),content:U.string().max(2e3).optional(),require_launch_channel:U.boolean().optional(),preview_image:U.object({height:U.number(),url:U.string(),width:U.number()}).optional(),components:U.array(U.object({type:U.literal(1),components:U.array(U.object({type:U.literal(2),style:U.number().gte(1).lte(5),label:U.string().max(80).optional(),custom_id:U.string().max(100).describe(`Developer-defined identifier for the button; max 100 characters`).optional()})).max(5).optional()})).optional(),pid:U.number().optional()}).describe(`Request for "SHARE_INTERACTION" Command`),Ns=U.object({success:U.boolean()}).describe(`Response for "SHARE_INTERACTION" Command`),Ps=U.object({custom_id:U.string().max(64).optional(),message:U.string().max(1e3),link_id:U.string().max(64).optional()}).describe(`Request for "SHARE_LINK" Command`),Fs=U.object({success:U.boolean(),didCopyLink:U.boolean(),didSendMessage:U.boolean()}).describe(`Response for "SHARE_LINK" Command`),Is=U.object({relationships:U.array(U.object({type:U.number(),user:U.object({id:U.string(),username:U.string(),global_name:U.union([U.string(),U.null()]).optional(),discriminator:U.string(),avatar:U.union([U.string(),U.null()]).optional(),flags:U.number(),bot:U.boolean(),avatar_decoration_data:U.union([U.object({asset:U.union([U.string(),U.null()]).optional(),skuId:U.string().optional(),expiresAt:U.number().optional()}),U.null()]).optional(),premium_type:U.union([U.number(),U.null()]).optional()}),presence:U.object({status:U.string(),activity:U.union([U.object({session_id:U.string().optional(),type:U.number().optional(),name:U.string(),url:U.union([U.string(),U.null()]).optional(),application_id:U.string().optional(),status_display_type:U.number().optional(),state:U.string().optional(),state_url:U.string().optional(),details:U.string().optional(),details_url:U.string().optional(),emoji:U.union([U.object({name:U.string(),id:U.union([U.string(),U.null()]).optional(),animated:U.union([U.boolean(),U.null()]).optional()}),U.null()]).optional(),assets:U.object({large_image:U.string().optional(),large_text:U.string().optional(),large_url:U.string().optional(),small_image:U.string().optional(),small_text:U.string().optional(),small_url:U.string().optional()}).optional(),timestamps:U.object({start:U.number().optional(),end:U.number().optional()}).optional(),party:U.object({id:U.string().optional(),size:U.array(U.number()).min(2).max(2).optional(),privacy:U.number().optional()}).optional(),secrets:U.object({match:U.string().optional(),join:U.string().optional()}).optional(),sync_id:U.string().optional(),created_at:U.number().optional(),instance:U.boolean().optional(),flags:U.number().optional(),metadata:U.object({}).optional(),platform:U.string().optional(),supported_platforms:U.array(U.string()).optional(),buttons:U.array(U.string()).optional(),hangStatus:U.string().optional()}),U.null()]).optional()}).optional()}))}).describe(`Response for "GET_RELATIONSHIPS" Command`),Ls=U.object({user_id:U.string(),content:U.string().min(0).max(1024).optional()}).describe(`Request for "INVITE_USER_EMBEDDED" Command`),Rs=U.object({id:U.string().max(64)}).describe(`Request for "GET_USER" Command`),zs=U.union([U.object({id:U.string(),username:U.string(),global_name:U.union([U.string(),U.null()]).optional(),discriminator:U.string(),avatar:U.union([U.string(),U.null()]).optional(),flags:U.number(),bot:U.boolean(),avatar_decoration_data:U.union([U.object({asset:U.union([U.string(),U.null()]).optional(),skuId:U.string().optional(),expiresAt:U.number().optional()}),U.null()]).optional(),premium_type:U.union([U.number(),U.null()]).optional()}),U.null()]),Bs=U.object({quest_id:U.string()}).describe(`Request for "GET_QUEST_ENROLLMENT_STATUS" Command`),Vs=U.object({quest_id:U.string(),is_enrolled:U.boolean(),enrolled_at:U.union([U.string(),U.null()]).optional()}).describe(`Response for "GET_QUEST_ENROLLMENT_STATUS" Command`),Hs=U.object({quest_id:U.string()}).describe(`Request for "QUEST_START_TIMER" Command`),Us=U.object({success:U.boolean()}).describe(`Response for "QUEST_START_TIMER" Command`),Ws=U.object({quest_id:U.string(),enrolled_at:U.union([U.string(),U.null()]).optional(),completed_at:U.union([U.string(),U.null()]).optional(),external_cta_url:U.string()}).describe(`Response for "GET_QUEST" Command`),Gs=U.object({ticket:U.string()}).describe(`Response for "REQUEST_PROXY_TICKET_REFRESH" Command`),Ks;(function(e){e.INITIATE_IMAGE_UPLOAD=`INITIATE_IMAGE_UPLOAD`,e.OPEN_SHARE_MOMENT_DIALOG=`OPEN_SHARE_MOMENT_DIALOG`,e.AUTHENTICATE=`AUTHENTICATE`,e.GET_ACTIVITY_INSTANCE_CONNECTED_PARTICIPANTS=`GET_ACTIVITY_INSTANCE_CONNECTED_PARTICIPANTS`,e.SHARE_INTERACTION=`SHARE_INTERACTION`,e.SHARE_LINK=`SHARE_LINK`,e.GET_RELATIONSHIPS=`GET_RELATIONSHIPS`,e.INVITE_USER_EMBEDDED=`INVITE_USER_EMBEDDED`,e.GET_USER=`GET_USER`,e.GET_QUEST_ENROLLMENT_STATUS=`GET_QUEST_ENROLLMENT_STATUS`,e.QUEST_START_TIMER=`QUEST_START_TIMER`,e.GET_QUEST=`GET_QUEST`,e.REQUEST_PROXY_TICKET_REFRESH=`REQUEST_PROXY_TICKET_REFRESH`})(Ks||={});var qs=U.object({}).optional().nullable(),Js=U.void(),Ys={[Ks.INITIATE_IMAGE_UPLOAD]:{request:Js,response:Ds},[Ks.OPEN_SHARE_MOMENT_DIALOG]:{request:Os,response:qs},[Ks.AUTHENTICATE]:{request:ks,response:As},[Ks.GET_ACTIVITY_INSTANCE_CONNECTED_PARTICIPANTS]:{request:Js,response:js},[Ks.SHARE_INTERACTION]:{request:Ms,response:Ns},[Ks.SHARE_LINK]:{request:Ps,response:Fs},[Ks.GET_RELATIONSHIPS]:{request:Js,response:Is},[Ks.INVITE_USER_EMBEDDED]:{request:Ls,response:qs},[Ks.GET_USER]:{request:Rs,response:zs},[Ks.GET_QUEST_ENROLLMENT_STATUS]:{request:Bs,response:Vs},[Ks.QUEST_START_TIMER]:{request:Hs,response:Us},[Ks.GET_QUEST]:{request:Js,response:Ws},[Ks.REQUEST_PROXY_TICKET_REFRESH]:{request:Js,response:Gs}},Xs=t({Activity:()=>dc,Attachment:()=>bc,CertifiedDevice:()=>Bc,CertifiedDeviceTypeObject:()=>zc,Channel:()=>hc,ChannelMention:()=>yc,ChannelTypesObject:()=>mc,Commands:()=>Qs,DISPATCH:()=>Zs,Embed:()=>Dc,EmbedAuthor:()=>Tc,EmbedField:()=>Ec,EmbedFooter:()=>xc,EmbedProvider:()=>wc,Emoji:()=>oc,Entitlement:()=>Wc,EntitlementTypesObject:()=>Uc,Guild:()=>vc,GuildMember:()=>ic,GuildMemberRPC:()=>ac,Image:()=>Sc,KeyTypesObject:()=>Pc,LayoutMode:()=>Qc,LayoutModeTypeObject:()=>Zc,Message:()=>Mc,MessageActivity:()=>kc,MessageApplication:()=>Ac,MessageReference:()=>jc,Orientation:()=>Xc,OrientationLockState:()=>Kc,OrientationLockStateTypeObject:()=>Gc,OrientationTypeObject:()=>Yc,PermissionOverwrite:()=>pc,PermissionOverwriteTypeObject:()=>fc,PresenceUpdate:()=>gc,Reaction:()=>Oc,ReceiveFramePayload:()=>$s,Relationship:()=>nc,Role:()=>_c,Scopes:()=>tc,ScopesObject:()=>ec,ShortcutKey:()=>Fc,Sku:()=>Hc,SkuTypeObject:()=>Vc,Status:()=>uc,StatusObject:()=>lc,ThermalState:()=>Jc,ThermalStateTypeObject:()=>qc,User:()=>rc,UserVoiceState:()=>cc,Video:()=>Cc,VoiceDevice:()=>Nc,VoiceSettingModeTypeObject:()=>Ic,VoiceSettingsIO:()=>Rc,VoiceSettingsMode:()=>Lc,VoiceState:()=>sc}),Zs=`DISPATCH`,Qs;(function(e){e.AUTHORIZE=`AUTHORIZE`,e.GET_GUILDS=`GET_GUILDS`,e.GET_GUILD=`GET_GUILD`,e.GET_CHANNEL=`GET_CHANNEL`,e.GET_CHANNELS=`GET_CHANNELS`,e.SELECT_VOICE_CHANNEL=`SELECT_VOICE_CHANNEL`,e.SELECT_TEXT_CHANNEL=`SELECT_TEXT_CHANNEL`,e.SUBSCRIBE=`SUBSCRIBE`,e.UNSUBSCRIBE=`UNSUBSCRIBE`,e.CAPTURE_SHORTCUT=`CAPTURE_SHORTCUT`,e.SET_CERTIFIED_DEVICES=`SET_CERTIFIED_DEVICES`,e.SET_ACTIVITY=`SET_ACTIVITY`,e.GET_SKUS=`GET_SKUS`,e.GET_ENTITLEMENTS=`GET_ENTITLEMENTS`,e.GET_SKUS_EMBEDDED=`GET_SKUS_EMBEDDED`,e.GET_ENTITLEMENTS_EMBEDDED=`GET_ENTITLEMENTS_EMBEDDED`,e.START_PURCHASE=`START_PURCHASE`,e.SET_CONFIG=`SET_CONFIG`,e.SEND_ANALYTICS_EVENT=`SEND_ANALYTICS_EVENT`,e.USER_SETTINGS_GET_LOCALE=`USER_SETTINGS_GET_LOCALE`,e.OPEN_EXTERNAL_LINK=`OPEN_EXTERNAL_LINK`,e.ENCOURAGE_HW_ACCELERATION=`ENCOURAGE_HW_ACCELERATION`,e.CAPTURE_LOG=`CAPTURE_LOG`,e.SET_ORIENTATION_LOCK_STATE=`SET_ORIENTATION_LOCK_STATE`,e.OPEN_INVITE_DIALOG=`OPEN_INVITE_DIALOG`,e.GET_PLATFORM_BEHAVIORS=`GET_PLATFORM_BEHAVIORS`,e.GET_CHANNEL_PERMISSIONS=`GET_CHANNEL_PERMISSIONS`,e.AUTHENTICATE=`AUTHENTICATE`,e.GET_ACTIVITY_INSTANCE_CONNECTED_PARTICIPANTS=`GET_ACTIVITY_INSTANCE_CONNECTED_PARTICIPANTS`,e.GET_QUEST=`GET_QUEST`,e.GET_QUEST_ENROLLMENT_STATUS=`GET_QUEST_ENROLLMENT_STATUS`,e.GET_RELATIONSHIPS=`GET_RELATIONSHIPS`,e.GET_USER=`GET_USER`,e.INITIATE_IMAGE_UPLOAD=`INITIATE_IMAGE_UPLOAD`,e.INVITE_USER_EMBEDDED=`INVITE_USER_EMBEDDED`,e.OPEN_SHARE_MOMENT_DIALOG=`OPEN_SHARE_MOMENT_DIALOG`,e.QUEST_START_TIMER=`QUEST_START_TIMER`,e.REQUEST_PROXY_TICKET_REFRESH=`REQUEST_PROXY_TICKET_REFRESH`,e.SHARE_INTERACTION=`SHARE_INTERACTION`,e.SHARE_LINK=`SHARE_LINK`})(Qs||={});var $s=H({cmd:V(),data:To(),evt:Co(),nonce:V()}).passthrough(),ec=Object.assign(Object.assign({},As.shape.scopes.element.overlayType._def.innerType.options[0].Values),{UNHANDLED:-1}),tc=Ts(ec),nc=Is.shape.relationships.element,rc=H({id:V(),username:V(),discriminator:V(),global_name:V().optional().nullable(),avatar:V().optional().nullable(),avatar_decoration_data:H({asset:V(),sku_id:V().optional()}).nullable(),bot:yo(),flags:go().optional().nullable(),premium_type:go().optional().nullable()}),ic=H({user:rc,nick:V().optional().nullable(),roles:Oo(V()),joined_at:V(),deaf:yo(),mute:yo()}),ac=H({user_id:V(),nick:V().optional().nullable(),guild_id:V(),avatar:V().optional().nullable(),avatar_decoration_data:H({asset:V(),sku_id:V().optional().nullable()}).optional().nullable(),color_string:V().optional().nullable()}),oc=H({id:V(),name:V().optional().nullable(),roles:Oo(V()).optional().nullable(),user:rc.optional().nullable(),require_colons:yo().optional().nullable(),managed:yo().optional().nullable(),animated:yo().optional().nullable(),available:yo().optional().nullable()}),sc=H({mute:yo(),deaf:yo(),self_mute:yo(),self_deaf:yo(),suppress:yo()}),cc=H({mute:yo(),nick:V(),user:rc,voice_state:sc,volume:go()}),lc={UNHANDLED:-1,IDLE:`idle`,DND:`dnd`,ONLINE:`online`,OFFLINE:`offline`},uc=Ts(lc),dc=H({name:V(),type:go(),url:V().optional().nullable(),created_at:go().optional().nullable(),timestamps:H({start:go(),end:go()}).partial().optional().nullable(),application_id:V().optional().nullable(),details:V().optional().nullable(),details_url:V().url().optional().nullable(),state:V().optional().nullable(),state_url:V().url().optional().nullable(),emoji:oc.optional().nullable(),party:H({id:V().optional().nullable(),size:Oo(go()).optional().nullable()}).optional().nullable(),assets:H({large_image:V().nullable(),large_text:V().nullable(),large_url:V().url().optional().nullable(),small_image:V().nullable(),small_text:V().nullable(),small_url:V().url().optional().nullable()}).partial().optional().nullable(),secrets:H({join:V(),match:V()}).partial().optional().nullable(),instance:yo().optional().nullable(),flags:go().optional().nullable()}),fc={UNHANDLED:-1,ROLE:0,MEMBER:1},pc=H({id:V(),type:Ts(fc),allow:V(),deny:V()}),mc={UNHANDLED:-1,DM:1,GROUP_DM:3,GUILD_TEXT:0,GUILD_VOICE:2,GUILD_CATEGORY:4,GUILD_ANNOUNCEMENT:5,GUILD_STORE:6,ANNOUNCEMENT_THREAD:10,PUBLIC_THREAD:11,PRIVATE_THREAD:12,GUILD_STAGE_VOICE:13,GUILD_DIRECTORY:14,GUILD_FORUM:15},hc=H({id:V(),type:Ts(mc),guild_id:V().optional().nullable(),position:go().optional().nullable(),permission_overwrites:Oo(pc).optional().nullable(),name:V().optional().nullable(),topic:V().optional().nullable(),nsfw:yo().optional().nullable(),last_message_id:V().optional().nullable(),bitrate:go().optional().nullable(),user_limit:go().optional().nullable(),rate_limit_per_user:go().optional().nullable(),recipients:Oo(rc).optional().nullable(),icon:V().optional().nullable(),owner_id:V().optional().nullable(),application_id:V().optional().nullable(),parent_id:V().optional().nullable(),last_pin_timestamp:V().optional().nullable()}),gc=H({user:rc,guild_id:V(),status:uc,activities:Oo(dc),client_status:H({desktop:uc,mobile:uc,web:uc}).partial()}),_c=H({id:V(),name:V(),color:go(),hoist:yo(),position:go(),permissions:V(),managed:yo(),mentionable:yo()}),vc=H({id:V(),name:V(),owner_id:V(),icon:V().nullable(),icon_hash:V().optional().nullable(),splash:V().nullable(),discovery_splash:V().nullable(),owner:yo().optional().nullable(),permissions:V().optional().nullable(),region:V(),afk_channel_id:V().nullable(),afk_timeout:go(),widget_enabled:yo().optional().nullable(),widget_channel_id:V().optional().nullable(),verification_level:go(),default_message_notifications:go(),explicit_content_filter:go(),roles:Oo(_c),emojis:Oo(oc),features:Oo(V()),mfa_level:go(),application_id:V().nullable(),system_channel_id:V().nullable(),system_channel_flags:go(),rules_channel_id:V().nullable(),joined_at:V().optional().nullable(),large:yo().optional().nullable(),unavailable:yo().optional().nullable(),member_count:go().optional().nullable(),voice_states:Oo(sc).optional().nullable(),members:Oo(ic).optional().nullable(),channels:Oo(hc).optional().nullable(),presences:Oo(gc).optional().nullable(),max_presences:go().optional().nullable(),max_members:go().optional().nullable(),vanity_url_code:V().nullable(),description:V().nullable(),banner:V().nullable(),premium_tier:go(),premium_subscription_count:go().optional().nullable(),preferred_locale:V(),public_updates_channel_id:V().nullable(),max_video_channel_users:go().optional().nullable(),approximate_member_count:go().optional().nullable(),approximate_presence_count:go().optional().nullable()}),yc=H({id:V(),guild_id:V(),type:go(),name:V()}),bc=H({id:V(),filename:V(),size:go(),url:V(),proxy_url:V(),height:go().optional().nullable(),width:go().optional().nullable()}),xc=H({text:V(),icon_url:V().optional().nullable(),proxy_icon_url:V().optional().nullable()}),Sc=H({url:V().optional().nullable(),proxy_url:V().optional().nullable(),height:go().optional().nullable(),width:go().optional().nullable()}),Cc=Sc.omit({proxy_url:!0}),wc=H({name:V().optional().nullable(),url:V().optional().nullable()}),Tc=H({name:V().optional().nullable(),url:V().optional().nullable(),icon_url:V().optional().nullable(),proxy_icon_url:V().optional().nullable()}),Ec=H({name:V(),value:V(),inline:yo()}),Dc=H({title:V().optional().nullable(),type:V().optional().nullable(),description:V().optional().nullable(),url:V().optional().nullable(),timestamp:V().optional().nullable(),color:go().optional().nullable(),footer:xc.optional().nullable(),image:Sc.optional().nullable(),thumbnail:Sc.optional().nullable(),video:Cc.optional().nullable(),provider:wc.optional().nullable(),author:Tc.optional().nullable(),fields:Oo(Ec).optional().nullable()}),Oc=H({count:go(),me:yo(),emoji:oc}),kc=H({type:go(),party_id:V().optional().nullable()}),Ac=H({id:V(),cover_image:V().optional().nullable(),description:V(),icon:V().optional().nullable(),name:V()}),jc=H({message_id:V().optional().nullable(),channel_id:V().optional().nullable(),guild_id:V().optional().nullable()}),Mc=H({id:V(),channel_id:V(),guild_id:V().optional().nullable(),author:rc.optional().nullable(),member:ic.optional().nullable(),content:V(),timestamp:V(),edited_timestamp:V().optional().nullable(),tts:yo(),mention_everyone:yo(),mentions:Oo(rc),mention_roles:Oo(V()),mention_channels:Oo(yc),attachments:Oo(bc),embeds:Oo(Dc),reactions:Oo(Oc).optional().nullable(),nonce:Ao([V(),go()]).optional().nullable(),pinned:yo(),webhook_id:V().optional().nullable(),type:go(),activity:kc.optional().nullable(),application:Ac.optional().nullable(),message_reference:jc.optional().nullable(),flags:go().optional().nullable(),stickers:Oo(To()).optional().nullable(),referenced_message:To().optional().nullable()}),Nc=H({id:V(),name:V()}),Pc={UNHANDLED:-1,KEYBOARD_KEY:0,MOUSE_BUTTON:1,KEYBOARD_MODIFIER_KEY:2,GAMEPAD_BUTTON:3},Fc=H({type:Ts(Pc),code:go(),name:V()}),Ic={UNHANDLED:-1,PUSH_TO_TALK:`PUSH_TO_TALK`,VOICE_ACTIVITY:`VOICE_ACTIVITY`},Lc=H({type:Ts(Ic),auto_threshold:yo(),threshold:go(),shortcut:Oo(Fc),delay:go()}),Rc=H({device_id:V(),volume:go(),available_devices:Oo(Nc)}),zc={UNHANDLED:-1,AUDIO_INPUT:`AUDIO_INPUT`,AUDIO_OUTPUT:`AUDIO_OUTPUT`,VIDEO_INPUT:`VIDEO_INPUT`},Bc=H({type:Ts(zc),id:V(),vendor:H({name:V(),url:V()}),model:H({name:V(),url:V()}),related:Oo(V()),echo_cancellation:yo().optional().nullable(),noise_suppression:yo().optional().nullable(),automatic_gain_control:yo().optional().nullable(),hardware_mute:yo().optional().nullable()}),Vc={UNHANDLED:-1,APPLICATION:1,DLC:2,CONSUMABLE:3,BUNDLE:4,SUBSCRIPTION:5},Hc=H({id:V(),name:V(),type:Ts(Vc),price:H({amount:go(),currency:V()}),application_id:V(),flags:go(),release_date:V().nullable()}),Uc={UNHANDLED:-1,PURCHASE:1,PREMIUM_SUBSCRIPTION:2,DEVELOPER_GIFT:3,TEST_MODE_PURCHASE:4,FREE_PURCHASE:5,USER_GIFT:6,PREMIUM_PURCHASE:7},Wc=H({id:V(),sku_id:V(),application_id:V(),user_id:V(),gift_code_flags:go(),type:Ts(Uc),gifter_user_id:V().optional().nullable(),branches:Oo(V()).optional().nullable(),starts_at:V().optional().nullable(),ends_at:V().optional().nullable(),parent_id:V().optional().nullable(),consumed:yo().optional().nullable(),deleted:yo().optional().nullable(),gift_code_batch_id:V().optional().nullable()}),Gc={UNHANDLED:-1,UNLOCKED:1,PORTRAIT:2,LANDSCAPE:3},Kc=Ts(Gc),qc={UNHANDLED:-1,NOMINAL:0,FAIR:1,SERIOUS:2,CRITICAL:3},Jc=Ts(qc),Yc={UNHANDLED:-1,PORTRAIT:0,LANDSCAPE:1},Xc=Ts(Yc),Zc={UNHANDLED:-1,FOCUSED:0,PIP:1,GRID:2},Qc=Ts(Zc),$c=`ERROR`,el;(function(e){e.READY=`READY`,e.VOICE_STATE_UPDATE=`VOICE_STATE_UPDATE`,e.SPEAKING_START=`SPEAKING_START`,e.SPEAKING_STOP=`SPEAKING_STOP`,e.ACTIVITY_LAYOUT_MODE_UPDATE=`ACTIVITY_LAYOUT_MODE_UPDATE`,e.ORIENTATION_UPDATE=`ORIENTATION_UPDATE`,e.CURRENT_USER_UPDATE=`CURRENT_USER_UPDATE`,e.CURRENT_GUILD_MEMBER_UPDATE=`CURRENT_GUILD_MEMBER_UPDATE`,e.ENTITLEMENT_CREATE=`ENTITLEMENT_CREATE`,e.THERMAL_STATE_UPDATE=`THERMAL_STATE_UPDATE`,e.ACTIVITY_INSTANCE_PARTICIPANTS_UPDATE=`ACTIVITY_INSTANCE_PARTICIPANTS_UPDATE`,e.RELATIONSHIP_UPDATE=`RELATIONSHIP_UPDATE`,e.ACTIVITY_JOIN=`ACTIVITY_JOIN`,e.QUEST_ENROLLMENT_STATUS_UPDATE=`QUEST_ENROLLMENT_STATUS_UPDATE`})(el||={});var tl=$s.extend({evt:Vo(el),nonce:V().nullable(),cmd:zo(Zs),data:H({}).passthrough()}),nl=$s.extend({evt:zo($c),data:H({code:go(),message:V().optional()}).passthrough(),cmd:Vo(Qs),nonce:V().nullable()}),rl=Ao([tl,tl.extend({evt:V()}),nl]);function il(e){let t=e.evt;if(!(t in el))throw Error(`Unrecognized event type ${e.evt}`);return al[t].payload.parse(e)}var al={[el.READY]:{payload:tl.extend({evt:zo(el.READY),data:H({v:go(),config:H({cdn_host:V().optional(),api_endpoint:V(),environment:V()}),user:H({id:V(),username:V(),discriminator:V(),avatar:V().optional()}).optional()})})},[el.VOICE_STATE_UPDATE]:{payload:tl.extend({evt:zo(el.VOICE_STATE_UPDATE),data:cc}),subscribeArgs:H({channel_id:V()})},[el.SPEAKING_START]:{payload:tl.extend({evt:zo(el.SPEAKING_START),data:H({lobby_id:V().optional(),channel_id:V().optional(),user_id:V()})}),subscribeArgs:H({lobby_id:V().nullable().optional(),channel_id:V().nullable().optional()})},[el.SPEAKING_STOP]:{payload:tl.extend({evt:zo(el.SPEAKING_STOP),data:H({lobby_id:V().optional(),channel_id:V().optional(),user_id:V()})}),subscribeArgs:H({lobby_id:V().nullable().optional(),channel_id:V().nullable().optional()})},[el.ACTIVITY_LAYOUT_MODE_UPDATE]:{payload:tl.extend({evt:zo(el.ACTIVITY_LAYOUT_MODE_UPDATE),data:H({layout_mode:Ts(Zc)})})},[el.ORIENTATION_UPDATE]:{payload:tl.extend({evt:zo(el.ORIENTATION_UPDATE),data:H({screen_orientation:Ts(Yc),orientation:Vo(Cs)})})},[el.CURRENT_USER_UPDATE]:{payload:tl.extend({evt:zo(el.CURRENT_USER_UPDATE),data:rc})},[el.CURRENT_GUILD_MEMBER_UPDATE]:{payload:tl.extend({evt:zo(el.CURRENT_GUILD_MEMBER_UPDATE),data:ac}),subscribeArgs:H({guild_id:V()})},[el.ENTITLEMENT_CREATE]:{payload:tl.extend({evt:zo(el.ENTITLEMENT_CREATE),data:H({entitlement:Wc})})},[el.THERMAL_STATE_UPDATE]:{payload:tl.extend({evt:zo(el.THERMAL_STATE_UPDATE),data:H({thermal_state:Jc})})},[el.ACTIVITY_INSTANCE_PARTICIPANTS_UPDATE]:{payload:tl.extend({evt:zo(el.ACTIVITY_INSTANCE_PARTICIPANTS_UPDATE),data:H({participants:js.shape.participants})})},[el.RELATIONSHIP_UPDATE]:{payload:tl.extend({evt:zo(el.RELATIONSHIP_UPDATE),data:nc})},[el.ACTIVITY_JOIN]:{payload:tl.extend({evt:zo(el.ACTIVITY_JOIN),data:H({applicationId:V(),secret:V()})})},[el.QUEST_ENROLLMENT_STATUS_UPDATE]:{payload:tl.extend({evt:zo(el.QUEST_ENROLLMENT_STATUS_UPDATE),data:H({quest_id:V(),is_enrolled:yo(),enrolled_at:V().date()})})}};function ol(e,t){throw t}var sl=H({}).nullable(),cl=H({code:V()}),ll=H({guilds:Oo(H({id:V(),name:V()}))}),ul=H({id:V(),name:V(),icon_url:V().optional(),members:Oo(ic)}),dl=H({id:V(),type:Ts(mc),guild_id:V().optional().nullable(),name:V().optional().nullable(),topic:V().optional().nullable(),bitrate:go().optional().nullable(),user_limit:go().optional().nullable(),position:go().optional().nullable(),voice_states:Oo(cc),messages:Oo(Mc)}),fl=H({channels:Oo(hc)});dl.nullable();var pl=dl.nullable(),ml=dl.nullable();H({input:Rc,output:Rc,mode:Lc,automatic_gain_control:yo(),echo_cancellation:yo(),noise_suppression:yo(),qos:yo(),silence_warning:yo(),deaf:yo(),mute:yo()});var hl=H({evt:V()}),gl=H({shortcut:Fc}),_l=dc,vl=H({skus:Oo(Hc)}),yl=H({entitlements:Oo(Wc)}),bl=Oo(Wc).nullable(),xl=H({use_interactive_pip:yo()}),Sl=H({locale:V()}),Cl=H({enabled:yo()}),wl=H({permissions:vo().or(V())}),Tl=Es(H({opened:yo().or(Co())}).default({opened:null})),El=H({iosKeyboardResizesView:Wo(yo())}),Dl=$s.extend({cmd:Vo(Qs),evt:Co()});function Ol({cmd:e,data:t}){switch(e){case Qs.AUTHORIZE:return cl.parse(t);case Qs.CAPTURE_SHORTCUT:return gl.parse(t);case Qs.ENCOURAGE_HW_ACCELERATION:return Cl.parse(t);case Qs.GET_CHANNEL:return dl.parse(t);case Qs.GET_CHANNELS:return fl.parse(t);case Qs.GET_CHANNEL_PERMISSIONS:return wl.parse(t);case Qs.GET_GUILD:return ul.parse(t);case Qs.GET_GUILDS:return ll.parse(t);case Qs.GET_PLATFORM_BEHAVIORS:return El.parse(t);case Qs.GET_CHANNEL:return dl.parse(t);case Qs.SELECT_TEXT_CHANNEL:return ml.parse(t);case Qs.SELECT_VOICE_CHANNEL:return pl.parse(t);case Qs.SET_ACTIVITY:return _l.parse(t);case Qs.GET_SKUS_EMBEDDED:return vl.parse(t);case Qs.GET_ENTITLEMENTS_EMBEDDED:return yl.parse(t);case Qs.SET_CONFIG:return xl.parse(t);case Qs.START_PURCHASE:return bl.parse(t);case Qs.SUBSCRIBE:case Qs.UNSUBSCRIBE:return hl.parse(t);case Qs.USER_SETTINGS_GET_LOCALE:return Sl.parse(t);case Qs.OPEN_EXTERNAL_LINK:return Tl.parse(t);case Qs.SET_ORIENTATION_LOCK_STATE:case Qs.SET_CERTIFIED_DEVICES:case Qs.SEND_ANALYTICS_EVENT:case Qs.OPEN_INVITE_DIALOG:case Qs.CAPTURE_LOG:case Qs.GET_SKUS:case Qs.GET_ENTITLEMENTS:return sl.parse(t);case Qs.AUTHENTICATE:case Qs.GET_ACTIVITY_INSTANCE_CONNECTED_PARTICIPANTS:case Qs.GET_QUEST:case Qs.GET_QUEST_ENROLLMENT_STATUS:case Qs.GET_RELATIONSHIPS:case Qs.GET_USER:case Qs.INITIATE_IMAGE_UPLOAD:case Qs.INVITE_USER_EMBEDDED:case Qs.OPEN_SHARE_MOMENT_DIALOG:case Qs.QUEST_START_TIMER:case Qs.REQUEST_PROXY_TICKET_REFRESH:case Qs.SHARE_INTERACTION:case Qs.SHARE_LINK:let{response:n}=Ys[e];return n.parse(t);default:ol(e,Error(`Unrecognized command ${e}`))}}function kl(e){return Object.assign(Object.assign({},e),{data:Ol(e)})}H({frame_id:V(),platform:Vo(ws).optional().nullable()}),H({v:zo(1),encoding:zo(`json`).optional(),client_id:V(),frame_id:V()});var Al=H({code:go(),message:V().optional()}),jl=H({evt:V().nullable(),nonce:V().nullable(),data:To().nullable(),cmd:V()}).passthrough();function Ml(e){let t=jl.parse(e);return t.evt==null?kl(Dl.passthrough().parse(t)):t.evt===`ERROR`?nl.parse(t):il(rl.parse(t))}function Nl(e,t,n,r=()=>void 0){let i=$s.extend({cmd:zo(t),data:n});return async n=>{let a=await e({cmd:t,args:n,transfer:r(n)});return i.parse(a).data}}function Pl(e,t=()=>void 0){let n=Ys[e].response,r=$s.extend({cmd:zo(e),data:n});return n=>async i=>{let a=await n({cmd:e,args:i,transfer:t(i)});return r.parse(a).data}}var Fl=e=>Nl(e,Qs.AUTHORIZE,cl),Il=e=>Nl(e,Qs.CAPTURE_LOG,sl),Ll=e=>Nl(e,Qs.ENCOURAGE_HW_ACCELERATION,Cl),Rl=e=>Nl(e,Qs.GET_CHANNEL,dl),zl=e=>Nl(e,Qs.GET_ENTITLEMENTS_EMBEDDED,yl),Bl=e=>Nl(e,Qs.GET_SKUS_EMBEDDED,vl),Vl=e=>Nl(e,Qs.GET_CHANNEL_PERMISSIONS,wl),Hl=e=>Nl(e,Qs.GET_PLATFORM_BEHAVIORS,El),Ul=e=>Nl(e,Qs.OPEN_EXTERNAL_LINK,Tl),Wl=e=>Nl(e,Qs.OPEN_INVITE_DIALOG,sl);dc.pick({state:!0,state_url:!0,details:!0,details_url:!0,timestamps:!0,assets:!0,party:!0,secrets:!0,instance:!0,type:!0}).extend({type:dc.shape.type.optional(),instance:dc.shape.instance.optional()}).nullable();var Gl=e=>Nl(e,Qs.SET_ACTIVITY,_l),Kl=e=>Nl(e,Qs.SET_CONFIG,xl);function ql({sendCommand:e,cmd:t,response:n,fallbackTransform:r,transferTransform:i=()=>void 0}){let a=$s.extend({cmd:zo(t),data:n});return async n=>{try{let r=await e({cmd:t,args:n,transfer:i(n)});return a.parse(r).data}catch(o){if(o.code===Ss.INVALID_PAYLOAD){let o=r(n),s=await e({cmd:t,args:o,transfer:i(o)});return a.parse(s).data}throw o}}}var Jl=e=>({lock_state:e.lock_state,picture_in_picture_lock_state:e.picture_in_picture_lock_state}),Yl=e=>ql({sendCommand:e,cmd:Qs.SET_ORIENTATION_LOCK_STATE,response:sl,fallbackTransform:Jl}),Xl=e=>Nl(e,Qs.START_PURCHASE,bl),Zl=e=>Nl(e,Qs.USER_SETTINGS_GET_LOCALE,Sl),Ql=Pl(Ks.AUTHENTICATE),$l=Pl(Ks.GET_ACTIVITY_INSTANCE_CONNECTED_PARTICIPANTS),eu=Pl(Ks.GET_QUEST),tu=Pl(Ks.GET_QUEST_ENROLLMENT_STATUS),nu=Pl(Ks.GET_RELATIONSHIPS),ru=Pl(Ks.GET_USER),iu=Pl(Ks.INITIATE_IMAGE_UPLOAD),au=Pl(Ks.INVITE_USER_EMBEDDED),ou=Pl(Ks.OPEN_SHARE_MOMENT_DIALOG),su=Pl(Ks.QUEST_START_TIMER),cu=Pl(Ks.REQUEST_PROXY_TICKET_REFRESH),lu=Pl(Ks.SHARE_INTERACTION),uu=Pl(Ks.SHARE_LINK);function du(e){return{authorize:Fl(e),captureLog:Il(e),encourageHardwareAcceleration:Ll(e),getChannel:Rl(e),getChannelPermissions:Vl(e),getEntitlements:zl(e),getPlatformBehaviors:Hl(e),getSkus:Bl(e),openExternalLink:Ul(e),openInviteDialog:Wl(e),setActivity:Gl(e),setConfig:Kl(e),setOrientationLockState:Yl(e),startPurchase:Xl(e),userSettingsGetLocale:Zl(e),getInstanceConnectedParticipants:$l(e),authenticate:Ql(e),getActivityInstanceConnectedParticipants:$l(e),getQuest:eu(e),getQuestEnrollmentStatus:tu(e),getRelationships:nu(e),getUser:ru(e),initiateImageUpload:iu(e),inviteUserEmbedded:au(e),openShareMomentDialog:ou(e),questStartTimer:su(e),requestProxyTicketRefresh:cu(e),shareInteraction:lu(e),shareLink:uu(e)}}var fu=class extends Error{constructor(e,t=``){super(t),this.code=e,this.message=t,this.name=`Discord SDK Error`}};function pu(){return{disableConsoleLogOverride:!1}}var mu=[`log`,`warn`,`debug`,`info`,`error`];function hu(e,t,n){let r=e[t],i=e;r&&(e[t]=function(){let e=[].slice.call(arguments);n(t,``+e.join(` `)),r.apply(i,e)})}var gu=`2.5.0`,_u={randomUUID:typeof crypto<`u`&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)},vu,yu=new Uint8Array(16);function bu(){if(!vu){if(typeof crypto>`u`||!crypto.getRandomValues)throw Error(`crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported`);vu=crypto.getRandomValues.bind(crypto)}return vu(yu)}var xu=[];for(let e=0;e<256;++e)xu.push((e+256).toString(16).slice(1));function Su(e,t=0){return(xu[e[t+0]]+xu[e[t+1]]+xu[e[t+2]]+xu[e[t+3]]+`-`+xu[e[t+4]]+xu[e[t+5]]+`-`+xu[e[t+6]]+xu[e[t+7]]+`-`+xu[e[t+8]]+xu[e[t+9]]+`-`+xu[e[t+10]]+xu[e[t+11]]+xu[e[t+12]]+xu[e[t+13]]+xu[e[t+14]]+xu[e[t+15]]).toLowerCase()}function Cu(e,t,n){if(_u.randomUUID&&!t&&!e)return _u.randomUUID();e||={};let r=e.random??e.rng?.()??bu();if(r.length<16)throw Error(`Random bytes length must be >= 16`);return r[6]=r[6]&15|64,r[8]=r[8]&63|128,Su(r)}var wu;(function(e){e[e.HANDSHAKE=0]=`HANDSHAKE`,e[e.FRAME=1]=`FRAME`,e[e.CLOSE=2]=`CLOSE`,e[e.HELLO=3]=`HELLO`})(wu||={});var Tu=new Set(Eu());function Eu(){return typeof window>`u`?[]:[window.location.origin,`https://discord.com`,`https://discordapp.com`,`https://ptb.discord.com`,`https://ptb.discordapp.com`,`https://canary.discord.com`,`https://canary.discordapp.com`,`https://staging.discord.co`,`http://localhost:3333`,`https://pax.discord.com`,`null`]}function Du(){return[window.parent.opener??window.parent,document.referrer?document.referrer:`*`]}var Ou=class{getTransfer(e){switch(e.cmd){case Qs.SUBSCRIBE:case Qs.UNSUBSCRIBE:return;default:return e.transfer??void 0}}constructor(e,t){if(this.sdkVersion=gu,this.mobileAppVersion=null,this.source=null,this.sourceOrigin=``,this.eventBus=new Ai,this.pendingCommands=new Map,this.sendCommand=e=>{var t;if(this.source==null)throw Error(`Attempting to send message before initialization`);let n=Cu();return(t=this.source)==null||t.postMessage([wu.FRAME,Object.assign(Object.assign({},e),{nonce:n})],this.sourceOrigin,this.getTransfer(e)),new Promise((e,t)=>{this.pendingCommands.set(n,{resolve:e,reject:t})})},this.commands=du(this.sendCommand),this.handleMessage=e=>{if(!Tu.has(e.origin))return;let t=e.data;if(!Array.isArray(t))return;let[n,r]=t;switch(n){case wu.HELLO:return;case wu.CLOSE:return this.handleClose(r);case wu.HANDSHAKE:return this.handleHandshake();case wu.FRAME:return this.handleFrame(r);default:throw Error(`Invalid message format`)}},this.isReady=!1,this.clientId=e,this.configuration=t??pu(),typeof window<`u`&&window.addEventListener(`message`,this.handleMessage),typeof window>`u`){this.frameId=``,this.instanceId=``,this.customId=null,this.referrerId=null,this.platform=ws.DESKTOP,this.guildId=null,this.channelId=null,this.locationId=null;return}let n=new URLSearchParams(this._getSearch()),r=n.get(`frame_id`);if(!r)throw Error(`frame_id query param is not defined`);this.frameId=r;let i=n.get(`instance_id`);if(!i)throw Error(`instance_id query param is not defined`);this.instanceId=i;let a=n.get(`platform`);if(!a)throw Error(`platform query param is not defined`);if(a!==ws.DESKTOP&&a!==ws.MOBILE)throw Error(`Invalid query param "platform" of "${a}". Valid values are "${ws.DESKTOP}" or "${ws.MOBILE}"`);this.platform=a,this.customId=n.get(`custom_id`),this.referrerId=n.get(`referrer_id`),this.guildId=n.get(`guild_id`),this.channelId=n.get(`channel_id`),this.locationId=n.get(`location_id`),this.mobileAppVersion=n.get(`mobile_app_version`),[this.source,this.sourceOrigin]=Du(),this.addOnReadyListener(),this.handshake()}close(e,t){var n;window.removeEventListener(`message`,this.handleMessage);let r=Cu();(n=this.source)==null||n.postMessage([wu.CLOSE,{code:e,message:t,nonce:r}],this.sourceOrigin)}async subscribe(e,t,...n){let[r]=n,i=this.eventBus.listenerCount(e),a=this.eventBus.on(e,t);return Object.values(el).includes(e)&&e!==el.READY&&i===0&&await this.sendCommand({cmd:Qs.SUBSCRIBE,args:r,evt:e}),a}async unsubscribe(e,t,...n){let[r]=n;return e!==el.READY&&this.eventBus.listenerCount(e)===1&&await this.sendCommand({cmd:Qs.UNSUBSCRIBE,evt:e,args:r}),this.eventBus.off(e,t)}async ready(){this.isReady||await new Promise(e=>{this.eventBus.once(el.READY,e)})}parseMajorMobileVersion(){if(this.mobileAppVersion&&this.mobileAppVersion.includes(`.`))try{return parseInt(this.mobileAppVersion.split(`.`)[0])}catch{return-1}return-1}handshake(){var e;let t={v:1,encoding:`json`,client_id:this.clientId,frame_id:this.frameId},n=this.parseMajorMobileVersion();(this.platform===ws.DESKTOP||n>=250)&&(t.sdk_version=this.sdkVersion),(e=this.source)==null||e.postMessage([wu.HANDSHAKE,t],this.sourceOrigin)}addOnReadyListener(){this.eventBus.once(el.READY,()=>{this.overrideConsoleLogging(),this.isReady=!0})}overrideConsoleLogging(){if(this.configuration.disableConsoleLogOverride)return;let e=(e,t)=>{this.commands.captureLog({level:e,message:t})};mu.forEach(t=>{hu(console,t,e)})}handleClose(e){Al.parse(e)}handleHandshake(){}handleFrame(e){var t,n;let r;try{r=Ml(e)}catch(t){console.error(`Failed to parse`,e),console.error(t);return}if(r.cmd===`DISPATCH`)this.eventBus.emit(r.evt,r.data);else{if(r.evt===`ERROR`){if(r.nonce!=null){(t=this.pendingCommands.get(r.nonce))==null||t.reject(r.data),this.pendingCommands.delete(r.nonce);return}this.eventBus.emit(`error`,new fu(r.data.code,r.data.message))}if(r.nonce==null){console.error(`Missing nonce`,e);return}(n=this.pendingCommands.get(r.nonce))==null||n.resolve(r),this.pendingCommands.delete(r.nonce)}}_getSearch(){return typeof window>`u`?``:window.location.search}},ku=1e9,Au={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:`2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286`},ju=!0,Mu=`[DecimalError] `,Nu=Mu+`Invalid argument: `,Pu=Mu+`Exponent out of range: `,Fu=Math.floor,Iu=Math.pow,Lu=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Ru,zu=1e7,Bu=7,Vu=9007199254740991,Hu=Fu(Vu/Bu),Uu={};Uu.absoluteValue=Uu.abs=function(){var e=new this.constructor(this);return e.s&&=1,e},Uu.comparedTo=Uu.cmp=function(e){var t,n,r,i,a=this;if(e=new a.constructor(e),a.s!==e.s)return a.s||-e.s;if(a.e!==e.e)return a.e>e.e^a.s<0?1:-1;for(r=a.d.length,i=e.d.length,t=0,n=re.d[t]^a.s<0?1:-1;return r===i?0:r>i^a.s<0?1:-1},Uu.decimalPlaces=Uu.dp=function(){var e=this,t=e.d.length-1,n=(t-e.e)*Bu;if(t=e.d[t],t)for(;t%10==0;t/=10)n--;return n<0?0:n},Uu.dividedBy=Uu.div=function(e){return qu(this,new this.constructor(e))},Uu.dividedToIntegerBy=Uu.idiv=function(e){var t=this,n=t.constructor;return ed(qu(t,new n(e),0,1),n.precision)},Uu.equals=Uu.eq=function(e){return!this.cmp(e)},Uu.exponent=function(){return Yu(this)},Uu.greaterThan=Uu.gt=function(e){return this.cmp(e)>0},Uu.greaterThanOrEqualTo=Uu.gte=function(e){return this.cmp(e)>=0},Uu.isInteger=Uu.isint=function(){return this.e>this.d.length-2},Uu.isNegative=Uu.isneg=function(){return this.s<0},Uu.isPositive=Uu.ispos=function(){return this.s>0},Uu.isZero=function(){return this.s===0},Uu.lessThan=Uu.lt=function(e){return this.cmp(e)<0},Uu.lessThanOrEqualTo=Uu.lte=function(e){return this.cmp(e)<1},Uu.logarithm=Uu.log=function(e){var t,n=this,r=n.constructor,i=r.precision,a=i+5;if(e===void 0)e=new r(10);else if(e=new r(e),e.s<1||e.eq(Ru))throw Error(Mu+`NaN`);if(n.s<1)throw Error(Mu+(n.s?`NaN`:`-Infinity`));return n.eq(Ru)?new r(0):(ju=!1,t=qu(Qu(n,a),Qu(e,a),a),ju=!0,ed(t,i))},Uu.minus=Uu.sub=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?td(t,e):Wu(t,(e.s=-e.s,e))},Uu.modulo=Uu.mod=function(e){var t,n=this,r=n.constructor,i=r.precision;if(e=new r(e),!e.s)throw Error(Mu+`NaN`);return n.s?(ju=!1,t=qu(n,e,0,1).times(e),ju=!0,n.minus(t)):ed(new r(n),i)},Uu.naturalExponential=Uu.exp=function(){return Ju(this)},Uu.naturalLogarithm=Uu.ln=function(){return Qu(this)},Uu.negated=Uu.neg=function(){var e=new this.constructor(this);return e.s=-e.s||0,e},Uu.plus=Uu.add=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?Wu(t,e):td(t,(e.s=-e.s,e))},Uu.precision=Uu.sd=function(e){var t,n,r,i=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(Nu+e);if(t=Yu(i)+1,r=i.d.length-1,n=r*Bu+1,r=i.d[r],r){for(;r%10==0;r/=10)n--;for(r=i.d[0];r>=10;r/=10)n++}return e&&t>n?t:n},Uu.squareRoot=Uu.sqrt=function(){var e,t,n,r,i,a,o,s=this,c=s.constructor;if(s.s<1){if(!s.s)return new c(0);throw Error(Mu+`NaN`)}for(e=Yu(s),ju=!1,i=Math.sqrt(+s),i==0||i==1/0?(t=Ku(s.d),(t.length+e)%2==0&&(t+=`0`),i=Math.sqrt(t),e=Fu((e+1)/2)-(e<0||e%2),i==1/0?t=`5e`+e:(t=i.toExponential(),t=t.slice(0,t.indexOf(`e`)+1)+e),r=new c(t)):r=new c(i.toString()),n=c.precision,i=o=n+3;;)if(a=r,r=a.plus(qu(s,a,o+2)).times(.5),Ku(a.d).slice(0,o)===(t=Ku(r.d)).slice(0,o)){if(t=t.slice(o-3,o+1),i==o&&t==`4999`){if(ed(a,n+1,0),a.times(a).eq(s)){r=a;break}}else if(t!=`9999`)break;o+=4}return ju=!0,ed(r,n)},Uu.times=Uu.mul=function(e){var t,n,r,i,a,o,s,c,l,u=this,d=u.constructor,f=u.d,p=(e=new d(e)).d;if(!u.s||!e.s)return new d(0);for(e.s*=u.s,n=u.e+e.e,c=f.length,l=p.length,c=0;){for(t=0,i=c+r;i>r;)s=a[i]+p[r]*f[i-r-1]+t,a[i--]=s%zu|0,t=s/zu|0;a[i]=(a[i]+t)%zu|0}for(;!a[--o];)a.pop();return t?++n:a.shift(),e.d=a,e.e=n,ju?ed(e,d.precision):e},Uu.toDecimalPlaces=Uu.todp=function(e,t){var n=this,r=n.constructor;return n=new r(n),e===void 0?n:(Gu(e,0,ku),t===void 0?t=r.rounding:Gu(t,0,8),ed(n,e+Yu(n)+1,t))},Uu.toExponential=function(e,t){var n,r=this,i=r.constructor;return e===void 0?n=nd(r,!0):(Gu(e,0,ku),t===void 0?t=i.rounding:Gu(t,0,8),r=ed(new i(r),e+1,t),n=nd(r,!0,e+1)),n},Uu.toFixed=function(e,t){var n,r,i=this,a=i.constructor;return e===void 0?nd(i):(Gu(e,0,ku),t===void 0?t=a.rounding:Gu(t,0,8),r=ed(new a(i),e+Yu(i)+1,t),n=nd(r.abs(),!1,e+Yu(r)+1),i.isneg()&&!i.isZero()?`-`+n:n)},Uu.toInteger=Uu.toint=function(){var e=this,t=e.constructor;return ed(new t(e),Yu(e)+1,t.rounding)},Uu.toNumber=function(){return+this},Uu.toPower=Uu.pow=function(e){var t,n,r,i,a,o,s=this,c=s.constructor,l=12,u=+(e=new c(e));if(!e.s)return new c(Ru);if(s=new c(s),!s.s){if(e.s<1)throw Error(Mu+`Infinity`);return s}if(s.eq(Ru))return s;if(r=c.precision,e.eq(Ru))return ed(s,r);if(t=e.e,n=e.d.length-1,o=t>=n,a=s.s,!o){if(a<0)throw Error(Mu+`NaN`)}else if((n=u<0?-u:u)<=Vu){for(i=new c(Ru),t=Math.ceil(r/Bu+4),ju=!1;n%2&&(i=i.times(s),rd(i.d,t)),n=Fu(n/2),n!==0;)s=s.times(s),rd(s.d,t);return ju=!0,e.s<0?new c(Ru).div(i):ed(i,r)}return a=a<0&&e.d[Math.max(t,n)]&1?-1:1,s.s=1,ju=!1,i=e.times(Qu(s,r+l)),ju=!0,i=Ju(i),i.s=a,i},Uu.toPrecision=function(e,t){var n,r,i=this,a=i.constructor;return e===void 0?(n=Yu(i),r=nd(i,n<=a.toExpNeg||n>=a.toExpPos)):(Gu(e,1,ku),t===void 0?t=a.rounding:Gu(t,0,8),i=ed(new a(i),e,t),n=Yu(i),r=nd(i,e<=n||n<=a.toExpNeg,e)),r},Uu.toSignificantDigits=Uu.tosd=function(e,t){var n=this,r=n.constructor;return e===void 0?(e=r.precision,t=r.rounding):(Gu(e,1,ku),t===void 0?t=r.rounding:Gu(t,0,8)),ed(new r(n),e,t)},Uu.toString=Uu.valueOf=Uu.val=Uu.toJSON=Uu[Symbol.for(`nodejs.util.inspect.custom`)]=function(){var e=this,t=Yu(e),n=e.constructor;return nd(e,t<=n.toExpNeg||t>=n.toExpPos)};function Wu(e,t){var n,r,i,a,o,s,c,l,u=e.constructor,d=u.precision;if(!e.s||!t.s)return t.s||(t=new u(e)),ju?ed(t,d):t;if(c=e.d,l=t.d,o=e.e,i=t.e,c=c.slice(),a=o-i,a){for(a<0?(r=c,a=-a,s=l.length):(r=l,i=o,s=c.length),o=Math.ceil(d/Bu),s=o>s?o+1:s+1,a>s&&(a=s,r.length=1),r.reverse();a--;)r.push(0);r.reverse()}for(s=c.length,a=l.length,s-a<0&&(a=s,r=l,l=c,c=r),n=0;a;)n=(c[--a]=c[a]+l[a]+n)/zu|0,c[a]%=zu;for(n&&(c.unshift(n),++i),s=c.length;c[--s]==0;)c.pop();return t.d=c,t.e=i,ju?ed(t,d):t}function Gu(e,t,n){if(e!==~~e||en)throw Error(Nu+e)}function Ku(e){var t,n,r,i=e.length-1,a=``,o=e[0];if(i>0){for(a+=o,t=1;tr?1:-1;else for(i=a=0;it[i]?1:-1;break}return a}function n(e,t,n){for(var r=0;n--;)e[n]-=r,r=+(e[n]1;)e.shift()}return function(r,i,a,o){var s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T=r.constructor,E=r.s==i.s?1:-1,D=r.d,O=i.d;if(!r.s)return new T(r);if(!i.s)throw Error(Mu+`Division by zero`);for(c=r.e-i.e,C=O.length,x=D.length,p=new T(E),m=p.d=[],l=0;O[l]==(D[l]||0);)++l;if(O[l]>(D[l]||0)&&--c,v=a==null?a=T.precision:o?a+(Yu(r)-Yu(i))+1:a,v<0)return new T(0);if(v=v/Bu+2|0,l=0,C==1)for(u=0,O=O[0],v++;(l1&&(O=e(O,u),D=e(D,u),C=O.length,x=D.length),b=C,h=D.slice(0,C),g=h.length;g=zu/2&&++S;do u=0,s=t(O,h,C,g),s<0?(_=h[0],C!=g&&(_=_*zu+(h[1]||0)),u=_/S|0,u>1?(u>=zu&&(u=zu-1),d=e(O,u),f=d.length,g=h.length,s=t(d,h,f,g),s==1&&(u--,n(d,C16)throw Error(Pu+Yu(e));if(!e.s)return new u(Ru);for(t==null?(ju=!1,s=d):s=t,o=new u(.03125);e.abs().gte(.1);)e=e.times(o),l+=5;for(r=Math.log(Iu(2,l))/Math.LN10*2+5|0,s+=r,n=i=a=new u(Ru),u.precision=s;;){if(i=ed(i.times(e),s),n=n.times(++c),o=a.plus(qu(i,n,s)),Ku(o.d).slice(0,s)===Ku(a.d).slice(0,s)){for(;l--;)a=ed(a.times(a),s);return u.precision=d,t==null?(ju=!0,ed(a,d)):a}a=o}}function Yu(e){for(var t=e.e*Bu,n=e.d[0];n>=10;n/=10)t++;return t}function Xu(e,t,n){if(t>e.LN10.sd())throw ju=!0,n&&(e.precision=n),Error(Mu+`LN10 precision limit exceeded`);return ed(new e(e.LN10),t)}function Zu(e){for(var t=``;e--;)t+=`0`;return t}function Qu(e,t){var n,r,i,a,o,s,c,l,u,d=1,f=10,p=e,m=p.d,h=p.constructor,g=h.precision;if(p.s<1)throw Error(Mu+(p.s?`NaN`:`-Infinity`));if(p.eq(Ru))return new h(0);if(t==null?(ju=!1,l=g):l=t,p.eq(10))return t??(ju=!0),Xu(h,l);if(l+=f,h.precision=l,n=Ku(m),r=n.charAt(0),a=Yu(p),Math.abs(a)<0x5543df729c000){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)p=p.times(e),n=Ku(p.d),r=n.charAt(0),d++;a=Yu(p),r>1?(p=new h(`0.`+n),a++):p=new h(r+`.`+n.slice(1))}else return c=Xu(h,l+2,g).times(a+``),p=Qu(new h(r+`.`+n.slice(1)),l-f).plus(c),h.precision=g,t==null?(ju=!0,ed(p,g)):p;for(s=o=p=qu(p.minus(Ru),p.plus(Ru),l),u=ed(p.times(p),l),i=3;;){if(o=ed(o.times(u),l),c=s.plus(qu(o,new h(i),l)),Ku(c.d).slice(0,l)===Ku(s.d).slice(0,l))return s=s.times(2),a!==0&&(s=s.plus(Xu(h,l+2,g).times(a+``))),s=qu(s,new h(d),l),h.precision=g,t==null?(ju=!0,ed(s,g)):s;s=c,i+=2}}function $u(e,t){var n,r,i;for((n=t.indexOf(`.`))>-1&&(t=t.replace(`.`,``)),(r=t.search(/e/i))>0?(n<0&&(n=r),n+=+t.slice(r+1),t=t.substring(0,r)):n<0&&(n=t.length),r=0;t.charCodeAt(r)===48;)++r;for(i=t.length;t.charCodeAt(i-1)===48;)--i;if(t=t.slice(r,i),t){if(i-=r,n=n-r-1,e.e=Fu(n/Bu),e.d=[],r=(n+1)%Bu,n<0&&(r+=Bu),rHu||e.e<-Hu))throw Error(Pu+n)}else e.s=0,e.e=0,e.d=[0];return e}function ed(e,t,n){var r,i,a,o,s,c,l,u,d=e.d;for(o=1,a=d[0];a>=10;a/=10)o++;if(r=t-o,r<0)r+=Bu,i=t,l=d[u=0];else{if(u=Math.ceil((r+1)/Bu),a=d.length,u>=a)return e;for(l=a=d[u],o=1;a>=10;a/=10)o++;r%=Bu,i=r-Bu+o}if(n!==void 0&&(a=Iu(10,o-i-1),s=l/a%10|0,c=t<0||d[u+1]!==void 0||l%a,c=n<4?(s||c)&&(n==0||n==(e.s<0?3:2)):s>5||s==5&&(n==4||c||n==6&&(r>0?i>0?l/Iu(10,o-i):0:d[u-1])%10&1||n==(e.s<0?8:7))),t<1||!d[0])return c?(a=Yu(e),d.length=1,t=t-a-1,d[0]=Iu(10,(Bu-t%Bu)%Bu),e.e=Fu(-t/Bu)||0):(d.length=1,d[0]=e.e=e.s=0),e;if(r==0?(d.length=u,a=1,u--):(d.length=u+1,a=Iu(10,Bu-r),d[u]=i>0?(l/Iu(10,o-i)%Iu(10,i)|0)*a:0),c)for(;;)if(u==0){(d[0]+=a)==zu&&(d[0]=1,++e.e);break}else{if(d[u]+=a,d[u]!=zu)break;d[u--]=0,a=1}for(r=d.length;d[--r]===0;)d.pop();if(ju&&(e.e>Hu||e.e<-Hu))throw Error(Pu+Yu(e));return e}function td(e,t){var n,r,i,a,o,s,c,l,u,d,f=e.constructor,p=f.precision;if(!e.s||!t.s)return t.s?t.s=-t.s:t=new f(e),ju?ed(t,p):t;if(c=e.d,d=t.d,r=t.e,l=e.e,c=c.slice(),o=l-r,o){for(u=o<0,u?(n=c,o=-o,s=d.length):(n=d,r=l,s=c.length),i=Math.max(Math.ceil(p/Bu),s)+2,o>i&&(o=i,n.length=1),n.reverse(),i=o;i--;)n.push(0);n.reverse()}else{for(i=c.length,s=d.length,u=i0;--i)c[s++]=0;for(i=d.length;i>o;){if(c[--i]0?a=a.charAt(0)+`.`+a.slice(1)+Zu(r):o>1&&(a=a.charAt(0)+`.`+a.slice(1)),a=a+(i<0?`e`:`e+`)+i):i<0?(a=`0.`+Zu(-i-1)+a,n&&(r=n-o)>0&&(a+=Zu(r))):i>=o?(a+=Zu(i+1-o),n&&(r=n-i-1)>0&&(a=a+`.`+Zu(r))):((r=i+1)0&&(i+1===o&&(a+=`.`),a+=Zu(r))),e.s<0?`-`+a:a}function rd(e,t){if(e.length>t)return e.length=t,!0}function id(e){var t,n,r;function i(e){var t=this;if(!(t instanceof i))return new i(e);if(t.constructor=i,e instanceof i)t.s=e.s,t.e=e.e,t.d=(e=e.d)?e.slice():e;else{if(typeof e==`number`){if(e*0!=0)throw Error(Nu+e);if(e>0)t.s=1;else if(e<0)e=-e,t.s=-1;else{t.s=0,t.e=0,t.d=[0];return}if(e===~~e&&e<1e7){t.e=0,t.d=[e];return}return $u(t,e.toString())}if(typeof e!=`string`)throw Error(Nu+e);if(e.charCodeAt(0)===45?(e=e.slice(1),t.s=-1):t.s=1,Lu.test(e))$u(t,e);else throw Error(Nu+e)}}if(i.prototype=Uu,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.clone=id,i.config=i.set=ad,e===void 0&&(e={}),e)for(r=[`precision`,`rounding`,`toExpNeg`,`toExpPos`,`LN10`],t=0;t=i[t+1]&&r<=i[t+2])this[n]=r;else throw Error(Nu+n+`: `+r)}if((r=e[n=`LN10`])!==void 0){if(r==Math.LN10)this[n]=new this(r);else throw Error(Nu+n+`: `+r)}return this}Ru=new(id(Au))(1);var W;(function(e){e.AED=`aed`,e.AFN=`afn`,e.ALL=`all`,e.AMD=`amd`,e.ANG=`ang`,e.AOA=`aoa`,e.ARS=`ars`,e.AUD=`aud`,e.AWG=`awg`,e.AZN=`azn`,e.BAM=`bam`,e.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){var n=`__lodash_hash_undefined__`,r=9007199254740991,i=`[object Arguments]`,a=`[object Array]`,o=`[object Boolean]`,s=`[object Date]`,c=`[object Error]`,l=`[object Function]`,u=`[object Map]`,d=`[object Number]`,f=`[object Object]`,p=`[object Promise]`,m=`[object RegExp]`,h=`[object Set]`,g=`[object String]`,_=`[object Symbol]`,v=`[object WeakMap]`,y=`[object ArrayBuffer]`,b=`[object DataView]`,x=`[object Float32Array]`,S=`[object Float64Array]`,C=`[object Int8Array]`,w=`[object Int16Array]`,T=`[object Int32Array]`,E=`[object Uint8Array]`,D=`[object Uint8ClampedArray]`,O=`[object Uint16Array]`,k=`[object Uint32Array]`,A=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,j=/^\w*$/,ee=/^\./,M=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,te=/[\\^$.*+?()[\]{}|]/g,ne=/\\(\\)?/g,re=/^\[object .+?Constructor\]$/,ie=/^(?:0|[1-9]\d*)$/,N={};N[x]=N[S]=N[C]=N[w]=N[T]=N[E]=N[D]=N[O]=N[k]=!0,N[i]=N[a]=N[y]=N[o]=N[b]=N[s]=N[c]=N[l]=N[u]=N[d]=N[f]=N[m]=N[h]=N[g]=N[v]=!1;var ae=typeof Ti==`object`&&Ti&&Ti.Object===Object&&Ti,oe=typeof self==`object`&&self&&self.Object===Object&&self,se=ae||oe||globalThis,ce=t&&!t.nodeType&&t,le=ce&&e&&!e.nodeType&&e,P=le&&le.exports===ce&&ae.process,ue=function(){try{return P&&P.binding(`util`)}catch{}}(),de=ue&&ue.isTypedArray;function fe(e,t){for(var n=-1,r=e?e.length:0;++n-1}function ot(e,t){var n=this.__data__,r=Ct(n,e);return r<0?n.push([e,t]):n[r][1]=t,this}tt.prototype.clear=nt,tt.prototype.delete=rt,tt.prototype.get=it,tt.prototype.has=at,tt.prototype.set=ot;function st(e){var t=-1,n=e?e.length:0;for(this.clear();++ts))return!1;var l=a.get(e);if(l&&a.get(t))return l==t;var u=-1,d=!0,f=i&1?new pt:void 0;for(a.set(e,t),a.set(t,e);++u-1&&e%1==0&&e-1&&e%1==0&&e<=r}function gn(e){var t=typeof e;return!!e&&(t==`object`||t==`function`)}function _n(e){return!!e&&typeof e==`object`}function vn(e){return typeof e==`symbol`||_n(e)&&De.call(e)==_}var yn=de?ge(de):Pt;function bn(e){return e==null?``:Bt(e)}function xn(e,t,n){var r=e==null?void 0:Dt(e,t);return r===void 0?n:r}function Sn(e,t){return e!=null&&Xt(e,t,kt)}function Cn(e){return fn(e)?St(e):It(e)}function wn(e,t,n){var r=dn(e)||yn(e);if(t=Ft(t),n==null){if(r||gn(e)){var i=e.constructor;n=r?dn(e)?new i:[]:mn(i)?wt(je(e)):{}}else n={}}return(r?fe:Et)(e,function(e,r,i){return t(n,e,r,i)}),n}function Tn(e){return e}function En(e){return Qt(e)?me(on(e)):zt(e)}e.exports=wn})(od,od.exports)),od.exports}cd();var{Commands:ld}=Xs,ud=[`identify`,`guilds.members.read`];function dd(e,t){if(e instanceof vi)return e;if(typeof e==`object`&&e&&`code`in e){let n=e.code,r=Object.values(Ss).filter(e=>typeof e==`number`);if(typeof n==`number`&&r.includes(n))return new vi(`${t}_${n}`)}return new vi(t)}var fd=15e3,pd=12e4,md=15e3;function hd(e=window.location.search){let t=new URLSearchParams(e),n=t.getAll(`frame_id`),r=t.getAll(`platform`);if(n.length!==1||n[0]===void 0||n[0].length===0||n[0].length>255||r.length!==1||![`desktop`,`mobile`].includes(r[0]??``))throw new vi(`invalid_launch`)}async function gd(e,t,n,r,i){let a=null,o=new Promise((e,n)=>{t!==void 0&&(a=()=>n(new vi(`cancelled`)),t.addEventListener(`abort`,a,{once:!0}),t.aborted&&a())}),s=null,c=new Promise((e,t)=>{s=setTimeout(()=>t(new vi(r)),i)}),l=Promise.resolve().then(()=>{if(t?.aborted)throw new vi(`cancelled`);return e()}).catch(e=>{throw dd(e,n)});try{return await Promise.race([l,o,c])}finally{s!==null&&clearTimeout(s),t!==void 0&&a!==null&&t.removeEventListener(`abort`,a)}}var _d=class{makeSDK;sdk=null;authenticated=!1;closed=!1;constructor(e=e=>new Ou(e)){this.makeSDK=e}async authorize(e){let t=bi();hd();let n=await Si(t,e),r=this.open(n.client_id),i=()=>{if(e?.aborted)throw new vi(`cancelled`)};try{if(i(),await gd(()=>r.ready(),e,`sdk_ready_failed`,`sdk_ready_timeout`,fd),i(),r.instanceId!==t)throw new vi(`instance_mismatch`);let a=await gd(()=>r.commands.authorize({client_id:n.client_id,response_type:`code`,state:n.state,prompt:`none`,scope:[...ud]}),e,`authorize_failed`,`authorize_timeout`,pd);i();let o=await Ci(a.code,n.state,e);if(i(),!this.authenticated){if(await gd(()=>r.commands.authenticate({access_token:o.access_token}),e,`sdk_authenticate_failed`,`sdk_authenticate_timeout`,md)==null)throw new vi(`sdk_authenticate_failed`);this.authenticated=!0,i()}let s=o.ticket;return{sdk:r,bootstrap:n,player:o.player,takeTicket:()=>{let e=s;return s=null,e},destroy:()=>{s=null}}}catch(t){throw e?.aborted?new vi(`cancelled`):new vi(dd(t,`authorization_failed`).code,!0)}}close(){if(!this.closed&&(this.closed=!0,this.sdk!==null))try{this.sdk.close(xs.CLOSE_NORMAL,`Hands session closed`)}catch{}}open(e){if(this.closed)throw new vi(`cancelled`);if(this.sdk!==null)return this.sdk;try{this.sdk=this.makeSDK(e)}catch(e){throw new vi(dd(e,`sdk_initialization_failed`).code,!0)}return this.sdk}},vd={Digit1:`corner_cut`,Numpad1:`corner_cut`,Digit2:`corner_swelling`,Numpad2:`corner_swelling`,Digit3:`corner_breath`,Numpad3:`corner_breath`},yd={2:`corner_cut`,3:`corner_swelling`,1:`corner_breath`},bd=[{kind:`corner_cut`,choice:`cut`,key:`1`,title:`Close the cut`},{kind:`corner_swelling`,choice:`swelling`,key:`2`,title:`Bring down the swelling`},{kind:`corner_breath`,choice:`breath`,key:`3`,title:`Catch your breath`}],xd={cut:`Your corner is closing the cut.`,swelling:`Your corner is bringing the swelling down.`,breath:`Your corner is getting your breath back.`,balanced:`Your corner did a little of everything.`},Sd=1500,Cd=1e3;function wd(e){return e<150?`small`:e<350?`nasty`:e<550?`deep`:`dangerous`}var Td=(e,t)=>Math.round(Math.max(0,Math.min(1,e/t))*100);function Ed(e){let{trauma:t}=e,n=Math.max(t.left_cut,t.right_cut),r=Math.max(0,n-x.cut.worse_cut),i=Math.max(t.left_eye,t.right_eye),a=Math.max(0,i-x.swelling.eyes),o=i>=p?a0,swelling:Math.max(t.left_eye,t.right_eye)>0||t.swelling>0,breath:!0,balanced:!1}}function Od(){try{return[...navigator.getGamepads?.()??[]].find(e=>e!==null&&e.connected&&e.mapping===`standard`)??null}catch{return null}}var kd=class{pick;now;element;buttons=new Map;details=new Map;status;visible=!1;choice=null;pending=null;shown=null;frozen=null;available=null;padFrame=0;padPrevious=new Set;measuredTop=null;resize=()=>{this.measuredTop=null};keydown=e=>{let t=vd[e.code];t!==void 0&&this.visible&&!e.repeat&&(e.preventDefault(),this.choose(t))};constructor(e,t,n=()=>performance.now()){this.pick=t,this.now=n;let r=document.createElement(`section`);r.className=`corner`,r.dataset.corner=``,r.hidden=!0,r.setAttribute(`aria-label`,`Instructions for your corner`);let i=document.createElement(`p`);i.className=`corner-title`,i.textContent=`YOUR CORNER`;let a=document.createElement(`div`);a.className=`corner-choices`;for(let{kind:e,key:t,title:n}of bd){let r=document.createElement(`button`);r.type=`button`,r.dataset.cornerPick=e;let i=document.createElement(`kbd`);i.textContent=t;let o=document.createElement(`strong`);o.textContent=n;let s=document.createElement(`span`);r.append(i,o,s),r.addEventListener(`click`,()=>this.choose(e)),a.append(r),this.buttons.set(e,r),this.details.set(e,s)}this.status=document.createElement(`p`),this.status.className=`corner-status`,this.status.setAttribute(`role`,`status`),r.append(i,a,this.status),e.append(r),this.element=r,window.addEventListener(`keydown`,this.keydown),window.addEventListener(`resize`,this.resize)}update(e,t,n){let r=e?.fighters.find(e=>e.player_id===t);if(!(n&&e!==null&&e.phase===`rest`&&r!==void 0)||r===void 0){this.setVisible(!1),this.choice=null,this.pending=null,this.shown=null,this.frozen=null;return}this.setVisible(!0),this.choice=r.corner_choice,(this.choice!==null||this.pending!==null&&this.now()-this.pending.at>Sd)&&(this.pending=null);let i=this.choice!==null||this.pending!==null;i||(this.frozen=null);let a=i&&this.frozen!==null?this.frozen:Ed(r);this.shown=a;let o=Dd(r);this.available=o;for(let{kind:e,choice:t}of bd){let n=this.buttons.get(e),r=this.details.get(e);r.textContent!==a[t]&&(r.textContent=a[t]),n.disabled=i||!o[t],n.toggleAttribute(`data-picked`,this.choice===t||this.pending?.kind===e)}let s=this.choice===null?this.pending===null?`Tell your corner what to work on before the bell.`:`Calling it to your corner…`:xd[this.choice];this.status.textContent!==s&&(this.status.textContent=s)}choose(e){if(!this.visible||this.choice!==null||this.pending!==null)return;let t=bd.find(t=>t.kind===e)?.choice;if(t!==void 0&&this.available?.[t]!==!1&&this.pick(e)){this.frozen=this.shown,this.pending={kind:e,at:this.now()};for(let[t,n]of this.buttons)n.disabled=!0,n.toggleAttribute(`data-picked`,t===e);this.status.textContent=`Calling it to your corner…`}}setVisible(e){if(e!==this.visible){if(this.visible=e,this.element.hidden=!e,this.measuredTop=null,this.padPrevious.clear(),e){let e=Od();for(let t of Object.keys(yd))e?.buttons[Number(t)]?.pressed===!0&&this.padPrevious.add(Number(t));this.padFrame=requestAnimationFrame(()=>this.pollPad())}else cancelAnimationFrame(this.padFrame)}}top(){if(!this.visible)return null;if(this.measuredTop===null){let e=this.element.getBoundingClientRect();if(e.height<=0)return null;this.measuredTop=e.top-(this.element.parentElement?.getBoundingClientRect().top??0)}return this.measuredTop}pollPad(){if(!this.visible)return;let e=Od();if(e!==null)for(let[t,n]of Object.entries(yd)){let r=Number(t),i=e.buttons[r]?.pressed===!0;i&&!this.padPrevious.has(r)&&this.choose(n),i?this.padPrevious.add(r):this.padPrevious.delete(r)}this.padFrame=requestAnimationFrame(()=>this.pollPad())}destroy(){this.setVisible(!1),window.removeEventListener(`keydown`,this.keydown),window.removeEventListener(`resize`,this.resize),this.element.remove()}},Ad={invalid_launch:`open Hands from a Discord voice channel with Play now`,cancelled:`the session was cancelled`,authorization_failed:`Discord did not authorize the session`,authorize_failed:`Discord did not authorize the session`,authorize_timeout:`Discord took too long to authorize the session`,sdk_ready_failed:`the Discord client did not respond`,sdk_ready_timeout:`the Discord client took too long to respond`,sdk_authenticate_failed:`Discord did not confirm your identity`,sdk_authenticate_timeout:`Discord took too long to confirm your identity`,sdk_initialization_failed:`the Discord client could not start the activity`,instance_mismatch:`this window belongs to a different activity instance`,bootstrap_failed:`the Hands server could not be reached`,token_failed:`the Hands server rejected the sign-in`,invalid_bootstrap:`the Hands server sent an unexpected reply`,invalid_token_response:`the Hands server sent an unexpected reply`,ticket_unavailable:`the session ticket was already used`,protocol_error:`the server and client disagree on the protocol`,unexpected_error:`something unexpected went wrong`,authentication_timeout:`the connection took too long to authenticate`,authentication_required:`the connection was not authenticated`,invalid_ticket:`the session ticket was rejected`,invalid_request:`the server rejected the request`,invalid_input:`the server rejected an input frame`,input_queue_full:`the server could not keep up with the inputs`,rate_limited:`too many requests were sent; wait a moment`,service_busy:`the server is busy right now`,service_unavailable:`the server is unavailable right now`,upstream_unavailable:`Discord is unavailable right now`,room_closed:`the bout has already ended; use Play now to start another`,room_full:`both seats in this bout are taken`,already_in_room:`you are already in a bout in another channel`,match_not_started:`the bout has not started yet`,connection_replaced:`this seat was taken over by a newer connection`,spectator_read_only:`spectators cannot send input`,server_shutting_down:`the server is restarting`,internal_error:`the server hit an internal error`,not_in_activity:`you are not a participant of this activity`,invalid_activity:`this activity instance is not valid`,invalid_state:`the sign-in state expired; retry`,invalid_guild:`this activity belongs to another server`,persistence_failed:`the result could not be saved`,rematch_unavailable:`the ring could not be cleared for a rematch; use Play now to start another bout`,network_unavailable:`the connection to the Hands server could not be opened`,match_abandoned:`both fighters lost their connection and the bout was called off`};function jd(e){if(e===`client_outdated`)return`Hands was updated. Reload to continue (client_outdated).`;let t=Ad[e]??Ad[e.replace(/_\d+$/u,``)];return t===void 0?`Unable to continue (${e}).`:`Unable to continue: ${t} (${e}).`}function Md(){try{if(window.matchMedia?.(`(pointer: coarse)`).matches)return!0}catch{}return(navigator.maxTouchPoints??0)>0&&new URLSearchParams(window.location.search).get(`platform`)===`mobile`}var Nd=[{label:`JAB`,punchClass:`jab`},{label:`STRAIGHT`,punchClass:`straight`},{label:`HOOK`,punchClass:`hook`},{label:`UPPER`,punchClass:`uppercut`}],Pd=[{label:`◀ SLIP`,name:`Slip left`,kind:`slip_left`},{label:`WEAVE`,name:`Weave`,kind:`weave`},{label:`SLIP ▶`,name:`Slip right`,kind:`slip_right`},{label:`PULL`,name:`Pull`,kind:`pull`},{label:`CLINCH`,name:`Clinch`,kind:`clinch`}],Fd=class{sharedActions;root;stickZone;stickBase;stickKnob;pads=[];moves=[];stickPointer=null;stickOrigin={x:0,y:0};moveX=0;moveY=0;body=!1;power=!1;guard=`none`;knockdown=!1;enabled=!0;heldPointers=new Map;heldListener=null;constructor(e,t){this.sharedActions=t,this.root=document.createElement(`div`),this.root.className=`touch-controls`,this.root.setAttribute(`aria-label`,`Touch controls`),this.root.innerHTML=`
-
-
${Pd.map(e=>``).join(``)}
-
- - - - -
-
${Nd.map(e=>``).join(``)}
-
`,e.append(this.root),this.stickZone=this.root.querySelector(`[data-stick]`),this.stickBase=this.root.querySelector(`[data-stick-base]`),this.stickKnob=this.root.querySelector(`[data-stick-knob]`),this.pads.push(...this.root.querySelectorAll(`[data-punch]`)),this.moves.push(...this.root.querySelectorAll(`[data-move]`)),this.bind()}bind(){let e=this.stickZone;e.addEventListener(`pointerdown`,t=>{if(this.stickPointer!==null)return;t.preventDefault(),this.stickPointer=t.pointerId,this.stickOrigin={x:t.clientX,y:t.clientY},e.setPointerCapture(t.pointerId);let n=e.getBoundingClientRect();this.stickBase.style.left=`${t.clientX-n.left}px`,this.stickBase.style.top=`${t.clientY-n.top}px`,this.stickBase.classList.add(`active`),this.updateStick(t.clientX,t.clientY)}),e.addEventListener(`pointermove`,e=>{e.pointerId===this.stickPointer&&(e.preventDefault(),this.updateStick(e.clientX,e.clientY))});let t=e=>{e.pointerId===this.stickPointer&&(this.stickPointer=null,this.moveX=0,this.moveY=0,this.stickKnob.style.transform=`translate(-50%, -50%)`,this.stickBase.classList.remove(`active`),this.heldListener?.())};e.addEventListener(`pointerup`,t),e.addEventListener(`pointercancel`,t);for(let e of this.pads)e.addEventListener(`pointerdown`,t=>{if(!this.enabled)return;t.preventDefault();let n=e.getBoundingClientRect(),r=t.clientX-n.lefte.classList.remove(`pressed`),120)});for(let e of this.moves)e.addEventListener(`pointerdown`,t=>{this.enabled&&!this.knockdown&&(t.preventDefault(),this.sharedActions.push(`touch`,{kind:e.dataset.move}),e.classList.add(`pressed`),window.setTimeout(()=>e.classList.remove(`pressed`),120))});for(let e of this.root.querySelectorAll(`[data-mod], [data-guard]`)){let t=e.dataset.mod??e.dataset.guard??``,n=n=>{n.preventDefault(),e.setPointerCapture(n.pointerId),this.heldPointers.set(n.pointerId,t),this.syncHeld(),e.classList.add(`pressed`)},r=n=>{this.heldPointers.delete(n.pointerId)&&(this.syncHeld(),e.classList.toggle(`pressed`,[...this.heldPointers.values()].includes(t)))};e.addEventListener(`pointerdown`,n),e.addEventListener(`pointerup`,r),e.addEventListener(`pointercancel`,r)}}syncHeld(){let e=[...this.heldPointers.values()];this.body=e.includes(`body`),this.power=e.includes(`power`);let t=e.findLast(e=>e===`guard_high`||e===`guard_low`)??`none`,n=t!==this.guard;this.guard=t,n&&this.heldListener?.()}get powerHeld(){return this.enabled&&this.power}onHeldChange(e){this.heldListener=e}updateStick(e,t){let n=e-this.stickOrigin.x,r=t-this.stickOrigin.y,i=Math.hypot(n,r);i>56&&(n=n/i*56,r=r/i*56),this.stickKnob.style.transform=`translate(calc(-50% + ${n}px), calc(-50% + ${r}px))`;let a=Math.min(1,i/56),o=a<.15?0:(a-.15)/.85,s=i>0?n/Math.max(i,1e-6):0,c=i>0?r/Math.max(i,1e-6):0;this.moveX=Math.round(s*o*1e3)||0,this.moveY=Math.round(-c*o*1e3)||0,this.heldListener?.()}setKnockdown(e){if(this.knockdown!==e){this.knockdown=e,this.root.classList.toggle(`knockdown`,e);for(let[t,n]of this.pads.entries()){let r=n.querySelector(`.touch-pad-label`);r!==null&&(r.textContent=e?t%2==0?`GET UP`:`RHYTHM`:Nd[t].label)}}}setEnabled(e,t=e){this.enabled=e,this.root.classList.toggle(`disabled`,!t),this.root.classList.toggle(`resting`,t&&!e),t?e||this.sharedActions.clearSource(`touch`):this.reset()}frame(){return this.enabled?{moveX:this.moveX,moveY:this.moveY,defense:this.guard,actions:[]}:{moveX:0,moveY:0,defense:`none`,actions:[]}}reset(){this.stickPointer=null,this.moveX=0,this.moveY=0,this.body=!1,this.power=!1,this.guard=`none`,this.heldPointers.clear(),this.stickBase.classList.remove(`active`);for(let e of this.root.querySelectorAll(`.pressed`))e.classList.remove(`pressed`);this.sharedActions.clearSource(`touch`)}destroy(){this.reset(),this.root.remove()}},Id={block:[55,.12,.22],hit:[85,.3,.42],counter_hit:[105,.38,.5],stun:[125,.42,.55],knockdown:[180,.62,.65],parry:[60,.18,.4],body_collapse:[170,.55,.3]},Ld={injury:[150,.55,.6],vomit:[90,.15,.45],finish_him:[180,.65,.3],fatality:[180,.65,.65],death:[170,.5,.12]},Rd=class{settings;constructor(e){this.settings=e}event(e,t=!1){if(!this.settings().haptics)return;let n=Id[e.kind];n!==void 0&&this.rumble(t?[n[0]*1.6,n[1]+.2,n[2]+.15]:n)}gore(e){!this.settings().haptics||e.kind===`death`&&Oe(e.cause)!==null||this.rumble(Ld[e.kind])}rumble(e){let t=this.padActuator();if(t===null)this.vibrate(e[0]);else try{Promise.resolve(t.playEffect(`dual-rumble`,{duration:Math.min(180,Math.max(0,e[0])),strongMagnitude:Math.min(.65,Math.max(0,e[1])),weakMagnitude:Math.min(.65,Math.max(0,e[2]))})).catch(()=>void 0)}catch{}}padActuator(){if(typeof navigator.getGamepads!=`function`)return null;let e;try{e=[...navigator.getGamepads.call(navigator)]}catch{return null}let t=e.find(e=>e!==null&&e.connected&&`vibrationActuator`in e)?.vibrationActuator;return t==null||typeof t.playEffect!=`function`?null:t}vibrate(e){if(Md()&&typeof navigator.vibrate==`function`)try{navigator.vibrate(Math.min(180,Math.max(0,e)))}catch{}}},zd={KeyF:[`left`,`jab`],KeyJ:[`right`,`jab`],KeyR:[`left`,`straight`],KeyU:[`right`,`straight`],KeyG:[`left`,`hook`],KeyH:[`right`,`hook`],KeyT:[`left`,`uppercut`],KeyY:[`right`,`uppercut`]},Bd={KeyZ:{kind:`slip_left`},KeyX:{kind:`slip_right`},KeyC:{kind:`weave`},KeyV:{kind:`pull`},KeyB:{kind:`clinch`},KeyN:{kind:`switch_stance`},KeyM:{kind:`taunt`},Digit1:{kind:`foul`,foul:`low_blow`},Digit2:{kind:`foul`,foul:`headbutt`},ArrowLeft:{kind:`get_up_left`},ArrowRight:{kind:`get_up_right`}},Vd=new Set([...Object.keys(zd),...Object.keys(Bd),`KeyW`,`KeyA`,`KeyS`,`KeyD`,`KeyQ`,`KeyE`,`ShiftLeft`,`ShiftRight`,`AltLeft`,`AltRight`]),Hd=[`Move: W up · S down · A left · D right`,`High / low guard: Q / E`,`Left/right jab: F / J`,`Left/right straight: R / U`,`Left/right hook: G / H`,`Left/right uppercut: T / Y`,`Body: Shift · Power: hold Alt (Option ⌥ on a Mac) with the punch, slower to throw and far heavier`,`Slip: Z / X · Weave: C · Pull: V`,`Clinch: B · Stance: N · Taunt: M · Fouls (on purpose): Shift+1 low blow / Shift+2 headbutt`,`Get-up rhythm: ← / →`,`Camera: K cycles broadcast, close and over the shoulder (behind your fighter, W walks at the opponent and A / D circle him).`,`Style pick before the bout: arrow keys choose · Enter settles · 1–5 settle on that card at once.`,`Controller move: left stick. High / low guard: left / right shoulder (independent of punches).`,`Controller face classes: bottom jab · right straight · left hook · top uppercut.`,`Controller face hand: hold D-pad left for left hand or D-pad right for right hand, then press a face punch; otherwise punches use the right hand. A direction used for a punch is consumed and does not evade.`,`Controller modifiers: left trigger body · right trigger power.`,`Controller actions: left stick press clinch · right stick press switch stance · hold right trigger + right stick press to taunt · D-pad up weave · D-pad down pull · tap and release D-pad left/right to slip; while down, D-pad left/right performs the private get-up rhythm immediately.`,`Controller fouls: View/Back low blow · Menu/Start headbutt.`,`Controller style pick: D-pad or left stick to choose · bottom face button settles.`,`Right-stick gesture: horizontal 0–22.5° hook · 22.5–45° jab · 45–70° straight · 70–90° uppercut; left/right direction selects hand.`,`Between rounds, tell your corner what to work on: 1 close the cut · 2 bring down the swelling · 3 catch your breath (controller: left, top or right face button; or tap).`,`Touch: drag the left side to move · tap a punch pad's left or right half for that hand · hold BODY, POWER, GUARD or LOW · tap ◀ SLIP, SLIP ▶, WEAVE, PULL or CLINCH.`],Ud=`Move WASD · Jab F/J · Straight R/U · Hook G/H · Uppercut T/Y · Guard Q/E · Body Shift · Power Alt/Option ⌥`,Wd=`Drag on the left to move · Tap the pads to punch, L or R hand · Hold BODY, POWER or GUARD · Tap SLIP, WEAVE, PULL or CLINCH`,Gd=`Drag left to move · Tap pads to punch · Hold GUARD`,Kd=(e,t)=>e?t<480?Gd:Wd:Ud,qd=[{title:`Keyboard`,items:Hd.filter(e=>!e.startsWith(`Controller`)&&!e.startsWith(`Right-stick`)&&!e.startsWith(`Between rounds`)&&!e.startsWith(`Touch`))},{title:`Between rounds`,items:Hd.filter(e=>e.startsWith(`Between rounds`))},{title:`Controller`,items:Hd.filter(e=>e.startsWith(`Controller`)||e.startsWith(`Right-stick`))},{title:`Touch`,items:Hd.filter(e=>e.startsWith(`Touch`))}];function Jd(e,t){return e.kind===t.kind?e.kind===`punch`&&t.kind===`punch`?e.hand===t.hand&&e.class===t.class&&e.target===t.target&&e.power===t.power:e.kind===`foul`&&t.kind===`foul`?e.foul===t.foul:!0:!1}function Yd(e,t,n){if(n<1||e.length>0&&Jd(e.at(-1),t))return;let r=e.length-n+1;r>0&&e.splice(0,r),e.push(t)}var Xd=class{maximum;queue=[];counter=0;listener=null;constructor(e=1){this.maximum=e}setListener(e){this.listener=e}push(e,t){if(this.maximum<1)return;let n=this.queue.at(-1);if(n!==void 0&&Jd(n.action,t)){n.source=e;return}let r={...t,id:`c${this.counter+=1}`},i=this.queue.length-this.maximum+1;i>0&&this.queue.splice(0,i),this.queue.push({action:r,source:e}),this.listener?.(r)}clear(){this.queue.length=0}clearSource(e){let t=this.queue.filter(t=>t.source!==e);this.queue.splice(0,this.queue.length,...t)}drain(e){return this.queue.splice(0,e).map(e=>e.action)}};function Zd(e,t,n=.18){let r=Math.hypot(e,t);if(!Number.isFinite(r)||r<=n)return{x:0,y:0};let i=(Math.min(1,r)-n)/(1-n);return{x:e/r*i,y:t/r*i}}var Qd=(e,t)=>{let n=Math.atan2(Math.abs(t),Math.abs(e))*180/Math.PI;return n<22.5?`hook`:n<45?`jab`:n<70?`straight`:`uppercut`},$d=class{active=!1;hand=`right`;target=`head`;power=`normal`;peak={x:0,y:0};peakMagnitude=0;update(e,t,n,r){let i=Math.hypot(e,t);if(!this.active&&i>=.55&&Math.abs(e)>=.12)return this.active=!0,this.hand=e<0?`left`:`right`,this.target=n?`body`:`head`,this.power=r?`power`:`normal`,this.peak={x:e,y:t},this.peakMagnitude=i,null;if(!this.active)return null;if(i>this.peakMagnitude&&(this.peak={x:e,y:t},this.peakMagnitude=i),i<=.25){let e={kind:`punch`,hand:this.hand,class:Qd(this.peak.x,this.peak.y),target:this.target,power:this.power};return this.reset(),e}return null}reset(){this.active=!1,this.peak={x:0,y:0},this.peakMagnitude=0}},ef=[`jab`,`straight`,`hook`,`uppercut`],tf=(e,t)=>e.buttons[t]?.pressed===!0;function nf(){let e=navigator.getGamepads;if(typeof e!=`function`)return null;try{return[...e.call(navigator)].find(e=>e!==null&&e.connected&&e.mapping===`standard`)??null}catch{return null}}var rf=class{maximumQueue;sharedActions;gesture=new $d;queue=[];previous=new Set;selectorConsumed=new Map;raf=0;currentId=null;moveX=0;moveY=0;defense=`none`;knockdown=!1;enabled=!0;trigger=!1;heldListener=null;disconnect=e=>{e.gamepad.id===this.currentId&&this.reset()};constructor(e=1,t){this.maximumQueue=e,this.sharedActions=t,window.addEventListener(`gamepaddisconnected`,this.disconnect),this.raf=requestAnimationFrame(()=>this.poll())}onHeldChange(e){this.heldListener=e}push(e){this.sharedActions===void 0?Yd(this.queue,e,this.maximumQueue):this.sharedActions.push(`gamepad`,e)}poll(){if(!this.enabled){this.reset(),this.schedulePoll();return}let e=nf();if(e===null){this.currentId!==null&&this.reset(),this.schedulePoll();return}this.currentId!==null&&this.currentId!==e.id&&this.reset(),this.currentId=e.id;let t=Zd(e.axes[0]??0,e.axes[1]??0),n=Math.round(t.x*1e3),r=Math.round(-t.y*1e3),i=tf(e,4)?`guard_high`:tf(e,5)?`guard_low`:`none`,a=n!==this.moveX||r!==this.moveY||i!==this.defense;this.moveX=n,this.moveY=r,this.defense=i,a&&this.heldListener?.(),this.trigger=tf(e,7);let o=this.gesture.update(e.axes[2]??0,e.axes[3]??0,tf(e,6),this.trigger);o!==null&&this.push(o);let s=ef.some((t,n)=>tf(e,n)&&!this.previous.has(n));for(let t of[14,15]){let n=tf(e,t),r=this.previous.has(t);this.knockdown?(n&&!r&&this.push({kind:t===14?`get_up_left`:`get_up_right`}),this.selectorConsumed.delete(t)):n?(r||this.selectorConsumed.set(t,!1),s&&this.selectorConsumed.set(t,!0)):r&&(this.selectorConsumed.get(t)===!1&&this.push({kind:t===14?`slip_left`:`slip_right`}),this.selectorConsumed.delete(t))}for(let t=0;tthis.poll())}setKnockdown(e){this.knockdown=e}get powerHeld(){return this.enabled&&this.trigger}setEnabled(e){this.enabled=e,e||this.reset()}frame(e=4){let t=this.sharedActions===void 0?this.queue.splice(0,e):[];return{moveX:this.moveX,moveY:this.moveY,defense:this.defense,actions:t}}reset(){this.currentId=null,this.moveX=this.moveY=0,this.defense=`none`,this.trigger=!1,this.queue.length=0,this.sharedActions?.clearSource(`gamepad`),this.previous.clear(),this.selectorConsumed.clear(),this.gesture.reset()}destroy(){cancelAnimationFrame(this.raf),window.removeEventListener(`gamepaddisconnected`,this.disconnect),this.reset()}},af=new Set([`KeyW`,`KeyA`,`KeyS`,`KeyD`,`KeyQ`,`KeyE`]),of=new Set([`ShiftLeft`,`ShiftRight`,`AltLeft`,`AltRight`]),sf=class{target;maximumQueue;sharedActions;held=new Set;queue=[];enabled=!0;altFlag=!1;heldListener=null;keydown=e=>{if(this.altFlag=e.altKey,!Vd.has(e.code))return;if(!this.enabled){this.hold(e.code,e.repeat);return}if(e.preventDefault(),this.hold(e.code,e.repeat),e.repeat)return;let t=zd[e.code];if(t!==void 0)this.push({kind:`punch`,hand:t[0],class:t[1],target:this.hasShift(e)?`body`:`head`,power:this.alt?`power`:`normal`});else{let t=Bd[e.code];t!==void 0&&(t.kind!==`foul`||this.hasShift(e))&&this.push(t)}};keyup=e=>{this.altFlag=e.altKey,e.code===`MetaLeft`||e.code===`MetaRight`?this.letGo(e=>!of.has(e)):Vd.has(e.code)&&(this.enabled&&e.preventDefault(),this.letGo(t=>t===e.code))};visibility=()=>{document.hidden&&this.reset()};blur=()=>this.reset();constructor(e=window,t=1,n){this.target=e,this.maximumQueue=t,this.sharedActions=n,e.addEventListener(`keydown`,this.keydown),e.addEventListener(`keyup`,this.keyup),e.addEventListener(`blur`,this.blur),document.addEventListener(`visibilitychange`,this.visibility)}onHeldChange(e){this.heldListener=e}hold(e,t){t&&this.held.has(e)||(this.held.delete(e),this.held.add(e),af.has(e)&&this.heldListener?.())}letGo(e){let t=!1;for(let n of this.held)e(n)&&(this.held.delete(n),t||=af.has(n));t&&this.heldListener?.()}axis(e,t){let n=0;for(let r of this.held)r===e?n=1:r===t&&(n=-1);return n}hasShift(e){return e.shiftKey||this.held.has(`ShiftLeft`)||this.held.has(`ShiftRight`)}get alt(){return this.altFlag||this.held.has(`AltLeft`)||this.held.has(`AltRight`)}get powerHeld(){return this.enabled&&this.alt}push(e){this.sharedActions===void 0?Yd(this.queue,e,this.maximumQueue):this.sharedActions.push(`keyboard`,e)}setEnabled(e){this.enabled=e,e||(this.queue.length=0,this.sharedActions?.clearSource(`keyboard`))}frame(e=4){if(!this.enabled)return{moveX:0,moveY:0,defense:`none`,actions:[]};let t=this.axis(`KeyD`,`KeyA`)*1e3,n=this.axis(`KeyW`,`KeyS`)*1e3;t!==0&&n!==0&&(t=Math.sign(t)*707,n=Math.sign(n)*707);let r=this.axis(`KeyQ`,`KeyE`);return{moveX:t,moveY:n,defense:r>0?`guard_high`:r<0?`guard_low`:`none`,actions:this.sharedActions===void 0?this.queue.splice(0,e):[]}}reset(){this.letGo(()=>!0),this.altFlag=!1,this.queue.length=0,this.sharedActions?.clearSource(`keyboard`)}destroy(){this.reset(),this.target.removeEventListener(`keydown`,this.keydown),this.target.removeEventListener(`keyup`,this.keyup),this.target.removeEventListener(`blur`,this.blur),document.removeEventListener(`visibilitychange`,this.visibility)}};function cf(e,t,n,r){let i=e=>Math.max(-1e3,Math.min(1e3,Math.round(e)))||0;return{moveX:i(-r*e+n*t),moveY:i(-n*e-r*t)}}var lf=(e,t,n,r)=>Math.abs(Math.atan2(e*r-t*n,e*n+t*r)),uf=Math.PI/4-.01,df=Math.PI/8,ff=300,pf=class{actions=new Xd(1);keyboard;gamepad;touch=null;reset=()=>{this.keyboard.reset(),this.gamepad.reset(),this.touch?.reset(),this.actions.clear(),this.gamepad.setKnockdown(!1)};heldChanged=()=>{let e=this.held(),t=this.sentHeld,n=e.moveX!==0||e.moveY!==0,r=t.moveX!==0||t.moveY!==0;(e.defense!==t.defense||n!==r||n&&(lf(e.moveX,e.moveY,t.moveX,t.moveY)>df||Math.abs(Math.hypot(e.moveX,e.moveY)-Math.hypot(t.moveX,t.moveY))>ff))&&(this.sentHeld=e,this.heldListener?.())};constructor(){this.keyboard=new sf(window,1,this.actions),this.gamepad=new rf(1,this.actions),this.keyboard.onHeldChange(this.heldChanged),this.gamepad.onHeldChange(this.heldChanged),window.addEventListener(`blur`,this.reset),document.addEventListener(`visibilitychange`,this.visibility)}visibility=()=>{document.hidden&&this.reset()};attachTouch(e,t=Md()){this.touch===null&&t&&(this.touch=new Fd(e,this.actions),this.touch.onHeldChange(this.heldChanged))}setActive(e,t=e){this.keyboard.setEnabled(e),this.gamepad.setEnabled(e),this.touch?.setEnabled(e,t)}setKnockdown(e){this.gamepad.setKnockdown(e),this.touch?.setKnockdown(e)}onAction(e){this.actions.setListener(e)}get powerHeld(){return this.keyboard.powerHeld||this.gamepad.powerHeld||this.touch?.powerHeld===!0}onHeldChange(e){this.heldListener=e}heldListener=null;sentHeld={moveX:0,moveY:0,defense:`none`};setViewForward(e){this.viewForward=e}viewForward=null;latched=null;held(){let e=this.keyboard.frame(0),t=this.gamepad.frame(0),n=this.touch?.frame()??null,r=t.moveX===0?n!==null&&n.moveX!==0?n.moveX:e.moveX:t.moveX,i=t.moveY===0?n!==null&&n.moveY!==0?n.moveY:e.moveY:t.moveY,a=t.defense===`none`?n!==null&&n.defense!==`none`?n.defense:e.defense:t.defense;if(r===0&&i===0)return this.latched=null,{moveX:r,moveY:i,defense:a};let o=this.viewForward?.()??null,s=this.latched;s===null||lf(r,i,s.moveX,s.moveY)>uf?this.latched={moveX:r,moveY:i,forward:o===null?null:{x:o.x,z:o.z}}:s.forward!==null&&o!==null&&(s.forward.x=o.x,s.forward.z=o.z);let c=this.latched.forward;if(c===null)return{moveX:r,moveY:i,defense:a};let l=cf(r,i,c.x,c.z);return{moveX:l.moveX,moveY:l.moveY,defense:a}}frame(){return{...this.held(),actions:this.actions.drain(4)}}destroy(){window.removeEventListener(`blur`,this.reset),document.removeEventListener(`visibilitychange`,this.visibility),this.keyboard.destroy(),this.gamepad.destroy(),this.touch?.destroy()}},mf=(e,t,n)=>e+(t-e)*n,hf=(e,t,n)=>({...t,x:mf(e.x,t.x,n),y:mf(e.y,t.y,n),facing:mf(e.facing,t.facing,n),facing_x:mf(e.facing_x,t.facing_x,n),facing_y:mf(e.facing_y,t.facing_y,n),velocity_x:mf(e.velocity_x,t.velocity_x,n),velocity_y:mf(e.velocity_y,t.velocity_y,n),stamina:mf(e.stamina,t.stamina,n),maximum_stamina:mf(e.maximum_stamina,t.maximum_stamina,n),conditioning:mf(e.conditioning,t.conditioning,n),guard:mf(e.guard,t.guard,n),poise:mf(e.poise,t.poise,n)}),gf=(e,t,n)=>({...t,x:mf(e.x,t.x,n),y:mf(e.y,t.y,n),facing_x:mf(e.facing_x,t.facing_x,n),facing_y:mf(e.facing_y,t.facing_y,n),velocity_x:mf(e.velocity_x,t.velocity_x,n),velocity_y:mf(e.velocity_y,t.velocity_y,n)}),_f=1.5,vf=6,yf=.5,bf=2500,xf=1,Sf=.04,Cf=100,wf=.01,Tf=4,Ef=class{maximum;tickRate;initialDelayTicks;snapshots=[];offsetTicks=null;delayTicks;lastStarvationMs=-1/0;lastFrameMs=null;behindPushes=0;needs=[];constructor(e=8,t=30,n=2){this.maximum=e,this.tickRate=t,this.initialDelayTicks=n,this.delayTicks=n}get interpolationDelayTicks(){return this.delayTicks}push(e,t){let n=this.snapshots.at(-1);if(n!==void 0&&e.tick<=n.tick)return!1;if(this.snapshots.push(e),this.snapshots.length>this.maximum&&this.snapshots.shift(),t!==void 0&&Number.isFinite(t)){let n=e.tick-t*this.tickRate/1e3;this.offsetTicks!==null&&n=Tf&&this.restartClock(),this.offsetTicks===null?(this.offsetTicks=n,this.need(t,this.initialDelayTicks)):this.offsetTicks=Math.max(n,this.offsetTicks-wf),this.need(t,this.offsetTicks-n+xf)}return!0}resync(){this.restartClock()}restartClock(){this.offsetTicks=null,this.delayTicks=this.initialDelayTicks,this.lastStarvationMs=-1/0,this.behindPushes=0,this.needs.length=0}need(e,t){for(;this.needs.length>0&&this.needs.at(-1).ticks<=t;)this.needs.pop();this.needs.push({atMs:e,ticks:t})}recentNeed(e){for(;this.needs.length>0&&this.needs[0].atMs<=e-bf;)this.needs.shift();return this.needs[0]?.ticks??0}latest(){return this.snapshots.at(-1)??null}renderTick(e){let t=this.latest();if(t===null)return 0;let n=this.snapshots[0].tick;if(this.offsetTicks===null)return Math.max(n,t.tick-1);let r=this.lastFrameMs===null?0:Math.min(Cf,Math.max(0,e-this.lastFrameMs));this.lastFrameMs=e;let i=e*this.tickRate/1e3+this.offsetTicks-this.delayTicks;if(i>t.tick+.25)e-this.lastStarvationMs>250&&(this.lastStarvationMs=e,this.delayTicks=Math.min(vf,this.delayTicks+yf),this.need(e,this.delayTicks));else{let t=Math.max(_f,this.recentNeed(e));this.delayTicks>t&&(this.delayTicks=Math.max(t,this.delayTicks-Sf*r*this.tickRate/1e3))}return Math.min(t.tick,Math.max(n,i))}sample(e){let t=this.snapshots.findIndex(t=>t.tick>=e);if(t<=0)return this.snapshots[Math.max(0,t)]??this.latest();let n=this.snapshots[t-1],r=this.snapshots[t];if(n.phase!==r.phase||n.fighters.some((e,t)=>e.knockdowns!==r.fighters[t]?.knockdowns))return r;let i=Math.max(0,Math.min(1,(e-n.tick)/Math.max(1,r.tick-n.tick)));return{...r,fighters:[hf(n.fighters[0],r.fighters[0],i),hf(n.fighters[1],r.fighters[1],i)],referee:gf(n.referee,r.referee,i)}}clear(){this.snapshots.length=0,this.offsetTicks=null}},Df=class{highest=-1;accept(e){let t=new Set,n=e.filter(e=>e.event_id<=this.highest||t.has(e.event_id)?!1:(t.add(e.event_id),!0)).sort((e,t)=>e.event_id-t.event_id);for(let e of n)this.highest=Math.max(this.highest,e.event_id);return n}reset(){this.highest=-1}};function Of(e=window.location){let t=new URL(`/api/hands/ws`,e.origin);if(e.protocol===`https:`)t.protocol=`wss:`;else if(e.protocol===`http:`&&[`localhost`,`127.0.0.1`,`::1`].includes(e.hostname))t.protocol=`ws:`;else throw Error(`insecure_websocket_origin`);return t.search=``,t.hash=``,t.toString()}var kf=1,Af={moveX:0,moveY:0,defense:`none`,actions:[]},jf=33,Mf=8,Nf=50,Pf=20,Ff=10,If=2048;function Lf(e){try{return Dt(e)}catch(t){let n;try{let t=Ge(e);n=typeof t==`object`&&t&&`version`in t?t.version:void 0}catch{}throw typeof n==`number`&&n!==6?new vi(`client_outdated`,!0):t}}var Rf=class{getInput;callbacks;makeSocket;now;socket=null;reconnectTicket;reconnectTimer=null;opponentPauseTimer=null;inputTimer=null;reconnectDeadline=0;opponentPauseDeadline=0;opponentPaused=!1;attempts=0;nextSequence=0;playerId=null;sentAt=new Map;actionSequences=new Map;latencyMs=null;serverTick=0;role=null;active=!1;resting=!1;boutStarted=!1;disposed=!1;terminal=!1;inputSuppressed=!1;pointerFocus=!1;listenersBound=!1;lastInputSentAt=-1/0;sendTimes=[];edgeSendTimes=[];heldSendTimes=[];heldTimer=null;pressWaiting=!1;constructor(e,t,n,r=e=>new WebSocket(e),i=()=>performance.now()){this.getInput=t,this.callbacks=n,this.makeSocket=r,this.now=i,this.reconnectTicket=e}start(){this.disposed||this.listenersBound||(this.bindInputListeners(),this.connect(),!this.disposed&&!this.terminal&&(this.inputTimer=window.setInterval(()=>this.periodicFlush(),jf)))}bindInputListeners(){this.listenersBound=!0,window.addEventListener(`blur`,this.onInputLoss),window.addEventListener(`focus`,this.onInputRegain),window.addEventListener(`pointerdown`,this.onPagePointer,!0),document.addEventListener(`visibilitychange`,this.onVisibilityChange)}setActive(e){this.setInputActive(e)}setInputActive(e){let t=this.active;this.active=e,e?this.boutStarted=!0:t&&this.sendInput(Af,!0)}notifyAction(){this.pressWaiting=!0,this.now()-(this.edgeSendTimes.at(-1)??-1/0)=Pf||this.flushInput()&&this.edgeSendTimes.push(this.lastInputSentAt)}notifyHeld(){let e=Mf-(this.now()-Math.max(this.edgeSendTimes.at(-1)??-1/0,this.heldSendTimes.at(-1)??-1/0));e>0?this.heldTimer??=window.setTimeout(()=>{this.heldTimer=null,this.notifyHeld()},e):this.withinLastSecond(this.heldSendTimes)>=Ff||this.sendsInLastSecond()>=40||this.flushInput()&&this.heldSendTimes.push(this.lastInputSentAt)}periodicFlush(){this.now()-Math.max(this.edgeSendTimes.at(-1)??-1/0,this.heldSendTimes.at(-1)??-1/0)=40||this.flushInput()}sendsInLastSecond(){return this.withinLastSecond(this.sendTimes)}withinLastSecond(e){let t=this.now()-1e3;for(;e.length>0&&e[0]<=t;)e.shift();return e.length}onInputLoss=()=>{this.inputSuppressed||(this.sendInput(Af,this.boutStarted),this.inputSuppressed=!0,this.pointerFocus=!1)};onInputRegain=()=>{!document.hidden&&document.hasFocus()&&(this.inputSuppressed=!1)};onPagePointer=()=>{if(!document.hidden&&(this.pointerFocus=!0,this.inputSuppressed=!1,!document.hasFocus()))try{window.focus()}catch{}};onVisibilityChange=()=>{document.hidden?this.onInputLoss():this.onInputRegain()};connect(){if(this.disposed||this.terminal)return;let e=this.reconnectTicket;if(e===null){this.terminal=!0,this.stopInputLifecycle(),this.callbacks.onFreshAuth();return}let t;try{t=this.makeSocket(Of())}catch{this.terminal=!0,this.stopInputLifecycle(),this.callbacks.onFatal(`network_unavailable`);return}this.socket=t,t.binaryType=`arraybuffer`,t.onopen=()=>{if(!(this.socket!==t||this.disposed))try{t.send(JSON.stringify({version:6,type:`authenticate`,ticket:e})),this.reconnectTicket=null}catch{this.handleClose(t)}},t.onmessage=e=>this.handleMessage(t,e),t.onerror=()=>void 0,t.onclose=()=>this.handleClose(t)}handleMessage(e,t){if(!(this.socket!==e||this.disposed||this.terminal))try{if(typeof t.data!=`string`&&!(t.data instanceof ArrayBuffer))throw Error(`unsupported_frame`);let n=Lf(t.data);if(this.applyMessage(n),n.type===`ticket`){try{e.send(JSON.stringify({version:6,type:`ticket_ack`,refresh_id:n.refresh_id}))}catch{this.handleClose(e)}return}this.callbacks.onMessage(n),n.type===`error`?this.terminate(n.code,e):n.type===`final`&&(this.terminal=!0,this.clearTransportReconnect(!0),this.clearOpponentPause(!0),this.stopInputLifecycle(),this.socket===e&&(this.socket=null),e.onopen=e.onmessage=e.onclose=e.onerror=null,e.close(1e3,`complete`))}catch(e){this.callbacks.onFatal(wi(e)),this.dispose()}}applyMessage(e){if(e.type===`welcome`){if(e.reconnect_ticket===void 0)throw Error(`missing_reconnect_ticket`);this.reconnectTicket=e.reconnect_ticket,this.serverTick=e.server_tick;let t=this.role===`spectator`&&e.role===`fighter`;this.role=e.role,this.playerId=e.role===`fighter`?e.player_id:null,this.sentAt.clear(),e.role===`fighter`?this.nextSequence=Math.max(this.nextSequence,e.next_sequence):this.stopInputLifecycle(),t&&(this.listenersBound||this.bindInputListeners(),this.inputTimer??=window.setInterval(()=>this.periodicFlush(),jf)),this.attempts=0,this.clearTransportReconnect(!0)}else e.type===`ticket`?this.reconnectTicket=e.reconnect_ticket:e.type===`snapshot`?(this.serverTick=Math.max(this.serverTick,e.payload.tick),this.setInputActive([`countdown`,`fight`,`knockdown`,`foul_recovery`,`referee_down`,`finish`].includes(e.payload.phase)),this.resting=e.payload.phase===`rest`,this.observeAcknowledgement(e.payload)):e.type===`paused`?(this.setInputActive(!1),this.startOpponentPause(e.grace_ms)):e.type===`resumed`?(this.setInputActive(!0),this.attempts=0,this.clearOpponentPause(!0)):e.type===`select`?this.clearOpponentPause(!0):e.type===`ready`?(this.clearOpponentPause(!0),this.setInputActive(!0)):e.type===`waiting`?(this.clearOpponentPause(!0),this.setInputActive(!1)):(e.type===`final`||e.type===`error`)&&(this.active=!1,this.clearOpponentPause(!0))}terminate(e,t){this.terminal=!0,this.active=!1,this.clearTransportReconnect(!0),this.clearOpponentPause(!0),this.stopInputLifecycle(),this.callbacks.onFatal(e),this.socket===t&&(this.socket=null,t.onopen=t.onmessage=t.onclose=t.onerror=null,t.close(1e3,`terminal`))}handleClose(e){if(this.socket!==e||(this.socket=null,this.active=!1,this.disposed||this.terminal))return;if(this.reconnectTicket===null){this.terminal=!0,this.stopInputLifecycle(),this.callbacks.onFreshAuth();return}this.clearOpponentPause(!1),this.reconnectDeadline===0&&(this.reconnectDeadline=this.now()+2e4);let t=Math.max(0,this.reconnectDeadline-this.now());if(this.callbacks.onReconnect(t),t<=0){this.terminal=!0,this.stopInputLifecycle(),this.callbacks.onFreshAuth();return}let n=Math.min(3e3,250*2**Math.min(this.attempts,4),t);this.attempts+=1,this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=null,this.callbacks.onReconnect(Math.max(0,this.reconnectDeadline-this.now())),this.connect()},n)}requestCpu(e){let t=this.socket;if(this.role!==`fighter`||this.disposed||this.terminal||t?.readyState!==kf)return!1;try{return t.send(Nt(e)),!0}catch{return this.handleClose(t),!1}}chooseStyle(e,t){let n=this.socket;if(this.role!==`fighter`||this.disposed||this.terminal||n?.readyState!==kf)return!1;try{return n.send(jt(e,t)),!0}catch{return this.handleClose(n),!1}}get inputLatencyMs(){return this.latencyMs}sequenceOf(e){return this.actionSequences.get(e)??null}observeAcknowledgement(e){if(this.playerId===null)return;let t=e.fighters.find(e=>e.player_id===this.playerId);if(t===void 0||t.last_input_sequence<0)return;let n=this.sentAt.get(t.last_input_sequence);if(n!==void 0){let e=Math.max(0,this.now()-n);this.latencyMs=this.latencyMs===null?e:this.latencyMs*.8+e*.2}for(let e of this.sentAt.keys())e<=t.last_input_sequence&&this.sentAt.delete(e)}sendInput(e,t=!1){return(this.active||t)&&this.transmit(e)}sendCornerChoice(e){return this.resting?this.transmit({moveX:0,moveY:0,defense:`none`,actions:[{kind:e}]}):!1}transmit(e){let t=this.socket;if(this.role!==`fighter`||this.disposed||this.terminal||t?.readyState!==kf)return!1;try{let n=e.actions.slice(0,4);t.send(At(this.nextSequence,this.serverTick,{...e,actions:n})),this.sentAt.set(this.nextSequence,this.now()),this.sentAt.size>128&&this.sentAt.delete(this.sentAt.keys().next().value);for(let e of n)e.id!==void 0&&this.actionSequences.set(e.id,this.nextSequence);for(;this.actionSequences.size>64;)this.actionSequences.delete(this.actionSequences.keys().next().value);return this.nextSequence+=1,this.lastInputSentAt=this.now(),this.sendTimes.push(this.lastInputSentAt),!0}catch{return this.handleClose(t),!1}}flushInput(){return this.inputSuppressed||document.hidden||!(this.pointerFocus||document.hasFocus())||this.sendsInLastSecond()>=Nf||(this.socket?.bufferedAmount??0)>If||!this.sendInput(this.getInput())?!1:(this.pressWaiting=!1,!0)}startOpponentPause(e){this.clearOpponentPause(!1),this.opponentPaused=!0,this.opponentPauseDeadline=this.now()+e,this.callbacks.onReconnect(e),e>0&&this.scheduleOpponentPauseTick()}scheduleOpponentPauseTick(){let e=Math.max(0,this.opponentPauseDeadline-this.now());e<=0?(this.opponentPauseDeadline=0,this.callbacks.onReconnect(0)):this.opponentPauseTimer=window.setTimeout(()=>{this.opponentPauseTimer=null;let e=Math.max(0,this.opponentPauseDeadline-this.now());this.callbacks.onReconnect(e),e>0?this.scheduleOpponentPauseTick():this.opponentPauseDeadline=0},Math.min(250,e))}clearOpponentPause(e){let t=this.opponentPaused;this.opponentPaused=!1,this.opponentPauseDeadline=0,this.opponentPauseTimer!==null&&(clearTimeout(this.opponentPauseTimer),this.opponentPauseTimer=null),e&&t&&this.callbacks.onReconnect(0)}cancelReconnect(){this.reconnectTimer!==null&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}clearTransportReconnect(e){let t=this.reconnectDeadline!==0;this.reconnectDeadline=0,this.cancelReconnect(),e&&t&&this.callbacks.onReconnect(0)}stopInputLifecycle(){this.inputTimer!==null&&(clearInterval(this.inputTimer),this.inputTimer=null),this.heldTimer!==null&&(clearTimeout(this.heldTimer),this.heldTimer=null),this.listenersBound&&=(window.removeEventListener(`blur`,this.onInputLoss),window.removeEventListener(`focus`,this.onInputRegain),window.removeEventListener(`pointerdown`,this.onPagePointer,!0),document.removeEventListener(`visibilitychange`,this.onVisibilityChange),!1)}dispose(){if(this.disposed)return;this.disposed=!0,this.active=!1,this.reconnectTicket=null,this.clearTransportReconnect(!0),this.clearOpponentPause(!0),this.stopInputLifecycle();let e=this.socket;this.socket=null,e!==null&&(e.onopen=e.onmessage=e.onclose=e.onerror=null,e.close(1e3,`teardown`))}},zf={play:`CALLAHAN`,colour:`OKAFOR`,announcer:`RING ANNOUNCER`},Bf=.3,Vf=.9,Hf=.25,Uf=2.6,Wf=4.5,Gf=12,Kf=.8,qf=6,Jf=9,Yf=6,Xf=42,Zf=8,Qf=15,$f=10,ep=[60,480,640],tp=500,np=.2,rp=.3,ip=120,ap={knockdown:[`Down goes {b}!`,`{a} drops {b}!`,`{b} is down! What a shot from {a}!`,`Down goes {b}! {a} found the chin!`],knockdownAgain:[`{b} is down again!`,`Down for the second time! {b} is in deep trouble!`,`{a} puts {b} down again!`],knockdownCounter:[`Down goes {b}, off a perfect counter!`,`{a} times it, and {b} is down!`],struggle:[`{b} is struggling to get up...`,`{b} is trying to beat the count...`,`Can {b} get up?`],upLate:[`{b} beats the count at {n}!`,`Up at {n}! {b} is still in this!`,`{b} makes it up at {n}, but the legs look heavy.`],upEarly:[`{b} is up at {n}.`,`{b} is back up at the count of {n}.`,`Up at {n}. {b} wants to keep fighting.`],finishCall:[`{a} has to go for the finish now.`,`{b} needs to survive the next minute.`,`{b} has to hold and clear the head.`],hurt:[`{b} is hurt!`,`{a} has {b} in trouble!`,`{b}'s legs just buckled!`,`Big shot! {b} is wobbled!`,`{b} is rocked! Keep the pressure on, {a}!`],hurtBadly:[`{b} is out on their feet!`,`{b} is in all sorts of trouble!`,`{b} is badly hurt!`],guardBreak:[`{a} blasts right through the guard!`,`The guard is gone! {b} can't keep those hands up!`,`{a} breaks the guard down!`],counter:[`What a counter from {a}!`,`{a} times it perfectly! A {punch} on the counter!`,`{b} walked right into that {punch}!`,`Counter {punch} from {a}! Beautiful timing.`],bigShot:[`Big {punch} from {a}!`,`{a} lands a thudding {punch}!`,`That {punch} landed flush!`,`Huge {punch}! {b} felt that one.`],cut:[`{b} is cut over the {side} eye.`,`There's blood now. A cut over {b}'s {side} eye.`,`That's opened a cut over the {side} eye of {b}.`],cutWorse:[`That cut over {b}'s {side} eye is getting worse.`,`The blood is pouring from that {side} eye now.`,`{b} is bleeding badly from the {side} eye.`],cutGushing:[`That cut is gushing now! {b} is covered in it.`,`{b}'s face is a crimson mask, and nobody is stopping this!`],eyeSwelling:[`{b}'s {side} eye is swelling badly.`,`{b} is having trouble seeing out of that {side} eye.`],eyeShut:[`{b}'s {side} eye has closed completely!`,`That {side} eye is shut! {b} can't see them coming from that side.`,`{b} is fighting with one eye now.`],blindSide:[`{a} is working the blind side.`,`{b} never saw that one. Nothing is getting through that {side} eye.`,`Smart from {a}, punching where {b} can't see.`],parried:[`{a} picks it off and {b} is wide open!`,`Beautiful parry from {a}! {b} is off balance.`,`{a} slaps it away and {b} is left stranded.`],bodyCollapse:[`Body shot! {b} is going down!`,`{a} digs to the body and {b} is folding!`,`Oh, that body shot! {b} is in agony!`],knockdownBody:[`Down goes {b} from the body shot!`,`{b} takes a knee! That body shot took everything out!`,`{a} goes downstairs and {b} can't take it!`],cornerCut:[`{a}'s cutman is working on that cut.`,`They're working hard on the cut in {a}'s corner.`],cornerSwelling:[`{a}'s corner is getting the swelling down.`,`Ice and the enswell on that eye in {a}'s corner.`],cornerBreath:[`{a}'s corner wants the breath back first. Big drink of water.`,`{a} is told to breathe and settle down.`],combo:[`A three-punch combination from {a}!`,`{a} puts it together beautifully.`,`Lovely combination from {a}!`],unanswered:[`Five unanswered punches from {a}!`,`{a} is unloading! {b} has to fire back!`,`{b} is just covering up as {a} lets the hands go!`],jab:[`{a}'s jab is finding a home.`,`Stiff jab from {a}, and another.`,`{a} keeps popping that jab in {b}'s face.`],body:[`{a} is going to work on the body.`,`{a} keeps digging to the body.`,`Another one downstairs from {a}.`],payoff:[`The body work is paying off. {b} is slowing down.`,`Those body shots are taking it out of {b}.`,`{a} has invested in the body, and {b} is paying for it now.`],tiring:[`{b} is running on empty.`,`{b} is breathing hard. Those punches have nothing on them.`,`{b} has punched out. The tank is empty.`],takeover:[`{a} is taking over this round.`,`This is all {a} right now.`,`{a} is in complete control.`],clinch:[`{a} ties {b} up.`,`{a} grabs hold.`,`They're tied up in the clinch.`],holdingOn:[`{a} is hurt and holding on!`,`{a} grabs on for dear life!`,`Smart from {a}, holding on to clear the head.`],refBreak:[`The referee breaks them.`,`The referee steps in to separate them.`,`Break! The referee pulls them apart.`],refHit:[`{a} just tagged the referee!`,`Oh no, {a} has caught the referee!`,`That one landed on the referee!`],refDown:[`The referee is down! {a} has killed the referee!`,`Oh my goodness, the referee isn't moving! I think he's dead!`,`{a} has flattened the official for good! Absolute chaos!`],refBledOut:[`The referee has collapsed! He's bled out right there in the ring!`,`The referee goes down! He's lost too much blood!`],noRef:[`Nobody left to break them up!`,`No referee to part them, so they just let go.`],taunt:[`{a} drops the hands and invites {b} in!`,`Showboating from {a}! The crowd loves it.`,`{a} is taunting {b} now!`,`{a} sticks the chin out. Come and get it!`],lowBlow:[`Low blow from {a}! The referee steps in.`,`That's below the belt! {b} is doubled over.`,`{a} goes low, and the referee calls time.`],headbutt:[`Headbutt from {a}! The referee calls time.`,`{a} leads with the head! That's a foul.`],warning:[`A warning for {a}. One more and it costs a point.`,`The referee warns {a}. That can't happen again.`],deduction:[`The referee takes a point from {a}!`,`That costs {a} a point!`,`Point deduction! {a} has been warned enough.`],resume:[`And we're back underway.`,`Time in. Let's box.`],box:[`The referee waves them on. {b} has to survive now.`,`Box! {a} will be looking to finish it.`,`{b} has convinced the referee. Here comes {a}.`],evade:[`{a} slips it! Lovely head movement.`,`{b} misses, and {a} was never there.`,`Great defence from {a}.`],parry:[`{a} picks that off with the gloves.`,`{a} parries it away.`,`Tight defence from {a}.`],whiff:[`{a} misses wildly with the {punch}.`,`Big swing and a miss from {a}.`,`{a} throws everything into that {punch} and hits nothing but air.`],southpaw:[`{a} switches to southpaw.`,`{a} turns southpaw now.`],orthodox:[`{a} goes back to orthodox.`,`{a} switches back to orthodox.`],roundStart:[`Round {r}. Here we go.`,`We're underway in round {r}.`,`Round {r} is on.`],roundEnd:[`That's the bell to end round {r}.`,`The bell ends round {r}.`,`And that's round {r} in the books.`],savedByBell:[`Saved by the bell! {b} was in real trouble.`,`{b} is saved by the bell!`,`The bell rescues {b}!`],finalBell:[`That's the final bell!`,`The final bell! We go to the scorecards.`],summary:[`Round {r}: {a} landed {x} of {y}, {b} {z} of {w}.`],roundFor:[`I had that round for {a}.`,`{a} took that round.`,`That was {a}'s round.`],roundBig:[`The knockdown makes that a big round for {a}.`,`{a} wins that round big with the knockdown.`],roundClose:[`Close round. That one could go either way.`,`Tough round to score.`,`Nothing between them in that round.`],pullingAway:[`{a} is pulling away on the cards.`,`{b} needs something big. {a} is building a lead.`],ko:[`It's all over! {a} wins by knockout!`,`{b} can't beat the count! {a} wins it!`,`That's it! {a} has knocked out {b}!`],flashKo:[`Lights out! {b} is out cold!`,`One punch, and it's over! {a} wins!`,`Good night! {a} ends it with one shot!`],tko:[`Three knockdowns, and it's over! {a} wins!`,`The referee waves it off! {a} wins by stoppage!`],disqualified:[`{b} is disqualified!`,`That's it! {b} has been thrown out!`],forfeit:[`{b} has left the ring. {a} wins by forfeit.`],replay:[`Here it is again.`,`Let's see that one more time.`,`Watch {a} set it up...`],injBrokenNose:[`{b}'s nose is now mostly a suggestion.`,`That nose is broken. It is pointing at the exit, and so should {b}.`,`{a} has moved {b}'s nose to a different part of his face.`],injBrokenJaw:[`{b}'s jaw is broken. It is hanging off his face like a drawer left open.`,`That jaw has gone sideways. {b} will be eating through a straw, if he lives.`,`You can hear {b}'s jaw clicking from up here. That is not a good sound.`],injJawTorn:[`That is his jaw in the third row.`,`{a} has torn {b}'s jaw clean off! Somebody at ringside just caught a souvenir.`,`{b} has no lower jaw. His tongue is just hanging there like a necktie.`],injEyeOut:[`{b}'s {side} eye is out of his head! It is swinging on the nerve like a yo-yo.`,`The {side} eye has popped its socket. It is looking at {b}'s own cheek.`,`{a} has punched {b}'s {side} eye clean out. He can see his own shoes with it.`],injEarTorn:[`That is {b}'s {side} ear on the canvas. Somebody just trod on it.`,`{a} has taken the {side} ear clean off. {b} did not want to hear this anyway.`,`The {side} ear is gone. I think it is stuck to {a}'s glove.`],injFaceFlayed:[`The {side} half of {b}'s face has come off like a wet sock.`,`I can see {b}'s teeth through his {side} cheek. All of them.`,`{a} has peeled {b}'s face. That is muscle. That is bone. That is my lunch coming back up.`],injSkull:[`{b}'s skull has split open. That is his brain. I can see it thinking.`,`The top of {b}'s head is open like a boiled egg, and he is still standing.`,`That is brain, folks. One more upstairs and {b} forgets everything, permanently.`],injShoulder:[`{b}'s {side} shoulder has popped out. The arm is hanging like a coat on a hook.`,`The {side} shoulder is out of its socket. It is not supposed to be down there.`,`{b}'s {side} arm has come unplugged. His corner can shove it back in at the bell.`],injArmBroken:[`{b}'s {side} arm has snapped! The bone is out and waving at the crowd.`,`That {side} elbow now bends both ways. It is only meant to bend the one.`,`Compound fracture! {b}'s {side} forearm is dangling by the meat.`],injForearmSevered:[`{b}'s {side} forearm is off! The glove is still making a fist over there on the canvas.`,`{a} has taken the {side} arm off at the elbow, and {b} is punching with the stump!`,`There goes the {side} forearm. Somebody put it on ice. Actually, do not bother.`],injArmTorn:[`{a} has ripped {b}'s {side} arm off at the shoulder! It is on the canvas, still twitching!`,`The whole {side} arm is gone. That shoulder is a fire hose.`,`{b} has lost the {side} arm. The judges will take that into account.`],injRibs:[`{b}'s {side} ribs have caved in. One is sticking out of him like a coat hanger.`,`Those {side} ribs are through the skin. You can count them. I make it four.`,`The {side} side of {b} just folded like a lawn chair.`],injLiver:[`That is the liver, and it has burst. {b} is about to show us everything he ate today.`,`{b}'s liver just exploded inside him. He is turning a colour I have only seen on old fruit.`,`Liver shot, and it popped. {b} is filling up with blood on the inside.`],injDisemboweled:[`{b}'s belly is open and his guts are on the canvas! He is treading on them!`,`He is holding his intestines in with his glove and he still wants to fight.`,`{a} has unzipped {b} from hip to hip. That is twenty feet of intestine, and it is all coming out.`],injKnee:[`{b}'s {side} knee is bending the wrong way. Knees should not have a reverse gear.`,`The {side} knee has blown apart. I can see the kneecap. It is over by the ropes.`,`{b}'s {side} leg is held on by skin and optimism.`],ghastly:[`I would stop this fight. Nobody is going to stop this fight.`,`In any other sport that is a penalty.`,`{b} will feel that in the morning, if he gets one.`,`There are children watching this. They are cheering.`],shoulderBack:[`{b}'s corner has shoved the {side} shoulder back in. You could hear it from the cheap seats.`,`The {side} shoulder is back in its socket. {b} screamed, and then he said thank you.`,`They have popped {b}'s {side} shoulder back in. Good as new. It is not, but good as new.`],vomit:[`{a} is throwing up blood and bile all over the canvas. Mind your step.`,`There it goes. {a} is vomiting something black. That is the liver talking.`,`{a} is sick down his own chest. Blood, bile, and I think that was a tooth.`],finishHim:[`{b} is out on his feet and nobody is stopping it! Finish him!`,`{b} is just standing there, dead behind the eyes. {a} can do anything he likes with him.`,`This is it. {a} gets one free punch, and {b} will not be getting up from it. Ever.`],armless:[`{a} is trying to punch with arms he no longer has.`,`{a} just threw a punch. I will let somebody else tell him.`,`No arms, and {a} is still swinging. You have to admire it. You do not have to watch it.`,`{a} is waving two stumps at him. That is not a guard. That is a cry for help.`],fatEyesOut:[`{a} has punched both of {b}'s eyes out through the back of his head!`,`Two eyes, one punch! They are rolling across the ring. One of them is looking at me.`,`{b}'s eyes are out, and so is {b}. There is daylight coming through his face.`],fatHeadBurst:[`{b}'s head has exploded! It is just gone! It is all over the first three rows!`,`{a} hit him so hard his head burst like a dropped melon. The front row is wearing {b}.`],fatDecapitation:[`{a} has taken {b}'s head clean off! It is in the crowd! Somebody is holding it up!`,`Off comes the head! The body is still standing there, looking for it.`],fatSpineRip:[`The uppercut takes {b}'s head off, and his spine comes with it! All of it! Like boning a fish!`,`{b}'s head is in the air with the whole spine dangling off it. I have never seen that. Nobody has.`],fatHeartPunch:[`{a}'s fist has gone straight through {b}'s chest! That is his heart on the canvas, and it is still beating!`,`In through the chest and out the back! {a} is wearing {b} like a bracelet.`],fatGutting:[`{a} has emptied {b} onto the canvas! Everything he kept inside is now outside!`,`One straight to the gut and it all falls out. Liver, stomach, the lot. {b} is hollow.`],fatBisection:[`{a} has torn {b} in half at the waist! The legs are still standing! The top half is trying to crawl away!`,`{b} is in two pieces. The judges will have to score each half separately.`],fatTotalGib:[`{b} has exploded! There is nothing left! It is raining {b}!`,`{a} hit him and he just came apart. There are bits of {b} on the lights. There is a foot in my coffee.`],deathBledOut:[`{b} has bled to death, right there in the ring. There is more of him on the canvas than in him.`,`{b} is gone. He ran out of blood. You do need some.`,`And {b} just drops. Bled out. They will need a mop and a priest.`],deathBrain:[`That was the last of {b}'s brain, and {a} has punched it into soup. He is dead before he lands.`,`{b} is dead. His brain has left through the hole in his skull.`,`{b} is dead. You cannot fight without a brain. Plenty have tried.`],deathGutted:[`{b} is dead. {a} has punched what was left of his insides clean out of him.`,`That body shot went in one side and out the other. {b} is done, and I mean buried.`,`{b} has been gutted like a fish, and he has died like one, flapping.`],deathFatality:[`He is dead. I would like that on the record. {b} is extremely dead.`,`I have been doing this thirty years. I am going to need a different job.`,`Somebody tell {b}'s corner they can stop shouting advice.`],doubleDeath:[`They are both dead. Both of them. I do not know who to interview.`,`Two fighters, no survivors. The judges are going to hate this.`,`{a} and {b} have killed each other. Call it a draw. Call somebody.`]},op={ko:`ko`,flash_ko:`flashKo`,tko:`tko`,disqualification:`disqualified`,forfeit:`forfeit`},sp={broken_nose:`injBrokenNose`,broken_jaw:`injBrokenJaw`,jaw_torn:`injJawTorn`,eye_out:`injEyeOut`,ear_torn:`injEarTorn`,face_flayed:`injFaceFlayed`,skull_fractured:`injSkull`,shoulder_dislocated:`injShoulder`,arm_broken:`injArmBroken`,forearm_severed:`injForearmSevered`,arm_torn:`injArmTorn`,ribs_broken:`injRibs`,liver_ruptured:`injLiver`,disemboweled:`injDisemboweled`,knee_blown:`injKnee`},cp={eyes_out:`fatEyesOut`,head_burst:`fatHeadBurst`,decapitation:`fatDecapitation`,spine_rip:`fatSpineRip`,heart_punch:`fatHeartPunch`,gutting:`fatGutting`,bisection:`fatBisection`,total_gib:`fatTotalGib`},lp={bled_out:`deathBledOut`,brain:`deathBrain`,gutted:`deathGutted`},up=new Set([`injJawTorn`,`injEyeOut`,`injFaceFlayed`,`injSkull`,`injForearmSevered`,`injArmTorn`,`injDisemboweled`,`finishHim`,`fatEyesOut`,`fatHeadBurst`,`fatDecapitation`,`fatSpineRip`,`fatHeartPunch`,`fatGutting`,`fatBisection`,`fatTotalGib`,`deathBledOut`,`deathBrain`,`deathGutted`,`deathFatality`,`doubleDeath`]),dp={struggle:new Set([`knockdown`]),finishHim:new Set([`finish`])},fp=3.2,pp=4,mp=`struggle`,hp=new Set([`countdown`]),gp=3.2,_p=new Set([`knockdown`,`knockdownAgain`,`knockdownCounter`,`knockdownBody`,`bodyCollapse`,`upLate`,`upEarly`,`hurt`,`hurtBadly`,`lowBlow`,`headbutt`,`deduction`,`ko`,`flashKo`,`tko`,`disqualified`,`forfeit`,`replay`,`refDown`,`refBledOut`,`savedByBell`,`finalBell`,`roundEnd`,`roundStart`,`injBrokenNose`,`injBrokenJaw`,`injEarTorn`,`injShoulder`,`injArmBroken`,`injRibs`,`injLiver`,`injKnee`,...up]),vp=new Set([`lowBlow`,`headbutt`,`warning`,`deduction`,`box`,`tko`]),yp={fatEyesOut:99,fatHeadBurst:99,fatDecapitation:99,fatSpineRip:99,fatHeartPunch:99,fatGutting:99,fatBisection:99,fatTotalGib:99,doubleDeath:99,deathBledOut:98,deathBrain:98,deathGutted:98,deathFatality:98,finishHim:97,injJawTorn:96,injEyeOut:96,injFaceFlayed:96,injSkull:96,injForearmSevered:96,injArmTorn:96,injDisemboweled:96,injBrokenNose:85,injBrokenJaw:85,injEarTorn:85,injShoulder:85,injArmBroken:85,injRibs:85,injLiver:85,injKnee:85,vomit:66,shoulderBack:47,ghastly:44,armless:40,ko:98,flashKo:98,tko:98,disqualified:98,forfeit:98,refDown:97,refBledOut:97,refHit:72,knockdown:95,knockdownAgain:95,knockdownCounter:95,knockdownBody:95,bodyCollapse:86,upLate:90,upEarly:90,replay:88,deduction:84,lowBlow:82,headbutt:82,hurt:80,box:78,hurtBadly:80,holdingOn:76,savedByBell:74,finalBell:72,struggle:70,guardBreak:65,eyeShut:62,counter:60,parried:58,bigShot:55,roundEnd:52,cut:50,cutWorse:50,summary:50,cutGushing:48,eyeSwelling:48,cornerCut:47,cornerSwelling:47,cornerBreath:47,blindSide:42,roundFor:46,roundBig:46,roundClose:46,pullingAway:46,unanswered:45,finishCall:44,warning:42,combo:40,payoff:40,takeover:38,body:35,jab:30,tiring:30,roundStart:28,taunt:25,parry:22,evade:20,clinch:20,whiff:18,refBreak:12,noRef:12,southpaw:10,orthodox:10,resume:10},bp={finishCall:`colour`,payoff:`colour`,tiring:`colour`,takeover:`colour`,holdingOn:`colour`,taunt:`colour`,parry:`colour`,evade:`colour`,warning:`colour`,blindSide:`colour`,cornerCut:`colour`,cornerSwelling:`colour`,cornerBreath:`colour`,roundFor:`colour`,roundBig:`colour`,roundClose:`colour`,pullingAway:`colour`,cutGushing:`colour`,noRef:`colour`,jab:`colour`,ghastly:`colour`,shoulderBack:`colour`,vomit:`colour`,deathFatality:`colour`,doubleDeath:`colour`,armless:`colour`},xp={combo:6,jab:20,body:18,evade:12,parry:15,parried:8,blindSide:20,whiff:12,clinch:15,refBreak:20,taunt:10,southpaw:15,orthodox:15,bigShot:4,counter:3,unanswered:15,takeover:25,vomit:20,ghastly:14,armless:12},Sp=[`zero`,`one`,`two`,`three`,`four`,`five`,`six`,`seven`,`eight`,`nine`,`ten`,`eleven`,`twelve`,`thirteen`,`fourteen`,`fifteen`],Cp=e=>Sp[e]??String(e),wp=[...Sp,`sixteen`,`seventeen`,`eighteen`,`nineteen`],Tp=[``,``,`twenty`,`thirty`,`forty`,`fifty`,`sixty`,`seventy`,`eighty`,`ninety`];function Ep(e){return!Number.isInteger(e)||e<0||e>=1e3?String(e):e<20?wp[e]:e<100?`${Tp[Math.floor(e/10)]}${e%10==0?``:`-${wp[e%10]}`}`:`${wp[Math.floor(e/100)]} hundred${e%100==0?``:` and ${Ep(e%100)}`}`}function Dp(e,t=!0){if(ze(e))return`making a pro debut`;let n=e.draws>0?`${Ep(e.wins)}, ${Ep(e.losses)} and ${Ep(e.draws)}`:`${Ep(e.wins)} and ${e.losses===0?`oh`:Ep(e.losses)}`;return t&&e.knockouts>0?`${n}, ${Ep(e.knockouts)} by knockout`:n}function Op(e){return .85+e.length*.077+(e.split(`...`).length-1)*.35}var kp=.3;function Ap(e,t){let n=t-kp,r=[e=>[e.record===void 0?null:Dp(e.record),Bt(e.style)],e=>[Bt(e.style)],()=>[]];for(let t of r){let r=e.map((e,n)=>{let r=n===0?`In the blue corner`:`And in the red corner`,i=t(e).filter(e=>e!==null);return i.length===0?`${r}, ${e.name}!`:`${r}, ${i.join(`, `)}... ${e.name}!`});if(r.reduce((e,t)=>e+Op(t),0)<=n)return r}let i=`${e[0].name}... versus ${e[1].name}!`;return Op(i)<=n?[i]:[]}function jp(e,t){let n=e.replace(/\{(a|b|n|side|punch|r|x|y|z|w)\}/gu,(e,n)=>String(t[n]??``));return n.charAt(0).toUpperCase()+n.slice(1)}var Mp=(e,t)=>{let n=Math.imul((e|0)^Math.imul(t,2654435761),2246822507);return n^=n>>>13,n=Math.imul(n,3266489909),(n^n>>>16)>>>0};function Np(e){let t=e.split(`:`);return[t.at(-2),t.at(-1)]}function Pp(e,t){let[n=`punch`,r=`head`]=Np(e),i=t!==void 0&&t.action===n?t.action_hand:null,a=n===`jab`?`jab`:n===`straight`?i===null?`straight`:`${i} hand`:i===null?n:`${i} ${n}`;return r===`body`?`${a} to the body`:a}function Fp(e){if(e.phase===`knockdown`){let t=Math.max(...e.fighters.map(e=>e.get_up_count));return Math.min(1,.3+t*.07)}if(e.phase===`finish`)return 1;if(e.phase!==`fight`)return 0;let t=0;for(let[n,r]of e.fighters.entries()){let i=e.fighters[1-n];r.is_downed||(r.stunned_ticks>0?t=Math.max(t,.75):r.poise<150&&(t=Math.max(t,.45)),(Math.max(Math.abs(r.x),Math.abs(r.y))>400||Math.abs(r.x)+Math.abs(r.y)>640)&&Math.hypot(r.x-i.x,r.y-i.y)<150&&(t=Math.max(t,.4)))}return t}var Ip=()=>({thrown:0,landed:0,damage:0,knockdowns:0,body:0}),Lp=()=>({jabs:[],window:[],evasions:[],run:0,runTick:-1e3,unanswered:0,stunnedAt:-1e3,knockedDownAt:-1e5,lowSince:null,tiredRound:0,takeoverRound:0,payoffRound:0,cutMarks:[0,0],eyeShut:[!1,!1],eyeSwelling:[!1,!1],rounds:0}),Rp=class{hooks;queue=[];showing=null;lastEnd=-1/0;lastChoice=new Map;cooldowns=new Map;notes=new Map;tallies=new Map;players={};fighters=null;tickRate=30;introduced=!1;lastPhase=null;round=0;roundLength=null;fightRemaining=0;struggleCalled=-1;lastKnockdown=null;refereeDead=!1;final=null;verdictGiven=!1;resultCalled=!1;deaths=new Map;caption={line:null,opacity:0,entering:0};constructor(e={}){this.hooks=e}observe(e,t,n,r,i){this.players=n,this.fighters=e.fighters,this.refereeDead=e.referee?.alive===!1,this.tickRate=r,this.trackClock(e),this.introduced||(this.introduced=!0,e.phase===`countdown`&&e.round_number===1&&this.introduce(e,i));let a=t.find(e=>e.kind===`result`)??null;for(let n of t)this.consider(n,e,a,i);this.inspect(e,i),this.lastPhase=e.phase,this.dropOutOfPhase(e.phase,i)}dropOutOfPhase(e,t){for(let t=this.queue.length-1;t>=0;--t){let n=this.queue[t].phases;n!==null&&!n.has(e)&&this.queue.splice(t,1)}let n=this.showing;n!==null&&n.phases!==null&&!n.phases.has(e)&&(n.end=Math.min(n.end,t+Hf))}finish(e,t,n,r){this.players=t,this.final=e,n&&this.deaths.size<2&&(this.enqueue(this.announcement(`Ladies and gentlemen, we go to the scorecards.`,{kicker:`LADIES AND GENTLEMEN`,title:`WE GO TO THE SCORECARDS`,detail:``,corner:null},Yf,99),r,null,30),this.hooks.speak?.([`Ladies and gentlemen, we go to the scorecards.`])),e.method===`forfeit`&&!this.resultCalled&&e.winner_id!==null&&(this.resultCalled=!0,this.say(`forfeit`,e.round,r,{a:this.nameOf(e.winner_id),b:this.nameOf(this.otherId(e.winner_id))},`result`,0))}verdict(e){let t=this.final;if(t===null||this.verdictGiven)return;this.verdictGiven=!0;let n=ur(t);if(t.winner_id===null&&this.deaths.size>=2){let n=`Ladies and gentlemen, both fighters are dead. There is no winner.`;this.enqueue(this.announcement(n,{kicker:`ROUND ${t.round}`,title:`DOUBLE DEATH`,detail:`NO SURVIVORS`,corner:null},Jf,100),e,`verdict`,30),this.hooks.speak?.([n]);return}if(t.winner_id===null){let r=`After ${Cp(t.round)} rounds, this bout is scored a ${n.toLowerCase()}.`;this.enqueue(this.announcement(r,{kicker:`AFTER ${Cp(t.round).toUpperCase()} ROUNDS`,title:n,detail:``,corner:null},Jf,100),e,`verdict`,30),this.hooks.speak?.([r]);return}let r=this.nameOf(t.winner_id),i=n.toLowerCase();this.enqueue(this.announcement(`The winner, by ${i}: ${r}!`,{kicker:`THE WINNER, BY ${n}`,title:r.toUpperCase(),detail:``,corner:this.seatOf(t.winner_id)},Jf,100),e,`verdict`,30),this.hooks.speak?.([`And the winner, by ${i}... ${r}!`])}resultShown(e){let t=this.final;if(t===null||this.verdictGiven)return;if(t.method===`decision`||t.method===`draw`){this.verdict(e);return}if(this.verdictGiven=!0,t.winner_id===null)return;let n=this.nameOf(t.winner_id),r=this.otherId(t.winner_id),i=t.method===`death`,a=i&&r!==null?this.deaths.get(r)??null:null,o=i?a!==null&&Oe(a)!==null?`fatality`:`death`:{ko:`knockout`,flash_ko:`knockout`,tko:`technical knockout`,disqualification:`disqualification`,forfeit:`forfeit`}[t.method]??t.method.replaceAll(`_`,` `),s=this.stoppageClock(t.round),c=t.method===`ko`||t.method===`flash_ko`||t.method===`tko`||i,l=c&&s!==null?`${i?`DEAD`:`STOPPED`} AT ${s} OF ROUND ${t.round}`:`ROUND ${t.round}`,u=c&&s!==null?`${n} wins by ${o} at ${s} of round ${t.round}.`:`${n} wins by ${o} in round ${t.round}.`,d=`WINS BY ${o.toUpperCase()}${a===null?``:` · ${ke(a)}`}`;this.enqueue(this.announcement(u,{kicker:l,title:n.toUpperCase(),detail:d,corner:this.seatOf(t.winner_id)},Jf,100),e,`verdict`,30);let f=i?`${this.nameOf(r)} is dead`:this.refereeDead?`With the referee dead on the canvas, it is over`:`The referee stops the contest`,p=c&&s!==null?`${f} at ${s} of round ${Cp(t.round)}. `:``;this.hooks.speak?.([`${p}Your winner, by ${o}... ${n}!`])}replay(e,t=null){let n=t?.kind===`referee_down`?{actor:t.actor_id,target:null,tick:t.tick}:this.lastKnockdown;this.say(`replay`,n?.tick??0,e,{a:this.nameOf(n?.actor??null),b:this.nameOf(n?.target??null)},`replay`,.6,6)}current(e){for(let t=this.queue.length-1;t>=0;--t)this.queue[t].expires<=e&&this.queue.splice(t,1);this.showing!==null&&e>=this.showing.end&&(this.lastEnd=this.showing.end,this.showing=null);let t=null;for(let n of this.queue)n.at>e||(t===null||n.line.priority>t.line.priority||n.line.priority===t.line.priority&&n.at=this.lastEnd+Vf:t.line.urgent&&t.line.priority>n.line.priority&&e-n.start>=Kf)&&(this.queue.splice(this.queue.indexOf(t),1),this.showing={line:t.line,start:e,end:e+t.line.hold,moment:t.moment,phases:t.phases},t.spoken!==null&&this.hooks.speak?.([t.spoken]))}let n=this.showing;return n===null?null:(this.caption.line=n.line,this.caption.opacity=Math.max(0,Math.min(1,(e-n.start)/Hf,(n.end-e)/Hf)),this.caption.entering=Math.max(0,1-(e-n.start)/Hf),this.caption)}trackClock(e){e.phase===`fight`&&((this.lastPhase===`countdown`||this.lastPhase===`rest`)&&(this.roundLength={round:e.round_number,ticks:e.phase_ticks_remaining+1}),this.fightRemaining=e.phase_ticks_remaining),e.round_number!==this.round&&(this.round=e.round_number,this.tallies.clear())}stoppageClock(e){let t=this.roundLength;if(t===null||t.round!==e)return null;let n=Math.max(0,Math.floor((t.ticks-this.fightRemaining)/this.tickRate));return`${Math.floor(n/60)}:${String(n%60).padStart(2,`0`)}`}introduce(e,t){let n=e.phase_ticks_remaining/this.tickRate;if(n<1.2)return;let r=e.fighters.map(e=>this.nameOf(e.player_id)),i=e.fighters.map((e,t)=>({name:r[t],record:this.players[e.player_id]?.record,style:e.style})),a=Ap([i[0],i[1]],n),o=Math.max(1.4,a.length===2?Op(a[0]):n/2),s=[o,Math.max(1.4,n-o)];for(let n of[0,1]){let i=n===0?`blue`:`red`,c=this.players[e.fighters[n].player_id],l=zt(e.fighters[n].style),u=c===void 0?``:`${l===null?``:`${l} · `}${c.record===void 0?``:`${Be(c.record)} · `}${c.cpu===!0?`COMPUTER`:`RATED ${c.rating}`}`;this.enqueue(this.announcement(`In the ${i} corner, ${r[n]}.`,{kicker:`IN THE ${i.toUpperCase()} CORNER`,title:r[n].toUpperCase(),detail:u,corner:n},s[n],97),t+n*o,null,30,hp,a[n]??null)}}consider(e,t,n,r){let i=e.actor_id,a=e.target_id,o=`${e.tick}:${a??i??``}`,s={a:this.nameOf(i),b:this.nameOf(a)};switch(e.kind){case`punch_start`:i!==null&&(this.tally(i).thrown+=1);return;case`hit`:case`counter_hit`:i!==null&&a!==null&&!cr(e,t.events)&&this.landed(e,i,a,t,r);return;case`stun`:{if(a===null)return;this.notesFor(a).stunnedAt=e.tick;let t=this.fighter(a),n=t!==void 0&&(t.poise=A-6);this.say(n?`hurtBadly`:`hurt`,e.event_id,r,s,o);return}case`guard_break`:this.say(`guardBreak`,e.event_id,r,s,o);return;case`knockdown`:{if(a===null||(this.lastKnockdown={actor:i,target:a,tick:e.tick},this.notesFor(a).knockedDownAt=e.tick,i!==null&&(this.tally(i).knockdowns+=1),n!==null))return;let c=t.events.some(t=>t.kind===`counter_hit`&&t.tick===e.tick&&t.target_id===a);this.say(e.amount>=2?`knockdownAgain`:e.detail===`body`?`knockdownBody`:c?`knockdownCounter`:`knockdown`,e.event_id,r,s,o);return}case`body_collapse`:this.say(`bodyCollapse`,e.event_id,r,s,o);return;case`parry`:this.say(`parried`,e.event_id,r,s,o,Bf,void 0,i);return;case`eye_shut`:if(a===null||e.detail!==`left`&&e.detail!==`right`)return;this.notesFor(a).eyeShut[e.detail===`left`?0:1]=!0,this.say(`eyeShut`,e.event_id,r,{...s,side:e.detail},o);return;case`blind_side`:if(e.detail!==`left`&&e.detail!==`right`)return;this.say(`blindSide`,e.event_id,r,{...s,side:e.detail},null,Bf,void 0,i);return;case`corner`:{let t=e.detail===`cut`?`cornerCut`:e.detail===`swelling`?`cornerSwelling`:e.detail===`breath`?`cornerBreath`:null;t!==null&&this.say(t,e.event_id,r,s,null,Bf,void 0,i);return}case`count`:e.amount>=6&&this.struggleCalled!==this.lastKnockdown?.tick&&this.fighter(a)?.is_downed===!0&&(this.struggleCalled=this.lastKnockdown?.tick??e.tick,this.say(`struggle`,e.event_id,r,{a:this.nameOf(this.otherId(a)),b:this.nameOf(a)},mp));return;case`get_up`:{for(let e=this.queue.length-1;e>=0;--e)this.queue[e].moment===mp&&this.queue.splice(e,1);this.showing?.moment===mp&&(this.showing.end=Math.min(this.showing.end,r+Hf));let t={a:this.nameOf(this.otherId(i)),b:this.nameOf(i),n:Cp(e.amount)};this.say(e.amount>=8?`upLate`:`upEarly`,e.event_id,r,t,o),this.say(`finishCall`,e.event_id,r,t,null,3.4,4);return}case`perfect_block`:this.say(`parry`,e.event_id,r,s,o,Bf,void 0,i);return;case`evade`:{if(i===null)return;let t=this.notesFor(i);t.evasions=t.evasions.filter(t=>t>e.tick-$f*this.tickRate),t.evasions.push(e.tick),(this.fighter(a)?.action_power===`power`||t.evasions.length>=3)&&this.say(`evade`,e.event_id,r,s,o,Bf,void 0,i)&&(t.evasions.length=0);return}case`whiff`:{let t=this.fighter(i);if(t?.action_power!==`power`||t.action===null)return;this.say(`whiff`,e.event_id,r,{...s,punch:Pp(`${t.action}:${t.action_target??`head`}`,t)},o,Bf,void 0,i);return}case`clinch`:{if(i===null)return;let t=this.fighter(i),n=e.tick-this.notesFor(i).stunnedAt<=3*this.tickRate||t!==void 0&&t.poise<150;this.say(n?`holdingOn`:`clinch`,e.event_id,r,s,o,Bf,void 0,i);return}case`referee_break`:this.say(`refBreak`,e.event_id,r,s,null,Bf,void 0,`referee`);return;case`referee_hit`:this.say(`refHit`,e.event_id,r,s,o,Bf,void 0,i);return;case`referee_down`:this.say(e.action_id===null?`refBledOut`:`refDown`,e.event_id,r,s,o);return;case`clinch_break`:this.say(`noRef`,e.event_id,r,s,null,Bf);return;case`taunt`:this.say(`taunt`,e.event_id,r,{a:s.a,b:this.nameOf(this.otherId(i))},o,Bf,void 0,i);return;case`foul`:this.say(e.detail===`headbutt`?`headbutt`:`lowBlow`,e.event_id,r,s,o),this.fighter(i)?.warnings===1&&this.say(`warning`,e.event_id,r,s,null,3.6,4);return;case`point_deduction`:this.say(`deduction`,e.event_id,r,s,`deduction:${e.tick}`);return;case`resume`:this.say(`resume`,e.event_id,r,s,null);return;case`box`:this.say(`box`,e.event_id,r,{a:this.nameOf(this.otherId(a)),b:this.nameOf(a)},o);return;case`stance`:this.say(e.detail===`southpaw`?`southpaw`:`orthodox`,e.event_id,r,s,null,Bf,void 0,i);return;case`exhausted`:i!==null&&this.tired(i,e.event_id,r);return;case`bell`:e.detail===`round_start`?(this.tallies.clear(),t.round_number>=2&&this.say(`roundStart`,e.event_id,r,{r:t.round_number},null,Bf,gp)):e.detail===`round_end`&&this.roundEnded(e,t,n,r);return;case`injury`:{let n=fe.find(t=>t===e.detail);if(a===null||n===void 0)return;let i=sp[F(n)],c={...s,side:Se(n)??``};!up.has(i)&&t.events.some(t=>t.kind===`knockdown`&&t.tick===e.tick&&t.target_id===a)?this.sayAt(i,e.event_id,r+fp,c,8):this.say(i,e.event_id,r,c,o),up.has(i)&&this.say(`ghastly`,e.event_id,r,s,null,3.8,4);return}case`injury_healed`:{let t=fe.find(t=>t===e.detail);if(t===void 0||F(t)!==`shoulder_dislocated`)return;this.sayAt(`shoulderBack`,e.event_id,r+pp,{b:this.nameOf(a??i),side:Se(t)??``},9);return}case`armless`:this.say(`armless`,e.event_id,r,s,null,Bf,void 0,i);return;case`vomit`:this.say(`vomit`,e.event_id,r,{a:this.nameOf(i??a)},o,Bf,void 0,i??a);return;case`finish_him`:this.say(`finishHim`,e.event_id,r,s,o,0);return;case`fatality`:{let t=me.find(t=>t===e.detail);t!==void 0&&this.say(cp[t],e.event_id,r,s,o,0);return}case`death`:{let t=De(e.detail);if(t===null||a===null)return;this.deaths.set(a,t);let n={a:this.nameOf(i??this.otherId(a)),b:s.b};this.deaths.size>=2?this.say(`doubleDeath`,e.event_id,r,n,null,.6):t===`bled_out`||t===`brain`||t===`gutted`?this.say(lp[t],e.event_id,r,n,o,0):this.say(`deathFatality`,e.event_id,r,n,null,3.6);return}case`result`:this.resulted(e,r);return;default:return}}landed(e,t,n,r,i){let[a,o]=Np(e.detail),s=this.tally(t);s.landed+=1,s.damage+=e.amount,o===`body`&&(s.body+=1);let c=this.notesFor(t),l=this.notesFor(n);l.run=0,l.unanswered=0,c.run=e.tick-c.runTick<=Xf?c.run+1:1,c.runTick=e.tick,c.unanswered+=1,c.window=c.window.filter(t=>t>e.tick-Qf*this.tickRate),c.window.push(e.tick);let u=`${e.tick}:${n}`,d=r.fighters.find(e=>e.player_id===t),f={a:this.nameOf(t),b:this.nameOf(n),punch:Pp(e.detail,d)},p=d?.action_power===`power`&&d.action===a;if(e.kind===`counter_hit`&&e.amount>=40?this.say(`counter`,e.event_id,i,f,u,Bf,void 0,t):(e.amount>=85||p&&o===`head`&&e.amount>=60)&&this.say(`bigShot`,e.event_id,i,f,u,Bf,void 0,t),c.unanswered===5?this.say(`unanswered`,e.event_id,i,f,u,Bf,void 0,t):c.run===3&&this.say(`combo`,e.event_id,i,f,u,Bf,void 0,t),a===`jab`&&(c.jabs=c.jabs.filter(t=>t>e.tick-Zf*this.tickRate),c.jabs.push(e.tick),c.jabs.length>=3&&this.say(`jab`,e.event_id,i,f,null,Bf,void 0,t)&&(c.jabs.length=0)),o===`body`){let a=this.fighter(n);a!==void 0&&s.body>=5&&a.staminat>e.tick-Qf*this.tickRate).length;c.window.length>=7&&m<=2&&c.takeoverRound!==r.round_number&&(c.takeoverRound=r.round_number,this.say(`takeover`,e.event_id,i,f,null,Bf,void 0,t)&&this.hooks.cue?.(`chant`))}roundEnded(e,t,n,r){let i=t.round_number;if(n!==null){(n.detail===`decision`||n.detail===`draw`)&&this.say(`finalBell`,e.event_id,r,{},`bell`,Bf,gp);return}let a=t.fighters.find(t=>{let n=this.notesFor(t.player_id);return t.stunned_ticks>0||t.poise({id:e.player_id,tally:this.tally(e.player_id)})),[c,l]=o.tally.landed>=s.tally.landed?[o,s]:[s,o];c.tally.thrown+l.tally.thrown>0&&this.sayAt(`summary`,e.event_id,r+2.4,{r:i,a:this.nameOf(c.id),x:c.tally.landed,y:c.tally.thrown,b:this.nameOf(l.id),z:l.tally.landed,w:l.tally.thrown},5);let u=(o.tally.knockdowns-s.tally.knockdowns)*1e3+(o.tally.damage-s.tally.damage)+6*(o.tally.landed-s.tally.landed),d=Math.abs(u)0?o:s;d!==null&&(this.notesFor(d.id).rounds+=1);let f=d===null?null:d===o?s:o,p=d===null||f===null?0:this.notesFor(d.id).rounds-this.notesFor(f.id).rounds,m=d===null?`roundClose`:o.tally.knockdowns===s.tally.knockdowns?i>=2&&p>=2?`pullingAway`:`roundFor`:`roundBig`;this.sayAt(m,e.event_id,r+6.4,{a:this.nameOf(d?.id??null),b:this.nameOf(f?.id??null)},5)}resulted(e,t){let n=op[e.detail];if(n===void 0||this.resultCalled)return;this.resultCalled=!0;let r=e.actor_id;this.say(n,e.event_id,t,{a:this.nameOf(r),b:this.nameOf(this.otherId(r))},`result`,0)}inspect(e,t){if(e.phase===`fight`)for(let n of e.fighters){let r=this.notesFor(n.player_id),i={a:this.nameOf(this.otherId(n.player_id)),b:this.nameOf(n.player_id)};for(let[a,o]of[[0,`left`],[1,`right`]]){let s=a===0?n.trauma.left_cut:n.trauma.right_cut,c=r.cutMarks[a];c=ep[c]&&(r.cutMarks[a]=ep.filter(e=>s>=e).length,this.say(c===0?`cut`:c===1?`cutWorse`:`cutGushing`,e.tick+a,t,{...i,side:o},null));let l=a===0?n.trauma.left_eye:n.trauma.right_eye;!r.eyeSwelling[a]&&!r.eyeShut[a]&&l>=tp&&(r.eyeSwelling[a]=!0,this.say(`eyeSwelling`,e.tick+a,t,{...i,side:o},null))}let a=n.stamina/Math.max(1,n.maximum_stamina);a=2*this.tickRate&&this.tired(n.player_id,e.tick,t)):a>=rp&&(r.lowSince=null)}}tired(e,t,n){let r=this.notesFor(e);r.tiredRound!==this.round&&(r.tiredRound=this.round,this.say(`tiring`,t,n,{a:this.nameOf(this.otherId(e)),b:this.nameOf(e)},null))}say(e,t,n,r,i,a=Bf,o,s){let c=xp[e],l=`${e}:${s??``}`;if(c!==void 0){if(n<(this.cooldowns.get(l)??-1/0))return!1;this.cooldowns.set(l,n+c)}let u=jp(this.choose(e,t),r),d={speaker:bp[e]??`play`,text:u,priority:yp[e],urgent:_p.has(e),hold:zp(u),card:null},f=up.has(e);return this.enqueue(d,n+a,i,o??(f?Gf:void 0),dp[e]??null,null,f)}sayAt(e,t,n,r,i){let a=jp(this.choose(e,t),r);this.enqueue({speaker:bp[e]??`play`,text:a,priority:yp[e],urgent:_p.has(e),hold:zp(a),card:null},n,null,i)}announcement(e,t,n,r){return{speaker:`announcer`,text:e,priority:r,urgent:!0,hold:n,card:t}}choose(e,t){let n=ap[e],r=this.refereeDead&&vp.has(e)?n.filter(e=>!/referee/iu.test(e)):n,i=Mp(t,e.length*31+e.charCodeAt(0))%r.length;return r.length>1&&this.lastChoice.get(e)===i&&(i=(i+1)%r.length),this.lastChoice.set(e,i),r[i]}enqueue(e,t,n,r,i=null,a=null,o=!1){if(n!==null){if(!o&&this.queue.some(t=>t.moment===n&&t.line.priority>=e.priority)||!o&&this.showing?.moment===n&&this.showing.line.priority>=e.priority)return!1;for(let t=this.queue.length-1;t>=0;--t){let r=this.queue[t];r.moment===n&&!r.big&&r.line.priorityqf){let e=0;for(let t=1;tt.player_id===e)}otherId(e){let t=this.fighters;return t===null||e===null?null:t[0].player_id===e?t[1].player_id:t[1].player_id===e?t[0].player_id:null}seatOf(e){let t=this.fighters?.findIndex(t=>t.player_id===e)??-1;return t===0||t===1?t:null}nameOf(e){if(e===null)return`the fighter`;let t=this.players[e]?.name;if(t!==void 0&&t.trim().length>0)return t.trim();let n=this.seatOf(e);return n===0?`the blue corner`:n===1?`the red corner`:`the fighter`}};function zp(e){return Math.min(5.2,Math.max(2.2,1.4+e.length*.05))}var Bp=`attached`,Vp=1e3,Hp=1001,Up=1002,Wp=1003,Gp=1004,Kp=1005,qp=1006,Jp=1007,Yp=1008,Xp=1009,Zp=1010,Qp=1011,$p=1012,em=1013,tm=1014,nm=1015,rm=1016,im=1017,am=1018,om=1020,sm=35902,cm=35899,lm=1021,um=1022,dm=1023,fm=1026,pm=1027,mm=1028,hm=1029,gm=1030,_m=1031,vm=1033,ym=33776,bm=33777,xm=33778,Sm=33779,Cm=35840,wm=35841,Tm=35842,Em=35843,Dm=36196,Om=37492,km=37496,Am=37488,jm=37489,Mm=37490,Nm=37491,Pm=37808,Fm=37809,Im=37810,Lm=37811,Rm=37812,zm=37813,Bm=37814,Vm=37815,Hm=37816,Um=37817,Wm=37818,Gm=37819,Km=37820,qm=37821,Jm=36492,Ym=36494,Xm=36495,Zm=36283,Qm=36284,$m=36285,eh=36286,th=2300,nh=2301,rh=2302,ih=2303,ah=2400,oh=2401,sh=2402,ch=2500,lh=3200,uh=`srgb`,dh=`srgb-linear`,fh=`linear`,ph=`srgb`,mh=7680,hh=35044,gh=35048,_h=2e3;function vh(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function yh(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function bh(e){return document.createElementNS(`http://www.w3.org/1999/xhtml`,e)}function xh(){let e=bh(`canvas`);return e.style.display=`block`,e}var Sh={};function Ch(...e){let t=`THREE.`+e.shift();console.log(t,...e)}function wh(e){let t=e[0];if(typeof t==`string`&&t.startsWith(`TSL:`)){let t=e[1];t&&t.isStackTrace?e[0]+=` `+t.getLocation():e[1]=`Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.`}return e}function Th(...e){e=wh(e);let t=`THREE.`+e.shift();{let n=e[0];n&&n.isStackTrace?console.warn(n.getError(t)):console.warn(t,...e)}}function Eh(...e){e=wh(e);let t=`THREE.`+e.shift();{let n=e[0];n&&n.isStackTrace?console.error(n.getError(t)):console.error(t,...e)}}function Dh(...e){let t=e.join(` `);t in Sh||(Sh[t]=!0,Th(...e))}function Oh(e,t,n){return new Promise(function(r,i){function a(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:i();break;case e.TIMEOUT_EXPIRED:setTimeout(a,n);break;default:r()}}setTimeout(a,n)})}var kh={0:1,2:6,4:7,3:5,1:0,6:2,7:4,5:3},Ah=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n!==void 0&&n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let r=n[e];if(r!==void 0){let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let t=n.slice(0);for(let n=0,r=t.length;n>8&255]+jh[e>>16&255]+jh[e>>24&255]+`-`+jh[t&255]+jh[t>>8&255]+`-`+jh[t>>16&15|64]+jh[t>>24&255]+`-`+jh[n&63|128]+jh[n>>8&255]+`-`+jh[n>>16&255]+jh[n>>24&255]+jh[r&255]+jh[r>>8&255]+jh[r>>16&255]+jh[r>>24&255]).toLowerCase()}function Ih(e,t,n){return Math.max(t,Math.min(n,e))}function Lh(e,t){return(e%t+t)%t}function Rh(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)}function zh(e,t,n){return e===t?0:(n-e)/(t-e)}function Bh(e,t,n){return(1-n)*e+n*t}function Vh(e,t,n,r){return Bh(e,t,1-Math.exp(-n*r))}function Hh(e,t=1){return t-Math.abs(Lh(e,t*2)-t)}function Uh(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function Wh(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function Gh(e,t){return e+Math.floor(Math.random()*(t-e+1))}function Kh(e,t){return e+Math.random()*(t-e)}function qh(e){return e*(.5-Math.random())}function Jh(e){e!==void 0&&(Mh=e);let t=Mh+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function Yh(e){return e*Nh}function Xh(e){return e*Ph}function Zh(e){return e>0&&Number.isInteger(e)&&2**Math.round(Math.log2(e))===e}function Qh(e){return 2**Math.ceil(Math.log(e)/Math.LN2)}function $h(e){return 2**Math.floor(Math.log(e)/Math.LN2)}function eg(e,t,n,r,i){let a=Math.cos,o=Math.sin,s=a(n/2),c=o(n/2),l=a((t+r)/2),u=o((t+r)/2),d=a((t-r)/2),f=o((t-r)/2),p=a((r-t)/2),m=o((r-t)/2);switch(i){case`XYX`:e.set(s*u,c*d,c*f,s*l);break;case`YZY`:e.set(c*f,s*u,c*d,s*l);break;case`ZXZ`:e.set(c*d,c*f,s*u,s*l);break;case`XZX`:e.set(s*u,c*m,c*p,s*l);break;case`YXY`:e.set(c*p,s*u,c*m,s*l);break;case`ZYZ`:e.set(c*m,c*p,s*u,s*l);break;default:Th(`MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: `+i)}}function tg(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:case Uint8ClampedArray:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error(`THREE.MathUtils: Invalid component type.`)}}function ng(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:case Uint8ClampedArray:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error(`THREE.MathUtils: Invalid component type.`)}}var G={DEG2RAD:Nh,RAD2DEG:Ph,generateUUID:Fh,clamp:Ih,euclideanModulo:Lh,mapLinear:Rh,inverseLerp:zh,lerp:Bh,damp:Vh,pingpong:Hh,smoothstep:Uh,smootherstep:Wh,randInt:Gh,randFloat:Kh,randFloatSpread:qh,seededRandom:Jh,degToRad:Yh,radToDeg:Xh,isPowerOfTwo:Zh,ceilPowerOfTwo:Qh,floorPowerOfTwo:$h,setQuaternionFromProperEuler:eg,normalize:ng,denormalize:tg},K=class e{static{e.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error(`THREE.Vector2: index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error(`THREE.Vector2: index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Ih(this.x,e.x,t.x),this.y=Ih(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Ih(this.x,e,t),this.y=Ih(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Ih(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(Ih(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},rg=class{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,a,o){let s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],d=i[a+0],f=i[a+1],p=i[a+2],m=i[a+3];if(u!==m||s!==d||c!==f||l!==p){let e=s*d+c*f+l*p+u*m;e<0&&(d=-d,f=-f,p=-p,m=-m,e=-e);let t=1-o;if(e<.9995){let n=Math.acos(e),r=Math.sin(n);t=Math.sin(t*n)/r,o=Math.sin(o*n)/r,s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o}else{s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o;let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:Th(`Quaternion: .setFromEuler() encountered an unknown order: `+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Ih(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,r=-r,i=-i,a=-a,o=-o);let s=1-t;if(o<.9995){let e=Math.acos(o),c=Math.sin(e);s=Math.sin(s*e)/c,t=Math.sin(t*e)/c,this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this._onChangeCallback()}else this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},q=class e{static{e.prototype.isVector3=!0}constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error(`THREE.Vector3: index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error(`THREE.Vector3: index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(ag.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(ag.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=2*(a*r-o*n),l=2*(o*t-i*r),u=2*(i*n-a*t);return this.x=t+s*c+a*u-o*l,this.y=n+s*l+o*c-i*u,this.z=r+s*u+i*l-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Ih(this.x,e.x,t.x),this.y=Ih(this.y,e.y,t.y),this.z=Ih(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Ih(this.x,e,t),this.y=Ih(this.y,e,t),this.z=Ih(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Ih(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return ig.copy(this).projectOnVector(e),this.sub(ig)}reflect(e){return this.sub(ig.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(Ih(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},ig=new q,ag=new rg,og=class e{static{e.prototype.isMatrix3=!0}constructor(e,t,n,r,i,a,o,s,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,i,a,o,s,c)}set(e,t,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){return Dh(`Matrix3: .scale() is deprecated. Use .makeScale() instead.`),this.premultiply(sg.makeScale(e,t)),this}rotate(e){return Dh(`Matrix3: .rotate() is deprecated. Use .makeRotation() instead.`),this.premultiply(sg.makeRotation(-e)),this}translate(e,t){return Dh(`Matrix3: .translate() is deprecated. Use .makeTranslation() instead.`),this.premultiply(sg.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}},sg=new og,cg=new og().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),lg=new og().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function ug(){let e={enabled:!0,workingColorSpace:dh,spaces:{},convert:function(e,t,n){return this.enabled===!1||t===n||!t||!n||(this.spaces[t].transfer===`srgb`&&(e.r=fg(e.r),e.g=fg(e.g),e.b=fg(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===`srgb`&&(e.r=pg(e.r),e.g=pg(e.g),e.b=pg(e.b))),e},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===``?fh:this.spaces[e].transfer},getToneMappingMode:function(e){return this.spaces[e].outputColorSpaceConfig.toneMappingMode||`standard`},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(t,n){return Dh(`ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().`),e.workingToColorSpace(t,n)},toWorkingColorSpace:function(t,n){return Dh(`ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().`),e.colorSpaceToWorking(t,n)}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[dh]:{primaries:t,whitePoint:r,transfer:fh,toXYZ:cg,fromXYZ:lg,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:uh},outputColorSpaceConfig:{drawingBufferColorSpace:uh}},[uh]:{primaries:t,whitePoint:r,transfer:ph,toXYZ:cg,fromXYZ:lg,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:uh}}}),e}var dg=ug();function fg(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function pg(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}var mg,hg=class{static getDataURL(e,t=`image/png`){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>`u`)return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{mg===void 0&&(mg=bh(`canvas`)),mg.width=e.width,mg.height=e.height;let t=mg.getContext(`2d`);e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),n=mg}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap){let t=bh(`canvas`);t.width=e.width,t.height=e.height;let n=t.getContext(`2d`);n.drawImage(e,0,0,e.width,e.height);let r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let e=0;e1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(bg).x}get height(){return this.source.getSize(bg).y}get depth(){return this.source.getSize(bg).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){Th(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];r===void 0?Th(`Texture.setValues(): property '${t}' does not exist.`):r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:`Texture`,generator:`Texture.toJSON`},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:`dispose`})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Vp:e.x-=Math.floor(e.x);break;case Hp:e.x=e.x<0?0:1;break;case Up:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x-=Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case Vp:e.y-=Math.floor(e.y);break;case Hp:e.y=e.y<0?0:1;break;case Up:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y-=Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};xg.DEFAULT_IMAGE=null,xg.DEFAULT_MAPPING=300,xg.DEFAULT_ANISOTROPY=1;var Sg=class e{static{e.prototype.isVector4=!0}constructor(e=0,t=0,n=0,r=1){this.x=e,this.y=t,this.z=n,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error(`THREE.Vector4: index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error(`THREE.Vector4: index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w===void 0?1:e.w,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,i,a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],f=s[5],p=s[9],m=s[2],h=s[6],g=s[10];if(Math.abs(l-d)s&&e>_?e_?s1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t>>0}enable(e){this.mask|=1<1){for(let e=0;e1){for(let e=0;e0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type=`InstancedMesh`,r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type=`BatchedMesh`,r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox?e.boundingBox.toJSON():void 0,boundingSphere:e.boundingSphere?e.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(e=>({...e})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function i(t,n){return t[n.uuid]===void 0&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);let t=this.geometry.parameters;if(t!==void 0&&t.shapes!==void 0){let n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t0){r.children=[];for(let t=0;t0){r.animations=[];for(let t=0;t0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),c.length>0&&(n.skeletons=c),l.length>0&&(n.animations=l),u.length>0&&(n.nodes=u)}return n.object=r,n;function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot===null?null:e.pivot.clone(),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let t=0;t.025?(c.inputState.pinching=!1,this.dispatchEvent({type:`pinchend`,handedness:e.handedness,target:this})):!c.inputState.pinching&&o<=.015&&(c.inputState.pinching=!0,this.dispatchEvent({type:`pinchstart`,handedness:e.handedness,target:this}))}else s!==null&&e.gripSpace&&(i=t.getPose(e.gripSpace,n),i!==null&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1,s.eventsEnabled&&s.dispatchEvent({type:`gripUpdated`,data:e,target:this})));o!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&i!==null&&(r=i),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(n_)))}return o!==null&&(o.visible=r!==null),s!==null&&(s.visible=i!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new t_;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},i_={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},a_={h:0,s:0,l:0},o_={h:0,s:0,l:0};function s_(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}var J=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let t=e;t&&t.isColor?this.copy(t):typeof t==`number`?this.setHex(t):typeof t==`string`&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=uh){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,dg.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=dg.workingColorSpace){return this.r=e,this.g=t,this.b=n,dg.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=dg.workingColorSpace){if(e=Lh(e,1),t=Ih(t,0,1),n=Ih(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=s_(i,r,e+1/3),this.g=s_(i,r,e),this.b=s_(i,r,e-1/3)}return dg.colorSpaceToWorking(this,r),this}setStyle(e,t=uh){function n(t){t!==void 0&&parseFloat(t)<1&&Th(`Color: Alpha component of `+e+` will be ignored.`)}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],o=r[2];switch(a){case`rgb`:case`rgba`:if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case`hsl`:case`hsla`:if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:Th(`Color: Unknown color model `+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=r[1],i=n.length;if(i===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(n,16),t);Th(`Color: Invalid hex color `+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=uh){let n=i_[e.toLowerCase()];return n===void 0?Th(`Color: Unknown color `+e):this.setHex(n,t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=fg(e.r),this.g=fg(e.g),this.b=fg(e.b),this}copyLinearToSRGB(e){return this.r=pg(e.r),this.g=pg(e.g),this.b=pg(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=uh){return dg.workingToColorSpace(c_.copy(this),e),Math.round(Ih(c_.r*255,0,255))*65536+Math.round(Ih(c_.g*255,0,255))*256+Math.round(Ih(c_.b*255,0,255))}getHexString(e=uh){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=dg.workingColorSpace){dg.workingToColorSpace(c_.copy(this),t);let n=c_.r,r=c_.g,i=c_.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){d_.subVectors(r,t),f_.subVectors(n,t),p_.subVectors(e,t);let a=d_.dot(d_),o=d_.dot(f_),s=d_.dot(p_),c=f_.dot(f_),l=f_.dot(p_),u=a*c-o*o;if(u===0)return i.set(0,0,0),null;let d=1/u,f=(c*s-o*l)*d,p=(a*l-o*s)*d;return i.set(1-f-p,p,f)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,m_)!==null&&m_.x>=0&&m_.y>=0&&m_.x+m_.y<=1}static getInterpolation(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,m_)===null?(s.x=0,s.y=0,`z`in s&&(s.z=0),`w`in s&&(s.w=0),null):(s.setScalar(0),s.addScaledVector(i,m_.x),s.addScaledVector(a,m_.y),s.addScaledVector(o,m_.z),s)}static getInterpolatedAttribute(e,t,n,r,i,a){return x_.setScalar(0),S_.setScalar(0),C_.setScalar(0),x_.fromBufferAttribute(e,t),S_.fromBufferAttribute(e,n),C_.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(x_,i.x),a.addScaledVector(S_,i.y),a.addScaledVector(C_,i.z),a}static isFrontFacing(e,t,n,r){return d_.subVectors(n,t),f_.subVectors(e,t),d_.cross(f_).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return d_.subVectors(this.c,this.b),f_.subVectors(this.a,this.b),d_.cross(f_).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return e.getNormal(this.a,this.b,this.c,t)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,n){return e.getBarycoord(t,this.a,this.b,this.c,n)}getInterpolation(t,n,r,i,a){return e.getInterpolation(t,this.a,this.b,this.c,n,r,i,a)}containsPoint(t){return e.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return e.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,r=this.b,i=this.c,a,o;h_.subVectors(r,n),g_.subVectors(i,n),v_.subVectors(e,n);let s=h_.dot(v_),c=g_.dot(v_);if(s<=0&&c<=0)return t.copy(n);y_.subVectors(e,r);let l=h_.dot(y_),u=g_.dot(y_);if(l>=0&&u<=l)return t.copy(r);let d=s*u-l*c;if(d<=0&&s>=0&&l<=0)return a=s/(s-l),t.copy(n).addScaledVector(h_,a);b_.subVectors(e,i);let f=h_.dot(b_),p=g_.dot(b_);if(p>=0&&f<=p)return t.copy(i);let m=f*c-s*p;if(m<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(n).addScaledVector(g_,o);let h=l*p-f*u;if(h<=0&&u-l>=0&&f-p>=0)return __.subVectors(i,r),o=(u-l)/(u-l+(f-p)),t.copy(r).addScaledVector(__,o);let g=1/(h+m+d);return a=m*g,o=d*g,t.copy(n).addScaledVector(h_,a).addScaledVector(g_,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},T_=class{constructor(e=new q(1/0,1/0,1/0),t=new q(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,D_),D_.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(F_),I_.subVectors(this.max,F_),k_.subVectors(e.a,F_),A_.subVectors(e.b,F_),j_.subVectors(e.c,F_),M_.subVectors(A_,k_),N_.subVectors(j_,A_),P_.subVectors(k_,j_);let t=[0,-M_.z,M_.y,0,-N_.z,N_.y,0,-P_.z,P_.y,M_.z,0,-M_.x,N_.z,0,-N_.x,P_.z,0,-P_.x,-M_.y,M_.x,0,-N_.y,N_.x,0,-P_.y,P_.x,0];return!z_(t,k_,A_,j_,I_)||(t=[1,0,0,0,1,0,0,0,1],!z_(t,k_,A_,j_,I_))?!1:(L_.crossVectors(M_,N_),t=[L_.x,L_.y,L_.z],z_(t,k_,A_,j_,I_))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,D_).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(D_).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()||(E_[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),E_[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),E_[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),E_[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),E_[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),E_[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),E_[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),E_[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(E_)),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}},E_=[new q,new q,new q,new q,new q,new q,new q,new q],D_=new q,O_=new T_,k_=new q,A_=new q,j_=new q,M_=new q,N_=new q,P_=new q,F_=new q,I_=new q,L_=new q,R_=new q;function z_(e,t,n,r,i){for(let a=0,o=e.length-3;a<=o;a+=3){R_.fromArray(e,a);let o=i.x*Math.abs(R_.x)+i.y*Math.abs(R_.y)+i.z*Math.abs(R_.z),s=t.dot(R_),c=n.dot(R_),l=r.dot(R_);if(Math.max(-Math.max(s,c,l),Math.min(s,c,l))>o)return!1}return!0}var B_=new q,V_=new K,H_=0,U_=class extends Ah{constructor(e,t,n=!1){if(super(),Array.isArray(e))throw TypeError(`THREE.BufferAttribute: array should be a Typed Array.`);this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:H_++}),this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n,this.usage=hh,this.updateRanges=[],this.gpuType=nm,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;rthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius*=e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;J_.subVectors(e,this.center);let t=J_.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=(e-this.radius)*.5;this.center.addScaledVector(J_,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Y_.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(J_.copy(e.center).add(Y_)),this.expandByPoint(J_.copy(e.center).sub(Y_))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}},Z_=0,Q_=new Dg,$_=new e_,ev=new q,tv=new T_,nv=new T_,rv=new q,iv=class e extends Ah{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Z_++}),this.uuid=Fh(),this.name=``,this.type=`BufferGeometry`,this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return this.index=Array.isArray(e)?new(vh(e)?G_:W_)(e,1):e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let t=new og().getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return Q_.makeRotationFromQuaternion(e),this.applyMatrix4(Q_),this}rotateX(e){return Q_.makeRotationX(e),this.applyMatrix4(Q_),this}rotateY(e){return Q_.makeRotationY(e),this.applyMatrix4(Q_),this}rotateZ(e){return Q_.makeRotationZ(e),this.applyMatrix4(Q_),this}translate(e,t,n){return Q_.makeTranslation(e,t,n),this.applyMatrix4(Q_),this}scale(e,t,n){return Q_.makeScale(e,t,n),this.applyMatrix4(Q_),this}lookAt(e){return $_.lookAt(e),$_.updateMatrix(),this.applyMatrix4($_.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ev).negate(),this.translate(ev.x,ev.y,ev.z),this}setFromPoints(e){let t=this.getAttribute(`position`);if(t===void 0){let t=[];for(let n=0,r=e.length;nt.count&&Th(`BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.`),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new T_);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)Eh(`BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.`,this),this.boundingBox.set(new q(-1/0,-1/0,-1/0),new q(1/0,1/0,1/0));else{if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){let t=this.parameters;for(let n in t)t[n]!==void 0&&(e[n]=t[n]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let t in n){let r=n[t];e.data.attributes[t]=r.toJSON(e.data)}let r={},i=!1;for(let t in this.morphAttributes){let n=this.morphAttributes[t],a=[];for(let t=0,r=n.length;t0&&(r[t]=a,i=!0)}i&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let r=e.attributes;for(let e in r){let n=r[e];this.setAttribute(e,n.clone(t))}let i=e.morphAttributes;for(let e in i){let n=[],r=i[e];for(let e=0,i=r.length;e1)?null:t.copy(e.start).addScaledVector(r,a)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||uv.getNormalMatrix(e),r=this.coplanarPoint(cv).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}toJSON(){return{normal:this.normal.toArray(),constant:this.constant}}fromJSON(e){return this.normal.fromArray(e.normal),this.constant=e.constant,this}},fv=0,pv=class extends Ah{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:fv++}),this.uuid=Fh(),this.name=``,this.type=`Material`,this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new J(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=mh,this.stencilZFail=mh,this.stencilZPass=mh,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){Th(`Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];r===void 0?Th(`Material: '${t}' is not a property of THREE.${this.type}.`):r&&r.isColor?r.set(n):r&&r.isVector2&&n&&n.isVector2||r&&r.isEuler&&n&&n.isEuler||r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:`Material`,generator:`Material.toJSON`}};n.uuid=this.uuid,n.type=this.type,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,n.name=this.name,this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.retroreflectivity!==void 0&&(n.retroreflectivity=this.retroreflectivity),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0&&(n.clippingPlanes=this.clippingPlanes.map(e=>e.toJSON())),this.rotation!==void 0&&(n.rotation=this.rotation),this.depthPacking!==void 0&&(n.depthPacking=this.depthPacking),this.linewidth!==void 0&&(n.linewidth=this.linewidth),this.linecap!==void 0&&(n.linecap=this.linecap),this.linejoin!==void 0&&(n.linejoin=this.linejoin),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.wireframe!==void 0&&(n.wireframe=this.wireframe),this.wireframeLinewidth!==void 0&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==void 0&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==void 0&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading!==void 0&&(n.flatShading=this.flatShading),this.fog!==void 0&&(n.fog=this.fog),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=r(e.textures),i=r(e.images);t.length>0&&(n.textures=t),i.length>0&&(n.images=i)}return n}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new J().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.retroreflectivity!==void 0&&(this.retroreflectivity=e.retroreflectivity),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.clippingPlanes!==void 0&&(this.clippingPlanes=e.clippingPlanes.map(e=>new dv().fromJSON(e))),e.clipIntersection!==void 0&&(this.clipIntersection=e.clipIntersection),e.clipShadows!==void 0&&(this.clipShadows=e.clipShadows),e.depthPacking!==void 0&&(this.depthPacking=e.depthPacking),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.linecap!==void 0&&(this.linecap=e.linecap),e.linejoin!==void 0&&(this.linejoin=e.linejoin),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(this.vertexColors=typeof e.vertexColors==`number`?e.vertexColors>0:e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let t=e.normalScale;Array.isArray(t)===!1&&(t=[t,t]),this.normalScale=new K().fromArray(t)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new K().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let e=t.length;n=Array(e);for(let r=0;r!==e;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:`dispose`})}set needsUpdate(e){e===!0&&this.version++}},mv=new q,hv=new q,gv=new q,_v=new q,vv=class{constructor(e=new q,t=new q(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,mv)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=mv.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(mv.copy(this.origin).addScaledVector(this.direction,t),mv.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){hv.copy(e).add(t).multiplyScalar(.5),gv.copy(t).sub(e).normalize(),_v.copy(this.origin).sub(hv);let i=e.distanceTo(t)*.5,a=-this.direction.dot(gv),o=_v.dot(this.direction),s=-_v.dot(gv),c=_v.lengthSq(),l=Math.abs(1-a*a),u,d,f,p;if(l>0){if(u=a*s-o,d=a*o-s,p=i*l,u>=0){if(d>=-p){if(d<=p){let e=1/l;u*=e,d*=e,f=u*(u+a*d+2*o)+d*(a*u+d+2*s)+c}else d=i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c}else d=-i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c}else d<=-p?(u=Math.max(0,-(-a*i+o)),d=u>0?-i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c):d<=p?(u=0,d=Math.min(Math.max(-i,-s),i),f=d*(d+2*s)+c):(u=Math.max(0,-(a*i+o)),d=u>0?i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c)}else d=a>0?-i:i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),r&&r.copy(hv).addScaledVector(gv,d),f}intersectSphere(e,t){if(e.radius<0)return null;mv.subVectors(e.center,this.origin);let n=mv.dot(this.direction),r=mv.dot(mv)-n*n,i=e.radius*e.radius;if(r>i)return null;let a=Math.sqrt(i-r),o=n-a,s=n+a;return s<0?null:o<0?this.at(s,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),l>=0?(i=(e.min.y-d.y)*l,a=(e.max.y-d.y)*l):(i=(e.max.y-d.y)*l,a=(e.min.y-d.y)*l),n>a||i>r||((i>n||isNaN(n))&&(n=i),(a=0?(o=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||o>r)||((o>n||n!==n)&&(n=o),(s=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,mv)!==null}intersectTriangle(e,t,n,r,i){let a=this.origin,o=this.direction,s=o.x,c=o.y,l=o.z,u=e.x-a.x,d=e.y-a.y,f=e.z-a.z,p=t.x-a.x,m=t.y-a.y,h=t.z-a.z,g=n.x-a.x,_=n.y-a.y,v=n.z-a.z,y=Math.abs(s),b=Math.abs(c),x=Math.abs(l),S,C,w,T,E,D,O,k,A,j,ee,M;if(y>=b&&y>=x?(w=s,D=u,A=p,M=g,s>=0?(S=c,C=l,T=d,E=f,O=m,k=h,j=_,ee=v):(S=l,C=c,T=f,E=d,O=h,k=m,j=v,ee=_)):b>=x?(w=c,D=d,A=m,M=_,c>=0?(S=l,C=s,T=f,E=u,O=h,k=p,j=v,ee=g):(S=s,C=l,T=u,E=f,O=p,k=h,j=g,ee=v)):(w=l,D=f,A=h,M=v,l>=0?(S=s,C=c,T=u,E=d,O=p,k=m,j=g,ee=_):(S=c,C=s,T=d,E=u,O=m,k=p,j=_,ee=g)),w===0)return null;let te=S/w,ne=C/w,re=1/w,ie=T-te*D,N=E-ne*D,ae=O-te*A,oe=k-ne*A,se=j-te*M,ce=ee-ne*M,le=se*oe-ce*ae,P=ie*ce-N*se,ue=ae*N-oe*ie;if(r){if(le<0||P<0||ue<0)return null}else if((le<0||P<0||ue<0)&&(le>0||P>0||ue>0))return null;let de=le+P+ue;if(de===0)return null;let fe=re*(le*D+P*A+ue*M);return(de>0?fe<0:fe>0)?null:this.at(fe/de,i)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},yv=class extends pv{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type=`MeshBasicMaterial`,this.color=new J(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Lg,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},bv=new Dg,xv=new vv,Sv=new X_,Cv=new q,wv=new q,Tv=new q,Ev=new q,Dv=new q,Ov=new q,kv=new q,Av=new q,Y=class extends e_{constructor(e=new iv,t=new yv){super(),this.isMesh=!0,this.type=`Mesh`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e(e.far-e.near)**2)||(bv.copy(i).invert(),xv.copy(e.ray).applyMatrix4(bv),(n.boundingBox===null||xv.intersectsBox(n.boundingBox)!==!1)&&this._computeIntersections(e,t,xv)))}_computeIntersections(e,t,n){let r,i=this.geometry,a=this.material,o=i.index,s=i.attributes.position,c=i.attributes.uv,l=i.attributes.uv1,u=i.attributes.normal,d=i.groups,f=i.drawRange;if(o!==null){if(Array.isArray(a))for(let i=0,s=d.length;in.far?null:{distance:l,point:Av.clone(),object:e}}function Mv(e,t,n,r,i,a,o,s,c,l){e.getVertexPosition(s,wv),e.getVertexPosition(c,Tv),e.getVertexPosition(l,Ev);let u=jv(e,t,n,r,wv,Tv,Ev,kv);if(u){let e=new q;w_.getBarycoord(kv,wv,Tv,Ev,e),i&&(u.uv=w_.getInterpolatedAttribute(i,s,c,l,e,new K)),a&&(u.uv1=w_.getInterpolatedAttribute(a,s,c,l,e,new K)),o&&(u.normal=w_.getInterpolatedAttribute(o,s,c,l,e,new q),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));let t={a:s,b:c,c:l,normal:new q,materialIndex:0};w_.getNormal(wv,Tv,Ev,t.normal),u.face=t,u.barycoord=e}return u}var Nv=new Sg,Pv=new Sg,Fv=new Sg,Iv=new Sg,Lv=new Dg,Rv=new q,zv=new X_,Bv=new Dg,Vv=new vv,Hv=class extends Y{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type=`SkinnedMesh`,this.bindMode=Bp,this.bindMatrix=new Dg,this.bindMatrixInverse=new Dg,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;this.boundingBox===null&&(this.boundingBox=new T_),this.boundingBox.makeEmpty();let t=e.getAttribute(`position`);for(let e=0;e0?e.max.x:e.min.x,ay.y=r.normal.y>0?e.max.y:e.min.y,ay.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(ay)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}},sy=class extends pv{constructor(e){super(),this.isLineBasicMaterial=!0,this.type=`LineBasicMaterial`,this.color=new J(16777215),this.map=null,this.linewidth=1,this.linecap=`round`,this.linejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},cy=new q,ly=new q,uy=new Dg,dy=new vv,fy=new X_,py=new q,my=new q,hy=class extends e_{constructor(e=new iv,t=new sy){super(),this.isLine=!0,this.type=`Line`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let e=1,r=t.count;e0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;er)return;py.applyMatrix4(e.matrixWorld);let c=t.ray.origin.distanceTo(py);if(!(ct.far))return{distance:c,point:my.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}var _y=new q,vy=new q,yy=class extends hy{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type=`LineSegments`}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let e=0,r=t.count;e0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;ei.far)return;a.push({distance:c,distanceToRay:Math.sqrt(s),point:n,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}var Oy=class extends xg{constructor(e=[],t=301,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,s,c,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},ky=class extends xg{constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r,i,a,o,s,c),this.isCanvasTexture=!0,this.needsUpdate=!0}},Ay=class extends xg{constructor(e,t,n=tm,r,i,a,o=Wp,s=Wp,c,l=fm,u=1){if(l!==1026&&l!==1027)throw Error(`THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat`);super({width:e,height:t,depth:u},r,i,a,o,s,l,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new _g(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}},jy=class extends Ay{constructor(e,t=tm,n=301,r,i,a=Wp,o=Wp,s,c=fm){let l={width:e,height:e,depth:1},u=[l,l,l,l,l,l];super(e,e,t,n,r,i,a,o,s,c),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},My=class extends xg{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},Ny=class e extends iv{constructor(e=1,t=1,n=1,r=1,i=1,a=1){super(),this.type=`BoxGeometry`,this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:a};let o=this;r=Math.floor(r),i=Math.floor(i),a=Math.floor(a);let s=[],c=[],l=[],u=[],d=0,f=0;p(`z`,`y`,`x`,-1,-1,n,t,e,a,i,0),p(`z`,`y`,`x`,1,-1,n,t,-e,a,i,1),p(`x`,`z`,`y`,1,1,e,n,t,r,a,2),p(`x`,`z`,`y`,1,-1,e,n,-t,r,a,3),p(`x`,`y`,`z`,1,-1,e,t,n,r,i,4),p(`x`,`y`,`z`,-1,-1,e,t,-n,r,i,5),this.setIndex(s),this.setAttribute(`position`,new K_(c,3)),this.setAttribute(`normal`,new K_(l,3)),this.setAttribute(`uv`,new K_(u,2));function p(e,t,n,r,i,a,p,m,h,g,_){let v=a/h,y=p/g,b=a/2,x=p/2,S=m/2,C=h+1,w=g+1,T=0,E=0,D=new q;for(let a=0;a0?1:-1,l.push(D.x,D.y,D.z),u.push(s/h),u.push(1-a/g),T+=1}for(let e=0;e0){let e=(_-1)*m;for(let t=0;t0&&v(!0),t>0&&v(!1)),this.setIndex(l),this.setAttribute(`position`,new K_(u,3)),this.setAttribute(`normal`,new K_(d,3)),this.setAttribute(`uv`,new K_(f,2));function _(){let a=new q,_=new q,v=0,y=(t-e)/n;for(let c=0;c<=i;c++){let l=[],g=c/i,v=g*(t-e)+e;for(let e=0;e<=r;e++){let t=e/r,i=t*s+o,c=Math.sin(i),m=Math.cos(i);_.x=v*c,_.y=-g*n+h,_.z=v*m,u.push(_.x,_.y,_.z),a.set(c,y,m).normalize(),d.push(a.x,a.y,a.z),f.push(t,1-g),l.push(p++)}m.push(l)}for(let n=0;n0||r!==0)&&(l.push(a,o,c),v+=3),(t>0||r!==i-1)&&(l.push(o,s,c),v+=3)}c.addGroup(g,v,0),g+=v}function v(n){let i=p,a=new K,m=new q,_=0,v=n===!0?e:t,y=n===!0?1:-1;for(let e=1;e<=r;e++)u.push(0,h*y,0),d.push(0,y,0),f.push(.5,.5),p++;let b=p;for(let e=0;e<=r;e++){let t=e/r*s+o,n=Math.cos(t),i=Math.sin(t);m.x=v*i,m.y=h*y,m.z=v*n,u.push(m.x,m.y,m.z),d.push(0,y,0),a.x=n*.5+.5,a.y=i*.5*y+.5,f.push(a.x,a.y),p++}for(let e=0;e.9&&Math.min(t,n,r)<.1&&(t<.2&&(a[e+0]+=1),n<.2&&(a[e+2]+=1),r<.2&&(a[e+4]+=1))}}function d(e){i.push(e.x,e.y,e.z)}function f(t,n){let r=t*3;n.x=e[r+0],n.y=e[r+1],n.z=e[r+2]}function p(){let e=new q,t=new q,n=new q,r=new q,o=new K,s=new K,c=new K;for(let l=0,u=0;l0)s=r-1;else{s=r;break}if(r=s,n[r]===a)return r/(i-1);let l=n[r],u=n[r+1]-l,d=(a-l)/u;return(r+d)/(i-1)}getTangent(e,t){let n=1e-4,r=e-n,i=e+n;r<0&&(r=0),i>1&&(i=1);let a=this.getPoint(r),o=this.getPoint(i),s=t||(a.isVector2?new K:new q);return s.copy(o).sub(a).normalize(),s}getTangentAt(e,t){let n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){let n=new q,r=[],i=[],a=[],o=new q,s=new Dg;for(let t=0;t<=e;t++){let n=t/e;r[t]=this.getTangentAt(n,new q)}i[0]=new q,a[0]=new q;let c=Number.MAX_VALUE,l=Math.abs(r[0].x),u=Math.abs(r[0].y),d=Math.abs(r[0].z);l<=c&&(c=l,n.set(1,0,0)),u<=c&&(c=u,n.set(0,1,0)),d<=c&&n.set(0,0,1),o.crossVectors(r[0],n).normalize(),i[0].crossVectors(r[0],o),a[0].crossVectors(r[0],i[0]);for(let t=1;t<=e;t++){if(i[t]=i[t-1].clone(),a[t]=a[t-1].clone(),o.crossVectors(r[t-1],r[t]),o.length()>2**-52){o.normalize();let e=Math.acos(Ih(r[t-1].dot(r[t]),-1,1));i[t].applyMatrix4(s.makeRotationAxis(o,e))}a[t].crossVectors(r[t],i[t])}if(t===!0){let t=Math.acos(Ih(i[0].dot(i[e]),-1,1));t/=e,r[0].dot(o.crossVectors(i[0],i[e]))>0&&(t=-t);for(let n=1;n<=e;n++)i[n].applyMatrix4(s.makeRotationAxis(r[n],t*n)),a[n].crossVectors(r[n],i[n])}return{tangents:r,normals:i,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.7,type:`Curve`,generator:`Curve.toJSON`}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},By=class extends zy{constructor(e=0,t=0,n=1,r=1,i=0,a=Math.PI*2,o=!1,s=0){super(),this.isEllipseCurve=!0,this.type=`EllipseCurve`,this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=r,this.aStartAngle=i,this.aEndAngle=a,this.aClockwise=o,this.aRotation=s}getPoint(e,t=new K){let n=t,r=Math.PI*2,i=this.aEndAngle-this.aStartAngle,a=Math.abs(i)<2**-52;for(;i<0;)i+=r;for(;i>r;)i-=r;i<2**-52&&(i=a?0:r),this.aClockwise===!0&&!a&&(i===r?i=-r:i-=r);let o=this.aStartAngle+e*i,s=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){let e=Math.cos(this.aRotation),t=Math.sin(this.aRotation),n=s-this.aX,r=c-this.aY;s=n*e-r*t+this.aX,c=n*t+r*e+this.aY}return n.set(s,c)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},Vy=class extends By{constructor(e,t,n,r,i,a){super(e,t,n,n,r,i,a),this.isArcCurve=!0,this.type=`ArcCurve`}};function Hy(){let e=0,t=0,n=0,r=0;function i(i,a,o,s){e=i,t=o,n=-3*i+3*a-2*o-s,r=2*i-2*a+o+s}return{initCatmullRom:function(e,t,n,r,a){i(t,n,a*(n-e),a*(r-t))},initNonuniformCatmullRom:function(e,t,n,r,a,o,s){let c=(t-e)/a-(n-e)/(a+o)+(n-t)/o,l=(n-t)/o-(r-t)/(o+s)+(r-n)/s;c*=o,l*=o,i(t,n,c,l)},calc:function(i){let a=i*i,o=a*i;return e+t*i+n*a+r*o}}}var Uy=new q,Wy=new q,Gy=new Hy,Ky=new Hy,qy=new Hy,Jy=class extends zy{constructor(e=[],t=!1,n=`centripetal`,r=.5){super(),this.isCatmullRomCurve3=!0,this.type=`CatmullRomCurve3`,this.points=e,this.closed=t,this.curveType=n,this.tension=r}getPoint(e,t=new q){let n=t,r=this.points,i=r.length,a=(i-+!this.closed)*e,o=Math.floor(a),s=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/i)+1)*i:s===0&&o===i-1&&(o=i-2,s=1);let c,l;this.closed||o>0?c=r[(o-1)%i]:(Wy.subVectors(r[0],r[1]).add(r[0]),c=Wy);let u=r[o%i],d=r[(o+1)%i];if(this.closed||o+2r.length-2?r.length-1:a+1],u=r[a>r.length-3?r.length-1:a+2];return n.set(Yy(o,s.x,c.x,l.x,u.x),Yy(o,s.y,c.y,l.y,u.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t0)&&f.push(t,i,c),(e!==n-1||s{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var n={format:2,tick_rate:30,ring:{half_width:500,half_height:500,fighter_radius:38},limits:{max_stamina:1e3,max_conditioning:1e3,max_guard:700,max_poise:600},action_buffer_ticks:8,facing:{scale:1e3,turn_degrees_per_second:110},movement:{max_speed:10,blend_percent:75,recovery_speed_percent:60},evasion:{ticks:7,stamina:15},combos:{recovery_cancel_percent:50,chains:[[`jab`,`straight`],[`jab`,`hook`],[`straight`,`hook`],[`hook`,`uppercut`],[`uppercut`,`hook`]]},knockdown:{referee_walk_speed:9,count_ticks:20,mandatory_count:5,box_pause_ticks:20,get_up_stun_ticks:12,get_up_stamina:600,get_up_base:30,get_up_per_knockdown:16,get_up_trauma_divisor:28},countdown:{opening_ticks:90},tired:{startup_ticks:1,recovery_ticks:2,impact_percent:70},foul:{separation:45},hitstop_ms:{hit:78,block:45,power:140},fatigue_scaling:{startup_formula:`max(2, startup * 100 // fatigue - lead_jab_bonus)`,recovery_formula:`max(3, recovery * 100 // fatigue)`,lead_jab_bonus:1,rear_straight_impact_bonus:8},punches:{jab:{startup:3,active:2,recovery:4,reach:150,lateral_arc:42,impact:34,stamina_cost:25,whiff_cost:9,guard_damage:44,poise_damage:35,combo_window:7,startup_vulnerability:1,recovery_vulnerability:2},straight:{startup:4,active:2,recovery:6,reach:168,lateral_arc:38,impact:52,stamina_cost:39,whiff_cost:14,guard_damage:66,poise_damage:58,combo_window:8,startup_vulnerability:2,recovery_vulnerability:3},hook:{startup:5,active:2,recovery:7,reach:126,lateral_arc:92,impact:64,stamina_cost:47,whiff_cost:18,guard_damage:82,poise_damage:72,combo_window:9,startup_vulnerability:3,recovery_vulnerability:4},uppercut:{startup:5,active:2,recovery:8,reach:108,lateral_arc:54,impact:72,stamina_cost:53,whiff_cost:22,guard_damage:88,poise_damage:84,combo_window:10,startup_vulnerability:3,recovery_vulnerability:5}},variants:{body:{startup_add:1,reach_min:80,reach_sub:14,lateral_arc_add:8,impact_mul_num:92,impact_mul_den:100,stamina_cost_add:2,whiff_cost_add:2,poise_damage_mul_num:72,poise_damage_mul_den:100},power:{startup_add:3,active_add:1,recovery_add:3,reach_add:5,impact_mul_num:185,impact_mul_den:100,stamina_cost_mul_num:140,stamina_cost_mul_den:100,whiff_cost_mul_num:150,whiff_cost_mul_den:100,guard_damage_mul_num:220,guard_damage_mul_den:100,poise_damage_mul_num:175,poise_damage_mul_den:100,startup_vulnerability_add:1,recovery_vulnerability_add:1}},hurtboxes:{head:{radius:.13,length:.16,joint:`head`,offset_y:.12},torso:{radius:.21,length:.34,joint:`chest`,offset_y:.16}},corners:{reach:733},rest:{corner_offset:365,walk_speed:10},clinch:{hold_distance:60,draw_speed:6},referee:{radius:34,health:450,walk_speed:6,standoff:62,count_standoff:90,stagger_base_ticks:6,stagger_damage_divisor:8,stagger_max_ticks:30,down_ticks:150,bleed_health_divisor:60},corner:{cut:{worse_cut:250,other_cut:100,bleeding_kept_percent:30},swelling:{swelling:250,eyes:200},breath:{conditioning:180,body:150},balanced:{worse_cut:80,bleeding_kept_percent:75,swelling:80,eyes:60}},blind_side:{eye_threshold:700,impact_percent:120},parry:{stagger_ticks:16},body:{wind_percent:90,collapse_body_trauma:650,collapse_stamina:350,collapse_minimum_damage:40,collapse_delay_ticks:10,collapse_cooldown_ticks:300},styles:{balanced:{},boxer:{recovery_ticks:{jab:-1},reach_percent:102,impact_percent:98,poise_damage_percent:98},slugger:{impact_percent:108,poise_damage_percent:108,poise_taken_percent:95,stamina_cost_percent:115,recovery_ticks:{hook:1,uppercut:1},move_speed_percent:96},swarmer:{move_speed_percent:103,startup_ticks:{hook:-1,uppercut:-1},body_damage_percent:110,conditioning_loss_percent:85,impact_percent:96,poise_damage_percent:96,evasion_ticks:1},counter_puncher:{counter_bonus_percent:38,counter_window_ticks:3,evasion_ticks:1,perfect_block_ticks:1,impact_percent:96,poise_damage_percent:96}},stun:{flinch_minimum_damage:36,flinch_base_ticks:4,flinch_damage_divisor:16,rocked_counter_damage:50,rocked_power_damage:70,rocked_hurt_poise:180,rocked_base_ticks:12,rocked_damage_divisor:6,rocked_max_ticks:28,chain_max_ticks:36,immunity_ticks:18,rocked_immunity_ticks:8,moving_speed_percent:75},guard:{block_poise_percent:35,perfect_block_poise_percent:0,leak_base_percent:80,leak_minimum_percent:25,block_minimum:60,perfect_rearm_ticks:6,damage_percent:100,stamina_regen_percent:50,held_drain:3,break_stun_ticks:24,rearm:250},trauma:{head_per_damage_percent:60,eye_per_damage_percent:70,cut_per_damage_percent:80,jab_cut_percent:40,jab_swelling_percent:50,swelling_per_damage_percent:33,poise_ceiling_per_head_percent:30,poise_ceiling_floor:220,body_per_damage_percent:100,poise_regen_every_ticks:2,poise_damage_percent:85,cut_opens_eye:120,bleeding_cut_divisor:30},hitbox:{glove_radius:.11},injuries:{blood:{volume:1e3,bleeding_divisor:160,rest_percent:50,stages:[{below:600,stamina_regen_percent:75},{below:350,stamina_regen_percent:50},{below:150,stamina_regen_percent:25}]},kinds:{broken_nose:{drain:1,stamina_regen_percent:75,bleeding_floor:150},broken_jaw:{drain:1,poise_taken_percent:125},jaw_torn:{drain:5,poise_taken_percent:150,bleeding_floor:300},eye_out:{drain:2},ear_torn:{drain:1,poise_regen_ticks_add:1},face_flayed:{drain:4,vision_penalty:8},skull_fractured:{drain:4,poise_ceiling_percent:60},shoulder_dislocated:{drain:0,startup_add:2,impact_percent:50,guard_leak_add:20},arm_broken:{drain:3,startup_add:2,impact_percent:30,guard_leak_add:25},forearm_severed:{drain:12,impact_percent:20,reach_sub:45,guard_leak_add:35},arm_torn:{drain:20,guard_leak_add:50},ribs_broken:{drain:0,body_taken_percent:135,max_stamina_sub:60},liver_ruptured:{drain:6,stamina_regen_percent:60},disemboweled:{drain:12,move_speed_percent:75,max_stamina_sub:150,body_taken_percent:150},knee_blown:{drain:0,move_speed_percent:80}},triggers:{nose_wear:800,jaw_break_wear:320,jaw_tear_wear:640,ear_wear:280,eye_out_trauma:850,eye_out_damage:55,flay_cut:550,flay_damage:60,skull_head_trauma:1050,skull_damage:90,brain_death_wear:220,shoulder_wear:280,shoulder_whiff_wear:40,shoulder_parried_wear:90,arm_break_wear:1100,arm_guard_break_wear:300,arm_tear_damage:80,ribs_wear:260,liver_wear:260,gut_body_trauma:800,gut_damage:90,gutted_damage:90,knee_knockdowns:2},vomit:{every_ticks:240,stun_ticks:10},finish:{ticks:105},fatalities:{head:{jab:`eyes_out`,straight:`head_burst`,hook:`decapitation`,uppercut:`spine_rip`},body:{jab:`heart_punch`,straight:`gutting`,hook:`bisection`,uppercut:`total_gib`}}}},r=n.punches,i=n.variants,a=n.tick_rate;n.action_buffer_ticks;var o=n.hitstop_ms,s=n.hurtboxes,c=n.hitbox.glove_radius;n.fatigue_scaling;var l=n.rest.corner_offset,u=n.ring.half_width,d=n.ring.half_height,f=n.ring.fighter_radius,p=n.blind_side.eye_threshold,m=n.guard.block_minimum,h=n.guard.rearm,g=n.movement.max_speed,_=n.movement.blend_percent,v=n.movement.recovery_speed_percent,y=n.evasion.ticks,b=n.evasion.stamina,x=n.corner,S=n.corners.reach,C=n.combos.recovery_cancel_percent,w=new Set(n.combos.chains.map(([e,t])=>`${e}:${t}`));function T(e,t){return w.has(`${e}:${t}`)}function E(e){return e.startup+e.active+Math.floor(e.recovery*C/100)}function D(e,t,n,r,i,a=`balanced`){return t&&!i&&T(e,n.class)&&r>=fe(a,n.class,n.target,n.power)}function O(e){return r[e].combo_window}var k=n.stun.rocked_base_ticks,A=n.stun.rocked_max_ticks,j=n.knockdown,ee=j.count_ticks,M=1400,te=3,ne=j.get_up_base,re=j.get_up_base+te*j.get_up_per_knockdown+Math.floor(M/j.get_up_trauma_divisor),ie=n.stun.moving_speed_percent,ae=n.tired.startup_ticks,oe=n.tired.recovery_ticks;function se(e,t,n){let a=r[e],o=a.startup,s=a.active,c=a.recovery,l=a.reach,u=a.lateral_arc;if(t===`body`){let e=i.body;o+=e.startup_add??0,c+=e.recovery_add??0,l=Math.max(e.reach_min??0,l-(e.reach_sub??0)),u+=e.lateral_arc_add??0}if(n===`power`){let e=i.power;o+=e.startup_add??0,s+=e.active_add??0,c+=e.recovery_add??0,l+=e.reach_add??0}return{startup:o,active:s,recovery:c,reach:l,lateralArc:u}}function ce(e,t,n){let a=r[e].stamina_cost;return t===`body`&&(a+=i.body.stamina_cost_add??0),n===`power`&&(a=Math.floor(a*(i.power.stamina_cost_mul_num??1)/(i.power.stamina_cost_mul_den??1))),a}var le=n.styles,ue=new Map;function de(e){let t=ue.get(e);if(t!==void 0)return t;let n=le[e]??{},r={startupTicks:n.startup_ticks??{},recoveryTicks:n.recovery_ticks??{},staminaCostPercent:n.stamina_cost_percent??100,conditioningLossPercent:n.conditioning_loss_percent??100,moveSpeedPercent:n.move_speed_percent??100,evasionTicks:n.evasion_ticks??0};return ue.set(e,r),r}function fe(e,t,n,r){return Math.floor(ce(t,n,r)*de(e).staminaCostPercent/100)}function pe(e){return e.startup+e.active+e.recovery}var me=[`broken_nose`,`broken_jaw`,`jaw_torn`,`eye_left_out`,`eye_right_out`,`ear_left_torn`,`ear_right_torn`,`face_left_flayed`,`face_right_flayed`,`skull_fractured`,`shoulder_left_dislocated`,`shoulder_right_dislocated`,`arm_left_broken`,`arm_right_broken`,`forearm_left_severed`,`forearm_right_severed`,`arm_left_torn`,`arm_right_torn`,`ribs_left_broken`,`ribs_right_broken`,`liver_ruptured`,`disemboweled`,`knee_left_blown`,`knee_right_blown`];function he(e){return me.includes(e)}var ge=[`eyes_out`,`head_burst`,`decapitation`,`spine_rip`,`heart_punch`,`gutting`,`bisection`,`total_gib`],_e=[`nose`,`mouth`,`eye_left`,`eye_right`,`ear_left`,`ear_right`,`skull`,`neck`,`shoulder_left`,`shoulder_right`,`elbow_left`,`elbow_right`,`chest`,`ribs_left`,`ribs_right`,`liver`,`belly`,`waist`,`crotch`,`knee_left`,`knee_right`],ve=n.injuries,ye=ve.kinds,be=ve.blood.volume,xe=ve.blood.stages.map(e=>e.below),Se=ve.finish.ticks,Ce=(e,t)=>Array.isArray(e)?e.includes(t):e.has(t);function we(e){return e.includes(`_left_`)?`left`:e.includes(`_right_`)?`right`:null}function N(e){return e.replace(`_left_`,`_`).replace(`_right_`,`_`)}var Te={broken_nose:`BROKEN NOSE`,broken_jaw:`BROKEN JAW`,jaw_torn:`JAW TORN OFF`,eye_out:`EYE OUT`,ear_torn:`EAR TORN OFF`,face_flayed:`CHEEK FLAYED`,skull_fractured:`SKULL SPLIT OPEN`,shoulder_dislocated:`SHOULDER OUT`,arm_broken:`ARM SNAPPED`,forearm_severed:`FOREARM SEVERED`,arm_torn:`ARM TORN OFF`,ribs_broken:`RIBS CAVED IN`,liver_ruptured:`LIVER RUPTURED`,disemboweled:`DISEMBOWELED`,knee_blown:`KNEE BLOWN OUT`};function Ee(e){let t=we(e),n=Te[N(e)];return t===null?n:`${t.toUpperCase()} ${n}`}var P={eyes_out:`EYES PUNCHED OUT`,head_burst:`HEAD EXPLODED`,decapitation:`DECAPITATED`,spine_rip:`SPINE RIPPED OUT`,heart_punch:`HEART PUNCHED OUT`,gutting:`GUTTED`,bisection:`TORN IN HALF`,total_gib:`BLOWN TO PIECES`};function F(e){return P[e]}function De(e,t){return ve.fatalities[e][t]}function Oe(e){if(e===`bled_out`||e===`brain`||e===`gutted`)return e;let t=e.startsWith(`fatality:`)?e.slice(9):null;return t!==null&&ge.includes(t)?e:null}function ke(e){return e.startsWith(`fatality:`)?e.slice(9):null}function Ae(e){let t=ke(e);return t===null?e===`bled_out`?`BLED TO DEATH`:e===`brain`?`BRAIN DESTROYED`:`GUTTED`:F(t)}function je(e,t){return Ce(e,`arm_${t}_torn`)?`torn`:Ce(e,`forearm_${t}_severed`)?`severed`:Ce(e,`arm_${t}_broken`)?`broken`:Ce(e,`shoulder_${t}_dislocated`)?`dislocated`:`whole`}var Me={dislocated:`shoulder_dislocated`,broken:`arm_broken`,severed:`forearm_severed`,torn:`arm_torn`};function Ne(e,t){if(je(e,t)!==`torn`)return t;let n=t===`left`?`right`:`left`;return je(e,n)===`torn`?null:n}function Pe(e){return je(e,`left`)===`torn`&&je(e,`right`)===`torn`}function Fe(e,t){let n=je(e,t);return n===`whole`?0:ye[Me[n]].startup_add??0}var Ie=Object.fromEntries(me.map(e=>[e,ye[N(e)].move_speed_percent??100]));function Le(e,t){let n=e;for(let e of t){let t=Ie[e];t!==100&&(n=Math.floor(n*t/100))}return n}function Re(e){let t=0;for(let n of xe)e0?`-${e.draws}`:``}`}var Be=e=>e.wins+e.losses+e.draws===0;function Ve(e){return Be(e)?`PRO DEBUT`:`${ze(e)} (${e.knockouts} KO)`}var He=class extends Error{name=`ProtocolError`},Ue=2147483647,We=new TextEncoder;function Ge(e){let t=0,n=()=>{for(;/\s/u.test(e[t]??``);)t+=1},r=()=>{let n=t;if(e[t++]!==`"`)throw new He(`invalid JSON`);for(;t{n();let a=e[t];if(a===`{`){t+=1,n();let a=new Set;if(e[t]===`}`){t+=1;return}for(;;){n();let o=r();if(a.has(o))throw new He(`duplicate field ${o}`);if(a.add(o),n(),e[t++]!==`:`)throw new He(`invalid JSON`);i(),n();let s=e[t++];if(s===`}`)return;if(s!==`,`)throw new He(`invalid JSON`)}}if(a===`[`){if(t+=1,n(),e[t]===`]`){t+=1;return}for(;;){i(),n();let r=e[t++];if(r===`]`)return;if(r!==`,`)throw new He(`invalid JSON`)}}if(a===`"`){r();return}let o=e.slice(t),s=/^(?:-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?|true|false|null)/u.exec(o);if(!s)throw new He(`invalid JSON`);t+=s[0].length};if(i(),n(),t!==e.length)throw new He(`invalid JSON`)}function Ke(e){let t,n;if(typeof e==`string`?(t=We.encode(e),n=e):(t=e instanceof Uint8Array?e:new Uint8Array(e),n=new TextDecoder(`utf-8`,{fatal:!0}).decode(t)),t.byteLength>65536)throw new He(`server frame too large`);try{return Ge(n),JSON.parse(n)}catch(e){throw e instanceof He?e:new He(`invalid JSON`)}}function qe(e,t){if(typeof e!=`object`||!e||Array.isArray(e)||Object.getPrototypeOf(e)!==Object.prototype)throw new He(`${t} must be an object`);return e}function Je(e,t,n=[]){let r=new Set([...t,...n]),i=Object.keys(e);if(t.some(t=>!Object.hasOwn(e,t))||i.some(e=>!r.has(e)))throw new He(`schema mismatch`)}function I(e,t,n=0,r=Ue){if(!Number.isSafeInteger(e)||er)throw new He(`${t} must be a bounded integer`);return e}function Ye(e,t){if(typeof e!=`boolean`)throw new He(`${t} must be boolean`);return e}function Xe(e,t,n=255,r=1){if(typeof e!=`string`||e.lengthn||/[\u0000-\u001f\u007f]/u.test(e))throw new He(`${t} must be a bounded string`);return e}function Ze(e,t,n=255){return e===null?null:Xe(e,t,n)}function Qe(e,t,n){if(typeof e!=`string`||!t.includes(e))throw new He(`invalid ${n}`);return e}function $e(e,t,n){if(!Array.isArray(e)||e.length>n)throw new He(`${t} must be a bounded array`);return e}var et=[`left`,`right`],tt=[`jab`,`straight`,`hook`,`uppercut`],nt=[`head`,`body`],rt=[`normal`,`power`],it=[`orthodox`,`southpaw`],at=[`balanced`,`boxer`,`slugger`,`swarmer`,`counter_puncher`],ot=[`none`,`guard_high`,`guard_low`,`slip_left`,`slip_right`,`weave`,`pull`],st=[`none`,`guard_high`,`guard_low`],ct=[`slip_left`,`slip_right`,`weave`,`pull`,`clinch`,`switch_stance`,`get_up_left`,`get_up_right`,`taunt`,`corner_cut`,`corner_swelling`,`corner_breath`],lt=[`cut`,`swelling`,`breath`,`balanced`],ut=[`low_blow`,`headbutt`],dt=[`countdown`,`fight`,`knockdown`,`foul_recovery`,`referee_down`,`finish`,`rest`,`complete`],ft=[`ko`,`flash_ko`,`tko`,`death`,`disqualification`,`decision`,`draw`,`forfeit`];function pt(e){let t=qe(e,`record`);return Je(t,[`wins`,`losses`,`draws`,`knockouts`]),{wins:I(t.wins,`record.wins`),losses:I(t.losses,`record.losses`),draws:I(t.draws,`record.draws`),knockouts:I(t.knockouts,`record.knockouts`)}}function mt(e){let t=qe(e,`player`);Je(t,[`id`,`name`,`avatar`,`rating`,`connected`],[`cpu`,`record`,`style`]);let n=t.style===void 0?{}:{style:Qe(t.style,at,`player style`)},r=t.cpu===void 0?{}:{cpu:Ye(t.cpu,`cpu`)},i=t.record===void 0?{}:{record:pt(t.record)};return{id:Xe(t.id,`player.id`),name:Xe(t.name,`player.name`,80),avatar:Ze(t.avatar,`player.avatar`,128),rating:I(t.rating,`rating`),connected:Ye(t.connected,`connected`),...r,...i,...n}}function ht(e,t,n=1){let r=$e(e,`players`,2).map(mt);if(r.lengthe.id)).size!==r.length)throw new He(`players must be present and distinct`);return r}function gt(e){let t=qe(e,`trauma`);return Je(t,[`head`,`body`,`left_eye`,`right_eye`,`left_cut`,`right_cut`,`swelling`,`bleeding`]),{head:I(t.head,`head`,0,1400),body:I(t.body,`body`,0,1200),left_eye:I(t.left_eye,`left_eye`,0,1e3),right_eye:I(t.right_eye,`right_eye`,0,1e3),left_cut:I(t.left_cut,`left_cut`,0,1e3),right_cut:I(t.right_cut,`right_cut`,0,1e3),swelling:I(t.swelling,`swelling`,0,1e3),bleeding:I(t.bleeding,`bleeding`,0,1e3)}}var _t=g;function vt(e,t){return Math.max(-_t,Math.min(_t,I(e,t,-2147483647,Ue)))}function yt(e){let t=$e(e,`injuries`,me.length).map(e=>Qe(e,me,`injury`));for(let e=1;ee===null)&&[n,r,i,a].some(e=>e!==null))throw new He(`partial punch action`);let o=t.action_id===null?null:Xe(t.action_id,`action_id`,32),s=t.action_key===null?null:Xe(t.action_key,`action_key`,64);if([o,s].some(e=>e===null)!==[o,s].every(e=>e===null))throw new He(`partial action instance`);if(o!==null&&n===null)throw new He(`action instance without class`);let c=t.get_up_prompt===null?null:Qe(t.get_up_prompt,[`get_up_left`,`get_up_right`],`get-up prompt`),l=I(t.maximum_stamina,`maximum_stamina`,330,1e3),u=I(t.stamina,`stamina`,0,l),d=I(t.get_up_required,`get_up_required`,0,re),f=I(t.facing,`facing`,-1,1);if(f===0)throw new He(`invalid facing`);let p=I(t.facing_x,`facing_x`,-1e3,1e3),m=I(t.facing_y,`facing_y`,-1e3,1e3);if(p===0&&m===0)throw new He(`invalid facing vector`);if(d!==0&&d$e(e,`round scores`,15).map(e=>I(e,`score`,6,10)),r=n(t.player_one),i=n(t.player_two);if(r.length!==i.length)throw new He(`scorecard round mismatch`);return{judge:Xe(t.judge,`judge`,80),player_one:r,player_two:i}}function Ct(e){let t=$e(e,`scorecards`,3).map(St);if(t.length!==3)throw new He(`exactly three scorecards required`);return t}function wt(e,t){if(t===`draw`!=(e===null))throw new He(`incoherent finish result`)}function Tt(e){let t=qe(e,`result`);Je(t,[`match_id`,`activity_instance_id`,`guild_id`,`player_one_id`,`player_two_id`,`winner_id`,`finish_method`,`round_number`,`tick`,`scorecards`,`player_one_knockdowns`,`player_two_knockdowns`,`player_one_damage`,`player_two_damage`]);let n=Xe(t.player_one_id,`player_one_id`),r=Xe(t.player_two_id,`player_two_id`);if(n===r)throw new He(`result players must be distinct`);let i=Ze(t.winner_id,`winner_id`);if(i!==null&&i!==n&&i!==r)throw new He(`invalid winner`);let a=Qe(t.finish_method,ft,`finish method`);return wt(i,a),{match_id:Xe(t.match_id,`match_id`),activity_instance_id:Xe(t.activity_instance_id,`activity_instance_id`),guild_id:Xe(t.guild_id,`guild_id`),player_one_id:n,player_two_id:r,winner_id:i,finish_method:a,round_number:I(t.round_number,`round`,1,15),tick:I(t.tick,`tick`),scorecards:Ct(t.scorecards),player_one_knockdowns:I(t.player_one_knockdowns,`knockdowns`,0,3),player_two_knockdowns:I(t.player_two_knockdowns,`knockdowns`,0,3),player_one_damage:I(t.player_one_damage,`damage`),player_two_damage:I(t.player_two_damage,`damage`)}}function Et(e){let t=qe(e,`referee`);return Je(t,[`x`,`y`,`facing_x`,`facing_y`,`velocity_x`,`velocity_y`,`stunned_ticks`,`alive`,`trauma`]),{x:I(t.x,`referee.x`,-462,462),y:I(t.y,`referee.y`,-462,462),facing_x:I(t.facing_x,`referee.facing_x`,-1e3,1e3),facing_y:I(t.facing_y,`referee.facing_y`,-1e3,1e3),velocity_x:vt(t.velocity_x,`referee.velocity_x`),velocity_y:vt(t.velocity_y,`referee.velocity_y`),stunned_ticks:I(t.stunned_ticks,`referee.stunned_ticks`,0,90),alive:Ye(t.alive,`referee.alive`),trauma:gt(t.trauma)}}function Dt(e){let t=qe(e,`snapshot`);Je(t,[`tick`,`phase`,`round_number`,`phase_ticks_remaining`,`fighters`,`referee`,`events`,`result`,`checksum`]);let n=$e(t.fighters,`fighters`,2).map(bt);if(n.length!==2||n[0]?.player_id===n[1]?.player_id)throw new He(`snapshot requires two distinct fighters`);let r=Xe(t.checksum,`checksum`,64);if(!/^[a-f0-9]{64}$/u.test(r))throw new He(`invalid checksum`);return{tick:I(t.tick,`tick`),phase:Qe(t.phase,dt,`phase`),round_number:I(t.round_number,`round`,1,15),phase_ticks_remaining:I(t.phase_ticks_remaining,`phase ticks`),fighters:[n[0],n[1]],referee:Et(t.referee),events:$e(t.events,`events`,256).map(xt),result:t.result===null?null:Tt(t.result),checksum:r}}function Ot(e){let t=qe(Ke(e),`envelope`);if(t.version!==6)throw new He(`unsupported protocol version`);let n=Xe(t.type,`type`,32);if(n===`welcome`){let e=Qe(t.role,[`fighter`,`spectator`],`connection role`),r=Xe(t.player_id,`player_id`),i=t.reconnect_ticket===void 0?{}:{reconnect_ticket:Xe(t.reconnect_ticket,`reconnect_ticket`,4096)};if(e===`fighter`){Je(t,[`version`,`type`,`role`,`player_id`,`seat`,`rating`,`players`,`server_tick`,`next_sequence`],[`reconnect_ticket`]);let a=ht(t.players);if(!a.some(e=>e.id===r))throw new He(`welcome fighter is absent`);return{version:6,type:n,role:e,player_id:r,seat:I(t.seat,`seat`,1,2),rating:I(t.rating,`rating`),players:a,server_tick:I(t.server_tick,`server_tick`),next_sequence:I(t.next_sequence,`next_sequence`),...i}}Je(t,[`version`,`type`,`role`,`player_id`,`players`,`server_tick`],[`reconnect_ticket`]);let a=ht(t.players,void 0,0);if(a.some(e=>e.id===r))throw new He(`spectator cannot be a fighter`);return{version:6,type:n,role:e,player_id:r,players:a,server_tick:I(t.server_tick,`server_tick`),...i}}if(n===`ticket`)return Je(t,[`version`,`type`,`reconnect_ticket`,`refresh_id`]),{version:6,type:n,reconnect_ticket:Xe(t.reconnect_ticket,`reconnect_ticket`,4096),refresh_id:Xe(t.refresh_id,`refresh_id`,128,16)};if(n===`waiting`){if(Je(t,[`version`,`type`,`open_seats`]),t.open_seats!==1&&t.open_seats!==2)throw new He(`invalid open seats`);return{version:6,type:n,open_seats:t.open_seats}}if(n===`select`){Je(t,[`version`,`type`,`deadline_ms`,`players`,`ready`]);let e=ht(t.players,2),r=$e(t.ready,`ready`,2).map(e=>Xe(e,`ready player id`));if(new Set(r).size!==r.length||r.some(t=>!e.some(e=>e.id===t)))throw new He(`invalid ready fighters`);return{version:6,type:n,deadline_ms:I(t.deadline_ms,`deadline_ms`,0,6e4),players:[e[0],e[1]],ready:r}}if(n===`ready`){Je(t,[`version`,`type`,`players`]);let e=ht(t.players,2);return{version:6,type:n,players:[e[0],e[1]]}}if(n===`paused`)return Je(t,[`version`,`type`,`player_id`,`grace_ms`]),{version:6,type:n,player_id:Xe(t.player_id,`player_id`),grace_ms:I(t.grace_ms,`grace_ms`,0,6e4)};if(n===`resumed`)return Je(t,[`version`,`type`,`player_id`]),{version:6,type:n,player_id:Xe(t.player_id,`player_id`)};if(n===`snapshot`)return Je(t,[`version`,`type`,`payload`]),{version:6,type:n,payload:Dt(t.payload)};if(n===`error`)return Je(t,[`version`,`type`,`code`]),{version:6,type:n,code:Xe(t.code,`error code`,80)};if(n===`final`)return At(t,n);throw new He(`unsupported server message type`)}function kt(e,t){let n=Object.entries(qe(e,`punches`));if(n.length!==2||n.some(([e])=>!t.includes(e)))throw new He(`punches must count both fighters`);let r=Object.create(null);for(let[e,t]of n){let n=qe(t,`punch totals`);Je(n,[`thrown`,`landed`,`jabs_thrown`,`jabs_landed`]);let i=I(n.thrown,`thrown`),a=I(n.landed,`landed`,0,i),o=I(n.jabs_thrown,`jabs_thrown`,0,i);r[e]={thrown:i,landed:a,jabs_thrown:o,jabs_landed:I(n.jabs_landed,`jabs_landed`,0,Math.min(a,o))}}return r}function At(e,t){Je(e,[`version`,`type`,`match_id`,`winner_id`,`method`,`round`,`scorecards`,`ratings`],[`punches`]);let n=qe(e.ratings,`ratings`),r=Object.entries(n);if(r.length!==2)throw new He(`final requires two ratings`);let i=Object.create(null);for(let[e,t]of r){Xe(e,`rating player id`);let n=qe(t,`rating`);Je(n,[`before`,`after`]),i[e]={before:I(n.before,`before`),after:I(n.after,`after`)}}let a=Ze(e.winner_id,`winner_id`);if(a!==null&&!Object.hasOwn(i,a))throw new He(`winner absent from ratings`);let o=Qe(e.method,ft,`finish method`);wt(a,o);let s=e.punches===void 0?{}:{punches:kt(e.punches,Object.keys(i))};return{version:6,type:t,match_id:Xe(e.match_id,`match_id`),winner_id:a,method:o,round:I(e.round,`round`,1,15),scorecards:Ct(e.scorecards),ratings:i,...s}}function jt(e,t,n){return JSON.stringify({version:6,type:`input`,sequence:I(e,`sequence`),client_tick:I(t,`client tick`),move:{x:Math.max(-1e3,Math.min(1e3,Math.round(Number.isFinite(n.moveX)?n.moveX:0))),y:Math.max(-1e3,Math.min(1e3,Math.round(Number.isFinite(n.moveY)?n.moveY:0)))},defense:Qe(n.defense,st,`held defense`),actions:n.actions.slice(0,4).map(e=>{let t=e.id===void 0?{}:{id:e.id.slice(0,32)};return e.kind===`punch`?{kind:`punch`,hand:Qe(e.hand,et,`hand`),class:Qe(e.class,tt,`class`),target:Qe(e.target,nt,`target`),power:Qe(e.power,rt,`power`),...t}:e.kind===`foul`?{kind:`foul`,foul:Qe(e.foul,ut,`foul`),...t}:{kind:Qe(e.kind,ct,`action`),...t}})})}function Mt(e,t){return JSON.stringify({version:6,type:`style`,style:Qe(e,at,`fighter style`),ready:t===!0})}var Nt=[`rookie`,`contender`,`champion`];function Pt(e){return JSON.stringify({version:6,type:`cpu`,level:Qe(e,Nt,`computer level`)})}function Ft(e){let t=qe(e,`bootstrap`);if(Je(t,[`client_id`,`state`,`protocol`,`simulation`]),t.protocol!==6)throw new He(`unsupported protocol version`);let n=qe(t.simulation,`simulation`);return Je(n,[`tick_rate`,`ring_half_width`,`ring_half_height`]),{client_id:Xe(t.client_id,`client_id`,36),state:Xe(t.state,`state`,128),protocol:6,simulation:{tick_rate:I(n.tick_rate,`tick rate`,1,120),ring_half_width:I(n.ring_half_width,`ring width`,1),ring_half_height:I(n.ring_half_height,`ring height`,1)}}}function It(e){let t=qe(e,`token response`);Je(t,[`access_token`,`ticket`,`player`]);let n=qe(t.player,`player`);return Je(n,[`id`,`name`,`avatar`,`rating`]),{access_token:Xe(t.access_token,`access token`,4096),ticket:Xe(t.ticket,`ticket`,4096),player:{id:Xe(n.id,`id`),name:Xe(n.name,`name`,80),avatar:Ze(n.avatar,`avatar`,128),rating:I(n.rating,`rating`)}}}var Lt=[`Power`,`Hand speed`,`Footwork`,`Reach`,`Stamina`,`Defence`],Rt=[{style:`balanced`,name:`Balanced`,tag:`BALANCED`,detail:`Even at everything, no holes to exploit.`,stats:[3,3,3,3,3,3]},{style:`boxer`,name:`Boxer`,tag:`BOXER`,detail:`Snappy jab and long reach, lighter hands.`,stats:[2,4,3,4,3,3]},{style:`slugger`,name:`Slugger`,tag:`SLUGGER`,detail:`Heavy hands, hard chin, slow feet, tires sooner.`,stats:[5,2,2,3,2,4]},{style:`swarmer`,name:`Swarmer`,tag:`SWARMER`,detail:`Quick feet and head, digs to the body, never stops.`,stats:[2,4,4,3,4,3]},{style:`counter_puncher`,name:`Counter-puncher`,tag:`COUNTER`,detail:`Slips and parries, makes every miss cost.`,stats:[2,3,3,3,3,5]}],zt=e=>Rt.find(t=>t.style===e)??Rt[0];function Bt(e){return e===void 0||e===`balanced`?null:zt(e).tag}function Vt(e){return e===void 0||e===`balanced`?null:`the ${zt(e).name.toLowerCase()}`}var Ht=`hands.style.v1`;function Ut(e=Gt()){try{let t=e?.getItem(Ht);return at.find(e=>e===t)??`balanced`}catch{return`balanced`}}function Wt(e,t=Gt()){try{t?.setItem(Ht,e)}catch{}}function Gt(){try{return window.localStorage}catch{return null}}var Kt=400,qt={Digit1:0,Digit2:1,Digit3:2,Digit4:3,Digit5:4,Numpad1:0,Numpad2:1,Numpad3:2,Numpad4:3,Numpad5:4},Jt=.6;function Yt(){try{return[...navigator.getGamepads?.()??[]].find(e=>e!==null&&e.connected&&e.mapping===`standard`)??null}catch{return null}}function Xt(e){let t=new Set;if(e===null)return t;let n=t=>e.buttons[t]?.pressed===!0,r=e.axes[0]??0,i=e.axes[1]??0;return(n(12)||n(14)||r<-.6||i<-.6)&&t.add(`previous`),(n(13)||n(15)||r>Jt||i>Jt)&&t.add(`next`),n(0)&&t.add(`settle`),t}var Zt=class{send;now;element;buttons=new Map;clock;status;visible=!1;choosing=!1;highlighted;settled=!1;deadlineAt=0;timer=null;padFrame=0;padHeld=new Set;context=null;keydown=e=>{if(!this.visible||!this.choosing||e.repeat||e.ctrlKey||e.metaKey||e.altKey)return;let t=e.target;if(t instanceof HTMLElement&&t!==document.body&&!this.element.contains(t))return;let n=qt[e.code];n===void 0?e.code===`ArrowRight`||e.code===`ArrowDown`?(e.preventDefault(),this.move(this.neighbour(1))):e.code===`ArrowLeft`||e.code===`ArrowUp`?(e.preventDefault(),this.move(this.neighbour(-1))):e.code!==`Enter`&&e.code!==`Space`||t instanceof HTMLButtonElement||(e.preventDefault(),this.pick(this.highlighted,!0)):(e.preventDefault(),this.pick(Rt[n].style,!0))};constructor(e,t,n=()=>performance.now(),r=Ut()){this.send=t,this.now=n,this.highlighted=r;let i=document.createElement(`section`);i.className=`style-picker`,i.dataset.stylePicker=``,i.hidden=!0,i.setAttribute(`aria-label`,`Pick how your fighter boxes`);let a=document.createElement(`header`),o=document.createElement(`p`);o.className=`style-title`,o.textContent=`CHOOSE YOUR STYLE`,this.clock=document.createElement(`p`),this.clock.className=`style-clock`,a.append(o,this.clock);let s=document.createElement(`div`);s.className=`style-cards`;for(let[e,t]of Rt.entries()){let n=document.createElement(`button`);n.type=`button`,n.dataset.style=t.style,n.setAttribute(`aria-pressed`,`false`);let r=document.createElement(`kbd`);r.textContent=String(e+1);let i=document.createElement(`strong`);i.textContent=t.name;let a=document.createElement(`span`);a.textContent=t.detail;let o=document.createElement(`ul`);o.className=`style-stats`;for(let[e,n]of t.stats.entries()){let t=document.createElement(`li`);t.setAttribute(`aria-label`,`${Lt[e]} ${n} of 5`);let r=document.createElement(`small`);r.textContent=Lt[e];let i=document.createElement(`i`);i.dataset.value=String(n),t.append(r,i),o.append(t)}n.append(r,i,a,o),n.addEventListener(`click`,()=>this.pick(t.style,!0)),s.append(n),this.buttons.set(t.style,n)}this.status=document.createElement(`p`),this.status.className=`style-status`,this.status.setAttribute(`role`,`status`),i.append(a,s,this.status),e.append(i),this.element=i,window.addEventListener(`keydown`,this.keydown)}update(e,t,n){if(e===null){this.setVisible(!1),this.context=null,this.settled=!1;return}let r=this.context===null||!this.choosing&&n===`fighter`;this.context?.select!==e&&(this.deadlineAt=this.now()+e.deadline_ms-Kt),this.context={select:e,viewerId:t},this.choosing=n===`fighter`&&t!==null,this.settled=this.choosing&&(this.settled||e.ready.includes(t));let i=e.players.find(e=>e.id===t)?.style;this.settled&&i!==void 0&&(this.highlighted=i),r&&this.choosing&&!this.settled&&this.send(this.highlighted,!1),this.setVisible(!0),this.render()}pick(e,t){!this.choosing||this.settled||this.closed||(this.highlighted=e,this.send(e,t)&&(t&&(this.settled=!0),this.render()))}get closed(){return this.now()>=this.deadlineAt}neighbour(e){return Rt[(Rt.findIndex(e=>e.style===this.highlighted)+e+Rt.length)%Rt.length].style}move(e){this.pick(e,!1),this.settled||this.buttons.get(this.highlighted)?.focus()}render(){let e=this.context;if(e===null)return;let{select:t,viewerId:n}=e;for(let e of Rt){let t=this.buttons.get(e.style),n=this.choosing&&e.style===this.highlighted;t.disabled=!this.choosing||this.settled||this.closed,t.setAttribute(`aria-pressed`,String(n)),t.toggleAttribute(`data-chosen`,n),t.tabIndex=e.style===this.highlighted?0:-1}let r=`${Math.max(0,Math.ceil((this.deadlineAt-this.now())/1e3))}s`;this.clock.textContent!==r&&(this.clock.textContent=r);let i=t.players.filter(e=>e.id!==n&&(!e.connected||t.ready.includes(e.id))).map(e=>e.connected?`${e.name} is ready.`:`Waiting for ${e.name} to reconnect.`).join(` `),a=this.choosing?this.settled?i.length>0?`Ready as ${zt(this.highlighted).name}. ${i}`:`Ready as ${zt(this.highlighted).name}. Waiting for your opponent.`:i.length>0?`${i} Tap a style or press Enter to settle on yours.`:`Tap a style, or use the arrow keys and Enter.`:i.length>0?`The fighters are choosing. ${i}`:`The fighters are choosing their styles.`;this.status.textContent!==a&&(this.status.textContent=a)}setVisible(e){this.visible!==e&&(this.visible=e,this.element.hidden=!e,e?(this.timer=window.setInterval(()=>this.render(),250),this.padHeld=Xt(Yt()),this.padFrame=requestAnimationFrame(()=>this.pollPad())):(this.timer!==null&&window.clearInterval(this.timer),this.timer=null,cancelAnimationFrame(this.padFrame)))}pollPad(){if(!this.visible)return;let e=Xt(Yt());for(let t of e)this.padHeld.has(t)||(t===`settle`?this.pick(this.highlighted,!0):this.move(this.neighbour(t===`next`?1:-1)));this.padHeld=e,this.padFrame=requestAnimationFrame(()=>this.pollPad())}destroy(){this.setVisible(!1),window.removeEventListener(`keydown`,this.keydown),this.element.remove()}},Qt=/^[0-9]{17,20}$/u,$t=/^[A-Za-z0-9_]{1,128}$/u,en=`https://cdn.discordapp.com/avatars/`,tn=128,nn=8;function rn(e){return e.avatar===null||!Qt.test(e.id)||!$t.test(e.avatar)?null:new URL(`${e.id}/${e.avatar}.png?size=${tn}`,en).href}function an(e){let t=Array.from(e).find(e=>/[\p{L}\p{N}]/u.test(e));return t===void 0?`?`:t.toUpperCase()}var on=class{create;pictures=new Map;addresses=new Map;constructor(e=()=>new Image){this.create=e}get(e){if(e===void 0)return null;let t=this.addresses.get(e.id);(t===void 0||t.avatar!==e.avatar)&&(this.addresses.size>=nn&&this.addresses.clear(),t={avatar:e.avatar,url:rn(e)},this.addresses.set(e.id,t));let n=t.url;if(n===null)return null;let r=this.pictures.get(n);if(r!==void 0)return r.ready?r.image:null;if(this.pictures.size>=nn){let e=this.pictures.entries().next().value;e!==void 0&&this.drop(e[0],e[1])}let i={image:this.create(),ready:!1};return this.pictures.set(n,i),i.image.crossOrigin=`anonymous`,i.image.referrerPolicy=`no-referrer`,i.image.decoding=`async`,i.image.onload=()=>{i.ready=i.image.naturalWidth>0},i.image.onerror=()=>{i.ready=!1},i.image.src=n,null}dispose(){for(let[e,t]of[...this.pictures])this.drop(e,t);this.addresses.clear()}drop(e,t){t.image.onload=null,t.image.onerror=null,t.ready=!1,this.pictures.delete(e)}},sn=`POWER ARMED`,cn=1e3,ln=e=>e.reduce((e,t)=>e+t,0),un=(e,t,n)=>{if(e.measureText(t).width<=n)return t;let r=t;for(;r.length>1&&e.measureText(`${r}…`).width>n;)r=r.slice(0,-1);return`${r}…`},dn=(e,t,n,r)=>{for(let i=n;i>r;--i)if(e(i)<=t)return i;return r},fn=`#ff7066`;function pn(e,t,n,r,i,a){let o=i.spentBelow!==void 0&&i.value0&&(e.globalAlpha=i.alarm*.6,e.fillStyle=`#ff4632`,e.fillRect(t-1,n-1,r+2,11),e.globalAlpha=1),o){e.beginPath();for(let i=-9;i.5?`#ffffff`:`#ff9a90`,e.fillText(r,t,n-4)}}function hn(e,t,n,r,i,a,o){let s=()=>{e.beginPath(),e.arc(t,n,r,0,Math.PI*2),e.closePath()};e.save(),s(),e.fillStyle=`#0b1220`,e.fill(),i===null?(e.globalAlpha=.4,e.fillStyle=o,e.fill(),e.globalAlpha=1,e.fillStyle=`#f5f8ff`,e.textAlign=`center`,e.font=`800 ${Math.round(r*1.1)}px Inter, system-ui, sans-serif`,e.fillText(an(a),t,n+r*.39)):(e.save(),e.clip(),e.drawImage(i,t-r,n-r,r*2,r*2),e.restore()),s(),e.lineWidth=Math.max(1.5,r/9),e.strokeStyle=o,e.stroke(),e.restore()}function gn(e,t=[]){let n=e.left_eye>=p&&!t.includes(`eye_left_out`),r=e.right_eye>=p&&!t.includes(`eye_right_out`);return n&&r?`BOTH EYES SHUT`:n?`LEFT EYE SHUT`:r?`RIGHT EYE SHUT`:null}var _n={cut:`closing the cut`,swelling:`icing the swelling`,breath:`catching breath`,balanced:`a little of everything`};function vn(e){let t=e.flatMap((e,t)=>e.corner_choice===null?[]:[`${t===0?`Blue`:`Red`}: ${_n[e.corner_choice]}`]);return t.length===0?null:t.join(` · `)}function yn(e,t,n,r){e.save(),e.font=`900 12px Inter, system-ui, sans-serif`;let i=e.measureText(sn).width+16,a=r?t-i:t;e.shadowColor=`rgba(255,120,30,0.9)`,e.shadowBlur=12;let o=e.createLinearGradient(0,n,0,n+18);o.addColorStop(0,`#ffd36b`),o.addColorStop(1,`#ff6a1a`),e.fillStyle=o,e.fillRect(a,n,i,18),e.shadowBlur=0,e.fillStyle=`#2a0c00`,e.textAlign=`left`,e.fillText(sn,a+8,n+13),e.restore()}function bn(e,t,n,r,i){e.save(),e.font=`800 9px Inter, system-ui, sans-serif`;let a=e.measureText(r).width+12,o=i?t-a:t;e.fillStyle=`rgba(150,22,18,0.92)`,e.fillRect(o,n,a,14),e.fillStyle=`#ffe8e3`,e.textAlign=`left`,e.fillText(r,o+6,n+10),e.restore()}var xn={arm_torn:0,disemboweled:1,forearm_severed:2,skull_fractured:3,jaw_torn:4,face_flayed:5,eye_out:6,ear_torn:7,arm_broken:8,knee_blown:9,ribs_broken:10,broken_jaw:11,broken_nose:12,liver_ruptured:13,shoulder_dislocated:14},Sn=8,Cn=e=>xn[N(e)],wn={wide:4,compact:3};function Tn(e){return e.filter(t=>t!==`broken_jaw`||!e.includes(`jaw_torn`)).sort((e,t)=>Cn(e)-Cn(t))}function En(e,t){let n=e.slice(0,t).map(Ee);return e.length>t&&n.push(`+${e.length-t}`),n}var Dn=14,On=3,kn=`800 9px Inter, system-ui, sans-serif`,An={grave:`#c4160f`,plain:`rgba(122,18,14,0.92)`,count:`rgba(52,8,8,0.92)`},jn={grave:`#ffffff`,plain:`#ffe8e3`,count:`#ffb1a8`};function Mn(e,t,n,r,i,a){e.fillStyle=An[a],e.fillRect(t,n,r,Dn),e.fillStyle=jn[a],e.fillText(i,t+6,n+10)}function Nn(e,t,n,r,i,a,o){if(i.length===0)return n;let s=Tn(i),c=Math.min(a,s.length),l=En(s,a).map(e=>({label:e,width:0,offset:0,row:0}));e.save(),e.font=kn,e.textAlign=`left`;let u=0,d=0;for(let t of l)t.label=un(e,t.label,r-12),t.width=e.measureText(t.label).width+12,d>0&&d+On+t.width>r&&(u+=1,d=0),t.offset=d===0?0:d+On,t.row=u,d=t.offset+t.width;let f=n-(u+1)*17+On;return l.forEach((n,r)=>{let i=r>=c?`count`:Cn(s[r])r)break;Mn(e,o?t-p-f:t+p,n,f,d,a===null||Cn(a)>=Sn?`plain`:`grave`),l=p+f,u+=1}if(u>0&&u0?`${t.knockdowns} KD`:null,c=[s,t.warnings>0?`${t.warnings} WARNING${t.warnings===1?``:`S`}`:null,t.deductions>0?`−${t.deductions} PT${t.deductions===1?``:`S`}`:null,r>0?`${r} INJUR${r===1?`Y`:`IES`}`:null],l=[s,t.warnings>0?`W${t.warnings}`:null,t.deductions>0?`−${t.deductions}`:null,r>0?`${r} INJ`:null],u=(...e)=>e.filter(e=>e!==null).join(` · `),d=n?[u(i,...l),u(...l)]:[u(i,a,o,...c),u(i,o,...c),u(i,...c),u(i,...l),u(...l)];return d.filter((e,t)=>e!==``&&d.indexOf(e)===t)}var Wn=168;function Gn(e,t,n,r,i,a,o,s,c,l,u=!1){e.save(),e.beginPath(),s?(e.moveTo(t+14,n),e.lineTo(t+r,n),e.lineTo(t+r-14,n+62),e.lineTo(t,n+62)):(e.moveTo(t,n),e.lineTo(t+r-14,n),e.lineTo(t+r,n+62),e.lineTo(t+14,n+62)),e.closePath(),e.fillStyle=`rgba(3,6,12,0.82)`,e.fill(),e.strokeStyle=`rgba(190,200,220,0.22)`,e.lineWidth=1,e.stroke(),e.fillStyle=c,e.fillRect(s?t+r-5:t,n+4,5,54);let d=l===void 0?20:51;l!==void 0&&hn(e,s?t+r-11-16:t+11+16,n+4+16,16,l,i,c);let f=s?t+r-d:t+d;e.textAlign=s?`right`:`left`,e.fillStyle=`#f5f8ff`;let p=i.toUpperCase(),m=r-d-24;e.font=`800 ${dn(t=>(e.font=`800 ${t}px Inter, system-ui, sans-serif`,e.measureText(p).width),m,16,11)}px Inter, system-ui, sans-serif`,e.fillText(un(e,p,m),f,n+21);let h=r-d-14;if(u)e.fillStyle=`#ffb347`,e.font=`900 10px Inter, system-ui, sans-serif`,e.fillText(un(e,sn,h),f,n+35);else{e.fillStyle=`#93a3bd`;let t=(t,n)=>(e.font=`600 ${n}px Inter, system-ui, sans-serif`,e.measureText(t).width),r=a.find(e=>t(e,8)<=h)??a.at(-1)??``;e.font=`600 ${dn(e=>t(r,e),h,10,8)}px Inter, system-ui, sans-serif`,e.fillText(un(e,r,h),f,n+35)}let g=(r-52)/o.length,_=o.length*g+(o.length-1)*12,v=s?t+r-20-_:t+20;o.forEach((t,r)=>{pn(e,v+(g+12)*r,n+48,g,t,s)}),e.restore()}function Kn(e,t,n,r,i,a){let o=Wn;e.save(),e.beginPath(),e.moveTo(t-o/2+12,n),e.lineTo(t+o/2-12,n),e.lineTo(t+o/2,n+29),e.lineTo(t+o/2-12,n+58),e.lineTo(t-o/2+12,n+58),e.lineTo(t-o/2,n+29),e.closePath(),e.fillStyle=`rgba(4,6,12,0.88)`,e.fill();let s=e.createLinearGradient(t-o/2,n,t+o/2,n+58);s.addColorStop(0,`#8a6a26`),s.addColorStop(.5,`#f6d57a`),s.addColorStop(1,`#8a6a26`),e.strokeStyle=s,e.lineWidth=2,e.stroke(),e.textAlign=`center`,e.fillStyle=`#ffffff`,e.font=`800 22px ui-monospace, monospace`,e.fillText(r,t,n+27),e.fillStyle=`#f6d57a`,e.font=`800 12px Inter, system-ui, sans-serif`,e.fillText(i,t,n+44),a!==`FIGHT`&&(e.fillStyle=`#93a3bd`,e.font=`700 9px Inter, system-ui, sans-serif`,e.fillText(a,t,n+55)),e.restore()}var qn=78,Jn=50,Yn=.22,Xn=e=>e<480?Jn:qn,Zn=(e,t)=>Math.max(e<640?112:56,t*.1)+Xn(t)/2-t/2,Qn={upright:{bottom:118,height:274,moves:0,grid:118},landscape:{bottom:118,height:196,moves:102,grid:118},short:{bottom:112,height:154,moves:86,grid:92},shortHeight:350,reach:216,movesReach:134},$n=(e,t)=>e<=t?Qn.upright:t<=Qn.shortHeight?Qn.short:Qn.landscape;function er(e,t,n){let r=$n(e,t);return n<=t-r.bottom-r.height?0:Qn.reach+(r.moves>0&&n>t-r.bottom-r.moves?Qn.movesReach:0)}var tr=160;function nr(e,t,n=!1){let r=Xn(t),i=t/2+Zn(e,t)-r/2,a=Math.min(320,e-24),o=e/2+a/2;if(n&&e<=t)er(e,t,i+r+8)>0&&(r=Jn);else if(n){let n=e<640?Math.min(e/2-Wn/2-8,e-er(e,t,56+r)):0,s=n-12>=tr;s&&(i=56);let c=s?n:e-er(e,t,i+r);o>c&&(a=Math.min(a,c-12),o=c)}return{x:o-a,y:i,width:a,height:r}}var rr={width:380,height:150},ir=112;function ar(e,t,n=!1){let r=$n(e,t),i=t-r.bottom-r.grid,a=e<=t,o=n&&a?Math.min(t-ir,i-8):t-ir,s=Math.max(56,Math.min(Math.max(t*.24,gr(t,e<640)+34),o-rr.height)),c=Math.min(rr.width,e-24),l=e/2+c/2;if(n&&!a&&s+rr.height>i){let t=e-Qn.reach;l>t&&(c=Math.min(c,t-12),l=t)}return{x:l-c,y:s,width:c,height:rr.height}}function or(e,t,n,r){let i=t.height===Jn,a=t.x+t.width/2;e.fillStyle=`rgba(3,6,12,0.88)`,e.fillRect(t.x,t.y,t.width,t.height),e.strokeStyle=`rgba(246,213,122,0.45)`,e.lineWidth=1.5,e.strokeRect(t.x+2,t.y+2,t.width-4,t.height-4),e.textAlign=`center`,e.fillStyle=`#ffd77a`,Lr(e,n,a,t.y+(i?22:34),t.width-24,800,i?17:22,12),e.fillStyle=`#c8d3e6`,e.font=`600 ${i?11:12}px Inter, system-ui, sans-serif`,e.fillText(un(e,r,t.width-24),a,t.y+(i?39:58))}var sr=class{fightTicks=null;round=0;ticks(e){return e.round_number!==this.round&&(this.round=e.round_number,this.fightTicks=null),e.phase===`fight`&&(this.fightTicks=e.phase_ticks_remaining),(e.phase===`knockdown`||e.phase===`foul_recovery`||e.phase===`referee_down`||e.phase===`finish`||e.phase===`complete`)&&this.fightTicks!==null?this.fightTicks:e.phase_ticks_remaining}},cr=()=>({thrown:0,landed:0,jabsThrown:0,jabsLanded:0});function lr(e,t){return e.action_id!==null&&t.some(t=>(t.kind===`block`||t.kind===`perfect_block`)&&t.tick===e.tick&&t.action_id===e.action_id&&t.actor_id===e.target_id)}var ur=class{stats=new Map;totals=new Map;record(e,t=[]){if(e.kind===`bell`)e.detail===`round_start`&&this.stats.clear();else if(e.actor_id!==null){if(e.kind===`punch_start`){let t=+(e.detail.split(`:`)[1]===`jab`);for(let n of[this.entry(this.stats,e.actor_id),this.entry(this.totals,e.actor_id)])n.thrown+=1,n.jabsThrown+=t}else if((e.kind===`hit`||e.kind===`counter_hit`)&&!lr(e,t)){let t=+(e.detail.split(`:`)[0]===`jab`);for(let n of[this.entry(this.stats,e.actor_id),this.entry(this.totals,e.actor_id)])n.landed+=1,n.jabsLanded+=t}}}get(e){return this.stats.get(e)??cr()}total(e){return this.totals.get(e)??cr()}entry(e,t){let n=e.get(t);return n===void 0&&(n=cr(),e.set(t,n)),n}};function dr(e){let t=e.method.replaceAll(`_`,` `).toUpperCase();if(e.method!==`decision`&&e.method!==`draw`)return t;let n=0,r=0,i=0;for(let t of e.scorecards){let e=ln(t.player_one),a=ln(t.player_two);e>a?n+=1:a>e?r+=1:i+=1}let a=e.scorecards.length;return a===0?t:e.method===`draw`?i===a?`UNANIMOUS DRAW`:n===r?`SPLIT DRAW`:`MAJORITY DRAW`:Math.max(n,r)===a?`UNANIMOUS DECISION`:i>0?`MAJORITY DECISION`:`SPLIT DECISION`}var fr=new Set([`ko`,`flash_ko`,`tko`,`death`]),pr=3.6,mr=2.4;function hr(e){return e===null?0:fr.has(e.method)?pr:e.method===`disqualification`?mr:0}var gr=(e,t)=>Math.max(e*.16,(t?112:56)+40),_r=(e,t)=>e!==null&&e>=(t?100:120),vr=`FINISH HIM!`,yr=`Impact, "Arial Black", Inter, system-ui, sans-serif`,br=2.2,xr=.82,Sr={name:15,nameGap:24,bar:10,foot:42},Cr={name:11,nameGap:15,bar:6,foot:26},wr=28,Tr=160;function Er(e,t,n=!1){let r=e<640?118:60,i=Math.round(Math.min(120,t*.17,(e-32)/5)),a=(e,t,n,r,i)=>{let a=i+Math.round(e*xr);return{centre:n,maxWidth:r,size:e,baseline:a,bottom:a+(t?Cr:Sr).foot,dense:t}};if(!n)return a(i,!1,e/2,e-32,r);let o=$n(e,t),s=t-o.bottom-o.height;for(let n of[!1,!0]){let c=null;for(let l of o.moves>0?[s,t-o.bottom-o.moves]:[s]){let o=Math.min(i,Math.floor((l-r-(n?Cr:Sr).foot)/xr));if(o=Tr&&(c={...s,maxWidth:e-2*u})}if(c!==null)return c}let c=nr(e,t,!0);return a(Math.max(12,Math.min(i,Math.floor((c.height-Cr.foot-4)/xr))),!0,c.x+c.width/2,c.width,c.y+2)}function Dr(e,t=null){let[n,r]=e;return t!==null&&(n.player_id===t||r.player_id===t)?n.player_id===t?n:r:n.poise===0==(r.poise===0)?n.knockdowns===r.knockdowns?n.stunned_ticks===r.stunned_ticks?null:n.stunned_ticks>r.stunned_ticks?n:r:n.knockdowns>r.knockdowns?n:r:n.poise===0?n:r}var Or=[`jab`,`straight`,`hook`,`uppercut`],kr=Or.map(e=>e.toUpperCase()),Ar=[`head`,`body`].map(e=>({target:e.toUpperCase(),fatalities:Or.map(t=>F(De(e,t)))})),jr=14,Mr=.4,Nr=[0,0,0,0];function Pr(e,t,n,r,i){e.save(),e.textAlign=`left`;for(let a of[!1,!0])for(let o=10;o>=8;--o){let s=o+5,c=(a?3:2)*s+6;if(n+c>i)continue;e.font=`700 ${o}px Inter, system-ui, sans-serif`;let l=o*.4,u=Math.max(...Ar.map(t=>e.measureText(t.target).width))+10,d=12+u+42;for(let[t,n]of kr.entries()){let r=e.measureText(n).width,i=a?r:0;for(let n of Ar)i=Math.max(i,e.measureText(n.fatalities[t]).width+(a?0:r+l));Nr[t]=i,d+=i}if(d>r)continue;let f=t-d/2;e.fillStyle=`rgba(3,6,12,0.78)`,e.fillRect(f,n,d,c);let p=n+2+o;if(a){e.fillStyle=`#f6d57a`;let t=f+6+u;for(let[n,r]of kr.entries())e.fillText(r,t,p),t+=Nr[n]+jr;p+=s}for(let t of Ar){e.fillStyle=fn,e.fillText(t.target,f+6,p);let n=f+6+u;for(let[r,i]of t.fatalities.entries()){let t=kr[r];a||(e.fillStyle=`#f6d57a`,e.fillText(t,n,p)),e.fillStyle=`#f5f8ff`,e.fillText(i,a?n:n+e.measureText(t).width+l,p),n+=Nr[r]+jr}p+=s}e.restore();return}e.restore()}function Fr(e,t,n,r,i,a){let o=i===null?0:.5-.5*Math.cos(i*br*Math.PI*2),s=t.dense?Cr:Sr;e.save(),e.textAlign=`center`,e.font=`italic 900 ${t.size}px ${yr}`;let c=e.measureText(vr).width,l=Math.min(t.size,t.size*t.maxWidth/(c*1.1)),u=l*(1+.08*o);e.font=`italic 900 ${u}px ${yr}`,e.lineJoin=`round`,e.lineWidth=Math.max(3,u*.12),e.strokeStyle=`rgba(10,0,0,0.92)`,e.shadowColor=`rgba(255,24,12,0.9)`,e.shadowBlur=14+24*o,e.strokeText(vr,t.centre,t.baseline),e.shadowBlur=0;let d=e.createLinearGradient(0,t.baseline-u*.8,0,t.baseline);d.addColorStop(0,`#ff5540`),d.addColorStop(.5,`#d8160d`),d.addColorStop(1,`#7d0705`),e.fillStyle=d,e.fillText(vr,t.centre,t.baseline),e.font=`800 ${s.name}px Inter, system-ui, sans-serif`,e.lineWidth=t.dense?3:4;let f=`ONE MORE PUNCH KILLS`;if(n!==null){let r=e.measureText(`${n} IS DEAD ON HIS FEET`).width<=t.maxWidth?` IS DEAD ON HIS FEET`:` IS DONE FOR`;f=`${un(e,n,Math.max(0,t.maxWidth-e.measureText(r).width))}${r}`}e.strokeText(f,t.centre,t.baseline+s.nameGap),e.fillStyle=`#ffe8e3`,e.fillText(f,t.centre,t.baseline+s.nameGap);let p=Math.min(420,t.maxWidth),m=t.bottom-s.bar-2,h=p*Math.max(0,Math.min(1,r));e.fillStyle=`rgba(2,4,9,0.85)`,e.fillRect(t.centre-p/2-1,m-1,p+2,s.bar+2),e.fillStyle=`#e0180f`,e.fillRect(t.centre-h/2,m,h,s.bar),e.strokeStyle=`rgba(255,112,102,0.85)`,e.lineWidth=1,e.strokeRect(t.centre-p/2-1.5,m-1.5,p+3,s.bar+3),e.restore(),a!==null&&Pr(e,t.centre,t.bottom+8,Math.min(t.maxWidth,c*l/t.size),a)}function Ir(e,t,n,r,i,a,o,s,c=30,l=null,u=null,d=null,f=null,p=null,g=null,_=null,v=!1,y=!1,b=null,x=null,S=!0){e.save();let C=Hn(t,n);e.scale(C,C),t/=C,n/=C,e.textBaseline=`alphabetic`;let w=e=>{let t=i[e.player_id];return t===void 0||g===null?null:g(t)},T=t<640,E=T?(t-56)/2:Math.min(300,t*.38,t/2-Wn/2-8-24),D=n-84,O=S?r.tick/c:null,k=Bn(t,n,v,r.phase===`rest`&&r.fighters.some(e=>e.player_id===a));o===null&&r.fighters.forEach((o,s)=>{let c=s===1,l=c?t-24-E:24,u=i[o.player_id],d=[{label:`${T?`STA`:`STAMINA`} ${Math.round(o.stamina)}`,value:o.stamina,maximum:o.maximum_stamina,from:`#ffe08a`,to:`#d9a53a`},{label:`${T?`HP`:`HEALTH`} ${Math.round(o.conditioning)}`,value:o.conditioning,maximum:cn,from:`#ff8a7a`,to:`#b02a20`},{label:o.guard_broken?`GUARD BROKEN`:`GUARD`,value:o.guard,maximum:700,from:`#9ec7ff`,to:`#3d6fb8`,spentBelow:o.guard_broken?h:m},{label:`POISE ${Math.round(o.poise)}`,value:o.poise,maximum:600,from:`#e8c890`,to:`#8a6a34`}],f=s===0?`#3d6fb8`:`#b02a20`,p=D-12,g=gn(o.trauma,o.injuries),_=Vn(o.blood_volume,O),b=r.phase===`fight`||r.phase===`countdown`||r.phase===`finish`&&Dr(r.fighters,x)?.player_id!==o.player_id,S=y&&o.player_id===a&&b,C=k?3:2,A=Math.min(64,(E-28-C*12)/C),j=A+12,ee=c?l+E+4-C*j:l+20,M=c?l+E-8:ee,te=ee+(c?C-2:0)*j,ne=0;if(k){let n=A<40,r=n&&_.label===`BLEEDING OUT`;pn(e,te,p,A,n?{...d[2],label:r?``:`GUARD`}:d[2],c),pn(e,te+j,p,A,n?{...d[3],label:r?``:`POISE`}:d[3],c),pn(e,c?ee:ee+2*j,p,A,n?{..._,label:r?``:`BLOOD`}:_,c),r&&mn(e,M,p,Ln,c,!1,_.alarm);let i=c?ee-12:ee+3*j;ne=Pn(e,i,p-5,c?i-t/2-4:t/2-4-i,g,o.injuries,c)}else{pn(e,te,p,A,d[2],c),pn(e,te+j,p,A,d[3],c);let t=2*A+12;pn(e,ee,p-Rn,t,_,c);let n=p-Rn-zn;g!==null&&(n-=18,bn(e,M,n,g,c)),n=Nn(e,M,n-4,T?E-24:t,o.injuries,T?wn.compact:wn.wide,c),S&&yn(e,M,n-18,c)}Gn(e,l,D,E,u?.name??`Fighter`,Un(u,o,T,ne),d.slice(0,2),c,f,T?void 0:w(o),k&&S),T&&!(v&&t>n)&&hn(e,t/2+(c?1:-1)*112,83,20,w(o),u?.name??`Fighter`,f)});let A=Math.floor((p??r.phase_ticks_remaining)/c),j=`${Math.floor(A/60)}:${String(A%60).padStart(2,`0`)}`,ee=r.phase===`knockdown`&&u===null&&r.fighters.some(e=>e.player_id===a&&e.is_downed)?ar(t,n,v):null,M=ee!==null&&T&&ee.y<112;o===null&&!M&&Kn(e,t/2,T?54:n-84,j,`ROUND ${r.round_number}`,r.phase===`complete`?`FINAL`:r.phase.replace(`_`,` `).toUpperCase());let te=d===null?0:Math.round(d);if(te>=100&&!T&&o===null&&!(v&&u!==null)&&r.fighters.some(e=>e.player_id===a)&&(e.save(),e.textAlign=v?`left`:`right`,e.font=`700 11px ui-monospace, monospace`,e.fillStyle=te<200?`rgba(240,200,110,0.9)`:`rgba(255,110,100,0.95)`,e.fillText(`SLOW CONNECTION ${te} ms`,v?24:t-24,76),e.restore()),u!==null){let t=T?120:64;e.save(),e.fillStyle=`rgba(3,6,12,0.82)`,e.fillRect(24,t,196,34),e.fillStyle=`#ff3b3b`,e.beginPath(),e.arc(42,t+17,6,0,Math.PI*2),e.fill(),e.fillStyle=`#f6f7fb`,e.font=`800 14px Inter, system-ui, sans-serif`,e.textAlign=`left`,e.fillText(u,56,t+22),e.restore()}f!==null&&r.phase===`fight`&&(e.save(),e.textAlign=`center`,e.font=`900 46px Inter, system-ui, sans-serif`,e.lineWidth=6,e.strokeStyle=`rgba(0,0,0,0.75)`,e.strokeText(f,t/2,n*Yn),e.fillStyle=`#f6d57a`,e.fillText(f,t/2,n*Yn),e.restore()),r.phase===`countdown`&&or(e,nr(t,n,v),`ROUND ${r.round_number}`,`Touch gloves. Protect yourself at all times.`);let ne=gr(n,T);if(r.phase===`knockdown`&&u===null){let n=r.fighters.find(e=>e.is_downed),a=n??r.fighters.find(e=>e.player_id===_),o=a===void 0?null:(i[a.player_id]?.name??`Fighter`).toUpperCase();e.save(),e.textAlign=`center`,e.font=`900 44px Inter, system-ui, sans-serif`,e.lineWidth=6,e.strokeStyle=`rgba(0,0,0,0.75)`,(ee===null||ee.y>=ne+6)&&(e.strokeText(`KNOCKDOWN`,t/2,ne),e.fillStyle=`#ff4d4d`,e.fillText(`KNOCKDOWN`,t/2,ne)),e.font=`700 15px Inter, system-ui, sans-serif`,e.fillStyle=`#e6ecf7`;let s=n===void 0?` BEAT THE COUNT`:` IS DOWN`,c=o===null?`STANDING EIGHT`:`${un(e,o,Math.min(t*.5,t-32-e.measureText(s).width))}${s}`;(ee===null||ee.y>=ne+30)&&e.fillText(c,t/2,ne+24),e.restore()}if(r.phase===`knockdown`&&u===null){let i=r.fighters.find(e=>e.player_id===a),o=Math.max(...r.fighters.map(e=>e.get_up_count));if(i?.is_downed!==!0)o>=1&&(e.save(),e.textAlign=`center`,e.font=`900 36px Inter, system-ui, sans-serif`,e.lineWidth=5,e.strokeStyle=`rgba(0,0,0,0.75)`,e.strokeText(`COUNT ${o}`,t/2,ne+64),e.fillStyle=`#ffd77a`,e.fillText(`COUNT ${o}`,t/2,ne+64),e.restore());else{let{x:a,y:s,width:c,height:l}=ee??ar(t,n,v),u=a+c/2;e.fillStyle=`rgba(3,6,12,0.88)`,e.fillRect(a,s,c,l),e.strokeStyle=`rgba(246,213,122,0.5)`,e.lineWidth=2,e.strokeRect(a+2,s+2,c-4,l-4),e.textAlign=`center`,e.fillStyle=`#ffd77a`,e.font=`800 30px Inter, system-ui, sans-serif`,e.fillText(o>=1?`COUNT ${o}`:`GET UP!`,u,s+40);let d=i?.is_downed===!0?i.get_up_prompt:null;if(d!=null&&i!==void 0){let t=r.tick>=i.get_up_window_start_tick&&r.tick<=i.get_up_window_end_tick,n=d===`get_up_left`?`←`:`→`;t?(e.fillStyle=`#ffe9a8`,e.font=`900 64px Inter, system-ui, sans-serif`,e.fillText(n,u-90,s+106),e.fillStyle=`#7dffa8`,e.font=`900 34px Inter, system-ui, sans-serif`,e.fillText(`NOW!`,u+62,s+100)):(e.fillStyle=`#8fa3c8`,e.font=`800 30px Inter, system-ui, sans-serif`,e.fillText(`GET READY ${n}`,u,s+98));let o=c-60,l=Math.max(0,Math.min(1,i.get_up_meter/Math.max(1,i.get_up_required)));e.fillStyle=`rgba(2,4,9,0.9)`,e.fillRect(a+30,s+120,o,16);let f=e.createLinearGradient(a+30,0,a+30+o,0);f.addColorStop(0,`#7dffa8`),f.addColorStop(1,`#2ea860`),e.fillStyle=f,e.fillRect(a+30,s+120,o*l,16),e.strokeStyle=`rgba(210,220,235,0.5)`,e.lineWidth=1,e.strokeRect(a+29.5,s+119.5,o+1,17)}else e.fillStyle=`#c8d3e6`,e.font=`600 14px Inter, system-ui, sans-serif`,e.fillText(un(e,`Waiting for your rhythm instruction…`,c-24),u,s+100)}}if(r.phase===`finish`&&o===null&&u===null){let o=Dr(r.fighters,x),s=Er(t,n,v),c=o!==null&&o.player_id!==a&&r.fighters.some(e=>e.player_id===a);Fr(e,s,o===null?null:(i[o.player_id]?.name??`Fighter`).toUpperCase(),r.phase_ticks_remaining/Se,O,c&&!v?n*Mr:null)}if(r.phase===`foul_recovery`){let a=r.fighters.find(e=>e.is_foul_recovery_target);or(e,nr(t,n,v),`FOUL RECOVERY`,`${i[a?.player_id??``]?.name??`Fighter`} is recovering`)}if(r.phase===`rest`){let i=r.fighters.map((e,t)=>({corner:t===0?`Blue`:`Red`,stats:l?.get(e.player_id)??cr()})).filter(({stats:e})=>e.thrown>0||e.landed>0).map(({corner:e,stats:t})=>`${e} ${t.landed} of ${t.thrown}`).join(` · `),a=vn(r.fighters);or(e,nr(t,n,v),`CORNERS · RECOVER`,a??(i.length>0?`Landed this round: ${i}`:`Conditioning governs recovery`))}if(s>0){let r=Math.min(320,t-24),i=Xn(n);or(e,v?nr(t,n,!0):{x:t/2-r/2,y:n/2-i/2,width:r,height:i},`OPPONENT RECONNECTING · ${Math.ceil(s/1e3)}s`,`The bout is paused`)}if(o!==null){let a=r.fighters.map(e=>l?.total(e.player_id)??cr());qr(e,t,n,Br(o,r.fighters,i,a,b),!0,[w(r.fighters[0]),w(r.fighters[1])])}e.restore()}function Lr(e,t,n,r,i,a,o,s,c=`Inter, system-ui, sans-serif`){e.font=`${a} ${dn(n=>(e.font=`${a} ${n}px ${c}`,e.measureText(t).width),i,o,s)}px ${c}`,e.fillText(un(e,t,i),n,r)}var Rr={ko:`KNOCKOUT`,flash_ko:`FLASH KNOCKOUT`,tko:`TECHNICAL KNOCKOUT`,disqualification:`DISQUALIFICATION`,forfeit:`FORFEIT`},zr=(e,t)=>e>t?0:t>e?1:null;function Br(e,t,n,r,i=null){let a=t.map(e=>n[e.player_id]?.name??`Fighter`),o=e.winner_id===null?null:t[0].player_id===e.winner_id?0:t[1].player_id===e.winner_id?1:null,s=e.method===`draw`&&i!==null,c=[],l=[];if(e.method===`decision`||e.method===`draw`&&!s)for(let t of e.scorecards){let e=ln(t.player_one),n=ln(t.player_two);l.push({label:t.judge.toUpperCase(),values:[String(e),String(n)],lead:zr(e,n)})}let u=[t[1].knockdowns,t[0].knockdowns];(u[0]>0||u[1]>0)&&c.push({label:`KNOCKDOWNS`,values:[String(u[0]),String(u[1])],lead:zr(u[0],u[1])});let[d,f]=t.map(t=>e.punches?.[t.player_id]),p=e=>({thrown:e.thrown,landed:e.landed,jabsThrown:e.jabs_thrown,jabsLanded:e.jabs_landed}),m=d!==void 0&&f!==void 0?[p(d),p(f)]:r;if(m[0].thrown>0||m[1].thrown>0){let e=(e,t)=>t>0?`${Math.min(e,t)}/${t} (${Math.round(Math.min(e,t)/t*100)}%)`:`0/0`,t=m.map(e=>({landed:e.landed-e.jabsLanded,thrown:e.thrown-e.jabsThrown}));c.push({label:`TOTAL PUNCHES`,values:[e(m[0].landed,m[0].thrown),e(m[1].landed,m[1].thrown)],lead:zr(m[0].landed,m[1].landed)}),c.push({label:`JABS`,values:[e(m[0].jabsLanded,m[0].jabsThrown),e(m[1].jabsLanded,m[1].jabsThrown)],lead:zr(m[0].jabsLanded,m[1].jabsLanded)}),c.push({label:`POWER PUNCHES`,values:[e(t[0].landed,t[0].thrown),e(t[1].landed,t[1].thrown)],lead:zr(t[0].landed,t[1].landed)})}let[h,g]=t.map(t=>e.ratings[t.player_id]);if(t.some(e=>n[e.player_id]?.cpu===!0))c.push({label:`RATING`,values:[`Unrated`,`Unrated`],lead:null});else if(h!==void 0&&g!==void 0){let e=e=>`${e.after} (${e.after>=e.before?`+`:`−`}${Math.abs(e.after-e.before)})`;c.push({label:`RATING`,values:[e(h),e(g)],lead:null,news:[h.after>=h.before,g.after>=g.before]})}return{headline:e.method===`death`?i!==null&&ke(i)!==null?`FATALITY`:`DEATH`:s?`DOUBLE DEATH`:Rr[e.method]??dr(e),detail:i!==null&&(e.method===`death`||s)?`${Ae(i)} · ROUND ${e.round}`:`ROUND ${e.round}`,verdict:s?`NO SURVIVORS`:o===null?e.winner_id===null?`DRAW`:`${(n[e.winner_id]?.name??`Winner`).toUpperCase()} WINS`:`${a[o].toUpperCase()} WINS`,deadly:e.method===`death`||s,winnerSeat:o,names:a,judges:l,rows:c}}var Vr=[`#4f86d9`,`#d9483c`],Hr=14;function Ur(e,t,n,r){let i=Hn(e,t),a=Kr(e/i,t/i,n,r);return i===1?a:{...a,x:a.x*i,y:a.y*i,width:a.width*i,height:a.height*i,rowHeight:a.rowHeight*i,verdictHeight:a.verdictHeight*i,judgesHeight:a.judgesHeight*i}}var Wr=new Set([`KNOCKDOWNS`,`TOTAL PUNCHES`,`RATING`]),Gr=(e,t)=>t?e.rows.filter(e=>Wr.has(e.label)):e.rows;function Kr(e,t,n,r){let i=t<480,a=e>=900||e>=640&&i,o=Math.min(e-24,a?980:720),s=r?62:Hr,c=i?72:112,l=n.judges.length===0?0:i?36:52,u=c+l,d=Gr(n,i).length+1,f=t-(e<640?118:70)-14-Hr-s-(a?0:u),p=Math.max(16,Math.min(i?20:28,f/d)),m=Hr+(a?Math.max(u,d*p):u+d*p)+s;return{x:(e-o)/2,y:t-14-m,width:o,height:m,wide:a,dense:i,rowHeight:p,verdictHeight:c,judgesHeight:l}}function qr(e,t,n,r,i,a){let o=Kr(t,n,r,i),{x:s,y:c}=o;e.fillStyle=`rgba(3,6,12,0.9)`,e.fillRect(s,c,o.width,o.height),e.strokeStyle=r.deadly?`rgba(224,36,26,0.8)`:`rgba(246,213,122,0.55)`,e.lineWidth=2,e.strokeRect(s+1,c+1,o.width-2,o.height-2),e.textAlign=`center`;let l=(o.wide?o.width*.42:o.width)-32,u=o.wide?s+o.width*.21+4:t/2,d=c+Hr,f=o.verdictHeight/112;e.fillStyle=r.deadly?`#ff3a2c`:`#f6d57a`,Lr(e,r.headline,u,d+34*f,l,800,(o.wide||t>=640?32:28)*f,14),e.fillStyle=`#aebbd0`,Lr(e,r.detail,u,d+56*f,l,700,13*f,9),e.fillStyle=r.winnerSeat===null?`#f6f7fb`:Vr[r.winnerSeat],Lr(e,r.verdict,u,d+92*f,l,800,25*f,12);let p=l/Math.max(1,r.judges.length),m=d+o.verdictHeight;r.judges.forEach((t,n)=>{let r=u-l/2+p*(n+.5);e.fillStyle=`rgba(255,255,255,0.06)`,e.fillRect(r-p/2+3,m,p-6,o.judgesHeight-8),e.fillStyle=`#8fa3c8`,Lr(e,t.label,r,m+o.judgesHeight*.3,p-14,700,10,7),e.fillStyle=`#f6f7fb`,Lr(e,`${t.values[0]} – ${t.values[1]}`,r,m+o.judgesHeight*.7,p-14,800,o.dense?14:17,10)});let h=o.wide?s+o.width*.42:s+12,g=s+o.width-12-h,_=o.wide?d:m+o.judgesHeight,v=g*.36,y=(g-v)/2,b=[h+y/2,h+g-y/2],x=o.rowHeight,S=Math.min(16,x*.6),C=_+x*.7;e.fillStyle=`rgba(255,255,255,0.06)`,e.fillRect(h,_,g,x);let w=Math.max(6,x/2-2);for(let t of[0,1]){let n=t===0?-1:1;e.fillStyle=Vr[t],e.fillRect(t===0?h:h+g-4,_,4,x),hn(e,b[t]+n*(y/2-10-w),_+x/2,w,a[t],r.names[t],Vr[t]),e.textAlign=`center`,e.fillStyle=`#f6f7fb`,Lr(e,r.names[t],b[t]-n*(w+3+v/4),C,y+v/2-22-w*2,800,S,9)}for(let t of Gr(r,o.dense)){C+=x,e.fillStyle=`#8fa3c8`,Lr(e,t.label,h+g/2,C,v,700,Math.min(12,S),8);for(let n of[0,1])e.fillStyle=t.news===void 0?t.lead===n?`#f6f7fb`:`#aebbd0`:t.news[n]?`#55df9b`:`#ff7b74`,Lr(e,t.values[n],b[n],C,y-16,t.lead===n?800:600,S,9)}}var Jr=6,Yr=150;function Xr(){return typeof window<`u`&&typeof window.speechSynthesis==`object`&&window.speechSynthesis!==null&&typeof window.SpeechSynthesisUtterance==`function`}function Zr(e){let t=e.filter(e=>e.localService&&e.lang.toLowerCase().startsWith(`en`));return t.find(e=>e.default)??t[0]??null}var Qr=class{settings;synthesis;Utterance;queue=[];speaking=null;destroyed=!1;grave=!1;voice=null;voicesListed=!1;onVoicesChanged=null;cutoff=null;pendingShout=null;cutOff=null;shoutTimer=null;voicesChanged=()=>{this.listVoices(),this.voice===null&&this.cancel(),this.onVoicesChanged?.()};visibility=()=>{document.hidden&&this.cancel()};constructor(e,t=Xr()?window.speechSynthesis:null,n=Xr()?window.SpeechSynthesisUtterance:null){this.settings=e,this.synthesis=t,this.Utterance=n,this.listVoices(),t?.addEventListener?.(`voiceschanged`,this.voicesChanged),document.addEventListener(`visibilitychange`,this.visibility)}get supported(){return this.synthesis!==null&&this.Utterance!==null}get hasVoice(){return this.supported&&(this.voice!==null||!this.voicesListed)}speak(e){if(!this.supported||this.destroyed||document.hidden)return;let t=this.settings();!t.announcer||t.volume<=0||(this.voice===null&&this.listVoices(),this.voice!==null&&(this.queue.push(...e),this.queue.length>Jr&&this.queue.splice(0,this.queue.length-Jr),this.speaking===null&&this.pendingShout===null&&this.next()))}shout(e){let t=this.speaking??this.cutOff;if(this.cancel(),t===null){this.grave=!0,this.speak([e]),this.grave=!1;return}let n=()=>{this.pendingShout===n&&(this.clearShout(),t.onend=null,t.onerror=null,this.queue.unshift(e),this.grave=!0,this.next(),this.grave=!1)};this.pendingShout=n,this.cutOff=t,t.onend=n,t.onerror=n,this.shoutTimer=window.setTimeout(n,Yr)}settingsChanged(){let e=this.settings();(!e.announcer||e.volume<=0)&&this.cancel()}finishLine(e){this.queue.length=0,this.clearCutoff();let t=this.speaking;t!==null&&(this.cutoff=window.setTimeout(()=>{this.cutoff=null,this.speaking===t&&this.cancel()},e))}cancel(){this.queue.length=0,this.clearCutoff(),this.clearShout();let e=this.speaking;this.speaking=null,e!==null&&(e.onend=null,e.onerror=null,this.synthesis?.cancel())}destroy(){this.destroyed=!0,this.synthesis?.removeEventListener?.(`voiceschanged`,this.voicesChanged),document.removeEventListener(`visibilitychange`,this.visibility),this.onVoicesChanged=null,this.cancel()}clearCutoff(){this.cutoff!==null&&window.clearTimeout(this.cutoff),this.cutoff=null}clearShout(){this.shoutTimer!==null&&window.clearTimeout(this.shoutTimer),this.shoutTimer=null,this.pendingShout=null,this.cutOff=null}listVoices(){let e=this.synthesis?.getVoices()??[];e.length>0&&(this.voicesListed=!0),this.voice=Zr(e)}next(){let e=this.synthesis,t=this.Utterance,n=this.voice,r=this.queue.shift();if(e===null||t===null||r===void 0)return;let i=this.settings();if(!i.announcer||i.volume<=0||n===null||document.hidden){this.queue.length=0;return}let a=new t(r);a.volume=Math.min(1,i.volume),a.rate=this.grave?.8:.96,a.pitch=this.grave?.3:.82,a.voice=n,a.lang=n.lang;let o=()=>{this.speaking===a&&(this.speaking=null,this.clearCutoff(),this.next())};a.onend=o,a.onerror=o,this.speaking=a,e.speak(a)}},$r=[{name:`decapitation`,sampleRate:12e3,frames:7920,wav:`UklGRgQ+AABXQVZFZm10IBAAAAABAAEA4C4AAMBdAAACABAAZGF0YeA9AAAGAGAAd/9r/1b/Dv+d/kH+Of69/vL/gAGaAhUD9wKOAmICHwPSBLYGQ/pC+4r72/rQ+Sr5sPle+7X+MQM2BmQHHwfgBSEFpAU+CKkLYA649Q331faL9fnzlfMw9ST5+/5iBV4JDAtaCuYIVgdWB0kKSw/iE2HuFvGL8lnxVO/g7TXt4+6L8wT7agMsCvAN0g4gDb0K4QjzCOEMBhO+GHQdcuis667sVOsZ6dTmDeaH54Hr4fE9+0wECgylELYRuBDhDU0LfAnWCb8OABXvG6QiDyiLKwjk3uUl5fziMuAc3v/cvtx23kbj2Op98xH8EQYQD/ETiBVzFgkUHxCYDc0MWAtYC4sPrhWTHE4kpitIMV41DDlm11XZV9pG2ZPXOtVN0yrRjc/wzkXPstA51HDae+DX6I/xjfq1BBYNYRMgGAYaSRwnHU8dkxoAFz0USRJLECwP5A0ZDyUSzha7HdclaS2nNJw6o0JgRw9LVE6kUMZROMnOyWDLQMlWxRzEScGKv0u+eLx5uq+5xbnxuii8ub7nwOLDMMrT0IXWnt1r54DwWPp2A/YLiRBdF9wbex6gIAkibyGNH3IdGBpMFdESOA45C08JEQoUC1gMIBImGl0fFiogM7A6FEMZS1ZThlfAXGhgxGHyY1S6Cbszuki4dLensvmwaq+crAesQqy5rfiv1bR/un/B2swO2f3mdfQbAw8OrRS+HC0duyDeHmwZUhXJDocJfAmGC0ATOBemJCoytT+YTKJX0V1qY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BYI4AhkBmcGugUdAqP67fTg8ln1X/uOAkIGCgf1Bp4I2garBgIGkQIP/Ej22PNQ9RP6qwDYBAQGHQYhB7QHEwecBvwEKQAR+uX1aPSU9j/7xAALBKkE4gTrBSoH4Qa3BlYFegHO+433vvVl9vP5IP/5AkYEOgSDBFQGKwcMB78GqwSVAJD7Gvid9r72dPnM/VsBcgPiA/QD9wT/BjAHMwenBqMEtQAB/Pr4ofdk93/5z/zh/8ABHwIvArMCeQSbBokGSgacBccDUACG/N35kPgj+DP5/fvQ/t4AwgHlAQQCtwJcBEAGNAYeBnkFEARqATv+c/v6+Vr5KPld+oH8s/5KALQA+wDsAI0BtgKjBL0FtwVsBdAEbQMzAX3+Xfz++mf6N/qj+jb8Cf6A/zQAZABdAHsAGwFVAs4DCgUEBdwEbQSMAwwC7f/q/ZD8vvtp+077vPsb/Xf+e/8IABsAAQAFAHUAOgFWApcDPQQzBPcDhgOUAjYBiv8S/gT9mvxP/Ej8TfxW/VP+Hv+a/9L/wv/V/w0AoQBbAWcCQgNxA1gDIgOlAt0BwgCE/3r+yf13/Vf9Uf19/SP+1/5m/7j/3f/l/wQAPwC+AHABEwKEAnICQwL7AXkBygDr/y//qf5t/l7+Xv5n/sf+Mf92/5//qP+j/77/AABnAOAAQAF7AWMBQgEJAacAMwDB/3j/WP9R/1j/Xf+J/8H/3f/g/+H/6f/8/x4ARQBjAG4AYwBSADoAIAAMAAQABwA=`}],ei=`attached`,ti=1e3,ni=1001,ri=1002,ii=1003,ai=1004,oi=1005,si=1006,ci=1007,li=1008,ui=1009,di=1010,fi=1011,pi=1012,mi=1013,hi=1014,gi=1015,_i=1016,vi=1017,yi=1018,bi=1020,xi=35902,Si=35899,Ci=1021,wi=1022,Ti=1023,Ei=1026,Di=1027,Oi=1028,ki=1029,Ai=1030,ji=1031,Mi=1033,Ni=33776,Pi=33777,Fi=33778,Ii=33779,Li=35840,Ri=35841,zi=35842,Bi=35843,Vi=36196,Hi=37492,Ui=37496,Wi=37488,Gi=37489,Ki=37490,qi=37491,Ji=37808,Yi=37809,Xi=37810,Zi=37811,Qi=37812,$i=37813,ea=37814,ta=37815,na=37816,ra=37817,ia=37818,aa=37819,oa=37820,sa=37821,ca=36492,la=36494,ua=36495,da=36283,fa=36284,pa=36285,ma=36286,ha=2300,ga=2301,_a=2302,va=2303,ya=2400,ba=2401,xa=2402,Sa=2500,Ca=3200,wa=`srgb`,Ta=`srgb-linear`,Ea=`linear`,Da=`srgb`,Oa=7680,ka=35044,Aa=35048,ja=2e3;function Ma(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function Na(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Pa(e){return document.createElementNS(`http://www.w3.org/1999/xhtml`,e)}function Fa(){let e=Pa(`canvas`);return e.style.display=`block`,e}var Ia={};function La(...e){let t=`THREE.`+e.shift();console.log(t,...e)}function Ra(e){let t=e[0];if(typeof t==`string`&&t.startsWith(`TSL:`)){let t=e[1];t&&t.isStackTrace?e[0]+=` `+t.getLocation():e[1]=`Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.`}return e}function za(...e){e=Ra(e);let t=`THREE.`+e.shift();{let n=e[0];n&&n.isStackTrace?console.warn(n.getError(t)):console.warn(t,...e)}}function Ba(...e){e=Ra(e);let t=`THREE.`+e.shift();{let n=e[0];n&&n.isStackTrace?console.error(n.getError(t)):console.error(t,...e)}}function Va(...e){let t=e.join(` `);t in Ia||(Ia[t]=!0,za(...e))}function Ha(e,t,n){return new Promise(function(r,i){function a(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:i();break;case e.TIMEOUT_EXPIRED:setTimeout(a,n);break;default:r()}}setTimeout(a,n)})}var Ua={0:1,2:6,4:7,3:5,1:0,6:2,7:4,5:3},Wa=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n!==void 0&&n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let r=n[e];if(r!==void 0){let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let t=n.slice(0);for(let n=0,r=t.length;n>8&255]+Ga[e>>16&255]+Ga[e>>24&255]+`-`+Ga[t&255]+Ga[t>>8&255]+`-`+Ga[t>>16&15|64]+Ga[t>>24&255]+`-`+Ga[n&63|128]+Ga[n>>8&255]+`-`+Ga[n>>16&255]+Ga[n>>24&255]+Ga[r&255]+Ga[r>>8&255]+Ga[r>>16&255]+Ga[r>>24&255]).toLowerCase()}function Xa(e,t,n){return Math.max(t,Math.min(n,e))}function Za(e,t){return(e%t+t)%t}function Qa(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)}function $a(e,t,n){return e===t?0:(n-e)/(t-e)}function eo(e,t,n){return(1-n)*e+n*t}function to(e,t,n,r){return eo(e,t,1-Math.exp(-n*r))}function no(e,t=1){return t-Math.abs(Za(e,t*2)-t)}function ro(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function io(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function ao(e,t){return e+Math.floor(Math.random()*(t-e+1))}function oo(e,t){return e+Math.random()*(t-e)}function so(e){return e*(.5-Math.random())}function co(e){e!==void 0&&(Ka=e);let t=Ka+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function lo(e){return e*qa}function uo(e){return e*Ja}function fo(e){return e>0&&Number.isInteger(e)&&2**Math.round(Math.log2(e))===e}function po(e){return 2**Math.ceil(Math.log(e)/Math.LN2)}function mo(e){return 2**Math.floor(Math.log(e)/Math.LN2)}function ho(e,t,n,r,i){let a=Math.cos,o=Math.sin,s=a(n/2),c=o(n/2),l=a((t+r)/2),u=o((t+r)/2),d=a((t-r)/2),f=o((t-r)/2),p=a((r-t)/2),m=o((r-t)/2);switch(i){case`XYX`:e.set(s*u,c*d,c*f,s*l);break;case`YZY`:e.set(c*f,s*u,c*d,s*l);break;case`ZXZ`:e.set(c*d,c*f,s*u,s*l);break;case`XZX`:e.set(s*u,c*m,c*p,s*l);break;case`YXY`:e.set(c*p,s*u,c*m,s*l);break;case`ZYZ`:e.set(c*m,c*p,s*u,s*l);break;default:za(`MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: `+i)}}function go(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:case Uint8ClampedArray:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error(`THREE.MathUtils: Invalid component type.`)}}function _o(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:case Uint8ClampedArray:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error(`THREE.MathUtils: Invalid component type.`)}}var L={DEG2RAD:qa,RAD2DEG:Ja,generateUUID:Ya,clamp:Xa,euclideanModulo:Za,mapLinear:Qa,inverseLerp:$a,lerp:eo,damp:to,pingpong:no,smoothstep:ro,smootherstep:io,randInt:ao,randFloat:oo,randFloatSpread:so,seededRandom:co,degToRad:lo,radToDeg:uo,isPowerOfTwo:fo,ceilPowerOfTwo:po,floorPowerOfTwo:mo,setQuaternionFromProperEuler:ho,normalize:_o,denormalize:go},R=class e{static{e.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error(`THREE.Vector2: index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error(`THREE.Vector2: index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Xa(this.x,e.x,t.x),this.y=Xa(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Xa(this.x,e,t),this.y=Xa(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Xa(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(Xa(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},vo=class{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,a,o){let s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],d=i[a+0],f=i[a+1],p=i[a+2],m=i[a+3];if(u!==m||s!==d||c!==f||l!==p){let e=s*d+c*f+l*p+u*m;e<0&&(d=-d,f=-f,p=-p,m=-m,e=-e);let t=1-o;if(e<.9995){let n=Math.acos(e),r=Math.sin(n);t=Math.sin(t*n)/r,o=Math.sin(o*n)/r,s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o}else{s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o;let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:za(`Quaternion: .setFromEuler() encountered an unknown order: `+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Xa(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,r=-r,i=-i,a=-a,o=-o);let s=1-t;if(o<.9995){let e=Math.acos(o),c=Math.sin(e);s=Math.sin(s*e)/c,t=Math.sin(t*e)/c,this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this._onChangeCallback()}else this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},z=class e{static{e.prototype.isVector3=!0}constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error(`THREE.Vector3: index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error(`THREE.Vector3: index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(bo.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(bo.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=2*(a*r-o*n),l=2*(o*t-i*r),u=2*(i*n-a*t);return this.x=t+s*c+a*u-o*l,this.y=n+s*l+o*c-i*u,this.z=r+s*u+i*l-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Xa(this.x,e.x,t.x),this.y=Xa(this.y,e.y,t.y),this.z=Xa(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Xa(this.x,e,t),this.y=Xa(this.y,e,t),this.z=Xa(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Xa(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return yo.copy(this).projectOnVector(e),this.sub(yo)}reflect(e){return this.sub(yo.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(Xa(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},yo=new z,bo=new vo,xo=class e{static{e.prototype.isMatrix3=!0}constructor(e,t,n,r,i,a,o,s,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,i,a,o,s,c)}set(e,t,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){return Va(`Matrix3: .scale() is deprecated. Use .makeScale() instead.`),this.premultiply(So.makeScale(e,t)),this}rotate(e){return Va(`Matrix3: .rotate() is deprecated. Use .makeRotation() instead.`),this.premultiply(So.makeRotation(-e)),this}translate(e,t){return Va(`Matrix3: .translate() is deprecated. Use .makeTranslation() instead.`),this.premultiply(So.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}},So=new xo,Co=new xo().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),wo=new xo().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function To(){let e={enabled:!0,workingColorSpace:Ta,spaces:{},convert:function(e,t,n){return this.enabled===!1||t===n||!t||!n||(this.spaces[t].transfer===`srgb`&&(e.r=Do(e.r),e.g=Do(e.g),e.b=Do(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===`srgb`&&(e.r=Oo(e.r),e.g=Oo(e.g),e.b=Oo(e.b))),e},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===``?Ea:this.spaces[e].transfer},getToneMappingMode:function(e){return this.spaces[e].outputColorSpaceConfig.toneMappingMode||`standard`},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(t,n){return Va(`ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().`),e.workingToColorSpace(t,n)},toWorkingColorSpace:function(t,n){return Va(`ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().`),e.colorSpaceToWorking(t,n)}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[Ta]:{primaries:t,whitePoint:r,transfer:Ea,toXYZ:Co,fromXYZ:wo,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:wa},outputColorSpaceConfig:{drawingBufferColorSpace:wa}},[wa]:{primaries:t,whitePoint:r,transfer:Da,toXYZ:Co,fromXYZ:wo,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:wa}}}),e}var Eo=To();function Do(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function Oo(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}var ko,Ao=class{static getDataURL(e,t=`image/png`){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>`u`)return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{ko===void 0&&(ko=Pa(`canvas`)),ko.width=e.width,ko.height=e.height;let t=ko.getContext(`2d`);e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),n=ko}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap){let t=Pa(`canvas`);t.width=e.width,t.height=e.height;let n=t.getContext(`2d`);n.drawImage(e,0,0,e.width,e.height);let r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let e=0;e1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Fo).x}get height(){return this.source.getSize(Fo).y}get depth(){return this.source.getSize(Fo).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){za(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];r===void 0?za(`Texture.setValues(): property '${t}' does not exist.`):r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:`Texture`,generator:`Texture.toJSON`},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:`dispose`})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case ti:e.x-=Math.floor(e.x);break;case ni:e.x=e.x<0?0:1;break;case ri:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x-=Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case ti:e.y-=Math.floor(e.y);break;case ni:e.y=e.y<0?0:1;break;case ri:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y-=Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};Io.DEFAULT_IMAGE=null,Io.DEFAULT_MAPPING=300,Io.DEFAULT_ANISOTROPY=1;var Lo=class e{static{e.prototype.isVector4=!0}constructor(e=0,t=0,n=0,r=1){this.x=e,this.y=t,this.z=n,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error(`THREE.Vector4: index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error(`THREE.Vector4: index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w===void 0?1:e.w,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,i,a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],f=s[5],p=s[9],m=s[2],h=s[6],g=s[10];if(Math.abs(l-d)s&&e>_?e_?s1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t>>0}enable(e){this.mask|=1<1){for(let e=0;e1){for(let e=0;e0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type=`InstancedMesh`,r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type=`BatchedMesh`,r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox?e.boundingBox.toJSON():void 0,boundingSphere:e.boundingSphere?e.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(e=>({...e})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function i(t,n){return t[n.uuid]===void 0&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);let t=this.geometry.parameters;if(t!==void 0&&t.shapes!==void 0){let n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t0){r.children=[];for(let t=0;t0){r.animations=[];for(let t=0;t0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),c.length>0&&(n.skeletons=c),l.length>0&&(n.animations=l),u.length>0&&(n.nodes=u)}return n.object=r,n;function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot===null?null:e.pivot.clone(),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let t=0;t.025?(c.inputState.pinching=!1,this.dispatchEvent({type:`pinchend`,handedness:e.handedness,target:this})):!c.inputState.pinching&&o<=.015&&(c.inputState.pinching=!0,this.dispatchEvent({type:`pinchstart`,handedness:e.handedness,target:this}))}else s!==null&&e.gripSpace&&(i=t.getPose(e.gripSpace,n),i!==null&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1,s.eventsEnabled&&s.dispatchEvent({type:`gripUpdated`,data:e,target:this})));o!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&i!==null&&(r=i),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(_s)))}return o!==null&&(o.visible=r!==null),s!==null&&(s.visible=i!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new gs;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},ys={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},bs={h:0,s:0,l:0},xs={h:0,s:0,l:0};function Ss(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}var B=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let t=e;t&&t.isColor?this.copy(t):typeof t==`number`?this.setHex(t):typeof t==`string`&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=wa){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Eo.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=Eo.workingColorSpace){return this.r=e,this.g=t,this.b=n,Eo.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=Eo.workingColorSpace){if(e=Za(e,1),t=Xa(t,0,1),n=Xa(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=Ss(i,r,e+1/3),this.g=Ss(i,r,e),this.b=Ss(i,r,e-1/3)}return Eo.colorSpaceToWorking(this,r),this}setStyle(e,t=wa){function n(t){t!==void 0&&parseFloat(t)<1&&za(`Color: Alpha component of `+e+` will be ignored.`)}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],o=r[2];switch(a){case`rgb`:case`rgba`:if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case`hsl`:case`hsla`:if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:za(`Color: Unknown color model `+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=r[1],i=n.length;if(i===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(n,16),t);za(`Color: Invalid hex color `+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=wa){let n=ys[e.toLowerCase()];return n===void 0?za(`Color: Unknown color `+e):this.setHex(n,t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Do(e.r),this.g=Do(e.g),this.b=Do(e.b),this}copyLinearToSRGB(e){return this.r=Oo(e.r),this.g=Oo(e.g),this.b=Oo(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=wa){return Eo.workingToColorSpace(Cs.copy(this),e),Math.round(Xa(Cs.r*255,0,255))*65536+Math.round(Xa(Cs.g*255,0,255))*256+Math.round(Xa(Cs.b*255,0,255))}getHexString(e=wa){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Eo.workingColorSpace){Eo.workingToColorSpace(Cs.copy(this),t);let n=Cs.r,r=Cs.g,i=Cs.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){Es.subVectors(r,t),Ds.subVectors(n,t),Os.subVectors(e,t);let a=Es.dot(Es),o=Es.dot(Ds),s=Es.dot(Os),c=Ds.dot(Ds),l=Ds.dot(Os),u=a*c-o*o;if(u===0)return i.set(0,0,0),null;let d=1/u,f=(c*s-o*l)*d,p=(a*l-o*s)*d;return i.set(1-f-p,p,f)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,ks)!==null&&ks.x>=0&&ks.y>=0&&ks.x+ks.y<=1}static getInterpolation(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,ks)===null?(s.x=0,s.y=0,`z`in s&&(s.z=0),`w`in s&&(s.w=0),null):(s.setScalar(0),s.addScaledVector(i,ks.x),s.addScaledVector(a,ks.y),s.addScaledVector(o,ks.z),s)}static getInterpolatedAttribute(e,t,n,r,i,a){return Is.setScalar(0),Ls.setScalar(0),Rs.setScalar(0),Is.fromBufferAttribute(e,t),Ls.fromBufferAttribute(e,n),Rs.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(Is,i.x),a.addScaledVector(Ls,i.y),a.addScaledVector(Rs,i.z),a}static isFrontFacing(e,t,n,r){return Es.subVectors(n,t),Ds.subVectors(e,t),Es.cross(Ds).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Es.subVectors(this.c,this.b),Ds.subVectors(this.a,this.b),Es.cross(Ds).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return e.getNormal(this.a,this.b,this.c,t)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,n){return e.getBarycoord(t,this.a,this.b,this.c,n)}getInterpolation(t,n,r,i,a){return e.getInterpolation(t,this.a,this.b,this.c,n,r,i,a)}containsPoint(t){return e.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return e.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,r=this.b,i=this.c,a,o;As.subVectors(r,n),js.subVectors(i,n),Ns.subVectors(e,n);let s=As.dot(Ns),c=js.dot(Ns);if(s<=0&&c<=0)return t.copy(n);Ps.subVectors(e,r);let l=As.dot(Ps),u=js.dot(Ps);if(l>=0&&u<=l)return t.copy(r);let d=s*u-l*c;if(d<=0&&s>=0&&l<=0)return a=s/(s-l),t.copy(n).addScaledVector(As,a);Fs.subVectors(e,i);let f=As.dot(Fs),p=js.dot(Fs);if(p>=0&&f<=p)return t.copy(i);let m=f*c-s*p;if(m<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(n).addScaledVector(js,o);let h=l*p-f*u;if(h<=0&&u-l>=0&&f-p>=0)return Ms.subVectors(i,r),o=(u-l)/(u-l+(f-p)),t.copy(r).addScaledVector(Ms,o);let g=1/(h+m+d);return a=m*g,o=d*g,t.copy(n).addScaledVector(As,a).addScaledVector(js,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},Bs=class{constructor(e=new z(1/0,1/0,1/0),t=new z(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Hs),Hs.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Xs),Zs.subVectors(this.max,Xs),Ws.subVectors(e.a,Xs),Gs.subVectors(e.b,Xs),Ks.subVectors(e.c,Xs),qs.subVectors(Gs,Ws),Js.subVectors(Ks,Gs),Ys.subVectors(Ws,Ks);let t=[0,-qs.z,qs.y,0,-Js.z,Js.y,0,-Ys.z,Ys.y,qs.z,0,-qs.x,Js.z,0,-Js.x,Ys.z,0,-Ys.x,-qs.y,qs.x,0,-Js.y,Js.x,0,-Ys.y,Ys.x,0];return!ec(t,Ws,Gs,Ks,Zs)||(t=[1,0,0,0,1,0,0,0,1],!ec(t,Ws,Gs,Ks,Zs))?!1:(Qs.crossVectors(qs,Js),t=[Qs.x,Qs.y,Qs.z],ec(t,Ws,Gs,Ks,Zs))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Hs).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Hs).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()||(Vs[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Vs[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Vs[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Vs[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Vs[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Vs[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Vs[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Vs[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Vs)),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}},Vs=[new z,new z,new z,new z,new z,new z,new z,new z],Hs=new z,Us=new Bs,Ws=new z,Gs=new z,Ks=new z,qs=new z,Js=new z,Ys=new z,Xs=new z,Zs=new z,Qs=new z,$s=new z;function ec(e,t,n,r,i){for(let a=0,o=e.length-3;a<=o;a+=3){$s.fromArray(e,a);let o=i.x*Math.abs($s.x)+i.y*Math.abs($s.y)+i.z*Math.abs($s.z),s=t.dot($s),c=n.dot($s),l=r.dot($s);if(Math.max(-Math.max(s,c,l),Math.min(s,c,l))>o)return!1}return!0}var tc=new z,nc=new R,rc=0,ic=class extends Wa{constructor(e,t,n=!1){if(super(),Array.isArray(e))throw TypeError(`THREE.BufferAttribute: array should be a Typed Array.`);this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:rc++}),this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n,this.usage=ka,this.updateRanges=[],this.gpuType=gi,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;rthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius*=e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;lc.subVectors(e,this.center);let t=lc.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=(e-this.radius)*.5;this.center.addScaledVector(lc,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(uc.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(lc.copy(e.center).add(uc)),this.expandByPoint(lc.copy(e.center).sub(uc))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}},fc=0,pc=new Ho,mc=new hs,hc=new z,gc=new Bs,_c=new Bs,vc=new z,yc=class e extends Wa{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:fc++}),this.uuid=Ya(),this.name=``,this.type=`BufferGeometry`,this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return this.index=Array.isArray(e)?new(Ma(e)?oc:ac)(e,1):e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let t=new xo().getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return pc.makeRotationFromQuaternion(e),this.applyMatrix4(pc),this}rotateX(e){return pc.makeRotationX(e),this.applyMatrix4(pc),this}rotateY(e){return pc.makeRotationY(e),this.applyMatrix4(pc),this}rotateZ(e){return pc.makeRotationZ(e),this.applyMatrix4(pc),this}translate(e,t,n){return pc.makeTranslation(e,t,n),this.applyMatrix4(pc),this}scale(e,t,n){return pc.makeScale(e,t,n),this.applyMatrix4(pc),this}lookAt(e){return mc.lookAt(e),mc.updateMatrix(),this.applyMatrix4(mc.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(hc).negate(),this.translate(hc.x,hc.y,hc.z),this}setFromPoints(e){let t=this.getAttribute(`position`);if(t===void 0){let t=[];for(let n=0,r=e.length;nt.count&&za(`BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.`),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Bs);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)Ba(`BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.`,this),this.boundingBox.set(new z(-1/0,-1/0,-1/0),new z(1/0,1/0,1/0));else{if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){let t=this.parameters;for(let n in t)t[n]!==void 0&&(e[n]=t[n]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let t in n){let r=n[t];e.data.attributes[t]=r.toJSON(e.data)}let r={},i=!1;for(let t in this.morphAttributes){let n=this.morphAttributes[t],a=[];for(let t=0,r=n.length;t0&&(r[t]=a,i=!0)}i&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let r=e.attributes;for(let e in r){let n=r[e];this.setAttribute(e,n.clone(t))}let i=e.morphAttributes;for(let e in i){let n=[],r=i[e];for(let e=0,i=r.length;e1)?null:t.copy(e.start).addScaledVector(r,a)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||Tc.getNormalMatrix(e),r=this.coplanarPoint(Cc).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}toJSON(){return{normal:this.normal.toArray(),constant:this.constant}}fromJSON(e){return this.normal.fromArray(e.normal),this.constant=e.constant,this}},Dc=0,Oc=class extends Wa{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Dc++}),this.uuid=Ya(),this.name=``,this.type=`Material`,this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new B(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Oa,this.stencilZFail=Oa,this.stencilZPass=Oa,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){za(`Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];r===void 0?za(`Material: '${t}' is not a property of THREE.${this.type}.`):r&&r.isColor?r.set(n):r&&r.isVector2&&n&&n.isVector2||r&&r.isEuler&&n&&n.isEuler||r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:`Material`,generator:`Material.toJSON`}};n.uuid=this.uuid,n.type=this.type,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,n.name=this.name,this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.retroreflectivity!==void 0&&(n.retroreflectivity=this.retroreflectivity),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0&&(n.clippingPlanes=this.clippingPlanes.map(e=>e.toJSON())),this.rotation!==void 0&&(n.rotation=this.rotation),this.depthPacking!==void 0&&(n.depthPacking=this.depthPacking),this.linewidth!==void 0&&(n.linewidth=this.linewidth),this.linecap!==void 0&&(n.linecap=this.linecap),this.linejoin!==void 0&&(n.linejoin=this.linejoin),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.wireframe!==void 0&&(n.wireframe=this.wireframe),this.wireframeLinewidth!==void 0&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==void 0&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==void 0&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading!==void 0&&(n.flatShading=this.flatShading),this.fog!==void 0&&(n.fog=this.fog),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=r(e.textures),i=r(e.images);t.length>0&&(n.textures=t),i.length>0&&(n.images=i)}return n}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new B().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.retroreflectivity!==void 0&&(this.retroreflectivity=e.retroreflectivity),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.clippingPlanes!==void 0&&(this.clippingPlanes=e.clippingPlanes.map(e=>new Ec().fromJSON(e))),e.clipIntersection!==void 0&&(this.clipIntersection=e.clipIntersection),e.clipShadows!==void 0&&(this.clipShadows=e.clipShadows),e.depthPacking!==void 0&&(this.depthPacking=e.depthPacking),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.linecap!==void 0&&(this.linecap=e.linecap),e.linejoin!==void 0&&(this.linejoin=e.linejoin),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(this.vertexColors=typeof e.vertexColors==`number`?e.vertexColors>0:e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let t=e.normalScale;Array.isArray(t)===!1&&(t=[t,t]),this.normalScale=new R().fromArray(t)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new R().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let e=t.length;n=Array(e);for(let r=0;r!==e;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:`dispose`})}set needsUpdate(e){e===!0&&this.version++}},kc=new z,Ac=new z,jc=new z,Mc=new z,Nc=class{constructor(e=new z,t=new z(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,kc)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=kc.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(kc.copy(this.origin).addScaledVector(this.direction,t),kc.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){Ac.copy(e).add(t).multiplyScalar(.5),jc.copy(t).sub(e).normalize(),Mc.copy(this.origin).sub(Ac);let i=e.distanceTo(t)*.5,a=-this.direction.dot(jc),o=Mc.dot(this.direction),s=-Mc.dot(jc),c=Mc.lengthSq(),l=Math.abs(1-a*a),u,d,f,p;if(l>0){if(u=a*s-o,d=a*o-s,p=i*l,u>=0){if(d>=-p){if(d<=p){let e=1/l;u*=e,d*=e,f=u*(u+a*d+2*o)+d*(a*u+d+2*s)+c}else d=i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c}else d=-i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c}else d<=-p?(u=Math.max(0,-(-a*i+o)),d=u>0?-i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c):d<=p?(u=0,d=Math.min(Math.max(-i,-s),i),f=d*(d+2*s)+c):(u=Math.max(0,-(a*i+o)),d=u>0?i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c)}else d=a>0?-i:i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),r&&r.copy(Ac).addScaledVector(jc,d),f}intersectSphere(e,t){if(e.radius<0)return null;kc.subVectors(e.center,this.origin);let n=kc.dot(this.direction),r=kc.dot(kc)-n*n,i=e.radius*e.radius;if(r>i)return null;let a=Math.sqrt(i-r),o=n-a,s=n+a;return s<0?null:o<0?this.at(s,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),l>=0?(i=(e.min.y-d.y)*l,a=(e.max.y-d.y)*l):(i=(e.max.y-d.y)*l,a=(e.min.y-d.y)*l),n>a||i>r||((i>n||isNaN(n))&&(n=i),(a=0?(o=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||o>r)||((o>n||n!==n)&&(n=o),(s=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,kc)!==null}intersectTriangle(e,t,n,r,i){let a=this.origin,o=this.direction,s=o.x,c=o.y,l=o.z,u=e.x-a.x,d=e.y-a.y,f=e.z-a.z,p=t.x-a.x,m=t.y-a.y,h=t.z-a.z,g=n.x-a.x,_=n.y-a.y,v=n.z-a.z,y=Math.abs(s),b=Math.abs(c),x=Math.abs(l),S,C,w,T,E,D,O,k,A,j,ee,M;if(y>=b&&y>=x?(w=s,D=u,A=p,M=g,s>=0?(S=c,C=l,T=d,E=f,O=m,k=h,j=_,ee=v):(S=l,C=c,T=f,E=d,O=h,k=m,j=v,ee=_)):b>=x?(w=c,D=d,A=m,M=_,c>=0?(S=l,C=s,T=f,E=u,O=h,k=p,j=v,ee=g):(S=s,C=l,T=u,E=f,O=p,k=h,j=g,ee=v)):(w=l,D=f,A=h,M=v,l>=0?(S=s,C=c,T=u,E=d,O=p,k=m,j=g,ee=_):(S=c,C=s,T=d,E=u,O=m,k=p,j=_,ee=g)),w===0)return null;let te=S/w,ne=C/w,re=1/w,ie=T-te*D,ae=E-ne*D,oe=O-te*A,se=k-ne*A,ce=j-te*M,le=ee-ne*M,ue=ce*se-le*oe,de=ie*le-ae*ce,fe=oe*ae-se*ie;if(r){if(ue<0||de<0||fe<0)return null}else if((ue<0||de<0||fe<0)&&(ue>0||de>0||fe>0))return null;let pe=ue+de+fe;if(pe===0)return null;let me=re*(ue*D+de*A+fe*M);return(pe>0?me<0:me>0)?null:this.at(me/pe,i)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Pc=class extends Oc{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type=`MeshBasicMaterial`,this.color=new B(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Qo,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},Fc=new Ho,Ic=new Nc,Lc=new dc,Rc=new z,zc=new z,Bc=new z,Vc=new z,Hc=new z,Uc=new z,Wc=new z,Gc=new z,V=class extends hs{constructor(e=new yc,t=new Pc){super(),this.isMesh=!0,this.type=`Mesh`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e(e.far-e.near)**2)||(Fc.copy(i).invert(),Ic.copy(e.ray).applyMatrix4(Fc),(n.boundingBox===null||Ic.intersectsBox(n.boundingBox)!==!1)&&this._computeIntersections(e,t,Ic)))}_computeIntersections(e,t,n){let r,i=this.geometry,a=this.material,o=i.index,s=i.attributes.position,c=i.attributes.uv,l=i.attributes.uv1,u=i.attributes.normal,d=i.groups,f=i.drawRange;if(o!==null){if(Array.isArray(a))for(let i=0,s=d.length;in.far?null:{distance:l,point:Gc.clone(),object:e}}function qc(e,t,n,r,i,a,o,s,c,l){e.getVertexPosition(s,zc),e.getVertexPosition(c,Bc),e.getVertexPosition(l,Vc);let u=Kc(e,t,n,r,zc,Bc,Vc,Wc);if(u){let e=new z;zs.getBarycoord(Wc,zc,Bc,Vc,e),i&&(u.uv=zs.getInterpolatedAttribute(i,s,c,l,e,new R)),a&&(u.uv1=zs.getInterpolatedAttribute(a,s,c,l,e,new R)),o&&(u.normal=zs.getInterpolatedAttribute(o,s,c,l,e,new z),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));let t={a:s,b:c,c:l,normal:new z,materialIndex:0};zs.getNormal(zc,Bc,Vc,t.normal),u.face=t,u.barycoord=e}return u}var Jc=new Lo,Yc=new Lo,Xc=new Lo,Zc=new Lo,Qc=new Ho,$c=new z,el=new dc,tl=new Ho,nl=new Nc,rl=class extends V{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type=`SkinnedMesh`,this.bindMode=ei,this.bindMatrix=new Ho,this.bindMatrixInverse=new Ho,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Bs),this.boundingBox.makeEmpty();let t=e.getAttribute(`position`);for(let e=0;e0?e.max.x:e.min.x,bl.y=r.normal.y>0?e.max.y:e.min.y,bl.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(bl)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}},Sl=class extends Oc{constructor(e){super(),this.isLineBasicMaterial=!0,this.type=`LineBasicMaterial`,this.color=new B(16777215),this.map=null,this.linewidth=1,this.linecap=`round`,this.linejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},Cl=new z,wl=new z,Tl=new Ho,El=new Nc,Dl=new dc,Ol=new z,kl=new z,Al=class extends hs{constructor(e=new yc,t=new Sl){super(),this.isLine=!0,this.type=`Line`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let e=1,r=t.count;e0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;er)return;Ol.applyMatrix4(e.matrixWorld);let c=t.ray.origin.distanceTo(Ol);if(!(ct.far))return{distance:c,point:kl.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}var Ml=new z,Nl=new z,Pl=class extends Al{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type=`LineSegments`}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let e=0,r=t.count;e0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;ei.far)return;a.push({distance:c,distanceToRay:Math.sqrt(s),point:n,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}var Ul=class extends Io{constructor(e=[],t=301,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,s,c,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},Wl=class extends Io{constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r,i,a,o,s,c),this.isCanvasTexture=!0,this.needsUpdate=!0}},Gl=class extends Io{constructor(e,t,n=hi,r,i,a,o=ii,s=ii,c,l=Ei,u=1){if(l!==1026&&l!==1027)throw Error(`THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat`);super({width:e,height:t,depth:u},r,i,a,o,s,l,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Mo(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}},Kl=class extends Gl{constructor(e,t=hi,n=301,r,i,a=ii,o=ii,s,c=Ei){let l={width:e,height:e,depth:1},u=[l,l,l,l,l,l];super(e,e,t,n,r,i,a,o,s,c),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},ql=class extends Io{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},Jl=class e extends yc{constructor(e=1,t=1,n=1,r=1,i=1,a=1){super(),this.type=`BoxGeometry`,this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:a};let o=this;r=Math.floor(r),i=Math.floor(i),a=Math.floor(a);let s=[],c=[],l=[],u=[],d=0,f=0;p(`z`,`y`,`x`,-1,-1,n,t,e,a,i,0),p(`z`,`y`,`x`,1,-1,n,t,-e,a,i,1),p(`x`,`z`,`y`,1,1,e,n,t,r,a,2),p(`x`,`z`,`y`,1,-1,e,n,-t,r,a,3),p(`x`,`y`,`z`,1,-1,e,t,n,r,i,4),p(`x`,`y`,`z`,-1,-1,e,t,-n,r,i,5),this.setIndex(s),this.setAttribute(`position`,new sc(c,3)),this.setAttribute(`normal`,new sc(l,3)),this.setAttribute(`uv`,new sc(u,2));function p(e,t,n,r,i,a,p,m,h,g,_){let v=a/h,y=p/g,b=a/2,x=p/2,S=m/2,C=h+1,w=g+1,T=0,E=0,D=new z;for(let a=0;a0?1:-1,l.push(D.x,D.y,D.z),u.push(s/h),u.push(1-a/g),T+=1}for(let e=0;e0){let e=(_-1)*m;for(let t=0;t0&&v(!0),t>0&&v(!1)),this.setIndex(l),this.setAttribute(`position`,new sc(u,3)),this.setAttribute(`normal`,new sc(d,3)),this.setAttribute(`uv`,new sc(f,2));function _(){let a=new z,_=new z,v=0,y=(t-e)/n;for(let c=0;c<=i;c++){let l=[],g=c/i,v=g*(t-e)+e;for(let e=0;e<=r;e++){let t=e/r,i=t*s+o,c=Math.sin(i),m=Math.cos(i);_.x=v*c,_.y=-g*n+h,_.z=v*m,u.push(_.x,_.y,_.z),a.set(c,y,m).normalize(),d.push(a.x,a.y,a.z),f.push(t,1-g),l.push(p++)}m.push(l)}for(let n=0;n0||r!==0)&&(l.push(a,o,c),v+=3),(t>0||r!==i-1)&&(l.push(o,s,c),v+=3)}c.addGroup(g,v,0),g+=v}function v(n){let i=p,a=new R,m=new z,_=0,v=n===!0?e:t,y=n===!0?1:-1;for(let e=1;e<=r;e++)u.push(0,h*y,0),d.push(0,y,0),f.push(.5,.5),p++;let b=p;for(let e=0;e<=r;e++){let t=e/r*s+o,n=Math.cos(t),i=Math.sin(t);m.x=v*i,m.y=h*y,m.z=v*n,u.push(m.x,m.y,m.z),d.push(0,y,0),a.x=n*.5+.5,a.y=i*.5*y+.5,f.push(a.x,a.y),p++}for(let e=0;e.9&&Math.min(t,n,r)<.1&&(t<.2&&(a[e+0]+=1),n<.2&&(a[e+2]+=1),r<.2&&(a[e+4]+=1))}}function d(e){i.push(e.x,e.y,e.z)}function f(t,n){let r=t*3;n.x=e[r+0],n.y=e[r+1],n.z=e[r+2]}function p(){let e=new z,t=new z,n=new z,r=new z,o=new R,s=new R,c=new R;for(let l=0,u=0;l0)s=r-1;else{s=r;break}if(r=s,n[r]===a)return r/(i-1);let l=n[r],u=n[r+1]-l,d=(a-l)/u;return(r+d)/(i-1)}getTangent(e,t){let n=1e-4,r=e-n,i=e+n;r<0&&(r=0),i>1&&(i=1);let a=this.getPoint(r),o=this.getPoint(i),s=t||(a.isVector2?new R:new z);return s.copy(o).sub(a).normalize(),s}getTangentAt(e,t){let n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){let n=new z,r=[],i=[],a=[],o=new z,s=new Ho;for(let t=0;t<=e;t++){let n=t/e;r[t]=this.getTangentAt(n,new z)}i[0]=new z,a[0]=new z;let c=Number.MAX_VALUE,l=Math.abs(r[0].x),u=Math.abs(r[0].y),d=Math.abs(r[0].z);l<=c&&(c=l,n.set(1,0,0)),u<=c&&(c=u,n.set(0,1,0)),d<=c&&n.set(0,0,1),o.crossVectors(r[0],n).normalize(),i[0].crossVectors(r[0],o),a[0].crossVectors(r[0],i[0]);for(let t=1;t<=e;t++){if(i[t]=i[t-1].clone(),a[t]=a[t-1].clone(),o.crossVectors(r[t-1],r[t]),o.length()>2**-52){o.normalize();let e=Math.acos(Xa(r[t-1].dot(r[t]),-1,1));i[t].applyMatrix4(s.makeRotationAxis(o,e))}a[t].crossVectors(r[t],i[t])}if(t===!0){let t=Math.acos(Xa(i[0].dot(i[e]),-1,1));t/=e,r[0].dot(o.crossVectors(i[0],i[e]))>0&&(t=-t);for(let n=1;n<=e;n++)i[n].applyMatrix4(s.makeRotationAxis(r[n],t*n)),a[n].crossVectors(r[n],i[n])}return{tangents:r,normals:i,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.7,type:`Curve`,generator:`Curve.toJSON`}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},tu=class extends eu{constructor(e=0,t=0,n=1,r=1,i=0,a=Math.PI*2,o=!1,s=0){super(),this.isEllipseCurve=!0,this.type=`EllipseCurve`,this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=r,this.aStartAngle=i,this.aEndAngle=a,this.aClockwise=o,this.aRotation=s}getPoint(e,t=new R){let n=t,r=Math.PI*2,i=this.aEndAngle-this.aStartAngle,a=Math.abs(i)<2**-52;for(;i<0;)i+=r;for(;i>r;)i-=r;i<2**-52&&(i=a?0:r),this.aClockwise===!0&&!a&&(i===r?i=-r:i-=r);let o=this.aStartAngle+e*i,s=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){let e=Math.cos(this.aRotation),t=Math.sin(this.aRotation),n=s-this.aX,r=c-this.aY;s=n*e-r*t+this.aX,c=n*t+r*e+this.aY}return n.set(s,c)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},nu=class extends tu{constructor(e,t,n,r,i,a){super(e,t,n,n,r,i,a),this.isArcCurve=!0,this.type=`ArcCurve`}};function ru(){let e=0,t=0,n=0,r=0;function i(i,a,o,s){e=i,t=o,n=-3*i+3*a-2*o-s,r=2*i-2*a+o+s}return{initCatmullRom:function(e,t,n,r,a){i(t,n,a*(n-e),a*(r-t))},initNonuniformCatmullRom:function(e,t,n,r,a,o,s){let c=(t-e)/a-(n-e)/(a+o)+(n-t)/o,l=(n-t)/o-(r-t)/(o+s)+(r-n)/s;c*=o,l*=o,i(t,n,c,l)},calc:function(i){let a=i*i,o=a*i;return e+t*i+n*a+r*o}}}var iu=new z,au=new z,ou=new ru,su=new ru,cu=new ru,lu=class extends eu{constructor(e=[],t=!1,n=`centripetal`,r=.5){super(),this.isCatmullRomCurve3=!0,this.type=`CatmullRomCurve3`,this.points=e,this.closed=t,this.curveType=n,this.tension=r}getPoint(e,t=new z){let n=t,r=this.points,i=r.length,a=(i-+!this.closed)*e,o=Math.floor(a),s=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/i)+1)*i:s===0&&o===i-1&&(o=i-2,s=1);let c,l;this.closed||o>0?c=r[(o-1)%i]:(au.subVectors(r[0],r[1]).add(r[0]),c=au);let u=r[o%i],d=r[(o+1)%i];if(this.closed||o+2r.length-2?r.length-1:a+1],u=r[a>r.length-3?r.length-1:a+2];return n.set(uu(o,s.x,c.x,l.x,u.x),uu(o,s.y,c.y,l.y,u.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t0)&&f.push(t,i,c),(e!==n-1||s0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let e in this.extensions)this.extensions[e]===!0&&(n[e]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let n in e.uniforms){let r=e.uniforms[n];switch(this.uniforms[n]={},r.type){case`t`:this.uniforms[n].value=t[r.value]||null;break;case`c`:this.uniforms[n].value=new J().setHex(r.value);break;case`v2`:this.uniforms[n].value=new K().fromArray(r.value);break;case`v3`:this.uniforms[n].value=new q().fromArray(r.value);break;case`v4`:this.uniforms[n].value=new Sg().fromArray(r.value);break;case`m3`:this.uniforms[n].value=new og().fromArray(r.value);break;case`m4`:this.uniforms[n].value=new Dg().fromArray(r.value);break;default:this.uniforms[n].value=r.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(let t in e.extensions)this.extensions[t]=e.extensions[t];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}},kb=class extends Ob{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type=`RawShaderMaterial`}},Ab=class extends pv{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type=`MeshStandardMaterial`,this.defines={STANDARD:``},this.color=new J(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new J(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new K(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Lg,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:``},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},jb=class extends Ab{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:``,PHYSICAL:``},this.type=`MeshPhysicalMaterial`,this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new K(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Ih(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new J(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new J(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new J(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._retroreflectivity=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get retroreflectivity(){return this._retroreflectivity}set retroreflectivity(e){this._retroreflectivity>0!=e>0&&this.version++,this._retroreflectivity=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:``,PHYSICAL:``},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.retroreflectivity=e.retroreflectivity,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}},Mb=class extends pv{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type=`MeshDepthMaterial`,this.depthPacking=lh,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}},Nb=class extends pv{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type=`MeshDistanceMaterial`,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}};function Pb(e,t){return!e||e.constructor===t?e:typeof t.BYTES_PER_ELEMENT==`number`?new t(e):Array.prototype.slice.call(e)}function Fb(e){return e!==void 0&&e.inTangents!==void 0&&e.outTangents!==void 0}function Ib(e){function t(t,n){return e[t]-e[n]}let n=e.length,r=Array(n);for(let e=0;e!==n;++e)r[e]=e;return r.sort(t),r}function Lb(e,t,n){let r=e.length,i=new e.constructor(r);for(let a=0,o=0;o!==r;++a){let r=n[a]*t;for(let n=0;n!==t;++n)i[o++]=e[r+n]}return i}function Rb(e,t,n,r){let i=1,a=e[0];for(;a!==void 0&&a[r]===void 0;)a=e[i++];if(a===void 0)return;let o=a[r];if(o!==void 0){if(Array.isArray(o))do o=a[r],o!==void 0&&(t.push(a.time),n.push(...o)),a=e[i++];while(a!==void 0);else if(o.toArray!==void 0)do o=a[r],o!==void 0&&(t.push(a.time),o.toArray(n,n.length)),a=e[i++];while(a!==void 0);else do o=a[r],o!==void 0&&(t.push(a.time),n.push(o)),a=e[i++];while(a!==void 0)}}var zb=class{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r===void 0?new t.constructor(n):r,this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,r=t[n],i=t[n-1];validate_interval:{seek:{let a;linear_scan:{forward_scan:if(!(e=i)){let o=t[1];e=i)break seek}a=n,n=0;break linear_scan}break validate_interval}for(;n>>1;et;)--a;if(++a,i!==0||a!==r){i>=a&&(a=Math.max(a,1),i=a-1);let e=this.getValueSize();this.times=n.slice(i,a),this.values=this.values.slice(i*e,a*e)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(Eh(`KeyframeTrack: Invalid value size in track.`,this),e=!1);let n=this.times,r=this.values,i=n.length;i===0&&(Eh(`KeyframeTrack: Track is empty.`,this),e=!1);let a=null;for(let t=0;t!==i;t++){let r=n[t];if(typeof r==`number`&&isNaN(r)){Eh(`KeyframeTrack: Time is not a valid number.`,this,t,r),e=!1;break}if(a!==null&&a>r){Eh(`KeyframeTrack: Out of order keys.`,this,t,r,a),e=!1;break}a=r}if(r!==void 0&&yh(r))for(let t=0,n=r.length;t!==n;++t){let n=r[t];if(isNaN(n)){Eh(`KeyframeTrack: Value is not a valid number.`,this,t,n),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===rh,i=e.length-1,a=1;for(let o=1;o0){e[a]=e[i];for(let e=i*n,r=a*n,o=0;o!==n;++o)t[r+o]=t[e+o];++a}return a===e.length?(this.times=e,this.values=t):(this.times=e.slice(0,a),this.values=t.slice(0,a*n)),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,Fb(this.settings)&&(r.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()}),r}};function Jb(e,t){for(let n=0,r=e.length;n!==r;n+=2)e[n]*=t}qb.prototype.ValueTypeName=``,qb.prototype.TimeBufferType=Float32Array,qb.prototype.ValueBufferType=Float32Array,qb.prototype.DefaultInterpolation=nh;var Yb=class extends qb{constructor(e,t,n){super(e,t,n)}};Yb.prototype.ValueTypeName=`bool`,Yb.prototype.ValueBufferType=Array,Yb.prototype.DefaultInterpolation=th,Yb.prototype.InterpolantFactoryMethodLinear=void 0,Yb.prototype.InterpolantFactoryMethodSmooth=void 0;var Xb=class extends qb{constructor(e,t,n,r){super(e,t,n,r)}};Xb.prototype.ValueTypeName=`color`;var Zb=class extends qb{constructor(e,t,n,r){super(e,t,n,r)}};Zb.prototype.ValueTypeName=`number`;var Qb=class extends zb{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=(n-t)/(r-t),c=e*o;for(let e=c+o;c!==e;c+=4)rg.slerpFlat(i,0,a,c-o,a,c,s);return i}},$b=class extends qb{constructor(e,t,n,r){super(e,t,n,r)}InterpolantFactoryMethodLinear(e){return new Qb(this.times,this.values,this.getValueSize(),e)}};$b.prototype.ValueTypeName=`quaternion`,$b.prototype.InterpolantFactoryMethodSmooth=void 0;var ex=class extends qb{constructor(e,t,n){super(e,t,n)}};ex.prototype.ValueTypeName=`string`,ex.prototype.ValueBufferType=Array,ex.prototype.DefaultInterpolation=th,ex.prototype.InterpolantFactoryMethodLinear=void 0,ex.prototype.InterpolantFactoryMethodSmooth=void 0;var tx=class extends qb{constructor(e,t,n,r){super(e,t,n,r)}};tx.prototype.ValueTypeName=`vector`;var nx=class{constructor(e=``,t=-1,n=[],r=ch){this.name=e,this.tracks=n,this.duration=t,this.blendMode=r,this.uuid=Fh(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){let t=[],n=e.tracks,r=1/(e.fps||1);for(let e=0,i=n.length;e!==i;++e)t.push(ix(n[e]).scale(r));let i=new this(e.name,e.duration,t,e.blendMode);return i.uuid=e.uuid,i.userData=JSON.parse(e.userData||`{}`),i}static toJSON(e){let t=[],n=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let e=0,r=n.length;e!==r;++e)t.push(qb.toJSON(n[e]));return r}static CreateFromMorphTargetSequence(e,t,n,r){let i=t.length,a=[];for(let e=0;e1){let e=a[1],t=r[e];t||(r[e]=t=[]),t.push(n)}}let a=[];for(let e in r)a.push(this.CreateFromMorphTargetSequence(e,r[e],t,n));return a}resetDuration(){let e=this.tracks,t=0;for(let n=0,r=e.length;n!==r;++n){let e=this.tracks[n];t=Math.max(t,e.times[e.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e{t&&t(i),this.manager.itemEnd(e)},0);return}if(lx[e]!==void 0){lx[e].push({onLoad:t,onProgress:n,onError:r});return}lx[e]=[],lx[e].push({onLoad:t,onProgress:n,onError:r});let a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?`include`:`same-origin`,signal:typeof AbortSignal.any==`function`?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,s=this.responseType;fetch(a).then(t=>{if(t.status===200||t.status===0){if(t.status===0&&Th(`FileLoader: HTTP Status 0 received.`),typeof ReadableStream>`u`||t.body===void 0||t.body.getReader===void 0)return t;let n=lx[e],r=t.body.getReader(),i=t.headers.get(`X-File-Size`)||t.headers.get(`Content-Length`),a=i?parseInt(i):0,o=a!==0,s=0,c=new ReadableStream({start(e){t();function t(){r.read().then(({done:r,value:i})=>{if(r)e.close();else{s+=i.byteLength;let r=new ProgressEvent(`progress`,{lengthComputable:o,loaded:s,total:a});for(let e=0,t=n.length;e{e.error(t)})}}});return new Response(c)}throw new ux(`fetch for "${t.url}" responded with ${t.status}: ${t.statusText}`,t)}).then(e=>{switch(s){case`arraybuffer`:return e.arrayBuffer();case`blob`:return e.blob();case`document`:return e.text().then(e=>new DOMParser().parseFromString(e,o));case`json`:return e.json();default:if(o===``)return e.text();{let t=/charset="?([^;"\s]*)"?/i.exec(o),n=t&&t[1]?t[1].toLowerCase():void 0,r=new TextDecoder(n);return e.arrayBuffer().then(e=>r.decode(e))}}}).then(t=>{ax.add(`file:${e}`,t);let n=lx[e];delete lx[e];for(let e=0,r=n.length;e{let n=lx[e];if(n===void 0)throw this.manager.itemError(e),t;delete lx[e];for(let e=0,r=n.length;e{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}},fx=new WeakMap,px=class extends cx{constructor(e){super(e)}load(e,t,n,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let i=this,a=ax.get(`image:${e}`);if(a!==void 0){if(a.complete===!0)i.manager.itemStart(e),setTimeout(function(){t&&t(a),i.manager.itemEnd(e)},0);else{let e=fx.get(a);e===void 0&&(e=[],fx.set(a,e)),e.push({onLoad:t,onError:r})}return a}let o=bh(`img`);function s(){l(),t&&t(this);let n=fx.get(this)||[];for(let e=0;e`u`&&Th(`ImageBitmapLoader: createImageBitmap() not supported.`),typeof fetch>`u`&&Th(`ImageBitmapLoader: fetch() not supported.`),this.options={premultiplyAlpha:`none`},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,r){e===void 0&&(e=``),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let i=this,a=ax.get(`image-bitmap:${e}`);if(a!==void 0){if(i.manager.itemStart(e),a.then){a.then(n=>{Lx.has(a)===!0?(r&&r(Lx.get(a)),i.manager.itemError(e),i.manager.itemEnd(e)):(t&&t(n),i.manager.itemEnd(e))});return}setTimeout(function(){t&&t(a),i.manager.itemEnd(e)},0);return}let o={};o.credentials=this.crossOrigin===`anonymous`?`same-origin`:`include`,o.headers=this.requestHeader,o.signal=typeof AbortSignal.any==`function`?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;let s=fetch(e,o).then(function(e){return e.blob()}).then(function(e){return createImageBitmap(e,Object.assign({},i.options,{colorSpaceConversion:`none`}))}).then(function(n){return ax.add(`image-bitmap:${e}`,n),t&&t(n),i.manager.itemEnd(e),n}).catch(function(t){r&&r(t),Lx.set(s,t),ax.remove(`image-bitmap:${e}`),i.manager.itemError(e),i.manager.itemEnd(e)});ax.add(`image-bitmap:${e}`,s),i.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}},zx=-90,Bx=1,Vx=class extends e_{constructor(e,t,n){super(),this.type=`CubeCamera`,this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let r=new Ox(zx,Bx,e,t);r.layers=this.layers,this.add(r);let i=new Ox(zx,Bx,e,t);i.layers=this.layers,this.add(i);let a=new Ox(zx,Bx,e,t);a.layers=this.layers,this.add(a);let o=new Ox(zx,Bx,e,t);o.layers=this.layers,this.add(o);let s=new Ox(zx,Bx,e,t);s.layers=this.layers,this.add(s);let c=new Ox(zx,Bx,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,r,i,a,o,s]=t;for(let e of t)this.remove(e);if(e===2e3)n.up.set(0,1,0),n.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),i.up.set(0,0,-1),i.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),s.up.set(0,1,0),s.lookAt(0,0,-1);else if(e===2001)n.up.set(0,-1,0),n.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),i.up.set(0,0,1),i.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),s.up.set(0,-1,0),s.lookAt(0,0,-1);else throw Error(`THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: `+e);for(let e of t)this.add(e),e.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[i,a,o,s,c,l]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;let m=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let h=!1;h=e.isWebGLRenderer===!0?e.state.buffers.depth.getReversed():e.reversedDepthBuffer,e.setRenderTarget(n,0,r),h&&e.autoClear===!1&&e.clearDepth(),e.render(t,i),e.setRenderTarget(n,1,r),h&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(n,2,r),h&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(n,3,r),h&&e.autoClear===!1&&e.clearDepth(),e.render(t,s),e.setRenderTarget(n,4,r),h&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),n.texture.generateMipmaps=m,e.setRenderTarget(n,5,r),h&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(u,d,f),e.xr.enabled=p,n.texture.needsPMREMUpdate=!0}},Hx=class extends Ox{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},Ux=class{constructor(){this._previousTime=0,this._currentTime=0,this._startTime=performance.now(),this._delta=0,this._elapsed=0,this._timescale=1,this._document=null,this._pageVisibilityHandler=null}connect(e){this._document=e,e.hidden!==void 0&&(this._pageVisibilityHandler=Wx.bind(this),e.addEventListener(`visibilitychange`,this._pageVisibilityHandler,!1))}disconnect(){this._pageVisibilityHandler!==null&&(this._document.removeEventListener(`visibilitychange`,this._pageVisibilityHandler),this._pageVisibilityHandler=null),this._document=null}getDelta(){return this._delta/1e3}getElapsed(){return this._elapsed/1e3}getTimescale(){return this._timescale}setTimescale(e){return this._timescale=e,this}reset(){return this._currentTime=performance.now()-this._startTime,this}dispose(){this.disconnect()}update(e){return this._pageVisibilityHandler!==null&&this._document.hidden===!0?this._delta=0:(this._previousTime=this._currentTime,this._currentTime=(e===void 0?performance.now():e)-this._startTime,this._delta=(this._currentTime-this._previousTime)*this._timescale,this._elapsed+=this._delta),this}};function Wx(){this._document.hidden===!1&&this.reset()}var Gx=`\\[\\]\\.:\\/`,Kx=RegExp(`[\\[\\]\\.:\\/]`,`g`),qx=`[^\\[\\]\\.:\\/]`,Jx=`[^`+Gx.replace(`\\.`,``)+`]`,Yx=`((?:WC+[\\/:])*)`.replace(`WC`,qx),Xx=`(WCOD+)?`.replace(`WCOD`,Jx),Zx=`(?:\\.(WC+)(?:\\[(.+)\\])?)?`.replace(`WC`,qx),Qx=`\\.(WC+)(?:\\[(.+)\\])?`.replace(`WC`,qx),$x=RegExp(`^`+Yx+Xx+Zx+Qx+`$`),eS=[`material`,`materials`,`bones`,`map`],tS=class{constructor(e,t,n){let r=n||nS.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,i=n.length;r!==i;++r)n[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},nS=class e{constructor(t,n,r){this.path=n,this.parsedPath=r||e.parseTrackName(n),this.node=e.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,n,r){return t&&t.isAnimationObjectGroup?new e.Composite(t,n,r):new e(t,n,r)}static sanitizeNodeName(e){return e.replace(/\s/g,`_`).replace(Kx,``)}static parseTrackName(e){let t=$x.exec(e);if(t===null)throw Error(`THREE.PropertyBinding: Cannot parse trackName: `+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=n.nodeName&&n.nodeName.lastIndexOf(`.`);if(r!==void 0&&r!==-1){let e=n.nodeName.substring(r+1);eS.indexOf(e)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=e)}if(n.propertyName===null||n.propertyName.length===0)throw Error(`THREE.PropertyBinding: can not parse propertyName from trackName: `+e);return n}static findNode(e,t){if(t===void 0||t===``||t===`.`||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(e){for(let r=0;r=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,rS).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},aS=new q,oS=new Dg,sS=new Dg,cS=class extends yy{constructor(e){let t=lS(e),n=new iv,r=[],i=[];for(let e=0;ee.start-t.start);let t=0;for(let e=1;e0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let e in this.extensions)this.extensions[e]===!0&&(n[e]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let n in e.uniforms){let r=e.uniforms[n];switch(this.uniforms[n]={},r.type){case`t`:this.uniforms[n].value=t[r.value]||null;break;case`c`:this.uniforms[n].value=new B().setHex(r.value);break;case`v2`:this.uniforms[n].value=new R().fromArray(r.value);break;case`v3`:this.uniforms[n].value=new z().fromArray(r.value);break;case`v4`:this.uniforms[n].value=new Lo().fromArray(r.value);break;case`m3`:this.uniforms[n].value=new xo().fromArray(r.value);break;case`m4`:this.uniforms[n].value=new Ho().fromArray(r.value);break;default:this.uniforms[n].value=r.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(let t in e.extensions)this.extensions[t]=e.extensions[t];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}},Gu=class extends Wu{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type=`RawShaderMaterial`}},Ku=class extends Oc{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type=`MeshStandardMaterial`,this.defines={STANDARD:``},this.color=new B(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new B(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new R(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Qo,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:``},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},qu=class extends Ku{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:``,PHYSICAL:``},this.type=`MeshPhysicalMaterial`,this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new R(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Xa(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new B(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new B(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new B(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._retroreflectivity=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get retroreflectivity(){return this._retroreflectivity}set retroreflectivity(e){this._retroreflectivity>0!=e>0&&this.version++,this._retroreflectivity=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:``,PHYSICAL:``},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.retroreflectivity=e.retroreflectivity,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}},Ju=class extends Oc{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type=`MeshDepthMaterial`,this.depthPacking=Ca,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}},Yu=class extends Oc{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type=`MeshDistanceMaterial`,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}};function Xu(e,t){return!e||e.constructor===t?e:typeof t.BYTES_PER_ELEMENT==`number`?new t(e):Array.prototype.slice.call(e)}function Zu(e){return e!==void 0&&e.inTangents!==void 0&&e.outTangents!==void 0}function Qu(e){function t(t,n){return e[t]-e[n]}let n=e.length,r=Array(n);for(let e=0;e!==n;++e)r[e]=e;return r.sort(t),r}function $u(e,t,n){let r=e.length,i=new e.constructor(r);for(let a=0,o=0;o!==r;++a){let r=n[a]*t;for(let n=0;n!==t;++n)i[o++]=e[r+n]}return i}function ed(e,t,n,r){let i=1,a=e[0];for(;a!==void 0&&a[r]===void 0;)a=e[i++];if(a===void 0)return;let o=a[r];if(o!==void 0){if(Array.isArray(o))do o=a[r],o!==void 0&&(t.push(a.time),n.push(...o)),a=e[i++];while(a!==void 0);else if(o.toArray!==void 0)do o=a[r],o!==void 0&&(t.push(a.time),o.toArray(n,n.length)),a=e[i++];while(a!==void 0);else do o=a[r],o!==void 0&&(t.push(a.time),n.push(o)),a=e[i++];while(a!==void 0)}}var td=class{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r===void 0?new t.constructor(n):r,this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,r=t[n],i=t[n-1];validate_interval:{seek:{let a;linear_scan:{forward_scan:if(!(e=i)){let o=t[1];e=i)break seek}a=n,n=0;break linear_scan}break validate_interval}for(;n>>1;et;)--a;if(++a,i!==0||a!==r){i>=a&&(a=Math.max(a,1),i=a-1);let e=this.getValueSize();this.times=n.slice(i,a),this.values=this.values.slice(i*e,a*e)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(Ba(`KeyframeTrack: Invalid value size in track.`,this),e=!1);let n=this.times,r=this.values,i=n.length;i===0&&(Ba(`KeyframeTrack: Track is empty.`,this),e=!1);let a=null;for(let t=0;t!==i;t++){let r=n[t];if(typeof r==`number`&&isNaN(r)){Ba(`KeyframeTrack: Time is not a valid number.`,this,t,r),e=!1;break}if(a!==null&&a>r){Ba(`KeyframeTrack: Out of order keys.`,this,t,r,a),e=!1;break}a=r}if(r!==void 0&&Na(r))for(let t=0,n=r.length;t!==n;++t){let n=r[t];if(isNaN(n)){Ba(`KeyframeTrack: Value is not a valid number.`,this,t,n),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===_a,i=e.length-1,a=1;for(let o=1;o0){e[a]=e[i];for(let e=i*n,r=a*n,o=0;o!==n;++o)t[r+o]=t[e+o];++a}return a===e.length?(this.times=e,this.values=t):(this.times=e.slice(0,a),this.values=t.slice(0,a*n)),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,Zu(this.settings)&&(r.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()}),r}};function ud(e,t){for(let n=0,r=e.length;n!==r;n+=2)e[n]*=t}ld.prototype.ValueTypeName=``,ld.prototype.TimeBufferType=Float32Array,ld.prototype.ValueBufferType=Float32Array,ld.prototype.DefaultInterpolation=ga;var dd=class extends ld{constructor(e,t,n){super(e,t,n)}};dd.prototype.ValueTypeName=`bool`,dd.prototype.ValueBufferType=Array,dd.prototype.DefaultInterpolation=ha,dd.prototype.InterpolantFactoryMethodLinear=void 0,dd.prototype.InterpolantFactoryMethodSmooth=void 0;var fd=class extends ld{constructor(e,t,n,r){super(e,t,n,r)}};fd.prototype.ValueTypeName=`color`;var pd=class extends ld{constructor(e,t,n,r){super(e,t,n,r)}};pd.prototype.ValueTypeName=`number`;var md=class extends td{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=(n-t)/(r-t),c=e*o;for(let e=c+o;c!==e;c+=4)vo.slerpFlat(i,0,a,c-o,a,c,s);return i}},hd=class extends ld{constructor(e,t,n,r){super(e,t,n,r)}InterpolantFactoryMethodLinear(e){return new md(this.times,this.values,this.getValueSize(),e)}};hd.prototype.ValueTypeName=`quaternion`,hd.prototype.InterpolantFactoryMethodSmooth=void 0;var gd=class extends ld{constructor(e,t,n){super(e,t,n)}};gd.prototype.ValueTypeName=`string`,gd.prototype.ValueBufferType=Array,gd.prototype.DefaultInterpolation=ha,gd.prototype.InterpolantFactoryMethodLinear=void 0,gd.prototype.InterpolantFactoryMethodSmooth=void 0;var _d=class extends ld{constructor(e,t,n,r){super(e,t,n,r)}};_d.prototype.ValueTypeName=`vector`;var vd=class{constructor(e=``,t=-1,n=[],r=Sa){this.name=e,this.tracks=n,this.duration=t,this.blendMode=r,this.uuid=Ya(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){let t=[],n=e.tracks,r=1/(e.fps||1);for(let e=0,i=n.length;e!==i;++e)t.push(bd(n[e]).scale(r));let i=new this(e.name,e.duration,t,e.blendMode);return i.uuid=e.uuid,i.userData=JSON.parse(e.userData||`{}`),i}static toJSON(e){let t=[],n=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let e=0,r=n.length;e!==r;++e)t.push(ld.toJSON(n[e]));return r}static CreateFromMorphTargetSequence(e,t,n,r){let i=t.length,a=[];for(let e=0;e1){let e=a[1],t=r[e];t||(r[e]=t=[]),t.push(n)}}let a=[];for(let e in r)a.push(this.CreateFromMorphTargetSequence(e,r[e],t,n));return a}resetDuration(){let e=this.tracks,t=0;for(let n=0,r=e.length;n!==r;++n){let e=this.tracks[n];t=Math.max(t,e.times[e.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e{t&&t(i),this.manager.itemEnd(e)},0);return}if(Td[e]!==void 0){Td[e].push({onLoad:t,onProgress:n,onError:r});return}Td[e]=[],Td[e].push({onLoad:t,onProgress:n,onError:r});let a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?`include`:`same-origin`,signal:typeof AbortSignal.any==`function`?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,s=this.responseType;fetch(a).then(t=>{if(t.status===200||t.status===0){if(t.status===0&&za(`FileLoader: HTTP Status 0 received.`),typeof ReadableStream>`u`||t.body===void 0||t.body.getReader===void 0)return t;let n=Td[e],r=t.body.getReader(),i=t.headers.get(`X-File-Size`)||t.headers.get(`Content-Length`),a=i?parseInt(i):0,o=a!==0,s=0,c=new ReadableStream({start(e){t();function t(){r.read().then(({done:r,value:i})=>{if(r)e.close();else{s+=i.byteLength;let r=new ProgressEvent(`progress`,{lengthComputable:o,loaded:s,total:a});for(let e=0,t=n.length;e{e.error(t)})}}});return new Response(c)}throw new Ed(`fetch for "${t.url}" responded with ${t.status}: ${t.statusText}`,t)}).then(e=>{switch(s){case`arraybuffer`:return e.arrayBuffer();case`blob`:return e.blob();case`document`:return e.text().then(e=>new DOMParser().parseFromString(e,o));case`json`:return e.json();default:if(o===``)return e.text();{let t=/charset="?([^;"\s]*)"?/i.exec(o),n=t&&t[1]?t[1].toLowerCase():void 0,r=new TextDecoder(n);return e.arrayBuffer().then(e=>r.decode(e))}}}).then(t=>{xd.add(`file:${e}`,t);let n=Td[e];delete Td[e];for(let e=0,r=n.length;e{let n=Td[e];if(n===void 0)throw this.manager.itemError(e),t;delete Td[e];for(let e=0,r=n.length;e{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}},Od=new WeakMap,kd=class extends wd{constructor(e){super(e)}load(e,t,n,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let i=this,a=xd.get(`image:${e}`);if(a!==void 0){if(a.complete===!0)i.manager.itemStart(e),setTimeout(function(){t&&t(a),i.manager.itemEnd(e)},0);else{let e=Od.get(a);e===void 0&&(e=[],Od.set(a,e)),e.push({onLoad:t,onError:r})}return a}let o=Pa(`img`);function s(){l(),t&&t(this);let n=Od.get(this)||[];for(let e=0;e`u`&&za(`ImageBitmapLoader: createImageBitmap() not supported.`),typeof fetch>`u`&&za(`ImageBitmapLoader: fetch() not supported.`),this.options={premultiplyAlpha:`none`},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,r){e===void 0&&(e=``),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let i=this,a=xd.get(`image-bitmap:${e}`);if(a!==void 0){if(i.manager.itemStart(e),a.then){a.then(n=>{$d.has(a)===!0?(r&&r($d.get(a)),i.manager.itemError(e),i.manager.itemEnd(e)):(t&&t(n),i.manager.itemEnd(e))});return}setTimeout(function(){t&&t(a),i.manager.itemEnd(e)},0);return}let o={};o.credentials=this.crossOrigin===`anonymous`?`same-origin`:`include`,o.headers=this.requestHeader,o.signal=typeof AbortSignal.any==`function`?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;let s=fetch(e,o).then(function(e){return e.blob()}).then(function(e){return createImageBitmap(e,Object.assign({},i.options,{colorSpaceConversion:`none`}))}).then(function(n){return xd.add(`image-bitmap:${e}`,n),t&&t(n),i.manager.itemEnd(e),n}).catch(function(t){r&&r(t),$d.set(s,t),xd.remove(`image-bitmap:${e}`),i.manager.itemError(e),i.manager.itemEnd(e)});xd.add(`image-bitmap:${e}`,s),i.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}},tf=-90,nf=1,rf=class extends hs{constructor(e,t,n){super(),this.type=`CubeCamera`,this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let r=new Wd(tf,nf,e,t);r.layers=this.layers,this.add(r);let i=new Wd(tf,nf,e,t);i.layers=this.layers,this.add(i);let a=new Wd(tf,nf,e,t);a.layers=this.layers,this.add(a);let o=new Wd(tf,nf,e,t);o.layers=this.layers,this.add(o);let s=new Wd(tf,nf,e,t);s.layers=this.layers,this.add(s);let c=new Wd(tf,nf,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,r,i,a,o,s]=t;for(let e of t)this.remove(e);if(e===2e3)n.up.set(0,1,0),n.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),i.up.set(0,0,-1),i.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),s.up.set(0,1,0),s.lookAt(0,0,-1);else if(e===2001)n.up.set(0,-1,0),n.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),i.up.set(0,0,1),i.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),s.up.set(0,-1,0),s.lookAt(0,0,-1);else throw Error(`THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: `+e);for(let e of t)this.add(e),e.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[i,a,o,s,c,l]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;let m=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let h=!1;h=e.isWebGLRenderer===!0?e.state.buffers.depth.getReversed():e.reversedDepthBuffer,e.setRenderTarget(n,0,r),h&&e.autoClear===!1&&e.clearDepth(),e.render(t,i),e.setRenderTarget(n,1,r),h&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(n,2,r),h&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(n,3,r),h&&e.autoClear===!1&&e.clearDepth(),e.render(t,s),e.setRenderTarget(n,4,r),h&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),n.texture.generateMipmaps=m,e.setRenderTarget(n,5,r),h&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(u,d,f),e.xr.enabled=p,n.texture.needsPMREMUpdate=!0}},af=class extends Wd{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},of=class{constructor(){this._previousTime=0,this._currentTime=0,this._startTime=performance.now(),this._delta=0,this._elapsed=0,this._timescale=1,this._document=null,this._pageVisibilityHandler=null}connect(e){this._document=e,e.hidden!==void 0&&(this._pageVisibilityHandler=sf.bind(this),e.addEventListener(`visibilitychange`,this._pageVisibilityHandler,!1))}disconnect(){this._pageVisibilityHandler!==null&&(this._document.removeEventListener(`visibilitychange`,this._pageVisibilityHandler),this._pageVisibilityHandler=null),this._document=null}getDelta(){return this._delta/1e3}getElapsed(){return this._elapsed/1e3}getTimescale(){return this._timescale}setTimescale(e){return this._timescale=e,this}reset(){return this._currentTime=performance.now()-this._startTime,this}dispose(){this.disconnect()}update(e){return this._pageVisibilityHandler!==null&&this._document.hidden===!0?this._delta=0:(this._previousTime=this._currentTime,this._currentTime=(e===void 0?performance.now():e)-this._startTime,this._delta=(this._currentTime-this._previousTime)*this._timescale,this._elapsed+=this._delta),this}};function sf(){this._document.hidden===!1&&this.reset()}var cf=`\\[\\]\\.:\\/`,lf=RegExp(`[\\[\\]\\.:\\/]`,`g`),uf=`[^\\[\\]\\.:\\/]`,df=`[^`+cf.replace(`\\.`,``)+`]`,ff=`((?:WC+[\\/:])*)`.replace(`WC`,uf),pf=`(WCOD+)?`.replace(`WCOD`,df),mf=`(?:\\.(WC+)(?:\\[(.+)\\])?)?`.replace(`WC`,uf),hf=`\\.(WC+)(?:\\[(.+)\\])?`.replace(`WC`,uf),gf=RegExp(`^`+ff+pf+mf+hf+`$`),_f=[`material`,`materials`,`bones`,`map`],vf=class{constructor(e,t,n){let r=n||yf.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,i=n.length;r!==i;++r)n[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},yf=class e{constructor(t,n,r){this.path=n,this.parsedPath=r||e.parseTrackName(n),this.node=e.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,n,r){return t&&t.isAnimationObjectGroup?new e.Composite(t,n,r):new e(t,n,r)}static sanitizeNodeName(e){return e.replace(/\s/g,`_`).replace(lf,``)}static parseTrackName(e){let t=gf.exec(e);if(t===null)throw Error(`THREE.PropertyBinding: Cannot parse trackName: `+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=n.nodeName&&n.nodeName.lastIndexOf(`.`);if(r!==void 0&&r!==-1){let e=n.nodeName.substring(r+1);_f.indexOf(e)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=e)}if(n.propertyName===null||n.propertyName.length===0)throw Error(`THREE.PropertyBinding: can not parse propertyName from trackName: `+e);return n}static findNode(e,t){if(t===void 0||t===``||t===`.`||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(e){for(let r=0;r=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,bf).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},Sf=new z,Cf=new Ho,wf=new Ho,Tf=class extends Pl{constructor(e){let t=Ef(e),n=new yc,r=[],i=[];for(let e=0;ee.start-t.start);let t=0;for(let e=1;e #include #include -}`},X={common:{diffuse:{value:new J(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new og},alphaMap:{value:null},alphaMapTransform:{value:new og},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new og}},envmap:{envMap:{value:null},envMapRotation:{value:new og},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new og}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new og}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new og},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new og},normalScale:{value:new K(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new og},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new og}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new og}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new og}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new J(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new q},probesMax:{value:new q},probesResolution:{value:new q}},points:{diffuse:{value:new J(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new og},alphaTest:{value:0},uvTransform:{value:new og}},sprite:{diffuse:{value:new J(16777215)},opacity:{value:1},center:{value:new K(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new og},alphaMap:{value:null},alphaMapTransform:{value:new og},alphaTest:{value:0}}},gS={basic:{uniforms:xb([X.common,X.specularmap,X.envmap,X.aomap,X.lightmap,X.fog]),vertexShader:hS.meshbasic_vert,fragmentShader:hS.meshbasic_frag},lambert:{uniforms:xb([X.common,X.specularmap,X.envmap,X.aomap,X.lightmap,X.emissivemap,X.bumpmap,X.normalmap,X.displacementmap,X.fog,X.lights,{emissive:{value:new J(0)},envMapIntensity:{value:1}}]),vertexShader:hS.meshlambert_vert,fragmentShader:hS.meshlambert_frag},phong:{uniforms:xb([X.common,X.specularmap,X.envmap,X.aomap,X.lightmap,X.emissivemap,X.bumpmap,X.normalmap,X.displacementmap,X.fog,X.lights,{emissive:{value:new J(0)},specular:{value:new J(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:hS.meshphong_vert,fragmentShader:hS.meshphong_frag},standard:{uniforms:xb([X.common,X.envmap,X.aomap,X.lightmap,X.emissivemap,X.bumpmap,X.normalmap,X.displacementmap,X.roughnessmap,X.metalnessmap,X.fog,X.lights,{emissive:{value:new J(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:hS.meshphysical_vert,fragmentShader:hS.meshphysical_frag},toon:{uniforms:xb([X.common,X.aomap,X.lightmap,X.emissivemap,X.bumpmap,X.normalmap,X.displacementmap,X.gradientmap,X.fog,X.lights,{emissive:{value:new J(0)}}]),vertexShader:hS.meshtoon_vert,fragmentShader:hS.meshtoon_frag},matcap:{uniforms:xb([X.common,X.bumpmap,X.normalmap,X.displacementmap,X.fog,{matcap:{value:null}}]),vertexShader:hS.meshmatcap_vert,fragmentShader:hS.meshmatcap_frag},points:{uniforms:xb([X.points,X.fog]),vertexShader:hS.points_vert,fragmentShader:hS.points_frag},dashed:{uniforms:xb([X.common,X.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:hS.linedashed_vert,fragmentShader:hS.linedashed_frag},depth:{uniforms:xb([X.common,X.displacementmap]),vertexShader:hS.depth_vert,fragmentShader:hS.depth_frag},normal:{uniforms:xb([X.common,X.bumpmap,X.normalmap,X.displacementmap,{opacity:{value:1}}]),vertexShader:hS.meshnormal_vert,fragmentShader:hS.meshnormal_frag},sprite:{uniforms:xb([X.sprite,X.fog]),vertexShader:hS.sprite_vert,fragmentShader:hS.sprite_frag},background:{uniforms:{uvTransform:{value:new og},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:hS.background_vert,fragmentShader:hS.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new og}},vertexShader:hS.backgroundCube_vert,fragmentShader:hS.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:hS.cube_vert,fragmentShader:hS.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:hS.equirect_vert,fragmentShader:hS.equirect_frag},distance:{uniforms:xb([X.common,X.displacementmap,{referencePosition:{value:new q},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:hS.distance_vert,fragmentShader:hS.distance_frag},shadow:{uniforms:xb([X.lights,X.fog,{color:{value:new J(0)},opacity:{value:1}}]),vertexShader:hS.shadow_vert,fragmentShader:hS.shadow_frag}};gS.physical={uniforms:xb([gS.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new og},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new og},clearcoatNormalScale:{value:new K(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new og},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new og},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new og},sheen:{value:0},sheenColor:{value:new J(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new og},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new og},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new og},transmissionSamplerSize:{value:new K},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new og},attenuationDistance:{value:0},attenuationColor:{value:new J(0)},specularColor:{value:new J(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new og},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new og},anisotropyVector:{value:new K},anisotropyMap:{value:null},anisotropyMapTransform:{value:new og}}]),vertexShader:hS.meshphysical_vert,fragmentShader:hS.meshphysical_frag};var _S={r:0,b:0,g:0},vS=new Dg,yS=new og;yS.set(-1,0,0,0,1,0,0,0,1);function bS(e,t,n,r,i,a){let o=new J(0),s=i===!0?0:1,c,l,u=null,d=0,f=null;function p(e){let n=e.isScene===!0?e.background:null;if(n&&n.isTexture){let r=e.backgroundBlurriness>0;n=t.get(n,r)}return n}function m(t){let r=!1,i=p(t);i===null?g(o,s):i&&i.isColor&&(g(i,1),r=!0);let c=e.xr.getEnvironmentBlendMode();c===`additive`?n.buffers.color.setClear(0,0,0,1,a):c===`alpha-blend`&&n.buffers.color.setClear(0,0,0,0,a),(e.autoClear||r)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil))}function h(t,n){let i=p(n);i&&(i.isCubeTexture||i.mapping===306)?(l===void 0&&(l=new Y(new Ny(1,1,1),new Ob({name:`BackgroundCubeMaterial`,uniforms:bb(gS.backgroundCube.uniforms),vertexShader:gS.backgroundCube.vertexShader,fragmentShader:gS.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute(`normal`),l.geometry.deleteAttribute(`uv`),l.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(l)),l.material.uniforms.envMap.value=i,l.material.uniforms.backgroundBlurriness.value=n.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(vS.makeRotationFromEuler(n.backgroundRotation)).transpose(),i.isCubeTexture&&i.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(yS),l.material.toneMapped=dg.getTransfer(i.colorSpace)!==ph,(u!==i||d!==i.version||f!==e.toneMapping)&&(l.material.needsUpdate=!0,u=i,d=i.version,f=e.toneMapping),l.layers.enableAll(),t.unshift(l,l.geometry,l.material,0,0,null)):i&&i.isTexture&&(c===void 0&&(c=new Y(new hb(2,2),new Ob({name:`BackgroundMaterial`,uniforms:bb(gS.background.uniforms),vertexShader:gS.background.vertexShader,fragmentShader:gS.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute(`normal`),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(c)),c.material.uniforms.t2D.value=i,c.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,c.material.toneMapped=dg.getTransfer(i.colorSpace)!==ph,i.matrixAutoUpdate===!0&&i.updateMatrix(),c.material.uniforms.uvTransform.value.copy(i.matrix),(u!==i||d!==i.version||f!==e.toneMapping)&&(c.material.needsUpdate=!0,u=i,d=i.version,f=e.toneMapping),c.layers.enableAll(),t.unshift(c,c.geometry,c.material,0,0,null))}function g(t,r){t.getRGB(_S,wb(e)),n.buffers.color.setClear(_S.r,_S.g,_S.b,r,a)}function _(){l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return o},setClearColor:function(e,t=1){o.set(e),s=t,g(o,s)},getClearAlpha:function(){return s},setClearAlpha:function(e){s=e,g(o,s)},render:m,addToRenderList:h,dispose:_}}function xS(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),r={},i=f(null),a=i,o=!1;function s(n,r,i,s,c){let u=!1,f=d(n,s,i,r);a!==f&&(a=f,l(a.object)),u=p(n,s,i,c),u&&m(n,s,i,c),c!==null&&t.update(c,e.ELEMENT_ARRAY_BUFFER),(u||o)&&(o=!1,b(n,r,i,s),c!==null&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(c).buffer))}function c(){return e.createVertexArray()}function l(t){return e.bindVertexArray(t)}function u(t){return e.deleteVertexArray(t)}function d(e,t,n,i){let a=i.wireframe===!0,o=r[t.id];o===void 0&&(o={},r[t.id]=o);let s=e.isInstancedMesh===!0?e.id:0,l=o[s];l===void 0&&(l={},o[s]=l);let u=l[n.id];u===void 0&&(u={},l[n.id]=u);let d=u[a];return d===void 0&&(d=f(c()),u[a]=d),d}function f(e){let t=[],r=[],i=[];for(let e=0;e=0){let n=i[t],r=o[t];if(r===void 0&&(t===`instanceMatrix`&&e.instanceMatrix&&(r=e.instanceMatrix),t===`instanceColor`&&e.instanceColor&&(r=e.instanceColor)),n===void 0||n.attribute!==r||r&&n.data!==r.data)return!0;s++}return a.attributesNum!==s||a.index!==r}function m(e,t,n,r){let i={},o=t.attributes,s=0,c=n.getAttributes();for(let t in c)if(c[t].location>=0){let n=o[t];n===void 0&&(t===`instanceMatrix`&&e.instanceMatrix&&(n=e.instanceMatrix),t===`instanceColor`&&e.instanceColor&&(n=e.instanceColor));let r={};r.attribute=n,n&&n.data&&(r.data=n.data),i[t]=r,s++}a.attributes=i,a.attributesNum=s,a.index=r}function h(){let e=a.newAttributes;for(let t=0,n=e.length;t=0){let s=o[r];if(s===void 0&&(r===`instanceMatrix`&&n.instanceMatrix&&(s=n.instanceMatrix),r===`instanceColor`&&n.instanceColor&&(s=n.instanceColor)),s!==void 0){let r=s.normalized,o=s.itemSize,c=t.get(s);if(c===void 0)continue;let l=c.buffer,u=c.type,d=c.bytesPerElement,f=u===e.INT||u===e.UNSIGNED_INT||s.gpuType===1013;if(s.isInterleavedBufferAttribute){let t=s.data,c=t.stride,p=s.offset;if(t.isInstancedInterleavedBuffer){for(let e=0;e0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return`highp`;t=`mediump`}return t===`mediump`&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?`mediump`:`lowp`}let l=n.precision===void 0?`highp`:n.precision,u=c(l);u!==l&&(Th(`WebGLRenderer:`,l,`not supported, using`,u,`instead.`),l=u);let d=n.logarithmicDepthBuffer===!0,f=n.reversedDepthBuffer===!0&&t.has(`EXT_clip_control`);n.reversedDepthBuffer===!0&&f===!1&&Th(`WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.`);let p=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),m=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),h=e.getParameter(e.MAX_TEXTURE_SIZE),g=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),_=e.getParameter(e.MAX_VERTEX_ATTRIBS),v=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),y=e.getParameter(e.MAX_VARYING_VECTORS),b=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),x=e.getParameter(e.MAX_SAMPLES),S=e.getParameter(e.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:s,precision:l,logarithmicDepthBuffer:d,reversedDepthBuffer:f,maxTextures:p,maxVertexTextures:m,maxTextureSize:h,maxCubemapSize:g,maxAttributes:_,maxVertexUniforms:v,maxVaryings:y,maxFragmentUniforms:b,maxSamples:x,samples:S}}function wS(e){let t=this,n=null,r=0,i=!1,a=!1,o=new dv,s=new og,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t){let n=e.length!==0||t||r!==0||i;return i=t,r=e.length,n},this.beginShadows=function(){a=!0,u(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(e,t){n=u(e,t,0)},this.setState=function(t,o,s){let d=t.clippingPlanes,f=t.clipIntersection,p=t.clipShadows,m=e.get(t);if(!i||d===null||d.length===0||a&&!p)a?u(null):l();else{let e=a?0:r,t=e*4,i=m.clippingState||null;c.value=i,i=u(d,o,t,s);for(let e=0;e!==t;++e)i[e]=n[e];m.clippingState=i,this.numIntersection=f?this.numPlanes:0,this.numPlanes+=e}};function l(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),t.numPlanes=r,t.numIntersection=0}function u(e,n,r,i){let a=e===null?0:e.length,l=null;if(a!==0){if(l=c.value,i!==!0||l===null){let t=r+a*4,i=n.matrixWorldInverse;s.getNormalMatrix(i),(l===null||l.length0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=WS(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=US(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=2**this._lodMax}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?l:0,l,l),c.setRenderTarget(r),p&&c.render(d,a),c.render(e,a)}c.toneMapping=u,c.autoClear=l,e.background=m}_textureToCubeUV(e,t){let n=this._renderer,r=e.mapping===301||e.mapping===302;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=WS()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=US());let i=r?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=i;let o=i.uniforms;o.envMap.value=e;let s=this._cubeSize;BS(t,0,0,3*s,2*s),n.setRenderTarget(t),n.render(a,kS)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let r=this._lodMeshes.length;for(let t=1;td-TS?n-d+TS:0),m=4*(this._cubeSize-f);s.envMap.value=e.texture,s.roughness.value=u,s.mipInt.value=d-t,BS(i,p,m,3*f,2*f),r.setRenderTarget(i),r.render(o,kS),s.envMap.value=i.texture,s.roughness.value=0,s.mipInt.value=d-n,BS(e,p,m,3*f,2*f),r.setRenderTarget(e),r.render(o,kS)}_blur(e,t,n,r){let i=this._pingPongRenderTarget,a=Math.min(r,Math.PI)/Math.SQRT2;this._blurPass(e,i,t,n,a),this._blurPass(i,e,n,n,a)}_blurPass(e,t,n,r,i){let a=this._renderer,o=this._blurMaterial,s=this._lodMeshes[r];s.material=o;let c=o.uniforms;c.envMap.value=e.texture,c.sigma.value=i,c.mipInt.value=this._lodMax-n;let l=this._sizeLods[r];BS(t,3*l*(r>this._lodMax-TS?r-this._lodMax+TS:0),4*(this._cubeSize-l),3*l,2*l),a.setRenderTarget(t),a.render(s,kS)}};function RS(e){let t=[],n=[],r=e,i=e-TS+1+ES;for(let e=0;e2?0:-1,r=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];c.set(r,18*e);for(let t=0;t<6;t++){let n=s[t*2]*2-1,r=s[t*2+1]*2-1;e===0?IS.set(1,r,n):e===1?IS.set(-n,1,-r):e===2?IS.set(-n,r,1):e===3?IS.set(-1,r,-n):e===4?IS.set(-n,-1,r):IS.set(n,r,-1),IS.toArray(l,(e*6+t)*3)}}let u=new iv;u.setAttribute(`position`,new U_(c,3)),u.setAttribute(`outputDirection`,new U_(l,3)),n.push(new Y(u,null)),r>TS&&r--}return{lodMeshes:n,sizeLods:t}}function zS(e,t,n){let r=new wg(e,t,n);return r.texture.mapping=306,r.texture.name=`PMREM.cubeUv`,r.scissorTest=!0,r}function BS(e,t,n,r,i){e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i)}function VS(e,t,n){return new Ob({name:`PMREMGGXConvolution`,defines:{GGX_SAMPLES:OS,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:GS(),fragmentShader:` +}`},H={common:{diffuse:{value:new B(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new xo},alphaMap:{value:null},alphaMapTransform:{value:new xo},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new xo}},envmap:{envMap:{value:null},envMapRotation:{value:new xo},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new xo}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new xo}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new xo},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new xo},normalScale:{value:new R(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new xo},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new xo}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new xo}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new xo}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new B(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new z},probesMax:{value:new z},probesResolution:{value:new z}},points:{diffuse:{value:new B(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new xo},alphaTest:{value:0},uvTransform:{value:new xo}},sprite:{diffuse:{value:new B(16777215)},opacity:{value:1},center:{value:new R(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new xo},alphaMap:{value:null},alphaMapTransform:{value:new xo},alphaTest:{value:0}}},Nf={basic:{uniforms:Lu([H.common,H.specularmap,H.envmap,H.aomap,H.lightmap,H.fog]),vertexShader:Mf.meshbasic_vert,fragmentShader:Mf.meshbasic_frag},lambert:{uniforms:Lu([H.common,H.specularmap,H.envmap,H.aomap,H.lightmap,H.emissivemap,H.bumpmap,H.normalmap,H.displacementmap,H.fog,H.lights,{emissive:{value:new B(0)},envMapIntensity:{value:1}}]),vertexShader:Mf.meshlambert_vert,fragmentShader:Mf.meshlambert_frag},phong:{uniforms:Lu([H.common,H.specularmap,H.envmap,H.aomap,H.lightmap,H.emissivemap,H.bumpmap,H.normalmap,H.displacementmap,H.fog,H.lights,{emissive:{value:new B(0)},specular:{value:new B(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Mf.meshphong_vert,fragmentShader:Mf.meshphong_frag},standard:{uniforms:Lu([H.common,H.envmap,H.aomap,H.lightmap,H.emissivemap,H.bumpmap,H.normalmap,H.displacementmap,H.roughnessmap,H.metalnessmap,H.fog,H.lights,{emissive:{value:new B(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Mf.meshphysical_vert,fragmentShader:Mf.meshphysical_frag},toon:{uniforms:Lu([H.common,H.aomap,H.lightmap,H.emissivemap,H.bumpmap,H.normalmap,H.displacementmap,H.gradientmap,H.fog,H.lights,{emissive:{value:new B(0)}}]),vertexShader:Mf.meshtoon_vert,fragmentShader:Mf.meshtoon_frag},matcap:{uniforms:Lu([H.common,H.bumpmap,H.normalmap,H.displacementmap,H.fog,{matcap:{value:null}}]),vertexShader:Mf.meshmatcap_vert,fragmentShader:Mf.meshmatcap_frag},points:{uniforms:Lu([H.points,H.fog]),vertexShader:Mf.points_vert,fragmentShader:Mf.points_frag},dashed:{uniforms:Lu([H.common,H.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Mf.linedashed_vert,fragmentShader:Mf.linedashed_frag},depth:{uniforms:Lu([H.common,H.displacementmap]),vertexShader:Mf.depth_vert,fragmentShader:Mf.depth_frag},normal:{uniforms:Lu([H.common,H.bumpmap,H.normalmap,H.displacementmap,{opacity:{value:1}}]),vertexShader:Mf.meshnormal_vert,fragmentShader:Mf.meshnormal_frag},sprite:{uniforms:Lu([H.sprite,H.fog]),vertexShader:Mf.sprite_vert,fragmentShader:Mf.sprite_frag},background:{uniforms:{uvTransform:{value:new xo},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Mf.background_vert,fragmentShader:Mf.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new xo}},vertexShader:Mf.backgroundCube_vert,fragmentShader:Mf.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Mf.cube_vert,fragmentShader:Mf.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Mf.equirect_vert,fragmentShader:Mf.equirect_frag},distance:{uniforms:Lu([H.common,H.displacementmap,{referencePosition:{value:new z},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Mf.distance_vert,fragmentShader:Mf.distance_frag},shadow:{uniforms:Lu([H.lights,H.fog,{color:{value:new B(0)},opacity:{value:1}}]),vertexShader:Mf.shadow_vert,fragmentShader:Mf.shadow_frag}};Nf.physical={uniforms:Lu([Nf.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new xo},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new xo},clearcoatNormalScale:{value:new R(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new xo},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new xo},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new xo},sheen:{value:0},sheenColor:{value:new B(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new xo},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new xo},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new xo},transmissionSamplerSize:{value:new R},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new xo},attenuationDistance:{value:0},attenuationColor:{value:new B(0)},specularColor:{value:new B(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new xo},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new xo},anisotropyVector:{value:new R},anisotropyMap:{value:null},anisotropyMapTransform:{value:new xo}}]),vertexShader:Mf.meshphysical_vert,fragmentShader:Mf.meshphysical_frag};var Pf={r:0,b:0,g:0},Ff=new Ho,If=new xo;If.set(-1,0,0,0,1,0,0,0,1);function Lf(e,t,n,r,i,a){let o=new B(0),s=i===!0?0:1,c,l,u=null,d=0,f=null;function p(e){let n=e.isScene===!0?e.background:null;if(n&&n.isTexture){let r=e.backgroundBlurriness>0;n=t.get(n,r)}return n}function m(t){let r=!1,i=p(t);i===null?g(o,s):i&&i.isColor&&(g(i,1),r=!0);let c=e.xr.getEnvironmentBlendMode();c===`additive`?n.buffers.color.setClear(0,0,0,1,a):c===`alpha-blend`&&n.buffers.color.setClear(0,0,0,0,a),(e.autoClear||r)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil))}function h(t,n){let i=p(n);i&&(i.isCubeTexture||i.mapping===306)?(l===void 0&&(l=new V(new Jl(1,1,1),new Wu({name:`BackgroundCubeMaterial`,uniforms:Iu(Nf.backgroundCube.uniforms),vertexShader:Nf.backgroundCube.vertexShader,fragmentShader:Nf.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute(`normal`),l.geometry.deleteAttribute(`uv`),l.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(l)),l.material.uniforms.envMap.value=i,l.material.uniforms.backgroundBlurriness.value=n.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(Ff.makeRotationFromEuler(n.backgroundRotation)).transpose(),i.isCubeTexture&&i.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(If),l.material.toneMapped=Eo.getTransfer(i.colorSpace)!==Da,(u!==i||d!==i.version||f!==e.toneMapping)&&(l.material.needsUpdate=!0,u=i,d=i.version,f=e.toneMapping),l.layers.enableAll(),t.unshift(l,l.geometry,l.material,0,0,null)):i&&i.isTexture&&(c===void 0&&(c=new V(new Au(2,2),new Wu({name:`BackgroundMaterial`,uniforms:Iu(Nf.background.uniforms),vertexShader:Nf.background.vertexShader,fragmentShader:Nf.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute(`normal`),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(c)),c.material.uniforms.t2D.value=i,c.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,c.material.toneMapped=Eo.getTransfer(i.colorSpace)!==Da,i.matrixAutoUpdate===!0&&i.updateMatrix(),c.material.uniforms.uvTransform.value.copy(i.matrix),(u!==i||d!==i.version||f!==e.toneMapping)&&(c.material.needsUpdate=!0,u=i,d=i.version,f=e.toneMapping),c.layers.enableAll(),t.unshift(c,c.geometry,c.material,0,0,null))}function g(t,r){t.getRGB(Pf,Bu(e)),n.buffers.color.setClear(Pf.r,Pf.g,Pf.b,r,a)}function _(){l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return o},setClearColor:function(e,t=1){o.set(e),s=t,g(o,s)},getClearAlpha:function(){return s},setClearAlpha:function(e){s=e,g(o,s)},render:m,addToRenderList:h,dispose:_}}function Rf(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),r={},i=f(null),a=i,o=!1;function s(n,r,i,s,c){let u=!1,f=d(n,s,i,r);a!==f&&(a=f,l(a.object)),u=p(n,s,i,c),u&&m(n,s,i,c),c!==null&&t.update(c,e.ELEMENT_ARRAY_BUFFER),(u||o)&&(o=!1,b(n,r,i,s),c!==null&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(c).buffer))}function c(){return e.createVertexArray()}function l(t){return e.bindVertexArray(t)}function u(t){return e.deleteVertexArray(t)}function d(e,t,n,i){let a=i.wireframe===!0,o=r[t.id];o===void 0&&(o={},r[t.id]=o);let s=e.isInstancedMesh===!0?e.id:0,l=o[s];l===void 0&&(l={},o[s]=l);let u=l[n.id];u===void 0&&(u={},l[n.id]=u);let d=u[a];return d===void 0&&(d=f(c()),u[a]=d),d}function f(e){let t=[],r=[],i=[];for(let e=0;e=0){let n=i[t],r=o[t];if(r===void 0&&(t===`instanceMatrix`&&e.instanceMatrix&&(r=e.instanceMatrix),t===`instanceColor`&&e.instanceColor&&(r=e.instanceColor)),n===void 0||n.attribute!==r||r&&n.data!==r.data)return!0;s++}return a.attributesNum!==s||a.index!==r}function m(e,t,n,r){let i={},o=t.attributes,s=0,c=n.getAttributes();for(let t in c)if(c[t].location>=0){let n=o[t];n===void 0&&(t===`instanceMatrix`&&e.instanceMatrix&&(n=e.instanceMatrix),t===`instanceColor`&&e.instanceColor&&(n=e.instanceColor));let r={};r.attribute=n,n&&n.data&&(r.data=n.data),i[t]=r,s++}a.attributes=i,a.attributesNum=s,a.index=r}function h(){let e=a.newAttributes;for(let t=0,n=e.length;t=0){let s=o[r];if(s===void 0&&(r===`instanceMatrix`&&n.instanceMatrix&&(s=n.instanceMatrix),r===`instanceColor`&&n.instanceColor&&(s=n.instanceColor)),s!==void 0){let r=s.normalized,o=s.itemSize,c=t.get(s);if(c===void 0)continue;let l=c.buffer,u=c.type,d=c.bytesPerElement,f=u===e.INT||u===e.UNSIGNED_INT||s.gpuType===1013;if(s.isInterleavedBufferAttribute){let t=s.data,c=t.stride,p=s.offset;if(t.isInstancedInterleavedBuffer){for(let e=0;e0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return`highp`;t=`mediump`}return t===`mediump`&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?`mediump`:`lowp`}let l=n.precision===void 0?`highp`:n.precision,u=c(l);u!==l&&(za(`WebGLRenderer:`,l,`not supported, using`,u,`instead.`),l=u);let d=n.logarithmicDepthBuffer===!0,f=n.reversedDepthBuffer===!0&&t.has(`EXT_clip_control`);n.reversedDepthBuffer===!0&&f===!1&&za(`WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.`);let p=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),m=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),h=e.getParameter(e.MAX_TEXTURE_SIZE),g=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),_=e.getParameter(e.MAX_VERTEX_ATTRIBS),v=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),y=e.getParameter(e.MAX_VARYING_VECTORS),b=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),x=e.getParameter(e.MAX_SAMPLES),S=e.getParameter(e.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:s,precision:l,logarithmicDepthBuffer:d,reversedDepthBuffer:f,maxTextures:p,maxVertexTextures:m,maxTextureSize:h,maxCubemapSize:g,maxAttributes:_,maxVertexUniforms:v,maxVaryings:y,maxFragmentUniforms:b,maxSamples:x,samples:S}}function Vf(e){let t=this,n=null,r=0,i=!1,a=!1,o=new Ec,s=new xo,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t){let n=e.length!==0||t||r!==0||i;return i=t,r=e.length,n},this.beginShadows=function(){a=!0,u(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(e,t){n=u(e,t,0)},this.setState=function(t,o,s){let d=t.clippingPlanes,f=t.clipIntersection,p=t.clipShadows,m=e.get(t);if(!i||d===null||d.length===0||a&&!p)a?u(null):l();else{let e=a?0:r,t=e*4,i=m.clippingState||null;c.value=i,i=u(d,o,t,s);for(let e=0;e!==t;++e)i[e]=n[e];m.clippingState=i,this.numIntersection=f?this.numPlanes:0,this.numPlanes+=e}};function l(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),t.numPlanes=r,t.numIntersection=0}function u(e,n,r,i){let a=e===null?0:e.length,l=null;if(a!==0){if(l=c.value,i!==!0||l===null){let t=r+a*4,i=n.matrixWorldInverse;s.getNormalMatrix(i),(l===null||l.length0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=sp(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=op(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=2**this._lodMax}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?l:0,l,l),c.setRenderTarget(r),p&&c.render(d,a),c.render(e,a)}c.toneMapping=u,c.autoClear=l,e.background=m}_textureToCubeUV(e,t){let n=this._renderer,r=e.mapping===301||e.mapping===302;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=sp()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=op());let i=r?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=i;let o=i.uniforms;o.envMap.value=e;let s=this._cubeSize;rp(t,0,0,3*s,2*s),n.setRenderTarget(t),n.render(a,Kf)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let r=this._lodMeshes.length;for(let t=1;td-Hf?n-d+Hf:0),m=4*(this._cubeSize-f);s.envMap.value=e.texture,s.roughness.value=u,s.mipInt.value=d-t,rp(i,p,m,3*f,2*f),r.setRenderTarget(i),r.render(o,Kf),s.envMap.value=i.texture,s.roughness.value=0,s.mipInt.value=d-n,rp(e,p,m,3*f,2*f),r.setRenderTarget(e),r.render(o,Kf)}_blur(e,t,n,r){let i=this._pingPongRenderTarget,a=Math.min(r,Math.PI)/Math.SQRT2;this._blurPass(e,i,t,n,a),this._blurPass(i,e,n,n,a)}_blurPass(e,t,n,r,i){let a=this._renderer,o=this._blurMaterial,s=this._lodMeshes[r];s.material=o;let c=o.uniforms;c.envMap.value=e.texture,c.sigma.value=i,c.mipInt.value=this._lodMax-n;let l=this._sizeLods[r];rp(t,3*l*(r>this._lodMax-Hf?r-this._lodMax+Hf:0),4*(this._cubeSize-l),3*l,2*l),a.setRenderTarget(t),a.render(s,Kf)}};function tp(e){let t=[],n=[],r=e,i=e-Hf+1+Uf;for(let e=0;e2?0:-1,r=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];c.set(r,18*e);for(let t=0;t<6;t++){let n=s[t*2]*2-1,r=s[t*2+1]*2-1;e===0?$f.set(1,r,n):e===1?$f.set(-n,1,-r):e===2?$f.set(-n,r,1):e===3?$f.set(-1,r,-n):e===4?$f.set(-n,-1,r):$f.set(n,r,-1),$f.toArray(l,(e*6+t)*3)}}let u=new yc;u.setAttribute(`position`,new ic(c,3)),u.setAttribute(`outputDirection`,new ic(l,3)),n.push(new V(u,null)),r>Hf&&r--}return{lodMeshes:n,sizeLods:t}}function np(e,t,n){let r=new zo(e,t,n);return r.texture.mapping=306,r.texture.name=`PMREM.cubeUv`,r.scissorTest=!0,r}function rp(e,t,n,r,i){e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i)}function ip(e,t,n){return new Wu({name:`PMREMGGXConvolution`,defines:{GGX_SAMPLES:Gf,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:cp(),fragmentShader:` precision highp float; precision highp int; @@ -3934,7 +3924,7 @@ void main() { gl_FragColor = vec4(prefilteredColor, 1.0); } - `,blending:0,depthTest:!1,depthWrite:!1})}function HS(e,t,n){return new Ob({name:`SphericalGaussianBlur`,defines:{SAMPLES:DS,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},sigma:{value:0},mipInt:{value:0}},vertexShader:GS(),fragmentShader:` + `,blending:0,depthTest:!1,depthWrite:!1})}function ap(e,t,n){return new Wu({name:`SphericalGaussianBlur`,defines:{SAMPLES:Wf,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},sigma:{value:0},mipInt:{value:0}},vertexShader:cp(),fragmentShader:` precision highp float; precision highp int; @@ -3994,7 +3984,7 @@ void main() { gl_FragColor = vec4( accumColor / accumWeight, 1.0 ); } - `,blending:0,depthTest:!1,depthWrite:!1})}function US(){return new Ob({name:`EquirectangularToCubeUV`,uniforms:{envMap:{value:null}},vertexShader:GS(),fragmentShader:` + `,blending:0,depthTest:!1,depthWrite:!1})}function op(){return new Wu({name:`EquirectangularToCubeUV`,uniforms:{envMap:{value:null}},vertexShader:cp(),fragmentShader:` precision mediump float; precision mediump int; @@ -4013,7 +4003,7 @@ void main() { gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); } - `,blending:0,depthTest:!1,depthWrite:!1})}function WS(){return new Ob({name:`CubemapToCubeUV`,uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:GS(),fragmentShader:` + `,blending:0,depthTest:!1,depthWrite:!1})}function sp(){return new Wu({name:`CubemapToCubeUV`,uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:cp(),fragmentShader:` precision mediump float; precision mediump int; @@ -4029,7 +4019,7 @@ void main() { gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); } - `,blending:0,depthTest:!1,depthWrite:!1})}function GS(){return` + `,blending:0,depthTest:!1,depthWrite:!1})}function cp(){return` precision mediump float; precision mediump int; @@ -4044,7 +4034,7 @@ void main() { gl_Position = vec4( position, 1.0 ); } - `}var KS=class extends wg{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];this.texture=new Oy(r),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:` + `}var lp=class extends zo{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];this.texture=new Ul(r),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:` varying vec3 vWorldDirection; @@ -4079,7 +4069,7 @@ void main() { gl_FragColor = texture2D( tEquirect, sampleUV ); } - `},r=new Ny(5,5,5),i=new Ob({name:`CubemapFromEquirect`,uniforms:bb(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:1,blending:0});i.uniforms.tEquirect.value=t;let a=new Y(r,i),o=t.minFilter;return t.minFilter===1008&&(t.minFilter=qp),new Vx(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,r=!0){let i=e.getRenderTarget();for(let i=0;i<6;i++)e.setRenderTarget(this,i),e.clear(t,n,r);e.setRenderTarget(i)}};function qS(e){let t=new WeakMap,n=new WeakMap,r=null;function i(e,t=!1){return e==null?null:t?o(e):a(e)}function a(n){if(n&&n.isTexture){let r=n.mapping;if(r===303||r===304){if(t.has(n)){let e=t.get(n).texture;return s(e,n.mapping)}{let r=n.image;if(r&&r.height>0){let i=new KS(r.height);return i.fromEquirectangularTexture(e,n),t.set(n,i),n.addEventListener(`dispose`,l),s(i.texture,n.mapping)}return null}}}return n}function o(t){if(t&&t.isTexture){let i=t.mapping,a=i===303||i===304,o=i===301||i===302;if(a||o){let i=n.get(t),s=i===void 0?0:i.texture.pmremVersion;if(t.isRenderTargetTexture&&t.pmremVersion!==s)return r===null&&(r=new LS(e)),i=a?r.fromEquirectangular(t,i):r.fromCubemap(t,i),i.texture.pmremVersion=t.pmremVersion,n.set(t,i),i.texture;if(i!==void 0)return i.texture;{let s=t.image;return a&&s&&s.height>0||o&&s&&c(s)?(r===null&&(r=new LS(e)),i=a?r.fromEquirectangular(t):r.fromCubemap(t),i.texture.pmremVersion=t.pmremVersion,n.set(t,i),t.addEventListener(`dispose`,u),i.texture):null}}}return t}function s(e,t){return t===303?e.mapping=301:t===304&&(e.mapping=302),e}function c(e){let t=0;for(let n=0;n<6;n++)e[n]!==void 0&&t++;return t===6}function l(e){let n=e.target;n.removeEventListener(`dispose`,l);let r=t.get(n);r!==void 0&&(t.delete(n),r.dispose())}function u(e){let t=e.target;t.removeEventListener(`dispose`,u);let r=n.get(t);r!==void 0&&(n.delete(t),r.dispose())}function d(){t=new WeakMap,n=new WeakMap,r!==null&&(r.dispose(),r=null)}return{get:i,dispose:d}}function JS(e){let t={};function n(n){if(t[n]!==void 0)return t[n];let r=e.getExtension(n);return t[n]=r,r}return{has:function(e){return n(e)!==null},init:function(){n(`EXT_color_buffer_float`),n(`WEBGL_clip_cull_distance`),n(`OES_texture_float_linear`),n(`EXT_color_buffer_half_float`),n(`WEBGL_multisampled_render_to_texture`),n(`WEBGL_render_shared_exponent`)},get:function(e){let t=n(e);return t===null&&Dh(`WebGLRenderer: `+e+` extension not supported.`),t}}}function YS(e,t,n,r){let i={},a=new WeakMap;function o(e){let s=e.target;s.index!==null&&t.remove(s.index);for(let e in s.attributes)t.remove(s.attributes[e]);s.removeEventListener(`dispose`,o),delete i[s.id];let c=a.get(s);c&&(t.remove(c),a.delete(s)),r.releaseStatesOfGeometry(s),s.isInstancedBufferGeometry===!0&&delete s._maxInstanceCount,n.memory.geometries--}function s(e,t){return i[t.id]===!0||(t.addEventListener(`dispose`,o),i[t.id]=!0,n.memory.geometries++),t}function c(n){let r=n.attributes;for(let n in r)t.update(r[n],e.ARRAY_BUFFER)}function l(e){let n=[],r=e.index,i=e.attributes.position,o=0;if(i===void 0)return;if(r!==null){let e=r.array;o=r.version;for(let t=0,r=e.length;t=65535?G_:W_)(n,1);s.version=o;let c=a.get(e);c&&t.remove(c),a.set(e,s)}function u(e){let t=a.get(e);if(t){let n=e.index;n!==null&&t.versiont.maxTextureSize&&(m=Math.ceil(p/t.maxTextureSize),p=t.maxTextureSize);let h=new Float32Array(p*m*4*u),g=new Tg(h,p,m,u);g.type=nm,g.needsUpdate=!0;let _=f*4;for(let t=0;t0){let i=new lp(r.height);return i.fromEquirectangularTexture(e,n),t.set(n,i),n.addEventListener(`dispose`,l),s(i.texture,n.mapping)}return null}}}return n}function o(t){if(t&&t.isTexture){let i=t.mapping,a=i===303||i===304,o=i===301||i===302;if(a||o){let i=n.get(t),s=i===void 0?0:i.texture.pmremVersion;if(t.isRenderTargetTexture&&t.pmremVersion!==s)return r===null&&(r=new ep(e)),i=a?r.fromEquirectangular(t,i):r.fromCubemap(t,i),i.texture.pmremVersion=t.pmremVersion,n.set(t,i),i.texture;if(i!==void 0)return i.texture;{let s=t.image;return a&&s&&s.height>0||o&&s&&c(s)?(r===null&&(r=new ep(e)),i=a?r.fromEquirectangular(t):r.fromCubemap(t),i.texture.pmremVersion=t.pmremVersion,n.set(t,i),t.addEventListener(`dispose`,u),i.texture):null}}}return t}function s(e,t){return t===303?e.mapping=301:t===304&&(e.mapping=302),e}function c(e){let t=0;for(let n=0;n<6;n++)e[n]!==void 0&&t++;return t===6}function l(e){let n=e.target;n.removeEventListener(`dispose`,l);let r=t.get(n);r!==void 0&&(t.delete(n),r.dispose())}function u(e){let t=e.target;t.removeEventListener(`dispose`,u);let r=n.get(t);r!==void 0&&(n.delete(t),r.dispose())}function d(){t=new WeakMap,n=new WeakMap,r!==null&&(r.dispose(),r=null)}return{get:i,dispose:d}}function dp(e){let t={};function n(n){if(t[n]!==void 0)return t[n];let r=e.getExtension(n);return t[n]=r,r}return{has:function(e){return n(e)!==null},init:function(){n(`EXT_color_buffer_float`),n(`WEBGL_clip_cull_distance`),n(`OES_texture_float_linear`),n(`EXT_color_buffer_half_float`),n(`WEBGL_multisampled_render_to_texture`),n(`WEBGL_render_shared_exponent`)},get:function(e){let t=n(e);return t===null&&Va(`WebGLRenderer: `+e+` extension not supported.`),t}}}function fp(e,t,n,r){let i={},a=new WeakMap;function o(e){let s=e.target;s.index!==null&&t.remove(s.index);for(let e in s.attributes)t.remove(s.attributes[e]);s.removeEventListener(`dispose`,o),delete i[s.id];let c=a.get(s);c&&(t.remove(c),a.delete(s)),r.releaseStatesOfGeometry(s),s.isInstancedBufferGeometry===!0&&delete s._maxInstanceCount,n.memory.geometries--}function s(e,t){return i[t.id]===!0||(t.addEventListener(`dispose`,o),i[t.id]=!0,n.memory.geometries++),t}function c(n){let r=n.attributes;for(let n in r)t.update(r[n],e.ARRAY_BUFFER)}function l(e){let n=[],r=e.index,i=e.attributes.position,o=0;if(i===void 0)return;if(r!==null){let e=r.array;o=r.version;for(let t=0,r=e.length;t=65535?oc:ac)(n,1);s.version=o;let c=a.get(e);c&&t.remove(c),a.set(e,s)}function u(e){let t=a.get(e);if(t){let n=e.index;n!==null&&t.versiont.maxTextureSize&&(m=Math.ceil(p/t.maxTextureSize),p=t.maxTextureSize);let h=new Float32Array(p*m*4*u),g=new Bo(h,p,m,u);g.type=gi,g.needsUpdate=!0;let _=f*4;for(let t=0;t0&&v[0].isRenderPass===!0;let t=o.width,n=o.height;v.length>0&&s===null&&(s=new wg(t,n,{type:rm,depthBuffer:!1,stencilBuffer:!1}),c=new wg(t,n,{type:rm,depthBuffer:!1,stencilBuffer:!1}));for(let e=0;e0)return e;let i=t*n,a=sC[i];if(a===void 0&&(a=new Float32Array(i),sC[i]=a),t!==0){r.toArray(a,0);for(let r=1,i=0;r!==t;++r)i+=n,e[r].toArray(a,i)}return a}function pC(e,t){if(e.length!==t.length)return!1;for(let n=0,r=e.length;n0&&(this.seq=r.concat(i))}setValue(e,t,n,r){let i=this.map[t];i!==void 0&&i.setValue(e,n,r)}setOptional(e,t,n){let r=t[n];r!==void 0&&this.setValue(e,n,r)}static upload(e,t,n,r){for(let i=0,a=t.length;i!==a;++i){let a=t[i],o=n[a.id];o.needsUpdate!==!1&&a.setValue(e,o.value,r)}}static seqWithValue(e,t){let n=[];for(let r=0,i=e.length;r!==i;++r){let i=e[r];i.id in t&&n.push(i)}return n}};function lw(e,t,n){let r=e.createShader(t);return e.shaderSource(r,n),e.compileShader(r),r}var uw=37297,dw=0;function fw(e,t){let n=e.split(` + }`,depthTest:!1,depthWrite:!1}),d=new V(l,u),f=new Yd(-1,1,1,-1,0,1),p=null,m=null,h=!1,g,_=null,v=[],y=!1;this.setSize=function(e,t){o.setSize(e,t),s!==null&&s.setSize(e,t),c!==null&&c.setSize(e,t);for(let n=0;n0&&v[0].isRenderPass===!0;let t=o.width,n=o.height;v.length>0&&s===null&&(s=new zo(t,n,{type:_i,depthBuffer:!1,stencilBuffer:!1}),c=new zo(t,n,{type:_i,depthBuffer:!1,stencilBuffer:!1}));for(let e=0;e0)return e;let i=t*n,a=wp[i];if(a===void 0&&(a=new Float32Array(i),wp[i]=a),t!==0){r.toArray(a,0);for(let r=1,i=0;r!==t;++r)i+=n,e[r].toArray(a,i)}return a}function Ap(e,t){if(e.length!==t.length)return!1;for(let n=0,r=e.length;n0&&(this.seq=r.concat(i))}setValue(e,t,n,r){let i=this.map[t];i!==void 0&&i.setValue(e,n,r)}setOptional(e,t,n){let r=t[n];r!==void 0&&this.setValue(e,n,r)}static upload(e,t,n,r){for(let i=0,a=t.length;i!==a;++i){let a=t[i],o=n[a.id];o.needsUpdate!==!1&&a.setValue(e,o.value,r)}}static seqWithValue(e,t){let n=[];for(let r=0,i=e.length;r!==i;++r){let i=e[r];i.id in t&&n.push(i)}return n}};function Em(e,t,n){let r=e.createShader(t);return e.shaderSource(r,n),e.compileShader(r),r}var Dm=37297,Om=0;function km(e,t){let n=e.split(` `),r=[],i=Math.max(t-6,0),a=Math.min(t+6,n.length);for(let e=i;e`:` `} ${i}: ${n[e]}`)}return r.join(` -`)}var pw=new og;function mw(e){dg._getMatrix(pw,dg.workingColorSpace,e);let t=`mat3( ${pw.elements.map(e=>e.toFixed(4))} )`;switch(dg.getTransfer(e)){case fh:return[t,`LinearTransferOETF`];case ph:return[t,`sRGBTransferOETF`];default:return Th(`WebGLProgram: Unsupported color space: `,e),[t,`LinearTransferOETF`]}}function hw(e,t,n){let r=e.getShaderParameter(t,e.COMPILE_STATUS),i=(e.getShaderInfoLog(t)||``).trim();if(r&&i===``)return``;let a=/ERROR: 0:(\d+)/.exec(i);if(a){let r=parseInt(a[1]);return n.toUpperCase()+` +`)}var Am=new xo;function jm(e){Eo._getMatrix(Am,Eo.workingColorSpace,e);let t=`mat3( ${Am.elements.map(e=>e.toFixed(4))} )`;switch(Eo.getTransfer(e)){case Ea:return[t,`LinearTransferOETF`];case Da:return[t,`sRGBTransferOETF`];default:return za(`WebGLProgram: Unsupported color space: `,e),[t,`LinearTransferOETF`]}}function Mm(e,t,n){let r=e.getShaderParameter(t,e.COMPILE_STATUS),i=(e.getShaderInfoLog(t)||``).trim();if(r&&i===``)return``;let a=/ERROR: 0:(\d+)/.exec(i);if(a){let r=parseInt(a[1]);return n.toUpperCase()+` `+i+` -`+fw(e.getShaderSource(t),r)}return i}function gw(e,t){let n=mw(t);return[`vec4 ${e}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,`}`].join(` -`)}var _w={1:`Linear`,2:`Reinhard`,3:`Cineon`,4:`ACESFilmic`,6:`AgX`,7:`Neutral`,5:`Custom`};function vw(e,t){let n=_w[t];return n===void 0?(Th(`WebGLProgram: Unsupported toneMapping:`,t),`vec3 `+e+`( vec3 color ) { return LinearToneMapping( color ); }`):`vec3 `+e+`( vec3 color ) { return `+n+`ToneMapping( color ); }`}var yw=new q;function bw(){return dg.getLuminanceCoefficients(yw),[`float luminance( const in vec3 rgb ) {`,` const vec3 weights = vec3( ${yw.x.toFixed(4)}, ${yw.y.toFixed(4)}, ${yw.z.toFixed(4)} );`,` return dot( weights, rgb );`,`}`].join(` -`)}function xw(e){return[e.extensionClipCullDistance?`#extension GL_ANGLE_clip_cull_distance : require`:``,e.extensionMultiDraw?`#extension GL_ANGLE_multi_draw : require`:``].filter(ww).join(` -`)}function Sw(e){let t=[];for(let n in e){let r=e[n];r!==!1&&t.push(`#define `+n+` `+r)}return t.join(` -`)}function Cw(e,t){let n={},r=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let i=0;i/gm;function Ow(e){return e.replace(Dw,Aw)}var kw=new Map;function Aw(e,t){let n=hS[t];if(n===void 0){let e=kw.get(t);if(e!==void 0)n=hS[e],Th(`WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.`,t,e);else throw Error(`THREE.WebGLProgram: Can not resolve #include <`+t+`>`)}return Ow(n)}var jw=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function Mw(e){return e.replace(jw,Nw)}function Nw(e,t,n,r){let i=``;for(let e=parseInt(t);e/gm;function Gm(e){return e.replace(Wm,qm)}var Km=new Map;function qm(e,t){let n=Mf[t];if(n===void 0){let e=Km.get(t);if(e!==void 0)n=Mf[e],za(`WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.`,t,e);else throw Error(`THREE.WebGLProgram: Can not resolve #include <`+t+`>`)}return Gm(n)}var Jm=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function Ym(e){return e.replace(Jm,Xm)}function Xm(e,t,n,r){let i=``;for(let e=parseInt(t);e0&&(g+=` -`),_=[`#define SHADER_TYPE `+n.shaderType,`#define SHADER_NAME `+n.shaderName,m].filter(ww).join(` +`),_=[`#define SHADER_TYPE `+n.shaderType,`#define SHADER_NAME `+n.shaderName,m].filter(Vm).join(` `),_.length>0&&(_+=` -`)):(g=[Pw(n),`#define SHADER_TYPE `+n.shaderType,`#define SHADER_NAME `+n.shaderName,m,n.extensionClipCullDistance?`#define USE_CLIP_DISTANCE`:``,n.batching?`#define USE_BATCHING`:``,n.batchingColor?`#define USE_BATCHING_COLOR`:``,n.instancing?`#define USE_INSTANCING`:``,n.instancingColor?`#define USE_INSTANCING_COLOR`:``,n.instancingMorph?`#define USE_INSTANCING_MORPH`:``,n.useFog&&n.fog?`#define USE_FOG`:``,n.useFog&&n.fogExp2?`#define FOG_EXP2`:``,n.map?`#define USE_MAP`:``,n.envMap?`#define USE_ENVMAP`:``,n.envMap?`#define `+u:``,n.lightMap?`#define USE_LIGHTMAP`:``,n.aoMap?`#define USE_AOMAP`:``,n.bumpMap?`#define USE_BUMPMAP`:``,n.normalMap?`#define USE_NORMALMAP`:``,n.normalMapObjectSpace?`#define USE_NORMALMAP_OBJECTSPACE`:``,n.normalMapTangentSpace?`#define USE_NORMALMAP_TANGENTSPACE`:``,n.displacementMap?`#define USE_DISPLACEMENTMAP`:``,n.emissiveMap?`#define USE_EMISSIVEMAP`:``,n.anisotropy?`#define USE_ANISOTROPY`:``,n.anisotropyMap?`#define USE_ANISOTROPYMAP`:``,n.clearcoatMap?`#define USE_CLEARCOATMAP`:``,n.clearcoatRoughnessMap?`#define USE_CLEARCOAT_ROUGHNESSMAP`:``,n.clearcoatNormalMap?`#define USE_CLEARCOAT_NORMALMAP`:``,n.iridescenceMap?`#define USE_IRIDESCENCEMAP`:``,n.iridescenceThicknessMap?`#define USE_IRIDESCENCE_THICKNESSMAP`:``,n.specularMap?`#define USE_SPECULARMAP`:``,n.specularColorMap?`#define USE_SPECULAR_COLORMAP`:``,n.specularIntensityMap?`#define USE_SPECULAR_INTENSITYMAP`:``,n.roughnessMap?`#define USE_ROUGHNESSMAP`:``,n.metalnessMap?`#define USE_METALNESSMAP`:``,n.alphaMap?`#define USE_ALPHAMAP`:``,n.alphaHash?`#define USE_ALPHAHASH`:``,n.transmission?`#define USE_TRANSMISSION`:``,n.transmissionMap?`#define USE_TRANSMISSIONMAP`:``,n.thicknessMap?`#define USE_THICKNESSMAP`:``,n.sheenColorMap?`#define USE_SHEEN_COLORMAP`:``,n.sheenRoughnessMap?`#define USE_SHEEN_ROUGHNESSMAP`:``,n.mapUv?`#define MAP_UV `+n.mapUv:``,n.alphaMapUv?`#define ALPHAMAP_UV `+n.alphaMapUv:``,n.lightMapUv?`#define LIGHTMAP_UV `+n.lightMapUv:``,n.aoMapUv?`#define AOMAP_UV `+n.aoMapUv:``,n.emissiveMapUv?`#define EMISSIVEMAP_UV `+n.emissiveMapUv:``,n.bumpMapUv?`#define BUMPMAP_UV `+n.bumpMapUv:``,n.normalMapUv?`#define NORMALMAP_UV `+n.normalMapUv:``,n.displacementMapUv?`#define DISPLACEMENTMAP_UV `+n.displacementMapUv:``,n.metalnessMapUv?`#define METALNESSMAP_UV `+n.metalnessMapUv:``,n.roughnessMapUv?`#define ROUGHNESSMAP_UV `+n.roughnessMapUv:``,n.anisotropyMapUv?`#define ANISOTROPYMAP_UV `+n.anisotropyMapUv:``,n.clearcoatMapUv?`#define CLEARCOATMAP_UV `+n.clearcoatMapUv:``,n.clearcoatNormalMapUv?`#define CLEARCOAT_NORMALMAP_UV `+n.clearcoatNormalMapUv:``,n.clearcoatRoughnessMapUv?`#define CLEARCOAT_ROUGHNESSMAP_UV `+n.clearcoatRoughnessMapUv:``,n.iridescenceMapUv?`#define IRIDESCENCEMAP_UV `+n.iridescenceMapUv:``,n.iridescenceThicknessMapUv?`#define IRIDESCENCE_THICKNESSMAP_UV `+n.iridescenceThicknessMapUv:``,n.sheenColorMapUv?`#define SHEEN_COLORMAP_UV `+n.sheenColorMapUv:``,n.sheenRoughnessMapUv?`#define SHEEN_ROUGHNESSMAP_UV `+n.sheenRoughnessMapUv:``,n.specularMapUv?`#define SPECULARMAP_UV `+n.specularMapUv:``,n.specularColorMapUv?`#define SPECULAR_COLORMAP_UV `+n.specularColorMapUv:``,n.specularIntensityMapUv?`#define SPECULAR_INTENSITYMAP_UV `+n.specularIntensityMapUv:``,n.transmissionMapUv?`#define TRANSMISSIONMAP_UV `+n.transmissionMapUv:``,n.thicknessMapUv?`#define THICKNESSMAP_UV `+n.thicknessMapUv:``,n.vertexTangents&&n.flatShading===!1?`#define USE_TANGENT`:``,n.vertexNormals?`#define HAS_NORMAL`:``,n.vertexColors?`#define USE_COLOR`:``,n.vertexAlphas?`#define USE_COLOR_ALPHA`:``,n.vertexUv1s?`#define USE_UV1`:``,n.vertexUv2s?`#define USE_UV2`:``,n.vertexUv3s?`#define USE_UV3`:``,n.pointsUvs?`#define USE_POINTS_UV`:``,n.flatShading?`#define FLAT_SHADED`:``,n.skinning?`#define USE_SKINNING`:``,n.morphTargets?`#define USE_MORPHTARGETS`:``,n.morphNormals&&n.flatShading===!1?`#define USE_MORPHNORMALS`:``,n.morphColors?`#define USE_MORPHCOLORS`:``,n.morphTargetsCount>0?`#define MORPHTARGETS_TEXTURE_STRIDE `+n.morphTextureStride:``,n.morphTargetsCount>0?`#define MORPHTARGETS_COUNT `+n.morphTargetsCount:``,n.doubleSided?`#define DOUBLE_SIDED`:``,n.flipSided?`#define FLIP_SIDED`:``,n.shadowMapEnabled?`#define USE_SHADOWMAP`:``,n.shadowMapEnabled?`#define `+c:``,n.sizeAttenuation?`#define USE_SIZEATTENUATION`:``,n.numLightProbes>0?`#define USE_LIGHT_PROBES`:``,n.logarithmicDepthBuffer?`#define USE_LOGARITHMIC_DEPTH_BUFFER`:``,n.reversedDepthBuffer?`#define USE_REVERSED_DEPTH_BUFFER`:``,`uniform mat4 modelMatrix;`,`uniform mat4 modelViewMatrix;`,`uniform mat4 projectionMatrix;`,`uniform mat4 viewMatrix;`,`uniform mat3 normalMatrix;`,`uniform vec3 cameraPosition;`,`uniform bool isOrthographic;`,`#ifdef USE_INSTANCING`,` attribute mat4 instanceMatrix;`,`#endif`,`#ifdef USE_INSTANCING_COLOR`,` attribute vec3 instanceColor;`,`#endif`,`#ifdef USE_INSTANCING_MORPH`,` uniform sampler2D morphTexture;`,`#endif`,`attribute vec3 position;`,`attribute vec3 normal;`,`attribute vec2 uv;`,`#ifdef USE_UV1`,` attribute vec2 uv1;`,`#endif`,`#ifdef USE_UV2`,` attribute vec2 uv2;`,`#endif`,`#ifdef USE_UV3`,` attribute vec2 uv3;`,`#endif`,`#ifdef USE_TANGENT`,` attribute vec4 tangent;`,`#endif`,`#if defined( USE_COLOR_ALPHA )`,` attribute vec4 color;`,`#elif defined( USE_COLOR )`,` attribute vec3 color;`,`#endif`,`#ifdef USE_SKINNING`,` attribute vec4 skinIndex;`,` attribute vec4 skinWeight;`,`#endif`,` -`].filter(ww).join(` -`),_=[Pw(n),`#define SHADER_TYPE `+n.shaderType,`#define SHADER_NAME `+n.shaderName,m,n.useFog&&n.fog?`#define USE_FOG`:``,n.useFog&&n.fogExp2?`#define FOG_EXP2`:``,n.alphaToCoverage?`#define ALPHA_TO_COVERAGE`:``,n.map?`#define USE_MAP`:``,n.matcap?`#define USE_MATCAP`:``,n.envMap?`#define USE_ENVMAP`:``,n.envMap?`#define `+l:``,n.envMap?`#define `+u:``,n.envMap?`#define `+d:``,f?`#define CUBEUV_TEXEL_WIDTH `+f.texelWidth:``,f?`#define CUBEUV_TEXEL_HEIGHT `+f.texelHeight:``,f?`#define CUBEUV_MAX_MIP `+f.maxMip+`.0`:``,n.lightMap?`#define USE_LIGHTMAP`:``,n.aoMap?`#define USE_AOMAP`:``,n.bumpMap?`#define USE_BUMPMAP`:``,n.normalMap?`#define USE_NORMALMAP`:``,n.normalMapObjectSpace?`#define USE_NORMALMAP_OBJECTSPACE`:``,n.normalMapTangentSpace?`#define USE_NORMALMAP_TANGENTSPACE`:``,n.packedNormalMap?`#define USE_PACKED_NORMALMAP`:``,n.emissiveMap?`#define USE_EMISSIVEMAP`:``,n.anisotropy?`#define USE_ANISOTROPY`:``,n.anisotropyMap?`#define USE_ANISOTROPYMAP`:``,n.clearcoat?`#define USE_CLEARCOAT`:``,n.clearcoatMap?`#define USE_CLEARCOATMAP`:``,n.clearcoatRoughnessMap?`#define USE_CLEARCOAT_ROUGHNESSMAP`:``,n.clearcoatNormalMap?`#define USE_CLEARCOAT_NORMALMAP`:``,n.dispersion?`#define USE_DISPERSION`:``,n.retroreflection?`#define USE_RETROREFLECTION`:``,n.iridescence?`#define USE_IRIDESCENCE`:``,n.iridescenceMap?`#define USE_IRIDESCENCEMAP`:``,n.iridescenceThicknessMap?`#define USE_IRIDESCENCE_THICKNESSMAP`:``,n.specularMap?`#define USE_SPECULARMAP`:``,n.specularColorMap?`#define USE_SPECULAR_COLORMAP`:``,n.specularIntensityMap?`#define USE_SPECULAR_INTENSITYMAP`:``,n.roughnessMap?`#define USE_ROUGHNESSMAP`:``,n.metalnessMap?`#define USE_METALNESSMAP`:``,n.alphaMap?`#define USE_ALPHAMAP`:``,n.alphaTest?`#define USE_ALPHATEST`:``,n.alphaHash?`#define USE_ALPHAHASH`:``,n.sheen?`#define USE_SHEEN`:``,n.sheenColorMap?`#define USE_SHEEN_COLORMAP`:``,n.sheenRoughnessMap?`#define USE_SHEEN_ROUGHNESSMAP`:``,n.transmission?`#define USE_TRANSMISSION`:``,n.transmissionMap?`#define USE_TRANSMISSIONMAP`:``,n.thicknessMap?`#define USE_THICKNESSMAP`:``,n.vertexTangents&&n.flatShading===!1?`#define USE_TANGENT`:``,n.vertexColors||n.instancingColor?`#define USE_COLOR`:``,n.vertexAlphas||n.batchingColor?`#define USE_COLOR_ALPHA`:``,n.vertexUv1s?`#define USE_UV1`:``,n.vertexUv2s?`#define USE_UV2`:``,n.vertexUv3s?`#define USE_UV3`:``,n.pointsUvs?`#define USE_POINTS_UV`:``,n.gradientMap?`#define USE_GRADIENTMAP`:``,n.flatShading?`#define FLAT_SHADED`:``,n.doubleSided?`#define DOUBLE_SIDED`:``,n.flipSided?`#define FLIP_SIDED`:``,n.shadowMapEnabled?`#define USE_SHADOWMAP`:``,n.shadowMapEnabled?`#define `+c:``,n.premultipliedAlpha?`#define PREMULTIPLIED_ALPHA`:``,n.numLightProbes>0?`#define USE_LIGHT_PROBES`:``,n.numLightProbeGrids>0?`#define USE_LIGHT_PROBES_GRID`:``,n.decodeVideoTexture?`#define DECODE_VIDEO_TEXTURE`:``,n.decodeVideoTextureEmissive?`#define DECODE_VIDEO_TEXTURE_EMISSIVE`:``,n.logarithmicDepthBuffer?`#define USE_LOGARITHMIC_DEPTH_BUFFER`:``,n.reversedDepthBuffer?`#define USE_REVERSED_DEPTH_BUFFER`:``,`uniform mat4 viewMatrix;`,`uniform vec3 cameraPosition;`,`uniform bool isOrthographic;`,n.toneMapping===0?``:`#define TONE_MAPPING`,n.toneMapping===0?``:hS.tonemapping_pars_fragment,n.toneMapping===0?``:vw(`toneMapping`,n.toneMapping),n.dithering?`#define DITHERING`:``,n.opaque?`#define OPAQUE`:``,hS.colorspace_pars_fragment,gw(`linearToOutputTexel`,n.outputColorSpace),bw(),n.useDepthPacking?`#define DEPTH_PACKING `+n.depthPacking:``,` -`].filter(ww).join(` -`)),o=Ow(o),o=Tw(o,n),o=Ew(o,n),s=Ow(s),s=Tw(s,n),s=Ew(s,n),o=Mw(o),s=Mw(s),n.isRawShaderMaterial!==!0&&(v=`#version 300 es +`)):(g=[Zm(n),`#define SHADER_TYPE `+n.shaderType,`#define SHADER_NAME `+n.shaderName,m,n.extensionClipCullDistance?`#define USE_CLIP_DISTANCE`:``,n.batching?`#define USE_BATCHING`:``,n.batchingColor?`#define USE_BATCHING_COLOR`:``,n.instancing?`#define USE_INSTANCING`:``,n.instancingColor?`#define USE_INSTANCING_COLOR`:``,n.instancingMorph?`#define USE_INSTANCING_MORPH`:``,n.useFog&&n.fog?`#define USE_FOG`:``,n.useFog&&n.fogExp2?`#define FOG_EXP2`:``,n.map?`#define USE_MAP`:``,n.envMap?`#define USE_ENVMAP`:``,n.envMap?`#define `+u:``,n.lightMap?`#define USE_LIGHTMAP`:``,n.aoMap?`#define USE_AOMAP`:``,n.bumpMap?`#define USE_BUMPMAP`:``,n.normalMap?`#define USE_NORMALMAP`:``,n.normalMapObjectSpace?`#define USE_NORMALMAP_OBJECTSPACE`:``,n.normalMapTangentSpace?`#define USE_NORMALMAP_TANGENTSPACE`:``,n.displacementMap?`#define USE_DISPLACEMENTMAP`:``,n.emissiveMap?`#define USE_EMISSIVEMAP`:``,n.anisotropy?`#define USE_ANISOTROPY`:``,n.anisotropyMap?`#define USE_ANISOTROPYMAP`:``,n.clearcoatMap?`#define USE_CLEARCOATMAP`:``,n.clearcoatRoughnessMap?`#define USE_CLEARCOAT_ROUGHNESSMAP`:``,n.clearcoatNormalMap?`#define USE_CLEARCOAT_NORMALMAP`:``,n.iridescenceMap?`#define USE_IRIDESCENCEMAP`:``,n.iridescenceThicknessMap?`#define USE_IRIDESCENCE_THICKNESSMAP`:``,n.specularMap?`#define USE_SPECULARMAP`:``,n.specularColorMap?`#define USE_SPECULAR_COLORMAP`:``,n.specularIntensityMap?`#define USE_SPECULAR_INTENSITYMAP`:``,n.roughnessMap?`#define USE_ROUGHNESSMAP`:``,n.metalnessMap?`#define USE_METALNESSMAP`:``,n.alphaMap?`#define USE_ALPHAMAP`:``,n.alphaHash?`#define USE_ALPHAHASH`:``,n.transmission?`#define USE_TRANSMISSION`:``,n.transmissionMap?`#define USE_TRANSMISSIONMAP`:``,n.thicknessMap?`#define USE_THICKNESSMAP`:``,n.sheenColorMap?`#define USE_SHEEN_COLORMAP`:``,n.sheenRoughnessMap?`#define USE_SHEEN_ROUGHNESSMAP`:``,n.mapUv?`#define MAP_UV `+n.mapUv:``,n.alphaMapUv?`#define ALPHAMAP_UV `+n.alphaMapUv:``,n.lightMapUv?`#define LIGHTMAP_UV `+n.lightMapUv:``,n.aoMapUv?`#define AOMAP_UV `+n.aoMapUv:``,n.emissiveMapUv?`#define EMISSIVEMAP_UV `+n.emissiveMapUv:``,n.bumpMapUv?`#define BUMPMAP_UV `+n.bumpMapUv:``,n.normalMapUv?`#define NORMALMAP_UV `+n.normalMapUv:``,n.displacementMapUv?`#define DISPLACEMENTMAP_UV `+n.displacementMapUv:``,n.metalnessMapUv?`#define METALNESSMAP_UV `+n.metalnessMapUv:``,n.roughnessMapUv?`#define ROUGHNESSMAP_UV `+n.roughnessMapUv:``,n.anisotropyMapUv?`#define ANISOTROPYMAP_UV `+n.anisotropyMapUv:``,n.clearcoatMapUv?`#define CLEARCOATMAP_UV `+n.clearcoatMapUv:``,n.clearcoatNormalMapUv?`#define CLEARCOAT_NORMALMAP_UV `+n.clearcoatNormalMapUv:``,n.clearcoatRoughnessMapUv?`#define CLEARCOAT_ROUGHNESSMAP_UV `+n.clearcoatRoughnessMapUv:``,n.iridescenceMapUv?`#define IRIDESCENCEMAP_UV `+n.iridescenceMapUv:``,n.iridescenceThicknessMapUv?`#define IRIDESCENCE_THICKNESSMAP_UV `+n.iridescenceThicknessMapUv:``,n.sheenColorMapUv?`#define SHEEN_COLORMAP_UV `+n.sheenColorMapUv:``,n.sheenRoughnessMapUv?`#define SHEEN_ROUGHNESSMAP_UV `+n.sheenRoughnessMapUv:``,n.specularMapUv?`#define SPECULARMAP_UV `+n.specularMapUv:``,n.specularColorMapUv?`#define SPECULAR_COLORMAP_UV `+n.specularColorMapUv:``,n.specularIntensityMapUv?`#define SPECULAR_INTENSITYMAP_UV `+n.specularIntensityMapUv:``,n.transmissionMapUv?`#define TRANSMISSIONMAP_UV `+n.transmissionMapUv:``,n.thicknessMapUv?`#define THICKNESSMAP_UV `+n.thicknessMapUv:``,n.vertexTangents&&n.flatShading===!1?`#define USE_TANGENT`:``,n.vertexNormals?`#define HAS_NORMAL`:``,n.vertexColors?`#define USE_COLOR`:``,n.vertexAlphas?`#define USE_COLOR_ALPHA`:``,n.vertexUv1s?`#define USE_UV1`:``,n.vertexUv2s?`#define USE_UV2`:``,n.vertexUv3s?`#define USE_UV3`:``,n.pointsUvs?`#define USE_POINTS_UV`:``,n.flatShading?`#define FLAT_SHADED`:``,n.skinning?`#define USE_SKINNING`:``,n.morphTargets?`#define USE_MORPHTARGETS`:``,n.morphNormals&&n.flatShading===!1?`#define USE_MORPHNORMALS`:``,n.morphColors?`#define USE_MORPHCOLORS`:``,n.morphTargetsCount>0?`#define MORPHTARGETS_TEXTURE_STRIDE `+n.morphTextureStride:``,n.morphTargetsCount>0?`#define MORPHTARGETS_COUNT `+n.morphTargetsCount:``,n.doubleSided?`#define DOUBLE_SIDED`:``,n.flipSided?`#define FLIP_SIDED`:``,n.shadowMapEnabled?`#define USE_SHADOWMAP`:``,n.shadowMapEnabled?`#define `+c:``,n.sizeAttenuation?`#define USE_SIZEATTENUATION`:``,n.numLightProbes>0?`#define USE_LIGHT_PROBES`:``,n.logarithmicDepthBuffer?`#define USE_LOGARITHMIC_DEPTH_BUFFER`:``,n.reversedDepthBuffer?`#define USE_REVERSED_DEPTH_BUFFER`:``,`uniform mat4 modelMatrix;`,`uniform mat4 modelViewMatrix;`,`uniform mat4 projectionMatrix;`,`uniform mat4 viewMatrix;`,`uniform mat3 normalMatrix;`,`uniform vec3 cameraPosition;`,`uniform bool isOrthographic;`,`#ifdef USE_INSTANCING`,` attribute mat4 instanceMatrix;`,`#endif`,`#ifdef USE_INSTANCING_COLOR`,` attribute vec3 instanceColor;`,`#endif`,`#ifdef USE_INSTANCING_MORPH`,` uniform sampler2D morphTexture;`,`#endif`,`attribute vec3 position;`,`attribute vec3 normal;`,`attribute vec2 uv;`,`#ifdef USE_UV1`,` attribute vec2 uv1;`,`#endif`,`#ifdef USE_UV2`,` attribute vec2 uv2;`,`#endif`,`#ifdef USE_UV3`,` attribute vec2 uv3;`,`#endif`,`#ifdef USE_TANGENT`,` attribute vec4 tangent;`,`#endif`,`#if defined( USE_COLOR_ALPHA )`,` attribute vec4 color;`,`#elif defined( USE_COLOR )`,` attribute vec3 color;`,`#endif`,`#ifdef USE_SKINNING`,` attribute vec4 skinIndex;`,` attribute vec4 skinWeight;`,`#endif`,` +`].filter(Vm).join(` +`),_=[Zm(n),`#define SHADER_TYPE `+n.shaderType,`#define SHADER_NAME `+n.shaderName,m,n.useFog&&n.fog?`#define USE_FOG`:``,n.useFog&&n.fogExp2?`#define FOG_EXP2`:``,n.alphaToCoverage?`#define ALPHA_TO_COVERAGE`:``,n.map?`#define USE_MAP`:``,n.matcap?`#define USE_MATCAP`:``,n.envMap?`#define USE_ENVMAP`:``,n.envMap?`#define `+l:``,n.envMap?`#define `+u:``,n.envMap?`#define `+d:``,f?`#define CUBEUV_TEXEL_WIDTH `+f.texelWidth:``,f?`#define CUBEUV_TEXEL_HEIGHT `+f.texelHeight:``,f?`#define CUBEUV_MAX_MIP `+f.maxMip+`.0`:``,n.lightMap?`#define USE_LIGHTMAP`:``,n.aoMap?`#define USE_AOMAP`:``,n.bumpMap?`#define USE_BUMPMAP`:``,n.normalMap?`#define USE_NORMALMAP`:``,n.normalMapObjectSpace?`#define USE_NORMALMAP_OBJECTSPACE`:``,n.normalMapTangentSpace?`#define USE_NORMALMAP_TANGENTSPACE`:``,n.packedNormalMap?`#define USE_PACKED_NORMALMAP`:``,n.emissiveMap?`#define USE_EMISSIVEMAP`:``,n.anisotropy?`#define USE_ANISOTROPY`:``,n.anisotropyMap?`#define USE_ANISOTROPYMAP`:``,n.clearcoat?`#define USE_CLEARCOAT`:``,n.clearcoatMap?`#define USE_CLEARCOATMAP`:``,n.clearcoatRoughnessMap?`#define USE_CLEARCOAT_ROUGHNESSMAP`:``,n.clearcoatNormalMap?`#define USE_CLEARCOAT_NORMALMAP`:``,n.dispersion?`#define USE_DISPERSION`:``,n.retroreflection?`#define USE_RETROREFLECTION`:``,n.iridescence?`#define USE_IRIDESCENCE`:``,n.iridescenceMap?`#define USE_IRIDESCENCEMAP`:``,n.iridescenceThicknessMap?`#define USE_IRIDESCENCE_THICKNESSMAP`:``,n.specularMap?`#define USE_SPECULARMAP`:``,n.specularColorMap?`#define USE_SPECULAR_COLORMAP`:``,n.specularIntensityMap?`#define USE_SPECULAR_INTENSITYMAP`:``,n.roughnessMap?`#define USE_ROUGHNESSMAP`:``,n.metalnessMap?`#define USE_METALNESSMAP`:``,n.alphaMap?`#define USE_ALPHAMAP`:``,n.alphaTest?`#define USE_ALPHATEST`:``,n.alphaHash?`#define USE_ALPHAHASH`:``,n.sheen?`#define USE_SHEEN`:``,n.sheenColorMap?`#define USE_SHEEN_COLORMAP`:``,n.sheenRoughnessMap?`#define USE_SHEEN_ROUGHNESSMAP`:``,n.transmission?`#define USE_TRANSMISSION`:``,n.transmissionMap?`#define USE_TRANSMISSIONMAP`:``,n.thicknessMap?`#define USE_THICKNESSMAP`:``,n.vertexTangents&&n.flatShading===!1?`#define USE_TANGENT`:``,n.vertexColors||n.instancingColor?`#define USE_COLOR`:``,n.vertexAlphas||n.batchingColor?`#define USE_COLOR_ALPHA`:``,n.vertexUv1s?`#define USE_UV1`:``,n.vertexUv2s?`#define USE_UV2`:``,n.vertexUv3s?`#define USE_UV3`:``,n.pointsUvs?`#define USE_POINTS_UV`:``,n.gradientMap?`#define USE_GRADIENTMAP`:``,n.flatShading?`#define FLAT_SHADED`:``,n.doubleSided?`#define DOUBLE_SIDED`:``,n.flipSided?`#define FLIP_SIDED`:``,n.shadowMapEnabled?`#define USE_SHADOWMAP`:``,n.shadowMapEnabled?`#define `+c:``,n.premultipliedAlpha?`#define PREMULTIPLIED_ALPHA`:``,n.numLightProbes>0?`#define USE_LIGHT_PROBES`:``,n.numLightProbeGrids>0?`#define USE_LIGHT_PROBES_GRID`:``,n.decodeVideoTexture?`#define DECODE_VIDEO_TEXTURE`:``,n.decodeVideoTextureEmissive?`#define DECODE_VIDEO_TEXTURE_EMISSIVE`:``,n.logarithmicDepthBuffer?`#define USE_LOGARITHMIC_DEPTH_BUFFER`:``,n.reversedDepthBuffer?`#define USE_REVERSED_DEPTH_BUFFER`:``,`uniform mat4 viewMatrix;`,`uniform vec3 cameraPosition;`,`uniform bool isOrthographic;`,n.toneMapping===0?``:`#define TONE_MAPPING`,n.toneMapping===0?``:Mf.tonemapping_pars_fragment,n.toneMapping===0?``:Fm(`toneMapping`,n.toneMapping),n.dithering?`#define DITHERING`:``,n.opaque?`#define OPAQUE`:``,Mf.colorspace_pars_fragment,Nm(`linearToOutputTexel`,n.outputColorSpace),Lm(),n.useDepthPacking?`#define DEPTH_PACKING `+n.depthPacking:``,` +`].filter(Vm).join(` +`)),o=Gm(o),o=Hm(o,n),o=Um(o,n),s=Gm(s),s=Hm(s,n),s=Um(s,n),o=Ym(o),s=Ym(s),n.isRawShaderMaterial!==!0&&(v=`#version 300 es `,g=[p,`#define attribute in`,`#define varying out`,`#define texture2D texture`].join(` `)+` `+g,_=[`#define varying in`,n.glslVersion===`300 es`?``:`layout(location = 0) out highp vec4 pc_fragColor;`,n.glslVersion===`300 es`?``:`#define gl_FragColor pc_fragColor`,`#define gl_FragDepthEXT gl_FragDepth`,`#define texture2D texture`,`#define textureCube texture`,`#define texture2DProj textureProj`,`#define texture2DLodEXT textureLod`,`#define texture2DProjLodEXT textureProjLod`,`#define textureCubeLodEXT textureLod`,`#define texture2DGradEXT textureGrad`,`#define texture2DProjGradEXT textureProjGrad`,`#define textureCubeGradEXT textureGrad`].join(` `)+` -`+_);let y=v+g+o,b=v+_+s,x=lw(i,i.VERTEX_SHADER,y),S=lw(i,i.FRAGMENT_SHADER,b);i.attachShader(h,x),i.attachShader(h,S),n.index0AttributeName===void 0?n.hasPositionAttribute===!0&&i.bindAttribLocation(h,0,`position`):i.bindAttribLocation(h,0,n.index0AttributeName),i.linkProgram(h);function C(t){if(e.debug.checkShaderErrors){let n=i.getProgramInfoLog(h)||``,r=i.getShaderInfoLog(x)||``,a=i.getShaderInfoLog(S)||``,o=n.trim(),s=r.trim(),c=a.trim(),l=!0,u=!0;if(i.getProgramParameter(h,i.LINK_STATUS)===!1){if(l=!1,typeof e.debug.onShaderError==`function`)e.debug.onShaderError(i,h,x,S);else{let e=hw(i,x,`vertex`),n=hw(i,S,`fragment`);Eh(`WebGLProgram: Shader Error `+i.getError()+` - VALIDATE_STATUS `+i.getProgramParameter(h,i.VALIDATE_STATUS)+` +`+_);let y=v+g+o,b=v+_+s,x=Em(i,i.VERTEX_SHADER,y),S=Em(i,i.FRAGMENT_SHADER,b);i.attachShader(h,x),i.attachShader(h,S),n.index0AttributeName===void 0?n.hasPositionAttribute===!0&&i.bindAttribLocation(h,0,`position`):i.bindAttribLocation(h,0,n.index0AttributeName),i.linkProgram(h);function C(t){if(e.debug.checkShaderErrors){let n=i.getProgramInfoLog(h)||``,r=i.getShaderInfoLog(x)||``,a=i.getShaderInfoLog(S)||``,o=n.trim(),s=r.trim(),c=a.trim(),l=!0,u=!0;if(i.getProgramParameter(h,i.LINK_STATUS)===!1){if(l=!1,typeof e.debug.onShaderError==`function`)e.debug.onShaderError(i,h,x,S);else{let e=Mm(i,x,`vertex`),n=Mm(i,S,`fragment`);Ba(`WebGLProgram: Shader Error `+i.getError()+` - VALIDATE_STATUS `+i.getProgramParameter(h,i.VALIDATE_STATUS)+` Material Name: `+t.name+` Material Type: `+t.type+` Program Info Log: `+o+` `+e+` -`+n)}}else o===``?(s===``||c===``)&&(u=!1):Th(`WebGLProgram: Program Info Log:`,o);u&&(t.diagnostics={runnable:l,programLog:o,vertexShader:{log:s,prefix:g},fragmentShader:{log:c,prefix:_}})}i.deleteShader(x),i.deleteShader(S),w=new cw(i,h),T=Cw(i,h)}let w;this.getUniforms=function(){return w===void 0&&C(this),w};let T;this.getAttributes=function(){return T===void 0&&C(this),T};let E=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return E===!1&&(E=i.getProgramParameter(h,uw)),E},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(h),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=dw++,this.cacheKey=t,this.usedTimes=1,this.program=h,this.vertexShader=x,this.fragmentShader=S,this}var Gw=0,Kw=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){let r=this._getShaderCacheForMaterial(e);return r.has(t)===!1&&(r.add(t),t.usedTimes++),r.has(n)===!1&&(r.add(n),n.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let e of t)e.usedTimes--,e.usedTimes===0&&this.shaderCache.delete(e.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);return n===void 0&&(n=new qw(e),t.set(e,n)),n}},qw=class{constructor(e){this.id=Gw++,this.code=e,this.usedTimes=0}};function Jw(e){return e===1030||e===37490||e===36285}function Yw(e,t,n,r,i,a){let o=new Rg,s=new Kw,c=new Set,l=[],u=new Map,d=r.logarithmicDepthBuffer,f=r.precision,p={MeshDepthMaterial:`depth`,MeshDistanceMaterial:`distance`,MeshNormalMaterial:`normal`,MeshBasicMaterial:`basic`,MeshLambertMaterial:`lambert`,MeshPhongMaterial:`phong`,MeshToonMaterial:`toon`,MeshStandardMaterial:`physical`,MeshPhysicalMaterial:`physical`,MeshMatcapMaterial:`matcap`,LineBasicMaterial:`basic`,LineDashedMaterial:`dashed`,PointsMaterial:`points`,ShadowMaterial:`shadow`,SpriteMaterial:`sprite`};function m(e){return c.add(e),e===0?`uv`:`uv${e}`}function h(i,o,l,u,h,g){let _=u.fog,v=h.geometry,y=i.isMeshStandardMaterial||i.isMeshLambertMaterial||i.isMeshPhongMaterial?u.environment:null,b=i.isMeshStandardMaterial||i.isMeshLambertMaterial&&!i.envMap||i.isMeshPhongMaterial&&!i.envMap,x=t.get(i.envMap||y,b),S=x&&x.mapping===306?x.image.height:null,C=p[i.type];i.precision!==null&&(f=r.getMaxPrecision(i.precision),f!==i.precision&&Th(`WebGLProgram.getParameters:`,i.precision,`not supported, using`,f,`instead.`));let w=v.morphAttributes.position||v.morphAttributes.normal||v.morphAttributes.color,T=w===void 0?0:w.length,E=0;v.morphAttributes.position!==void 0&&(E=1),v.morphAttributes.normal!==void 0&&(E=2),v.morphAttributes.color!==void 0&&(E=3);let D,O,k,A;if(C){let e=gS[C];D=e.vertexShader,O=e.fragmentShader}else{D=i.vertexShader,O=i.fragmentShader;let e=s.getVertexShaderStage(i),t=s.getFragmentShaderStage(i);s.update(i,e,t),k=e.id,A=t.id}let j=e.getRenderTarget(),ee=e.state.buffers.depth.getReversed(),M=h.isInstancedMesh===!0,te=h.isBatchedMesh===!0,ne=!!i.map,re=!!i.matcap,ie=!!x,N=!!i.aoMap,ae=!!i.lightMap,oe=!!i.bumpMap&&i.wireframe===!1,se=!!i.normalMap,ce=!!i.displacementMap,le=!!i.emissiveMap,P=!!i.metalnessMap,ue=!!i.roughnessMap,de=i.anisotropy>0,fe=i.clearcoat>0,pe=i.dispersion>0,me=i.retroreflectivity>0,he=i.iridescence>0,ge=i.sheen>0,_e=i.transmission>0,ve=de&&!!i.anisotropyMap,ye=fe&&!!i.clearcoatMap,be=fe&&!!i.clearcoatNormalMap,xe=fe&&!!i.clearcoatRoughnessMap,Se=he&&!!i.iridescenceMap,F=he&&!!i.iridescenceThicknessMap,Ce=ge&&!!i.sheenColorMap,we=ge&&!!i.sheenRoughnessMap,Te=!!i.specularMap,I=!!i.specularColorMap,Ee=!!i.specularIntensityMap,De=_e&&!!i.transmissionMap,Oe=_e&&!!i.thicknessMap,ke=!!i.gradientMap,Ae=!!i.alphaMap,je=i.alphaTest>0,Me=!!i.alphaHash,Ne=!!i.extensions,Pe=0;i.toneMapped&&(j===null||j.isXRRenderTarget===!0)&&(Pe=e.toneMapping);let Fe={shaderID:C,shaderType:i.type,shaderName:i.name,vertexShader:D,fragmentShader:O,defines:i.defines,customVertexShaderID:k,customFragmentShaderID:A,isRawShaderMaterial:i.isRawShaderMaterial===!0,glslVersion:i.glslVersion,precision:f,batching:te,batchingColor:te&&h._colorsTexture!==null,instancing:M,instancingColor:M&&h.instanceColor!==null,instancingMorph:M&&h.morphTexture!==null,outputColorSpace:j===null?e.outputColorSpace:j.isXRRenderTarget===!0?j.texture.colorSpace:dg.workingColorSpace,alphaToCoverage:!!i.alphaToCoverage,map:ne,matcap:re,envMap:ie,envMapMode:ie&&x.mapping,envMapCubeUVHeight:S,aoMap:N,lightMap:ae,bumpMap:oe,normalMap:se,displacementMap:ce,emissiveMap:le,normalMapObjectSpace:se&&i.normalMapType===1,normalMapTangentSpace:se&&i.normalMapType===0,packedNormalMap:se&&i.normalMapType===0&&Jw(i.normalMap.format),metalnessMap:P,roughnessMap:ue,anisotropy:de,anisotropyMap:ve,clearcoat:fe,clearcoatMap:ye,clearcoatNormalMap:be,clearcoatRoughnessMap:xe,dispersion:pe,retroreflection:me,iridescence:he,iridescenceMap:Se,iridescenceThicknessMap:F,sheen:ge,sheenColorMap:Ce,sheenRoughnessMap:we,specularMap:Te,specularColorMap:I,specularIntensityMap:Ee,transmission:_e,transmissionMap:De,thicknessMap:Oe,gradientMap:ke,opaque:i.transparent===!1&&i.blending===1&&i.alphaToCoverage===!1,alphaMap:Ae,alphaTest:je,alphaHash:Me,combine:i.combine,mapUv:ne&&m(i.map.channel),aoMapUv:N&&m(i.aoMap.channel),lightMapUv:ae&&m(i.lightMap.channel),bumpMapUv:oe&&m(i.bumpMap.channel),normalMapUv:se&&m(i.normalMap.channel),displacementMapUv:ce&&m(i.displacementMap.channel),emissiveMapUv:le&&m(i.emissiveMap.channel),metalnessMapUv:P&&m(i.metalnessMap.channel),roughnessMapUv:ue&&m(i.roughnessMap.channel),anisotropyMapUv:ve&&m(i.anisotropyMap.channel),clearcoatMapUv:ye&&m(i.clearcoatMap.channel),clearcoatNormalMapUv:be&&m(i.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:xe&&m(i.clearcoatRoughnessMap.channel),iridescenceMapUv:Se&&m(i.iridescenceMap.channel),iridescenceThicknessMapUv:F&&m(i.iridescenceThicknessMap.channel),sheenColorMapUv:Ce&&m(i.sheenColorMap.channel),sheenRoughnessMapUv:we&&m(i.sheenRoughnessMap.channel),specularMapUv:Te&&m(i.specularMap.channel),specularColorMapUv:I&&m(i.specularColorMap.channel),specularIntensityMapUv:Ee&&m(i.specularIntensityMap.channel),transmissionMapUv:De&&m(i.transmissionMap.channel),thicknessMapUv:Oe&&m(i.thicknessMap.channel),alphaMapUv:Ae&&m(i.alphaMap.channel),vertexTangents:!!v.attributes.tangent&&(se||de),vertexNormals:!!v.attributes.normal,vertexColors:i.vertexColors,vertexAlphas:i.vertexColors===!0&&!!v.attributes.color&&v.attributes.color.itemSize===4,pointsUvs:h.isPoints===!0&&!!v.attributes.uv&&(ne||Ae),fog:!!_,useFog:i.fog===!0,fogExp2:!!_&&_.isFogExp2,flatShading:i.wireframe===!1&&(i.flatShading===!0||v.attributes.normal===void 0&&se===!1&&(i.isMeshLambertMaterial||i.isMeshPhongMaterial||i.isMeshStandardMaterial||i.isMeshPhysicalMaterial)),sizeAttenuation:i.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:ee,skinning:h.isSkinnedMesh===!0,hasPositionAttribute:v.attributes.position!==void 0,morphTargets:v.morphAttributes.position!==void 0,morphNormals:v.morphAttributes.normal!==void 0,morphColors:v.morphAttributes.color!==void 0,morphTargetsCount:T,morphTextureStride:E,numSunLights:o.sun.length,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numSunLightShadows:o.sunShadowMap.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numLightProbes:o.numLightProbes,numLightProbeGrids:g.length,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:i.dithering,shadowMapEnabled:e.shadowMap.enabled&&l.length>0,shadowMapType:e.shadowMap.type,toneMapping:Pe,decodeVideoTexture:ne&&i.map.isVideoTexture===!0&&dg.getTransfer(i.map.colorSpace)===`srgb`,decodeVideoTextureEmissive:le&&i.emissiveMap.isVideoTexture===!0&&dg.getTransfer(i.emissiveMap.colorSpace)===`srgb`,premultipliedAlpha:i.premultipliedAlpha,doubleSided:i.side===2,flipSided:i.side===1,useDepthPacking:i.depthPacking>=0,depthPacking:i.depthPacking||0,index0AttributeName:i.index0AttributeName,extensionClipCullDistance:Ne&&i.extensions.clipCullDistance===!0&&n.has(`WEBGL_clip_cull_distance`),extensionMultiDraw:(Ne&&i.extensions.multiDraw===!0||te)&&n.has(`WEBGL_multi_draw`),rendererExtensionParallelShaderCompile:n.has(`KHR_parallel_shader_compile`),customProgramCacheKey:i.customProgramCacheKey()};return Fe.vertexUv1s=c.has(1),Fe.vertexUv2s=c.has(2),Fe.vertexUv3s=c.has(3),c.clear(),Fe}function g(t){let n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),t.defines!==void 0)for(let e in t.defines)n.push(e),n.push(t.defines[e]);return t.isRawShaderMaterial===!1&&(_(n,t),v(n,t),n.push(e.outputColorSpace)),n.push(t.customProgramCacheKey),n.join()}function _(e,t){e.push(t.precision),e.push(t.outputColorSpace),e.push(t.envMapMode),e.push(t.envMapCubeUVHeight),e.push(t.mapUv),e.push(t.alphaMapUv),e.push(t.lightMapUv),e.push(t.aoMapUv),e.push(t.bumpMapUv),e.push(t.normalMapUv),e.push(t.displacementMapUv),e.push(t.emissiveMapUv),e.push(t.metalnessMapUv),e.push(t.roughnessMapUv),e.push(t.anisotropyMapUv),e.push(t.clearcoatMapUv),e.push(t.clearcoatNormalMapUv),e.push(t.clearcoatRoughnessMapUv),e.push(t.iridescenceMapUv),e.push(t.iridescenceThicknessMapUv),e.push(t.sheenColorMapUv),e.push(t.sheenRoughnessMapUv),e.push(t.specularMapUv),e.push(t.specularColorMapUv),e.push(t.specularIntensityMapUv),e.push(t.transmissionMapUv),e.push(t.thicknessMapUv),e.push(t.combine),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.morphAttributeCount),e.push(t.numSunLights),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numSpotLightMaps),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numSunLightShadows),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.numLightProbes),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}function v(e,t){o.disableAll(),t.instancing&&o.enable(0),t.instancingColor&&o.enable(1),t.instancingMorph&&o.enable(2),t.matcap&&o.enable(3),t.envMap&&o.enable(4),t.normalMapObjectSpace&&o.enable(5),t.normalMapTangentSpace&&o.enable(6),t.clearcoat&&o.enable(7),t.iridescence&&o.enable(8),t.alphaTest&&o.enable(9),t.vertexColors&&o.enable(10),t.vertexAlphas&&o.enable(11),t.vertexUv1s&&o.enable(12),t.vertexUv2s&&o.enable(13),t.vertexUv3s&&o.enable(14),t.vertexTangents&&o.enable(15),t.anisotropy&&o.enable(16),t.alphaHash&&o.enable(17),t.batching&&o.enable(18),t.dispersion&&o.enable(19),t.retroreflection&&o.enable(24),t.batchingColor&&o.enable(20),t.gradientMap&&o.enable(21),t.packedNormalMap&&o.enable(22),t.vertexNormals&&o.enable(23),e.push(o.mask),o.disableAll(),t.fog&&o.enable(0),t.useFog&&o.enable(1),t.flatShading&&o.enable(2),t.logarithmicDepthBuffer&&o.enable(3),t.reversedDepthBuffer&&o.enable(4),t.skinning&&o.enable(5),t.morphTargets&&o.enable(6),t.morphNormals&&o.enable(7),t.morphColors&&o.enable(8),t.premultipliedAlpha&&o.enable(9),t.shadowMapEnabled&&o.enable(10),t.doubleSided&&o.enable(11),t.flipSided&&o.enable(12),t.useDepthPacking&&o.enable(13),t.dithering&&o.enable(14),t.transmission&&o.enable(15),t.sheen&&o.enable(16),t.opaque&&o.enable(17),t.pointsUvs&&o.enable(18),t.decodeVideoTexture&&o.enable(19),t.decodeVideoTextureEmissive&&o.enable(20),t.alphaToCoverage&&o.enable(21),t.numLightProbeGrids>0&&o.enable(22),t.hasPositionAttribute&&o.enable(23),e.push(o.mask)}function y(e){let t=p[e.type],n;if(t){let e=gS[t];n=Tb.clone(e.uniforms)}else n=e.uniforms;return n}function b(t,n){let r=u.get(n);return r===void 0?(r=new Ww(e,n,t,i),l.push(r),u.set(n,r)):++r.usedTimes,r}function x(e){if(--e.usedTimes===0){let t=l.indexOf(e);l[t]=l[l.length-1],l.pop(),u.delete(e.cacheKey),e.destroy()}}function S(e){s.remove(e)}function C(){s.dispose()}return{getParameters:h,getProgramCacheKey:g,getUniforms:y,acquireProgram:b,releaseProgram:x,releaseShaderCache:S,programs:l,dispose:C}}function Xw(){let e=new WeakMap;function t(t){return e.has(t)}function n(t){let n=e.get(t);return n===void 0&&(n={},e.set(t,n)),n}function r(t){e.delete(t)}function i(t,n,r){e.get(t)[n]=r}function a(){e=new WeakMap}return{has:t,get:n,remove:r,update:i,dispose:a}}function Zw(e,t){return e.groupOrder===t.groupOrder?e.renderOrder===t.renderOrder?e.material.id===t.material.id?e.materialVariant===t.materialVariant?e.z===t.z?e.id-t.id:e.z-t.z:e.materialVariant-t.materialVariant:e.material.id-t.material.id:e.renderOrder-t.renderOrder:e.groupOrder-t.groupOrder}function Qw(e,t){return e.groupOrder===t.groupOrder?e.renderOrder===t.renderOrder?e.z===t.z?e.id-t.id:t.z-e.z:e.renderOrder-t.renderOrder:e.groupOrder-t.groupOrder}function $w(){let e=[],t=0,n=[],r=[],i=[];function a(){t=0,n.length=0,r.length=0,i.length=0}function o(e){let t=0;return e.isInstancedMesh&&(t+=2),e.isSkinnedMesh&&(t+=1),t}function s(n,r,i,a,s,c){let l=e[t];return l===void 0?(l={id:n.id,object:n,geometry:r,material:i,materialVariant:o(n),groupOrder:a,renderOrder:n.renderOrder,z:s,group:c},e[t]=l):(l.id=n.id,l.object=n,l.geometry=r,l.material=i,l.materialVariant=o(n),l.groupOrder=a,l.renderOrder=n.renderOrder,l.z=s,l.group=c),t++,l}function c(e,t,a,o,c,l,u){u.reversedDepth===!0&&(c=-c);let d=s(e,t,a,o,c,l);a.transmission>0?r.push(d):a.transparent===!0?i.push(d):n.push(d)}function l(e,t,a,o,c,l){let u=s(e,t,a,o,c,l);a.transmission>0?r.unshift(u):a.transparent===!0?i.unshift(u):n.unshift(u)}function u(e,t){n.length>1&&n.sort(e||Zw),r.length>1&&r.sort(t||Qw),i.length>1&&i.sort(t||Qw)}function d(){for(let n=t,r=e.length;n=r.length?(i=new $w,r.push(i)):i=r[n],i}function n(){e=new WeakMap}return{get:t,dispose:n}}function tT(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case`SunLight`:case`DirectionalLight`:n={direction:new q,color:new J};break;case`SpotLight`:n={position:new q,direction:new q,color:new J,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case`PointLight`:n={position:new q,color:new J,distance:0,decay:0};break;case`HemisphereLight`:n={direction:new q,skyColor:new J,groundColor:new J};break;case`RectAreaLight`:n={color:new J,position:new q,halfWidth:new q,halfHeight:new q}}return e[t.id]=n,n}}}function nT(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case`SunLight`:case`DirectionalLight`:n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new K};break;case`SpotLight`:n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new K};break;case`PointLight`:n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new K,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=n,n}}}var rT=0;function iT(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+ +!!t.map-!!e.map}function aT(e){let t=new tT,n=nT(),r={version:0,hash:{sunLength:-1,directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numSunShadows:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],sun:[],sunShadow:[],sunShadowMap:[],sunShadowMatrix:[],sunShadowCascade:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let e=0;e<9;e++)r.probe.push(new q);let i=new q,a=new Dg,o=new Dg;function s(i){let a=0,o=0,s=0;for(let e=0;e<9;e++)r.probe[e].set(0,0,0);let c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0;i.sort(iT);for(let e=0,S=i.length;e0&&(e.has(`OES_texture_float_linear`)===!0?(r.rectAreaLTC1=X.LTC_FLOAT_1,r.rectAreaLTC2=X.LTC_FLOAT_2):(r.rectAreaLTC1=X.LTC_HALF_1,r.rectAreaLTC2=X.LTC_HALF_2)),r.ambient[0]=a,r.ambient[1]=o,r.ambient[2]=s;let S=r.hash;(S.sunLength!==c||S.directionalLength!==d||S.pointLength!==f||S.spotLength!==p||S.rectAreaLength!==m||S.hemiLength!==h||S.numSunShadows!==l||S.numDirectionalShadows!==g||S.numPointShadows!==_||S.numSpotShadows!==v||S.numSpotMaps!==y||S.numLightProbes!==x)&&(r.sun.length=c,r.directional.length=d,r.spot.length=p,r.rectArea.length=m,r.point.length=f,r.hemi.length=h,r.sunShadow.length=l,r.sunShadowMap.length=l,r.sunShadowMatrix.length=u,r.sunShadowCascade.length=u,r.directionalShadow.length=g,r.directionalShadowMap.length=g,r.directionalShadowMatrix.length=g,r.pointShadow.length=_,r.pointShadowMap.length=_,r.pointShadowMatrix.length=_,r.spotShadow.length=v,r.spotShadowMap.length=v,r.spotLightMatrix.length=v+y-b,r.spotLightMap.length=y,r.numSpotLightShadowsWithMaps=b,r.numLightProbes=x,S.sunLength=c,S.directionalLength=d,S.pointLength=f,S.spotLength=p,S.rectAreaLength=m,S.hemiLength=h,S.numSunShadows=l,S.numDirectionalShadows=g,S.numPointShadows=_,S.numSpotShadows=v,S.numSpotMaps=y,S.numLightProbes=x,r.version=rT++)}function c(e,t){let n=0,s=0,c=0,l=0,u=0,d=0,f=t.matrixWorldInverse;for(let t=0,p=e.length;t=i.length?(a=new oT(e),i.push(a)):a=i[r],a}function r(){t=new WeakMap}return{get:n,dispose:r}}var cT=`void main() { +`+n)}}else o===``?(s===``||c===``)&&(u=!1):za(`WebGLProgram: Program Info Log:`,o);u&&(t.diagnostics={runnable:l,programLog:o,vertexShader:{log:s,prefix:g},fragmentShader:{log:c,prefix:_}})}i.deleteShader(x),i.deleteShader(S),w=new Tm(i,h),T=Bm(i,h)}let w;this.getUniforms=function(){return w===void 0&&C(this),w};let T;this.getAttributes=function(){return T===void 0&&C(this),T};let E=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return E===!1&&(E=i.getProgramParameter(h,Dm)),E},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(h),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=Om++,this.cacheKey=t,this.usedTimes=1,this.program=h,this.vertexShader=x,this.fragmentShader=S,this}var ch=0,lh=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){let r=this._getShaderCacheForMaterial(e);return r.has(t)===!1&&(r.add(t),t.usedTimes++),r.has(n)===!1&&(r.add(n),n.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let e of t)e.usedTimes--,e.usedTimes===0&&this.shaderCache.delete(e.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);return n===void 0&&(n=new uh(e),t.set(e,n)),n}},uh=class{constructor(e){this.id=ch++,this.code=e,this.usedTimes=0}};function dh(e){return e===1030||e===37490||e===36285}function fh(e,t,n,r,i,a){let o=new $o,s=new lh,c=new Set,l=[],u=new Map,d=r.logarithmicDepthBuffer,f=r.precision,p={MeshDepthMaterial:`depth`,MeshDistanceMaterial:`distance`,MeshNormalMaterial:`normal`,MeshBasicMaterial:`basic`,MeshLambertMaterial:`lambert`,MeshPhongMaterial:`phong`,MeshToonMaterial:`toon`,MeshStandardMaterial:`physical`,MeshPhysicalMaterial:`physical`,MeshMatcapMaterial:`matcap`,LineBasicMaterial:`basic`,LineDashedMaterial:`dashed`,PointsMaterial:`points`,ShadowMaterial:`shadow`,SpriteMaterial:`sprite`};function m(e){return c.add(e),e===0?`uv`:`uv${e}`}function h(i,o,l,u,h,g){let _=u.fog,v=h.geometry,y=i.isMeshStandardMaterial||i.isMeshLambertMaterial||i.isMeshPhongMaterial?u.environment:null,b=i.isMeshStandardMaterial||i.isMeshLambertMaterial&&!i.envMap||i.isMeshPhongMaterial&&!i.envMap,x=t.get(i.envMap||y,b),S=x&&x.mapping===306?x.image.height:null,C=p[i.type];i.precision!==null&&(f=r.getMaxPrecision(i.precision),f!==i.precision&&za(`WebGLProgram.getParameters:`,i.precision,`not supported, using`,f,`instead.`));let w=v.morphAttributes.position||v.morphAttributes.normal||v.morphAttributes.color,T=w===void 0?0:w.length,E=0;v.morphAttributes.position!==void 0&&(E=1),v.morphAttributes.normal!==void 0&&(E=2),v.morphAttributes.color!==void 0&&(E=3);let D,O,k,A;if(C){let e=Nf[C];D=e.vertexShader,O=e.fragmentShader}else{D=i.vertexShader,O=i.fragmentShader;let e=s.getVertexShaderStage(i),t=s.getFragmentShaderStage(i);s.update(i,e,t),k=e.id,A=t.id}let j=e.getRenderTarget(),ee=e.state.buffers.depth.getReversed(),M=h.isInstancedMesh===!0,te=h.isBatchedMesh===!0,ne=!!i.map,re=!!i.matcap,ie=!!x,ae=!!i.aoMap,oe=!!i.lightMap,se=!!i.bumpMap&&i.wireframe===!1,ce=!!i.normalMap,le=!!i.displacementMap,ue=!!i.emissiveMap,de=!!i.metalnessMap,fe=!!i.roughnessMap,pe=i.anisotropy>0,me=i.clearcoat>0,he=i.dispersion>0,ge=i.retroreflectivity>0,_e=i.iridescence>0,ve=i.sheen>0,ye=i.transmission>0,be=pe&&!!i.anisotropyMap,xe=me&&!!i.clearcoatMap,Se=me&&!!i.clearcoatNormalMap,Ce=me&&!!i.clearcoatRoughnessMap,we=_e&&!!i.iridescenceMap,N=_e&&!!i.iridescenceThicknessMap,Te=ve&&!!i.sheenColorMap,Ee=ve&&!!i.sheenRoughnessMap,P=!!i.specularMap,F=!!i.specularColorMap,De=!!i.specularIntensityMap,Oe=ye&&!!i.transmissionMap,ke=ye&&!!i.thicknessMap,Ae=!!i.gradientMap,je=!!i.alphaMap,Me=i.alphaTest>0,Ne=!!i.alphaHash,Pe=!!i.extensions,Fe=0;i.toneMapped&&(j===null||j.isXRRenderTarget===!0)&&(Fe=e.toneMapping);let Ie={shaderID:C,shaderType:i.type,shaderName:i.name,vertexShader:D,fragmentShader:O,defines:i.defines,customVertexShaderID:k,customFragmentShaderID:A,isRawShaderMaterial:i.isRawShaderMaterial===!0,glslVersion:i.glslVersion,precision:f,batching:te,batchingColor:te&&h._colorsTexture!==null,instancing:M,instancingColor:M&&h.instanceColor!==null,instancingMorph:M&&h.morphTexture!==null,outputColorSpace:j===null?e.outputColorSpace:j.isXRRenderTarget===!0?j.texture.colorSpace:Eo.workingColorSpace,alphaToCoverage:!!i.alphaToCoverage,map:ne,matcap:re,envMap:ie,envMapMode:ie&&x.mapping,envMapCubeUVHeight:S,aoMap:ae,lightMap:oe,bumpMap:se,normalMap:ce,displacementMap:le,emissiveMap:ue,normalMapObjectSpace:ce&&i.normalMapType===1,normalMapTangentSpace:ce&&i.normalMapType===0,packedNormalMap:ce&&i.normalMapType===0&&dh(i.normalMap.format),metalnessMap:de,roughnessMap:fe,anisotropy:pe,anisotropyMap:be,clearcoat:me,clearcoatMap:xe,clearcoatNormalMap:Se,clearcoatRoughnessMap:Ce,dispersion:he,retroreflection:ge,iridescence:_e,iridescenceMap:we,iridescenceThicknessMap:N,sheen:ve,sheenColorMap:Te,sheenRoughnessMap:Ee,specularMap:P,specularColorMap:F,specularIntensityMap:De,transmission:ye,transmissionMap:Oe,thicknessMap:ke,gradientMap:Ae,opaque:i.transparent===!1&&i.blending===1&&i.alphaToCoverage===!1,alphaMap:je,alphaTest:Me,alphaHash:Ne,combine:i.combine,mapUv:ne&&m(i.map.channel),aoMapUv:ae&&m(i.aoMap.channel),lightMapUv:oe&&m(i.lightMap.channel),bumpMapUv:se&&m(i.bumpMap.channel),normalMapUv:ce&&m(i.normalMap.channel),displacementMapUv:le&&m(i.displacementMap.channel),emissiveMapUv:ue&&m(i.emissiveMap.channel),metalnessMapUv:de&&m(i.metalnessMap.channel),roughnessMapUv:fe&&m(i.roughnessMap.channel),anisotropyMapUv:be&&m(i.anisotropyMap.channel),clearcoatMapUv:xe&&m(i.clearcoatMap.channel),clearcoatNormalMapUv:Se&&m(i.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ce&&m(i.clearcoatRoughnessMap.channel),iridescenceMapUv:we&&m(i.iridescenceMap.channel),iridescenceThicknessMapUv:N&&m(i.iridescenceThicknessMap.channel),sheenColorMapUv:Te&&m(i.sheenColorMap.channel),sheenRoughnessMapUv:Ee&&m(i.sheenRoughnessMap.channel),specularMapUv:P&&m(i.specularMap.channel),specularColorMapUv:F&&m(i.specularColorMap.channel),specularIntensityMapUv:De&&m(i.specularIntensityMap.channel),transmissionMapUv:Oe&&m(i.transmissionMap.channel),thicknessMapUv:ke&&m(i.thicknessMap.channel),alphaMapUv:je&&m(i.alphaMap.channel),vertexTangents:!!v.attributes.tangent&&(ce||pe),vertexNormals:!!v.attributes.normal,vertexColors:i.vertexColors,vertexAlphas:i.vertexColors===!0&&!!v.attributes.color&&v.attributes.color.itemSize===4,pointsUvs:h.isPoints===!0&&!!v.attributes.uv&&(ne||je),fog:!!_,useFog:i.fog===!0,fogExp2:!!_&&_.isFogExp2,flatShading:i.wireframe===!1&&(i.flatShading===!0||v.attributes.normal===void 0&&ce===!1&&(i.isMeshLambertMaterial||i.isMeshPhongMaterial||i.isMeshStandardMaterial||i.isMeshPhysicalMaterial)),sizeAttenuation:i.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:ee,skinning:h.isSkinnedMesh===!0,hasPositionAttribute:v.attributes.position!==void 0,morphTargets:v.morphAttributes.position!==void 0,morphNormals:v.morphAttributes.normal!==void 0,morphColors:v.morphAttributes.color!==void 0,morphTargetsCount:T,morphTextureStride:E,numSunLights:o.sun.length,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numSunLightShadows:o.sunShadowMap.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numLightProbes:o.numLightProbes,numLightProbeGrids:g.length,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:i.dithering,shadowMapEnabled:e.shadowMap.enabled&&l.length>0,shadowMapType:e.shadowMap.type,toneMapping:Fe,decodeVideoTexture:ne&&i.map.isVideoTexture===!0&&Eo.getTransfer(i.map.colorSpace)===`srgb`,decodeVideoTextureEmissive:ue&&i.emissiveMap.isVideoTexture===!0&&Eo.getTransfer(i.emissiveMap.colorSpace)===`srgb`,premultipliedAlpha:i.premultipliedAlpha,doubleSided:i.side===2,flipSided:i.side===1,useDepthPacking:i.depthPacking>=0,depthPacking:i.depthPacking||0,index0AttributeName:i.index0AttributeName,extensionClipCullDistance:Pe&&i.extensions.clipCullDistance===!0&&n.has(`WEBGL_clip_cull_distance`),extensionMultiDraw:(Pe&&i.extensions.multiDraw===!0||te)&&n.has(`WEBGL_multi_draw`),rendererExtensionParallelShaderCompile:n.has(`KHR_parallel_shader_compile`),customProgramCacheKey:i.customProgramCacheKey()};return Ie.vertexUv1s=c.has(1),Ie.vertexUv2s=c.has(2),Ie.vertexUv3s=c.has(3),c.clear(),Ie}function g(t){let n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),t.defines!==void 0)for(let e in t.defines)n.push(e),n.push(t.defines[e]);return t.isRawShaderMaterial===!1&&(_(n,t),v(n,t),n.push(e.outputColorSpace)),n.push(t.customProgramCacheKey),n.join()}function _(e,t){e.push(t.precision),e.push(t.outputColorSpace),e.push(t.envMapMode),e.push(t.envMapCubeUVHeight),e.push(t.mapUv),e.push(t.alphaMapUv),e.push(t.lightMapUv),e.push(t.aoMapUv),e.push(t.bumpMapUv),e.push(t.normalMapUv),e.push(t.displacementMapUv),e.push(t.emissiveMapUv),e.push(t.metalnessMapUv),e.push(t.roughnessMapUv),e.push(t.anisotropyMapUv),e.push(t.clearcoatMapUv),e.push(t.clearcoatNormalMapUv),e.push(t.clearcoatRoughnessMapUv),e.push(t.iridescenceMapUv),e.push(t.iridescenceThicknessMapUv),e.push(t.sheenColorMapUv),e.push(t.sheenRoughnessMapUv),e.push(t.specularMapUv),e.push(t.specularColorMapUv),e.push(t.specularIntensityMapUv),e.push(t.transmissionMapUv),e.push(t.thicknessMapUv),e.push(t.combine),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.morphAttributeCount),e.push(t.numSunLights),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numSpotLightMaps),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numSunLightShadows),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.numLightProbes),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}function v(e,t){o.disableAll(),t.instancing&&o.enable(0),t.instancingColor&&o.enable(1),t.instancingMorph&&o.enable(2),t.matcap&&o.enable(3),t.envMap&&o.enable(4),t.normalMapObjectSpace&&o.enable(5),t.normalMapTangentSpace&&o.enable(6),t.clearcoat&&o.enable(7),t.iridescence&&o.enable(8),t.alphaTest&&o.enable(9),t.vertexColors&&o.enable(10),t.vertexAlphas&&o.enable(11),t.vertexUv1s&&o.enable(12),t.vertexUv2s&&o.enable(13),t.vertexUv3s&&o.enable(14),t.vertexTangents&&o.enable(15),t.anisotropy&&o.enable(16),t.alphaHash&&o.enable(17),t.batching&&o.enable(18),t.dispersion&&o.enable(19),t.retroreflection&&o.enable(24),t.batchingColor&&o.enable(20),t.gradientMap&&o.enable(21),t.packedNormalMap&&o.enable(22),t.vertexNormals&&o.enable(23),e.push(o.mask),o.disableAll(),t.fog&&o.enable(0),t.useFog&&o.enable(1),t.flatShading&&o.enable(2),t.logarithmicDepthBuffer&&o.enable(3),t.reversedDepthBuffer&&o.enable(4),t.skinning&&o.enable(5),t.morphTargets&&o.enable(6),t.morphNormals&&o.enable(7),t.morphColors&&o.enable(8),t.premultipliedAlpha&&o.enable(9),t.shadowMapEnabled&&o.enable(10),t.doubleSided&&o.enable(11),t.flipSided&&o.enable(12),t.useDepthPacking&&o.enable(13),t.dithering&&o.enable(14),t.transmission&&o.enable(15),t.sheen&&o.enable(16),t.opaque&&o.enable(17),t.pointsUvs&&o.enable(18),t.decodeVideoTexture&&o.enable(19),t.decodeVideoTextureEmissive&&o.enable(20),t.alphaToCoverage&&o.enable(21),t.numLightProbeGrids>0&&o.enable(22),t.hasPositionAttribute&&o.enable(23),e.push(o.mask)}function y(e){let t=p[e.type],n;if(t){let e=Nf[t];n=Vu.clone(e.uniforms)}else n=e.uniforms;return n}function b(t,n){let r=u.get(n);return r===void 0?(r=new sh(e,n,t,i),l.push(r),u.set(n,r)):++r.usedTimes,r}function x(e){if(--e.usedTimes===0){let t=l.indexOf(e);l[t]=l[l.length-1],l.pop(),u.delete(e.cacheKey),e.destroy()}}function S(e){s.remove(e)}function C(){s.dispose()}return{getParameters:h,getProgramCacheKey:g,getUniforms:y,acquireProgram:b,releaseProgram:x,releaseShaderCache:S,programs:l,dispose:C}}function ph(){let e=new WeakMap;function t(t){return e.has(t)}function n(t){let n=e.get(t);return n===void 0&&(n={},e.set(t,n)),n}function r(t){e.delete(t)}function i(t,n,r){e.get(t)[n]=r}function a(){e=new WeakMap}return{has:t,get:n,remove:r,update:i,dispose:a}}function mh(e,t){return e.groupOrder===t.groupOrder?e.renderOrder===t.renderOrder?e.material.id===t.material.id?e.materialVariant===t.materialVariant?e.z===t.z?e.id-t.id:e.z-t.z:e.materialVariant-t.materialVariant:e.material.id-t.material.id:e.renderOrder-t.renderOrder:e.groupOrder-t.groupOrder}function hh(e,t){return e.groupOrder===t.groupOrder?e.renderOrder===t.renderOrder?e.z===t.z?e.id-t.id:t.z-e.z:e.renderOrder-t.renderOrder:e.groupOrder-t.groupOrder}function gh(){let e=[],t=0,n=[],r=[],i=[];function a(){t=0,n.length=0,r.length=0,i.length=0}function o(e){let t=0;return e.isInstancedMesh&&(t+=2),e.isSkinnedMesh&&(t+=1),t}function s(n,r,i,a,s,c){let l=e[t];return l===void 0?(l={id:n.id,object:n,geometry:r,material:i,materialVariant:o(n),groupOrder:a,renderOrder:n.renderOrder,z:s,group:c},e[t]=l):(l.id=n.id,l.object=n,l.geometry=r,l.material=i,l.materialVariant=o(n),l.groupOrder=a,l.renderOrder=n.renderOrder,l.z=s,l.group=c),t++,l}function c(e,t,a,o,c,l,u){u.reversedDepth===!0&&(c=-c);let d=s(e,t,a,o,c,l);a.transmission>0?r.push(d):a.transparent===!0?i.push(d):n.push(d)}function l(e,t,a,o,c,l){let u=s(e,t,a,o,c,l);a.transmission>0?r.unshift(u):a.transparent===!0?i.unshift(u):n.unshift(u)}function u(e,t){n.length>1&&n.sort(e||mh),r.length>1&&r.sort(t||hh),i.length>1&&i.sort(t||hh)}function d(){for(let n=t,r=e.length;n=r.length?(i=new gh,r.push(i)):i=r[n],i}function n(){e=new WeakMap}return{get:t,dispose:n}}function vh(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case`SunLight`:case`DirectionalLight`:n={direction:new z,color:new B};break;case`SpotLight`:n={position:new z,direction:new z,color:new B,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case`PointLight`:n={position:new z,color:new B,distance:0,decay:0};break;case`HemisphereLight`:n={direction:new z,skyColor:new B,groundColor:new B};break;case`RectAreaLight`:n={color:new B,position:new z,halfWidth:new z,halfHeight:new z}}return e[t.id]=n,n}}}function yh(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case`SunLight`:case`DirectionalLight`:n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new R};break;case`SpotLight`:n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new R};break;case`PointLight`:n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new R,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=n,n}}}var bh=0;function xh(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+ +!!t.map-!!e.map}function Sh(e){let t=new vh,n=yh(),r={version:0,hash:{sunLength:-1,directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numSunShadows:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],sun:[],sunShadow:[],sunShadowMap:[],sunShadowMatrix:[],sunShadowCascade:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let e=0;e<9;e++)r.probe.push(new z);let i=new z,a=new Ho,o=new Ho;function s(i){let a=0,o=0,s=0;for(let e=0;e<9;e++)r.probe[e].set(0,0,0);let c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0;i.sort(xh);for(let e=0,S=i.length;e0&&(e.has(`OES_texture_float_linear`)===!0?(r.rectAreaLTC1=H.LTC_FLOAT_1,r.rectAreaLTC2=H.LTC_FLOAT_2):(r.rectAreaLTC1=H.LTC_HALF_1,r.rectAreaLTC2=H.LTC_HALF_2)),r.ambient[0]=a,r.ambient[1]=o,r.ambient[2]=s;let S=r.hash;(S.sunLength!==c||S.directionalLength!==d||S.pointLength!==f||S.spotLength!==p||S.rectAreaLength!==m||S.hemiLength!==h||S.numSunShadows!==l||S.numDirectionalShadows!==g||S.numPointShadows!==_||S.numSpotShadows!==v||S.numSpotMaps!==y||S.numLightProbes!==x)&&(r.sun.length=c,r.directional.length=d,r.spot.length=p,r.rectArea.length=m,r.point.length=f,r.hemi.length=h,r.sunShadow.length=l,r.sunShadowMap.length=l,r.sunShadowMatrix.length=u,r.sunShadowCascade.length=u,r.directionalShadow.length=g,r.directionalShadowMap.length=g,r.directionalShadowMatrix.length=g,r.pointShadow.length=_,r.pointShadowMap.length=_,r.pointShadowMatrix.length=_,r.spotShadow.length=v,r.spotShadowMap.length=v,r.spotLightMatrix.length=v+y-b,r.spotLightMap.length=y,r.numSpotLightShadowsWithMaps=b,r.numLightProbes=x,S.sunLength=c,S.directionalLength=d,S.pointLength=f,S.spotLength=p,S.rectAreaLength=m,S.hemiLength=h,S.numSunShadows=l,S.numDirectionalShadows=g,S.numPointShadows=_,S.numSpotShadows=v,S.numSpotMaps=y,S.numLightProbes=x,r.version=bh++)}function c(e,t){let n=0,s=0,c=0,l=0,u=0,d=0,f=t.matrixWorldInverse;for(let t=0,p=e.length;t=i.length?(a=new Ch(e),i.push(a)):a=i[r],a}function r(){t=new WeakMap}return{get:n,dispose:r}}var Th=`void main() { gl_Position = vec4( position, 1.0 ); -}`,lT=`uniform sampler2D shadow_pass; +}`,Eh=`uniform sampler2D shadow_pass; uniform vec2 resolution; uniform float radius; void main() { @@ -4203,12 +4193,12 @@ void main() { squared_mean = squared_mean / samples; float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) ); gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 ); -}`,uT=[new q(1,0,0),new q(-1,0,0),new q(0,1,0),new q(0,-1,0),new q(0,0,1),new q(0,0,-1)],dT=[new q(0,-1,0),new q(0,-1,0),new q(0,0,1),new q(0,0,-1),new q(0,-1,0),new q(0,-1,0)],fT=new Dg,pT=new q,mT=new q;function hT(e,t,n){let r=new oy,i=new K,a=new K,o=new Sg,s=new Mb,c=new Nb,l={},u=n.maxTextureSize,d={0:1,1:0,2:2},f=new Ob({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new K},radius:{value:4}},vertexShader:cT,fragmentShader:lT}),p=f.clone();p.defines.HORIZONTAL_PASS=1;let m=new iv;m.setAttribute(`position`,new U_(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let h=new Y(m,f),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let _=this.type;this.render=function(t,n,s){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||t.length===0)return;this.type===2&&(Th(`WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead.`),this.type=1);let c=e.getRenderTarget(),l=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),f=e.state;f.setBlending(0),f.buffers.depth.getReversed()===!0?f.buffers.color.setClear(0,0,0,0):f.buffers.color.setClear(1,1,1,1),f.buffers.depth.setTest(!0),f.setScissorTest(!1);let p=_!==this.type;p&&n.traverse(function(e){e.material&&(Array.isArray(e.material)?e.material.forEach(e=>e.needsUpdate=!0):e.material.needsUpdate=!0)});for(let c=0,l=t.length;cu||i.y>u)&&(i.x>u&&(a.x=Math.floor(u/m.x),i.x=a.x*m.x,d.mapSize.x=a.x),i.y>u&&(a.y=Math.floor(u/m.y),i.y=a.y*m.y,d.mapSize.y=a.y));let h=e.state.buffers.depth.getReversed();if(d.camera._reversedDepth=h,d.map===null||p===!0){if(d.map!==null&&(d.map.depthTexture!==null&&(d.map.depthTexture.dispose(),d.map.depthTexture=null),d.map.dispose()),this.type===3){if(l.isPointLight){Th(`WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.`);continue}d.map=new wg(i.x,i.y,{format:gm,type:rm,minFilter:qp,magFilter:qp,generateMipmaps:!1}),d.map.texture.name=l.name+`.shadowMap`,d.map.depthTexture=new Ay(i.x,i.y,nm),d.map.depthTexture.name=l.name+`.shadowMapDepth`,d.map.depthTexture.format=fm,d.map.depthTexture.compareFunction=null,d.map.depthTexture.minFilter=Wp,d.map.depthTexture.magFilter=Wp}else l.isPointLight?(d.map=new KS(i.x),d.map.depthTexture=new jy(i.x,tm)):(d.map=new wg(i.x,i.y),d.map.depthTexture=new Ay(i.x,i.y,tm)),d.map.depthTexture.name=l.name+`.shadowMap`,d.map.depthTexture.format=fm,this.type===1?(d.map.depthTexture.compareFunction=h?518:515,d.map.depthTexture.minFilter=qp,d.map.depthTexture.magFilter=qp):(d.map.depthTexture.compareFunction=null,d.map.depthTexture.minFilter=Wp,d.map.depthTexture.magFilter=Wp);d.camera.updateProjectionMatrix()}d.map.isWebGLCubeRenderTarget!==!0&&(d.map.width!==i.x||d.map.height!==i.y)&&d.map.setSize(i.x,i.y);let g=d.map.isWebGLCubeRenderTarget?6:d.getViewportCount();l.isPointLight!==!0&&d.updateMatrices(l,s);for(let t=0;t0||n.map&&n.alphaTest>0||n.alphaToCoverage===!0){let e=a.uuid,t=n.uuid,r=l[e];r===void 0&&(r={},l[e]=r);let i=r[t];i===void 0&&(i=a.clone(),r[t]=i,n.addEventListener(`dispose`,x)),a=i}if(a.visible=n.visible,a.wireframe=n.wireframe,i===3?a.side=n.shadowSide===null?n.side:n.shadowSide:a.side=n.shadowSide===null?d[n.side]:n.shadowSide,a.alphaMap=n.alphaMap,a.alphaTest=n.alphaToCoverage===!0?.5:n.alphaTest,a.map=n.map,a.clipShadows=n.clipShadows,a.clippingPlanes=n.clippingPlanes,a.clipIntersection=n.clipIntersection,a.displacementMap=n.displacementMap,a.displacementScale=n.displacementScale,a.displacementBias=n.displacementBias,a.wireframeLinewidth=n.wireframeLinewidth,a.linewidth=n.linewidth,r.isPointLight===!0&&a.isMeshDistanceMaterial===!0){let t=e.properties.get(a);t.light=r}return a}function b(n,i,a,o,s){if(n.visible===!1)return;if(n.layers.test(i.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&s===3)&&(!n.frustumCulled||n.intersectsFrustum(r))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);let r=t.update(n),c=n.material;if(Array.isArray(c)){let t=r.groups;for(let l=0,u=t.length;l=2):(te=parseFloat(/^WebGL (\d)/.exec(ne)[1]),M=te>=1);let re=null,ie={},N=e.getParameter(e.SCISSOR_BOX),ae=e.getParameter(e.VIEWPORT),oe=new Sg().fromArray(N),se=new Sg().fromArray(ae);function ce(t,n,r,i){let a=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let o=0;o`u`?!1:/OculusBrowser/g.test(navigator.userAgent),l=new K,u=new WeakMap,d=new Set,f,p=new WeakMap,m=!1;try{m=typeof OffscreenCanvas<`u`&&new OffscreenCanvas(1,1).getContext(`2d`)!==null}catch{}function h(e,t){return m?new OffscreenCanvas(e,t):bh(`canvas`)}function g(e,t,n){let r=1,i=Te(e);if((i.width>n||i.height>n)&&(r=n/Math.max(i.width,i.height)),r<1){if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap||typeof VideoFrame<`u`&&e instanceof VideoFrame){let n=Math.floor(r*i.width),a=Math.floor(r*i.height);f===void 0&&(f=h(n,a));let o=t?h(n,a):f;return o.width=n,o.height=a,o.getContext(`2d`).drawImage(e,0,0,n,a),Th(`WebGLRenderer: Texture has been resized from (`+i.width+`x`+i.height+`) to (`+n+`x`+a+`).`),o}return`data`in e&&Th(`WebGLRenderer: Image in DataTexture is too big (`+i.width+`x`+i.height+`).`),e}return e}function _(e){return e.generateMipmaps}function v(t){e.generateMipmap(t)}function y(t){return t.isWebGLCubeRenderTarget?e.TEXTURE_CUBE_MAP:t.isWebGL3DRenderTarget?e.TEXTURE_3D:t.isWebGLArrayRenderTarget||t.isCompressedArrayTexture?e.TEXTURE_2D_ARRAY:e.TEXTURE_2D}function b(n,r,i,a,o,s=!1){if(n!==null){if(e[n]!==void 0)return e[n];Th(`WebGLRenderer: Attempt to use non-existing WebGL internal format '`+n+`'`)}let c;a&&(c=t.get(`EXT_texture_norm16`),c||Th(`WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension`));let l=r;if(r===e.RED&&(i===e.FLOAT&&(l=e.R32F),i===e.HALF_FLOAT&&(l=e.R16F),i===e.UNSIGNED_BYTE&&(l=e.R8),i===e.UNSIGNED_SHORT&&c&&(l=c.R16_EXT),i===e.SHORT&&c&&(l=c.R16_SNORM_EXT)),r===e.RED_INTEGER&&(i===e.UNSIGNED_BYTE&&(l=e.R8UI),i===e.UNSIGNED_SHORT&&(l=e.R16UI),i===e.UNSIGNED_INT&&(l=e.R32UI),i===e.BYTE&&(l=e.R8I),i===e.SHORT&&(l=e.R16I),i===e.INT&&(l=e.R32I)),r===e.RG&&(i===e.FLOAT&&(l=e.RG32F),i===e.HALF_FLOAT&&(l=e.RG16F),i===e.UNSIGNED_BYTE&&(l=e.RG8),i===e.UNSIGNED_SHORT&&c&&(l=c.RG16_EXT),i===e.SHORT&&c&&(l=c.RG16_SNORM_EXT)),r===e.RG_INTEGER&&(i===e.UNSIGNED_BYTE&&(l=e.RG8UI),i===e.UNSIGNED_SHORT&&(l=e.RG16UI),i===e.UNSIGNED_INT&&(l=e.RG32UI),i===e.BYTE&&(l=e.RG8I),i===e.SHORT&&(l=e.RG16I),i===e.INT&&(l=e.RG32I)),r===e.RGB_INTEGER&&(i===e.UNSIGNED_BYTE&&(l=e.RGB8UI),i===e.UNSIGNED_SHORT&&(l=e.RGB16UI),i===e.UNSIGNED_INT&&(l=e.RGB32UI),i===e.BYTE&&(l=e.RGB8I),i===e.SHORT&&(l=e.RGB16I),i===e.INT&&(l=e.RGB32I)),r===e.RGBA_INTEGER&&(i===e.UNSIGNED_BYTE&&(l=e.RGBA8UI),i===e.UNSIGNED_SHORT&&(l=e.RGBA16UI),i===e.UNSIGNED_INT&&(l=e.RGBA32UI),i===e.BYTE&&(l=e.RGBA8I),i===e.SHORT&&(l=e.RGBA16I),i===e.INT&&(l=e.RGBA32I)),r===e.RGB&&(i===e.UNSIGNED_SHORT&&c&&(l=c.RGB16_EXT),i===e.SHORT&&c&&(l=c.RGB16_SNORM_EXT),i===e.UNSIGNED_INT_5_9_9_9_REV&&(l=e.RGB9_E5),i===e.UNSIGNED_INT_10F_11F_11F_REV&&(l=e.R11F_G11F_B10F)),r===e.RGBA){let t=s?fh:dg.getTransfer(o);i===e.FLOAT&&(l=e.RGBA32F),i===e.HALF_FLOAT&&(l=e.RGBA16F),i===e.UNSIGNED_BYTE&&(l=t===`srgb`?e.SRGB8_ALPHA8:e.RGBA8),i===e.UNSIGNED_SHORT&&c&&(l=c.RGBA16_EXT),i===e.SHORT&&c&&(l=c.RGBA16_SNORM_EXT),i===e.UNSIGNED_SHORT_4_4_4_4&&(l=e.RGBA4),i===e.UNSIGNED_SHORT_5_5_5_1&&(l=e.RGB5_A1)}return(l===e.R16F||l===e.R32F||l===e.RG16F||l===e.RG32F||l===e.RGBA16F||l===e.RGBA32F)&&t.get(`EXT_color_buffer_float`),l}function x(t,n){let r;return t?n===null||n===1014||n===1020?r=e.DEPTH24_STENCIL8:n===1015?r=e.DEPTH32F_STENCIL8:n===1012&&(r=e.DEPTH24_STENCIL8,Th(`DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.`)):n===null||n===1014||n===1020?r=e.DEPTH_COMPONENT24:n===1015?r=e.DEPTH_COMPONENT32F:n===1012&&(r=e.DEPTH_COMPONENT16),r}function S(e,t){return _(e)===!0||e.isFramebufferTexture&&e.minFilter!==1003&&e.minFilter!==1006?Math.log2(Math.max(t.width,t.height))+1:e.mipmaps!==void 0&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function C(e){let t=e.target;t.removeEventListener(`dispose`,C),T(t),t.isVideoTexture&&u.delete(t),t.isHTMLTexture&&d.delete(t)}function w(e){let t=e.target;t.removeEventListener(`dispose`,w),D(t)}function T(e){let t=r.get(e);if(t.__webglInit===void 0)return;let n=e.source,i=p.get(n);if(i){let r=i[t.__cacheKey];r.usedTimes--,r.usedTimes===0&&E(e),Object.keys(i).length===0&&p.delete(n)}r.remove(e)}function E(t){let n=r.get(t);e.deleteTexture(n.__webglTexture);let i=t.source,a=p.get(i);delete a[n.__cacheKey],o.memory.textures--}function D(t){let n=r.get(t);if(t.depthTexture&&(t.depthTexture.dispose(),r.remove(t.depthTexture)),t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++){if(Array.isArray(n.__webglFramebuffer[t]))for(let r=0;r=i.maxTextures&&Th(`WebGLTextures: Trying to use `+(e+1)+` texture units while this GPU supports only `+i.maxTextures),O+=1,e}function M(e){let t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.wrapR||0),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.colorSpace),t.join()}function te(t,i){let a=r.get(t);if(t.isVideoTexture&&Ce(t),t.isRenderTargetTexture===!1&&t.isExternalTexture!==!0&&t.version>0&&a.__version!==t.version){let e=t.image;if(e===null)Th(`WebGLRenderer: Texture marked for update but no image data found.`);else if(e.complete===!1)Th(`WebGLRenderer: Texture marked for update but image is incomplete`);else{ue(a,t,i);return}}else t.isExternalTexture&&(a.__webglTexture=t.sourceTexture?t.sourceTexture:null);n.bindTexture(e.TEXTURE_2D,a.__webglTexture,e.TEXTURE0+i)}function ne(t,i){let a=r.get(t);t.isRenderTargetTexture===!1&&t.version>0&&a.__version!==t.version?ue(a,t,i):(t.isExternalTexture&&(a.__webglTexture=t.sourceTexture?t.sourceTexture:null),n.bindTexture(e.TEXTURE_2D_ARRAY,a.__webglTexture,e.TEXTURE0+i))}function re(t,i){let a=r.get(t);t.isRenderTargetTexture===!1&&t.version>0&&a.__version!==t.version?ue(a,t,i):n.bindTexture(e.TEXTURE_3D,a.__webglTexture,e.TEXTURE0+i)}function ie(t,i){let a=r.get(t);t.isCubeDepthTexture!==!0&&t.version>0&&a.__version!==t.version?de(a,t,i):n.bindTexture(e.TEXTURE_CUBE_MAP,a.__webglTexture,e.TEXTURE0+i)}let N={[Vp]:e.REPEAT,[Hp]:e.CLAMP_TO_EDGE,[Up]:e.MIRRORED_REPEAT},ae={[Wp]:e.NEAREST,[Gp]:e.NEAREST_MIPMAP_NEAREST,[Kp]:e.NEAREST_MIPMAP_LINEAR,[qp]:e.LINEAR,[Jp]:e.LINEAR_MIPMAP_NEAREST,[Yp]:e.LINEAR_MIPMAP_LINEAR},oe={512:e.NEVER,519:e.ALWAYS,513:e.LESS,515:e.LEQUAL,514:e.EQUAL,518:e.GEQUAL,516:e.GREATER,517:e.NOTEQUAL};function se(n,a){if(a.type===1015&&t.has(`OES_texture_float_linear`)===!1&&(a.magFilter===1006||a.magFilter===1007||a.magFilter===1005||a.magFilter===1008||a.minFilter===1006||a.minFilter===1007||a.minFilter===1005||a.minFilter===1008)&&Th(`WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.`),e.texParameteri(n,e.TEXTURE_WRAP_S,N[a.wrapS]),e.texParameteri(n,e.TEXTURE_WRAP_T,N[a.wrapT]),(n===e.TEXTURE_3D||n===e.TEXTURE_2D_ARRAY)&&e.texParameteri(n,e.TEXTURE_WRAP_R,N[a.wrapR]),e.texParameteri(n,e.TEXTURE_MAG_FILTER,ae[a.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,ae[a.minFilter]),a.compareFunction&&(e.texParameteri(n,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,oe[a.compareFunction])),t.has(`EXT_texture_filter_anisotropic`)===!0){if(a.magFilter===1003||a.minFilter!==1005&&a.minFilter!==1008||a.type===1015&&t.has(`OES_texture_float_linear`)===!1)return;if(a.anisotropy>1||r.get(a).__currentAnisotropy){let o=t.get(`EXT_texture_filter_anisotropic`);e.texParameterf(n,o.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,i.getMaxAnisotropy())),r.get(a).__currentAnisotropy=a.anisotropy}}}function ce(t,n){let r=!1;t.__webglInit===void 0&&(t.__webglInit=!0,n.addEventListener(`dispose`,C));let i=n.source,a=p.get(i);a===void 0&&(a={},p.set(i,a));let s=M(n);if(s!==t.__cacheKey){a[s]===void 0&&(a[s]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,r=!0),a[s].usedTimes++;let i=a[t.__cacheKey];i!==void 0&&(a[t.__cacheKey].usedTimes--,i.usedTimes===0&&E(n)),t.__cacheKey=s,t.__webglTexture=a[s].texture}return r}function le(e,t,n){return Math.floor(Math.floor(e/n)/t)}function P(t,r,i,a){let o=t.updateRanges;if(o.length===0)n.texSubImage2D(e.TEXTURE_2D,0,0,0,r.width,r.height,i,a,r.data);else{o.sort((e,t)=>e.start-t.start);let s=0;for(let e=1;e0){C&&w&&n.texStorage2D(e.TEXTURE_2D,E,m,y[0].width,y[0].height);for(let t=0,i=y.length;t0){let t=dS(h.width,h.height,o.format,o.type);for(let a of o.layerUpdates){let o=h.data.subarray(a*t/h.data.BYTES_PER_ELEMENT,(a+1)*t/h.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,i,0,0,a,h.width,h.height,1,r,o)}}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,i,0,0,0,h.width,h.height,t.depth,r,h.data)}}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,i,m,h.width,h.height,t.depth,0,h.data,0,0)}else Th(`WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()`)}else C?T&&n.texSubImage3D(e.TEXTURE_2D_ARRAY,i,0,0,0,h.width,h.height,t.depth,r,p,h.data):n.texImage3D(e.TEXTURE_2D_ARRAY,i,m,h.width,h.height,t.depth,0,r,p,h.data);o.layerUpdates.size>0&&o.clearLayerUpdates()}else{C&&w&&n.texStorage2D(e.TEXTURE_2D,E,m,y[0].width,y[0].height);for(let t=0,i=y.length;t0){let i=dS(t.width,t.height,o.format,o.type);for(let a of o.layerUpdates){let o=t.data.subarray(a*i/t.data.BYTES_PER_ELEMENT,(a+1)*i/t.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,a,t.width,t.height,1,r,p,o)}o.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,t.width,t.height,t.depth,r,p,t.data)}}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,m,t.width,t.height,t.depth,0,r,p,t.data)}else if(o.isData3DTexture)C?(w&&n.texStorage3D(e.TEXTURE_3D,E,m,t.width,t.height,t.depth),T&&n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,t.width,t.height,t.depth,r,p,t.data)):n.texImage3D(e.TEXTURE_3D,0,m,t.width,t.height,t.depth,0,r,p,t.data);else if(o.isFramebufferTexture){if(w){if(C)n.texStorage2D(e.TEXTURE_2D,E,m,t.width,t.height);else{let i=t.width,a=t.height;for(let t=0;t>=1,a>>=1}}}else if(o.isHTMLTexture){if(`texElementImage2D`in e){let n=e.canvas;if(n.hasAttribute(`layoutsubtree`)||n.setAttribute(`layoutsubtree`,`true`),t.parentNode!==n){n.appendChild(t),d.add(o),n.onpaint=e=>{let t=e.changedElements;for(let e of d)t.includes(e.image)&&(e.needsUpdate=!0)},n.requestPaint();return}if(e.texElementImage2D.length===3)e.texElementImage2D(e.TEXTURE_2D,e.RGBA8,t);else{let n=e.RGBA,r=e.RGBA,i=e.UNSIGNED_BYTE;e.texElementImage2D(e.TEXTURE_2D,0,n,r,i,t)}e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)}}else if(y.length>0){if(C&&w){let t=Te(y[0]);n.texStorage2D(e.TEXTURE_2D,E,m,t.width,t.height)}for(let t=0,i=y.length;t0&&D++;let t=Te(m[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,D,C,t.width,t.height)}for(let t=0;t<6;t++)if(p){w?E&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,m[t].width,m[t].height,y,x,m[t].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,C,m[t].width,m[t].height,0,y,x,m[t].data);for(let r=0;r>u),r=Math.max(1,i.height>>u);l===e.TEXTURE_3D||l===e.TEXTURE_2D_ARRAY?n.texImage3D(l,u,p,t,r,i.depth,0,d,f,null):n.texImage2D(l,u,p,t,r,0,d,f,null)}n.bindFramebuffer(e.FRAMEBUFFER,t),F(i)?s.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,c,l,h.__webglTexture,0,Se(i)):(l===e.TEXTURE_2D||l>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&l<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,c,l,h.__webglTexture,u),n.bindFramebuffer(e.FRAMEBUFFER,null)}function pe(t,n,r){if(e.bindRenderbuffer(e.RENDERBUFFER,t),n.depthBuffer){let i=n.depthTexture,a=i&&i.isDepthTexture?i.type:null,o=x(n.stencilBuffer,a),c=n.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;F(n)?s.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,Se(n),o,n.width,n.height):r?e.renderbufferStorageMultisample(e.RENDERBUFFER,Se(n),o,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,o,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,c,e.RENDERBUFFER,t)}else{let t=n.textures;for(let i=0;i{delete i.__boundDepthTexture,delete i.__depthDisposeCallback,e.removeEventListener(`dispose`,t)};e.addEventListener(`dispose`,t),i.__depthDisposeCallback=t}i.__boundDepthTexture=e}if(t.depthTexture&&!i.__autoAllocateDepthBuffer){if(a)for(let e=0;e<6;e++)me(i.__webglFramebuffer[e],t,e);else{let e=t.texture.mipmaps;e&&e.length>0?me(i.__webglFramebuffer[0],t,0):me(i.__webglFramebuffer,t,0)}}else if(a){i.__webglDepthbuffer=[];for(let r=0;r<6;r++)if(n.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer[r]),i.__webglDepthbuffer[r]===void 0)i.__webglDepthbuffer[r]=e.createRenderbuffer(),pe(i.__webglDepthbuffer[r],t,!1);else{let n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,a=i.__webglDepthbuffer[r];e.bindRenderbuffer(e.RENDERBUFFER,a),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,a)}}else{let r=t.texture.mipmaps;if(r&&r.length>0?n.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer[0]):n.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer),i.__webglDepthbuffer===void 0)i.__webglDepthbuffer=e.createRenderbuffer(),pe(i.__webglDepthbuffer,t,!1);else{let n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,r=i.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,r),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,r)}}n.bindFramebuffer(e.FRAMEBUFFER,null)}function ge(t,n,i){let a=r.get(t);n!==void 0&&fe(a.__webglFramebuffer,t,t.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0),i!==void 0&&he(t)}function _e(t){let i=t.texture,s=r.get(t),c=r.get(i);t.addEventListener(`dispose`,w);let l=t.textures,u=t.isWebGLCubeRenderTarget===!0,d=l.length>1;if(d||(c.__webglTexture===void 0&&(c.__webglTexture=e.createTexture()),c.__version=i.version,o.memory.textures++),u){s.__webglFramebuffer=[];for(let t=0;t<6;t++)if(i.mipmaps&&i.mipmaps.length>0){s.__webglFramebuffer[t]=[];for(let n=0;n0){s.__webglFramebuffer=[];for(let t=0;t0&&F(t)===!1){s.__webglMultisampledFramebuffer=e.createFramebuffer(),s.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,s.__webglMultisampledFramebuffer);for(let n=0;n0)for(let r=0;r0)for(let n=0;n0){if(F(t)===!1){let i=t.textures,a=t.width,o=t.height,s=e.COLOR_BUFFER_BIT,l=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,u=r.get(t),d=i.length>1;if(d)for(let t=0;t0?n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglFramebuffer[0]):n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglFramebuffer);for(let n=0;n0&&t.has(`WEBGL_multisampled_render_to_texture`)===!0&&n.__useRenderToTexture!==!1}function Ce(e){let t=o.render.frame;u.get(e)!==t&&(u.set(e,t),e.update())}function we(e,t){let n=e.colorSpace,r=e.format,i=e.type;return e.isCompressedTexture===!0||e.isVideoTexture===!0||n!==`srgb-linear`&&n!==``&&(dg.getTransfer(n)===`srgb`?(r!==1023||i!==1009)&&Th(`WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.`):Eh(`WebGLTextures: Unsupported texture color space:`,n)),t}function Te(e){return typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement?(l.width=e.naturalWidth||e.width,l.height=e.naturalHeight||e.height):typeof VideoFrame<`u`&&e instanceof VideoFrame?(l.width=e.displayWidth,l.height=e.displayHeight):(l.width=e.width,l.height=e.height),l}this.allocateTextureUnit=ee,this.resetTextureUnits=k,this.getTextureUnits=A,this.setTextureUnits=j,this.setTexture2D=te,this.setTexture2DArray=ne,this.setTexture3D=re,this.setTextureCube=ie,this.rebindTextures=ge,this.setupRenderTarget=_e,this.updateRenderTargetMipmap=ve,this.updateMultisampleRenderTarget=xe,this.setupDepthRenderbuffer=he,this.setupFrameBufferTexture=fe,this.useMultisampledRTT=F,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function vT(e,t){function n(n,r=``){let i,a=dg.getTransfer(r);if(n===1009)return e.UNSIGNED_BYTE;if(n===1017)return e.UNSIGNED_SHORT_4_4_4_4;if(n===1018)return e.UNSIGNED_SHORT_5_5_5_1;if(n===35902)return e.UNSIGNED_INT_5_9_9_9_REV;if(n===35899)return e.UNSIGNED_INT_10F_11F_11F_REV;if(n===1010)return e.BYTE;if(n===1011)return e.SHORT;if(n===1012)return e.UNSIGNED_SHORT;if(n===1013)return e.INT;if(n===1014)return e.UNSIGNED_INT;if(n===1015)return e.FLOAT;if(n===1016)return e.HALF_FLOAT;if(n===1021)return e.ALPHA;if(n===1022)return e.RGB;if(n===1023)return e.RGBA;if(n===1026)return e.DEPTH_COMPONENT;if(n===1027)return e.DEPTH_STENCIL;if(n===1028)return e.RED;if(n===1029)return e.RED_INTEGER;if(n===1030)return e.RG;if(n===1031)return e.RG_INTEGER;if(n===1033)return e.RGBA_INTEGER;if(n===33776||n===33777||n===33778||n===33779){if(a===`srgb`){if(i=t.get(`WEBGL_compressed_texture_s3tc_srgb`),i!==null){if(n===33776)return i.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===33777)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===33778)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===33779)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null}else if(i=t.get(`WEBGL_compressed_texture_s3tc`),i!==null){if(n===33776)return i.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===33777)return i.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===33778)return i.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===33779)return i.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null}if(n===35840||n===35841||n===35842||n===35843){if(i=t.get(`WEBGL_compressed_texture_pvrtc`),i!==null){if(n===35840)return i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===35841)return i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===35842)return i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===35843)return i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null}if(n===36196||n===37492||n===37496||n===37488||n===37489||n===37490||n===37491){if(i=t.get(`WEBGL_compressed_texture_etc`),i!==null){if(n===36196||n===37492)return a===`srgb`?i.COMPRESSED_SRGB8_ETC2:i.COMPRESSED_RGB8_ETC2;if(n===37496)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:i.COMPRESSED_RGBA8_ETC2_EAC;if(n===37488)return i.COMPRESSED_R11_EAC;if(n===37489)return i.COMPRESSED_SIGNED_R11_EAC;if(n===37490)return i.COMPRESSED_RG11_EAC;if(n===37491)return i.COMPRESSED_SIGNED_RG11_EAC}else return null}if(n===37808||n===37809||n===37810||n===37811||n===37812||n===37813||n===37814||n===37815||n===37816||n===37817||n===37818||n===37819||n===37820||n===37821){if(i=t.get(`WEBGL_compressed_texture_astc`),i!==null){if(n===37808)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:i.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===37809)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:i.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===37810)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:i.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===37811)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:i.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===37812)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:i.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===37813)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:i.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===37814)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:i.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===37815)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:i.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===37816)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:i.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===37817)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:i.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===37818)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:i.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===37819)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:i.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===37820)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:i.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===37821)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:i.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null}if(n===36492||n===36494||n===36495){if(i=t.get(`EXT_texture_compression_bptc`),i!==null){if(n===36492)return a===`srgb`?i.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:i.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===36494)return i.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===36495)return i.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null}if(n===36283||n===36284||n===36285||n===36286){if(i=t.get(`EXT_texture_compression_rgtc`),i!==null){if(n===36283)return i.COMPRESSED_RED_RGTC1_EXT;if(n===36284)return i.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===36285)return i.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===36286)return i.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null}return n===1020?e.UNSIGNED_INT_24_8:e[n]===void 0?null:e[n]}return{convert:n}}var yT=` +}`,Dh=[new z(1,0,0),new z(-1,0,0),new z(0,1,0),new z(0,-1,0),new z(0,0,1),new z(0,0,-1)],Oh=[new z(0,-1,0),new z(0,-1,0),new z(0,0,1),new z(0,0,-1),new z(0,-1,0),new z(0,-1,0)],kh=new Ho,Ah=new z,jh=new z;function Mh(e,t,n){let r=new xl,i=new R,a=new R,o=new Lo,s=new Ju,c=new Yu,l={},u=n.maxTextureSize,d={0:1,1:0,2:2},f=new Wu({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new R},radius:{value:4}},vertexShader:Th,fragmentShader:Eh}),p=f.clone();p.defines.HORIZONTAL_PASS=1;let m=new yc;m.setAttribute(`position`,new ic(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let h=new V(m,f),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let _=this.type;this.render=function(t,n,s){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||t.length===0)return;this.type===2&&(za(`WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead.`),this.type=1);let c=e.getRenderTarget(),l=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),f=e.state;f.setBlending(0),f.buffers.depth.getReversed()===!0?f.buffers.color.setClear(0,0,0,0):f.buffers.color.setClear(1,1,1,1),f.buffers.depth.setTest(!0),f.setScissorTest(!1);let p=_!==this.type;p&&n.traverse(function(e){e.material&&(Array.isArray(e.material)?e.material.forEach(e=>e.needsUpdate=!0):e.material.needsUpdate=!0)});for(let c=0,l=t.length;cu||i.y>u)&&(i.x>u&&(a.x=Math.floor(u/m.x),i.x=a.x*m.x,d.mapSize.x=a.x),i.y>u&&(a.y=Math.floor(u/m.y),i.y=a.y*m.y,d.mapSize.y=a.y));let h=e.state.buffers.depth.getReversed();if(d.camera._reversedDepth=h,d.map===null||p===!0){if(d.map!==null&&(d.map.depthTexture!==null&&(d.map.depthTexture.dispose(),d.map.depthTexture=null),d.map.dispose()),this.type===3){if(l.isPointLight){za(`WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.`);continue}d.map=new zo(i.x,i.y,{format:Ai,type:_i,minFilter:si,magFilter:si,generateMipmaps:!1}),d.map.texture.name=l.name+`.shadowMap`,d.map.depthTexture=new Gl(i.x,i.y,gi),d.map.depthTexture.name=l.name+`.shadowMapDepth`,d.map.depthTexture.format=Ei,d.map.depthTexture.compareFunction=null,d.map.depthTexture.minFilter=ii,d.map.depthTexture.magFilter=ii}else l.isPointLight?(d.map=new lp(i.x),d.map.depthTexture=new Kl(i.x,hi)):(d.map=new zo(i.x,i.y),d.map.depthTexture=new Gl(i.x,i.y,hi)),d.map.depthTexture.name=l.name+`.shadowMap`,d.map.depthTexture.format=Ei,this.type===1?(d.map.depthTexture.compareFunction=h?518:515,d.map.depthTexture.minFilter=si,d.map.depthTexture.magFilter=si):(d.map.depthTexture.compareFunction=null,d.map.depthTexture.minFilter=ii,d.map.depthTexture.magFilter=ii);d.camera.updateProjectionMatrix()}d.map.isWebGLCubeRenderTarget!==!0&&(d.map.width!==i.x||d.map.height!==i.y)&&d.map.setSize(i.x,i.y);let g=d.map.isWebGLCubeRenderTarget?6:d.getViewportCount();l.isPointLight!==!0&&d.updateMatrices(l,s);for(let t=0;t0||n.map&&n.alphaTest>0||n.alphaToCoverage===!0){let e=a.uuid,t=n.uuid,r=l[e];r===void 0&&(r={},l[e]=r);let i=r[t];i===void 0&&(i=a.clone(),r[t]=i,n.addEventListener(`dispose`,x)),a=i}if(a.visible=n.visible,a.wireframe=n.wireframe,i===3?a.side=n.shadowSide===null?n.side:n.shadowSide:a.side=n.shadowSide===null?d[n.side]:n.shadowSide,a.alphaMap=n.alphaMap,a.alphaTest=n.alphaToCoverage===!0?.5:n.alphaTest,a.map=n.map,a.clipShadows=n.clipShadows,a.clippingPlanes=n.clippingPlanes,a.clipIntersection=n.clipIntersection,a.displacementMap=n.displacementMap,a.displacementScale=n.displacementScale,a.displacementBias=n.displacementBias,a.wireframeLinewidth=n.wireframeLinewidth,a.linewidth=n.linewidth,r.isPointLight===!0&&a.isMeshDistanceMaterial===!0){let t=e.properties.get(a);t.light=r}return a}function b(n,i,a,o,s){if(n.visible===!1)return;if(n.layers.test(i.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&s===3)&&(!n.frustumCulled||n.intersectsFrustum(r))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);let r=t.update(n),c=n.material;if(Array.isArray(c)){let t=r.groups;for(let l=0,u=t.length;l=2):(te=parseFloat(/^WebGL (\d)/.exec(ne)[1]),M=te>=1);let re=null,ie={},ae=e.getParameter(e.SCISSOR_BOX),oe=e.getParameter(e.VIEWPORT),se=new Lo().fromArray(ae),ce=new Lo().fromArray(oe);function le(t,n,r,i){let a=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let o=0;o`u`?!1:/OculusBrowser/g.test(navigator.userAgent),l=new R,u=new WeakMap,d=new Set,f,p=new WeakMap,m=!1;try{m=typeof OffscreenCanvas<`u`&&new OffscreenCanvas(1,1).getContext(`2d`)!==null}catch{}function h(e,t){return m?new OffscreenCanvas(e,t):Pa(`canvas`)}function g(e,t,n){let r=1,i=P(e);if((i.width>n||i.height>n)&&(r=n/Math.max(i.width,i.height)),r<1){if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap||typeof VideoFrame<`u`&&e instanceof VideoFrame){let n=Math.floor(r*i.width),a=Math.floor(r*i.height);f===void 0&&(f=h(n,a));let o=t?h(n,a):f;return o.width=n,o.height=a,o.getContext(`2d`).drawImage(e,0,0,n,a),za(`WebGLRenderer: Texture has been resized from (`+i.width+`x`+i.height+`) to (`+n+`x`+a+`).`),o}return`data`in e&&za(`WebGLRenderer: Image in DataTexture is too big (`+i.width+`x`+i.height+`).`),e}return e}function _(e){return e.generateMipmaps}function v(t){e.generateMipmap(t)}function y(t){return t.isWebGLCubeRenderTarget?e.TEXTURE_CUBE_MAP:t.isWebGL3DRenderTarget?e.TEXTURE_3D:t.isWebGLArrayRenderTarget||t.isCompressedArrayTexture?e.TEXTURE_2D_ARRAY:e.TEXTURE_2D}function b(n,r,i,a,o,s=!1){if(n!==null){if(e[n]!==void 0)return e[n];za(`WebGLRenderer: Attempt to use non-existing WebGL internal format '`+n+`'`)}let c;a&&(c=t.get(`EXT_texture_norm16`),c||za(`WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension`));let l=r;if(r===e.RED&&(i===e.FLOAT&&(l=e.R32F),i===e.HALF_FLOAT&&(l=e.R16F),i===e.UNSIGNED_BYTE&&(l=e.R8),i===e.UNSIGNED_SHORT&&c&&(l=c.R16_EXT),i===e.SHORT&&c&&(l=c.R16_SNORM_EXT)),r===e.RED_INTEGER&&(i===e.UNSIGNED_BYTE&&(l=e.R8UI),i===e.UNSIGNED_SHORT&&(l=e.R16UI),i===e.UNSIGNED_INT&&(l=e.R32UI),i===e.BYTE&&(l=e.R8I),i===e.SHORT&&(l=e.R16I),i===e.INT&&(l=e.R32I)),r===e.RG&&(i===e.FLOAT&&(l=e.RG32F),i===e.HALF_FLOAT&&(l=e.RG16F),i===e.UNSIGNED_BYTE&&(l=e.RG8),i===e.UNSIGNED_SHORT&&c&&(l=c.RG16_EXT),i===e.SHORT&&c&&(l=c.RG16_SNORM_EXT)),r===e.RG_INTEGER&&(i===e.UNSIGNED_BYTE&&(l=e.RG8UI),i===e.UNSIGNED_SHORT&&(l=e.RG16UI),i===e.UNSIGNED_INT&&(l=e.RG32UI),i===e.BYTE&&(l=e.RG8I),i===e.SHORT&&(l=e.RG16I),i===e.INT&&(l=e.RG32I)),r===e.RGB_INTEGER&&(i===e.UNSIGNED_BYTE&&(l=e.RGB8UI),i===e.UNSIGNED_SHORT&&(l=e.RGB16UI),i===e.UNSIGNED_INT&&(l=e.RGB32UI),i===e.BYTE&&(l=e.RGB8I),i===e.SHORT&&(l=e.RGB16I),i===e.INT&&(l=e.RGB32I)),r===e.RGBA_INTEGER&&(i===e.UNSIGNED_BYTE&&(l=e.RGBA8UI),i===e.UNSIGNED_SHORT&&(l=e.RGBA16UI),i===e.UNSIGNED_INT&&(l=e.RGBA32UI),i===e.BYTE&&(l=e.RGBA8I),i===e.SHORT&&(l=e.RGBA16I),i===e.INT&&(l=e.RGBA32I)),r===e.RGB&&(i===e.UNSIGNED_SHORT&&c&&(l=c.RGB16_EXT),i===e.SHORT&&c&&(l=c.RGB16_SNORM_EXT),i===e.UNSIGNED_INT_5_9_9_9_REV&&(l=e.RGB9_E5),i===e.UNSIGNED_INT_10F_11F_11F_REV&&(l=e.R11F_G11F_B10F)),r===e.RGBA){let t=s?Ea:Eo.getTransfer(o);i===e.FLOAT&&(l=e.RGBA32F),i===e.HALF_FLOAT&&(l=e.RGBA16F),i===e.UNSIGNED_BYTE&&(l=t===`srgb`?e.SRGB8_ALPHA8:e.RGBA8),i===e.UNSIGNED_SHORT&&c&&(l=c.RGBA16_EXT),i===e.SHORT&&c&&(l=c.RGBA16_SNORM_EXT),i===e.UNSIGNED_SHORT_4_4_4_4&&(l=e.RGBA4),i===e.UNSIGNED_SHORT_5_5_5_1&&(l=e.RGB5_A1)}return(l===e.R16F||l===e.R32F||l===e.RG16F||l===e.RG32F||l===e.RGBA16F||l===e.RGBA32F)&&t.get(`EXT_color_buffer_float`),l}function x(t,n){let r;return t?n===null||n===1014||n===1020?r=e.DEPTH24_STENCIL8:n===1015?r=e.DEPTH32F_STENCIL8:n===1012&&(r=e.DEPTH24_STENCIL8,za(`DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.`)):n===null||n===1014||n===1020?r=e.DEPTH_COMPONENT24:n===1015?r=e.DEPTH_COMPONENT32F:n===1012&&(r=e.DEPTH_COMPONENT16),r}function S(e,t){return _(e)===!0||e.isFramebufferTexture&&e.minFilter!==1003&&e.minFilter!==1006?Math.log2(Math.max(t.width,t.height))+1:e.mipmaps!==void 0&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function C(e){let t=e.target;t.removeEventListener(`dispose`,C),T(t),t.isVideoTexture&&u.delete(t),t.isHTMLTexture&&d.delete(t)}function w(e){let t=e.target;t.removeEventListener(`dispose`,w),D(t)}function T(e){let t=r.get(e);if(t.__webglInit===void 0)return;let n=e.source,i=p.get(n);if(i){let r=i[t.__cacheKey];r.usedTimes--,r.usedTimes===0&&E(e),Object.keys(i).length===0&&p.delete(n)}r.remove(e)}function E(t){let n=r.get(t);e.deleteTexture(n.__webglTexture);let i=t.source,a=p.get(i);delete a[n.__cacheKey],o.memory.textures--}function D(t){let n=r.get(t);if(t.depthTexture&&(t.depthTexture.dispose(),r.remove(t.depthTexture)),t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++){if(Array.isArray(n.__webglFramebuffer[t]))for(let r=0;r=i.maxTextures&&za(`WebGLTextures: Trying to use `+(e+1)+` texture units while this GPU supports only `+i.maxTextures),O+=1,e}function M(e){let t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.wrapR||0),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.colorSpace),t.join()}function te(t,i){let a=r.get(t);if(t.isVideoTexture&&Te(t),t.isRenderTargetTexture===!1&&t.isExternalTexture!==!0&&t.version>0&&a.__version!==t.version){let e=t.image;if(e===null)za(`WebGLRenderer: Texture marked for update but no image data found.`);else if(e.complete===!1)za(`WebGLRenderer: Texture marked for update but image is incomplete`);else{fe(a,t,i);return}}else t.isExternalTexture&&(a.__webglTexture=t.sourceTexture?t.sourceTexture:null);n.bindTexture(e.TEXTURE_2D,a.__webglTexture,e.TEXTURE0+i)}function ne(t,i){let a=r.get(t);t.isRenderTargetTexture===!1&&t.version>0&&a.__version!==t.version?fe(a,t,i):(t.isExternalTexture&&(a.__webglTexture=t.sourceTexture?t.sourceTexture:null),n.bindTexture(e.TEXTURE_2D_ARRAY,a.__webglTexture,e.TEXTURE0+i))}function re(t,i){let a=r.get(t);t.isRenderTargetTexture===!1&&t.version>0&&a.__version!==t.version?fe(a,t,i):n.bindTexture(e.TEXTURE_3D,a.__webglTexture,e.TEXTURE0+i)}function ie(t,i){let a=r.get(t);t.isCubeDepthTexture!==!0&&t.version>0&&a.__version!==t.version?pe(a,t,i):n.bindTexture(e.TEXTURE_CUBE_MAP,a.__webglTexture,e.TEXTURE0+i)}let ae={[ti]:e.REPEAT,[ni]:e.CLAMP_TO_EDGE,[ri]:e.MIRRORED_REPEAT},oe={[ii]:e.NEAREST,[ai]:e.NEAREST_MIPMAP_NEAREST,[oi]:e.NEAREST_MIPMAP_LINEAR,[si]:e.LINEAR,[ci]:e.LINEAR_MIPMAP_NEAREST,[li]:e.LINEAR_MIPMAP_LINEAR},se={512:e.NEVER,519:e.ALWAYS,513:e.LESS,515:e.LEQUAL,514:e.EQUAL,518:e.GEQUAL,516:e.GREATER,517:e.NOTEQUAL};function ce(n,a){if(a.type===1015&&t.has(`OES_texture_float_linear`)===!1&&(a.magFilter===1006||a.magFilter===1007||a.magFilter===1005||a.magFilter===1008||a.minFilter===1006||a.minFilter===1007||a.minFilter===1005||a.minFilter===1008)&&za(`WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.`),e.texParameteri(n,e.TEXTURE_WRAP_S,ae[a.wrapS]),e.texParameteri(n,e.TEXTURE_WRAP_T,ae[a.wrapT]),(n===e.TEXTURE_3D||n===e.TEXTURE_2D_ARRAY)&&e.texParameteri(n,e.TEXTURE_WRAP_R,ae[a.wrapR]),e.texParameteri(n,e.TEXTURE_MAG_FILTER,oe[a.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,oe[a.minFilter]),a.compareFunction&&(e.texParameteri(n,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,se[a.compareFunction])),t.has(`EXT_texture_filter_anisotropic`)===!0){if(a.magFilter===1003||a.minFilter!==1005&&a.minFilter!==1008||a.type===1015&&t.has(`OES_texture_float_linear`)===!1)return;if(a.anisotropy>1||r.get(a).__currentAnisotropy){let o=t.get(`EXT_texture_filter_anisotropic`);e.texParameterf(n,o.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,i.getMaxAnisotropy())),r.get(a).__currentAnisotropy=a.anisotropy}}}function le(t,n){let r=!1;t.__webglInit===void 0&&(t.__webglInit=!0,n.addEventListener(`dispose`,C));let i=n.source,a=p.get(i);a===void 0&&(a={},p.set(i,a));let s=M(n);if(s!==t.__cacheKey){a[s]===void 0&&(a[s]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,r=!0),a[s].usedTimes++;let i=a[t.__cacheKey];i!==void 0&&(a[t.__cacheKey].usedTimes--,i.usedTimes===0&&E(n)),t.__cacheKey=s,t.__webglTexture=a[s].texture}return r}function ue(e,t,n){return Math.floor(Math.floor(e/n)/t)}function de(t,r,i,a){let o=t.updateRanges;if(o.length===0)n.texSubImage2D(e.TEXTURE_2D,0,0,0,r.width,r.height,i,a,r.data);else{o.sort((e,t)=>e.start-t.start);let s=0;for(let e=1;e0){C&&w&&n.texStorage2D(e.TEXTURE_2D,E,m,y[0].width,y[0].height);for(let t=0,i=y.length;t0){let t=Of(h.width,h.height,o.format,o.type);for(let a of o.layerUpdates){let o=h.data.subarray(a*t/h.data.BYTES_PER_ELEMENT,(a+1)*t/h.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,i,0,0,a,h.width,h.height,1,r,o)}}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,i,0,0,0,h.width,h.height,t.depth,r,h.data)}}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,i,m,h.width,h.height,t.depth,0,h.data,0,0)}else za(`WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()`)}else C?T&&n.texSubImage3D(e.TEXTURE_2D_ARRAY,i,0,0,0,h.width,h.height,t.depth,r,p,h.data):n.texImage3D(e.TEXTURE_2D_ARRAY,i,m,h.width,h.height,t.depth,0,r,p,h.data);o.layerUpdates.size>0&&o.clearLayerUpdates()}else{C&&w&&n.texStorage2D(e.TEXTURE_2D,E,m,y[0].width,y[0].height);for(let t=0,i=y.length;t0){let i=Of(t.width,t.height,o.format,o.type);for(let a of o.layerUpdates){let o=t.data.subarray(a*i/t.data.BYTES_PER_ELEMENT,(a+1)*i/t.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,a,t.width,t.height,1,r,p,o)}o.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,t.width,t.height,t.depth,r,p,t.data)}}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,m,t.width,t.height,t.depth,0,r,p,t.data)}else if(o.isData3DTexture)C?(w&&n.texStorage3D(e.TEXTURE_3D,E,m,t.width,t.height,t.depth),T&&n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,t.width,t.height,t.depth,r,p,t.data)):n.texImage3D(e.TEXTURE_3D,0,m,t.width,t.height,t.depth,0,r,p,t.data);else if(o.isFramebufferTexture){if(w){if(C)n.texStorage2D(e.TEXTURE_2D,E,m,t.width,t.height);else{let i=t.width,a=t.height;for(let t=0;t>=1,a>>=1}}}else if(o.isHTMLTexture){if(`texElementImage2D`in e){let n=e.canvas;if(n.hasAttribute(`layoutsubtree`)||n.setAttribute(`layoutsubtree`,`true`),t.parentNode!==n){n.appendChild(t),d.add(o),n.onpaint=e=>{let t=e.changedElements;for(let e of d)t.includes(e.image)&&(e.needsUpdate=!0)},n.requestPaint();return}if(e.texElementImage2D.length===3)e.texElementImage2D(e.TEXTURE_2D,e.RGBA8,t);else{let n=e.RGBA,r=e.RGBA,i=e.UNSIGNED_BYTE;e.texElementImage2D(e.TEXTURE_2D,0,n,r,i,t)}e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)}}else if(y.length>0){if(C&&w){let t=P(y[0]);n.texStorage2D(e.TEXTURE_2D,E,m,t.width,t.height)}for(let t=0,i=y.length;t0&&D++;let t=P(m[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,D,C,t.width,t.height)}for(let t=0;t<6;t++)if(p){w?E&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,m[t].width,m[t].height,y,x,m[t].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,C,m[t].width,m[t].height,0,y,x,m[t].data);for(let r=0;r>u),r=Math.max(1,i.height>>u);l===e.TEXTURE_3D||l===e.TEXTURE_2D_ARRAY?n.texImage3D(l,u,p,t,r,i.depth,0,d,f,null):n.texImage2D(l,u,p,t,r,0,d,f,null)}n.bindFramebuffer(e.FRAMEBUFFER,t),N(i)?s.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,c,l,h.__webglTexture,0,we(i)):(l===e.TEXTURE_2D||l>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&l<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,c,l,h.__webglTexture,u),n.bindFramebuffer(e.FRAMEBUFFER,null)}function he(t,n,r){if(e.bindRenderbuffer(e.RENDERBUFFER,t),n.depthBuffer){let i=n.depthTexture,a=i&&i.isDepthTexture?i.type:null,o=x(n.stencilBuffer,a),c=n.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;N(n)?s.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,we(n),o,n.width,n.height):r?e.renderbufferStorageMultisample(e.RENDERBUFFER,we(n),o,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,o,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,c,e.RENDERBUFFER,t)}else{let t=n.textures;for(let i=0;i{delete i.__boundDepthTexture,delete i.__depthDisposeCallback,e.removeEventListener(`dispose`,t)};e.addEventListener(`dispose`,t),i.__depthDisposeCallback=t}i.__boundDepthTexture=e}if(t.depthTexture&&!i.__autoAllocateDepthBuffer){if(a)for(let e=0;e<6;e++)ge(i.__webglFramebuffer[e],t,e);else{let e=t.texture.mipmaps;e&&e.length>0?ge(i.__webglFramebuffer[0],t,0):ge(i.__webglFramebuffer,t,0)}}else if(a){i.__webglDepthbuffer=[];for(let r=0;r<6;r++)if(n.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer[r]),i.__webglDepthbuffer[r]===void 0)i.__webglDepthbuffer[r]=e.createRenderbuffer(),he(i.__webglDepthbuffer[r],t,!1);else{let n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,a=i.__webglDepthbuffer[r];e.bindRenderbuffer(e.RENDERBUFFER,a),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,a)}}else{let r=t.texture.mipmaps;if(r&&r.length>0?n.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer[0]):n.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer),i.__webglDepthbuffer===void 0)i.__webglDepthbuffer=e.createRenderbuffer(),he(i.__webglDepthbuffer,t,!1);else{let n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,r=i.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,r),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,r)}}n.bindFramebuffer(e.FRAMEBUFFER,null)}function ve(t,n,i){let a=r.get(t);n!==void 0&&me(a.__webglFramebuffer,t,t.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0),i!==void 0&&_e(t)}function ye(t){let i=t.texture,s=r.get(t),c=r.get(i);t.addEventListener(`dispose`,w);let l=t.textures,u=t.isWebGLCubeRenderTarget===!0,d=l.length>1;if(d||(c.__webglTexture===void 0&&(c.__webglTexture=e.createTexture()),c.__version=i.version,o.memory.textures++),u){s.__webglFramebuffer=[];for(let t=0;t<6;t++)if(i.mipmaps&&i.mipmaps.length>0){s.__webglFramebuffer[t]=[];for(let n=0;n0){s.__webglFramebuffer=[];for(let t=0;t0&&N(t)===!1){s.__webglMultisampledFramebuffer=e.createFramebuffer(),s.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,s.__webglMultisampledFramebuffer);for(let n=0;n0)for(let r=0;r0)for(let n=0;n0){if(N(t)===!1){let i=t.textures,a=t.width,o=t.height,s=e.COLOR_BUFFER_BIT,l=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,u=r.get(t),d=i.length>1;if(d)for(let t=0;t0?n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglFramebuffer[0]):n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglFramebuffer);for(let n=0;n0&&t.has(`WEBGL_multisampled_render_to_texture`)===!0&&n.__useRenderToTexture!==!1}function Te(e){let t=o.render.frame;u.get(e)!==t&&(u.set(e,t),e.update())}function Ee(e,t){let n=e.colorSpace,r=e.format,i=e.type;return e.isCompressedTexture===!0||e.isVideoTexture===!0||n!==`srgb-linear`&&n!==``&&(Eo.getTransfer(n)===`srgb`?(r!==1023||i!==1009)&&za(`WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.`):Ba(`WebGLTextures: Unsupported texture color space:`,n)),t}function P(e){return typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement?(l.width=e.naturalWidth||e.width,l.height=e.naturalHeight||e.height):typeof VideoFrame<`u`&&e instanceof VideoFrame?(l.width=e.displayWidth,l.height=e.displayHeight):(l.width=e.width,l.height=e.height),l}this.allocateTextureUnit=ee,this.resetTextureUnits=k,this.getTextureUnits=A,this.setTextureUnits=j,this.setTexture2D=te,this.setTexture2DArray=ne,this.setTexture3D=re,this.setTextureCube=ie,this.rebindTextures=ve,this.setupRenderTarget=ye,this.updateRenderTargetMipmap=be,this.updateMultisampleRenderTarget=Ce,this.setupDepthRenderbuffer=_e,this.setupFrameBufferTexture=me,this.useMultisampledRTT=N,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function Fh(e,t){function n(n,r=``){let i,a=Eo.getTransfer(r);if(n===1009)return e.UNSIGNED_BYTE;if(n===1017)return e.UNSIGNED_SHORT_4_4_4_4;if(n===1018)return e.UNSIGNED_SHORT_5_5_5_1;if(n===35902)return e.UNSIGNED_INT_5_9_9_9_REV;if(n===35899)return e.UNSIGNED_INT_10F_11F_11F_REV;if(n===1010)return e.BYTE;if(n===1011)return e.SHORT;if(n===1012)return e.UNSIGNED_SHORT;if(n===1013)return e.INT;if(n===1014)return e.UNSIGNED_INT;if(n===1015)return e.FLOAT;if(n===1016)return e.HALF_FLOAT;if(n===1021)return e.ALPHA;if(n===1022)return e.RGB;if(n===1023)return e.RGBA;if(n===1026)return e.DEPTH_COMPONENT;if(n===1027)return e.DEPTH_STENCIL;if(n===1028)return e.RED;if(n===1029)return e.RED_INTEGER;if(n===1030)return e.RG;if(n===1031)return e.RG_INTEGER;if(n===1033)return e.RGBA_INTEGER;if(n===33776||n===33777||n===33778||n===33779){if(a===`srgb`){if(i=t.get(`WEBGL_compressed_texture_s3tc_srgb`),i!==null){if(n===33776)return i.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===33777)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===33778)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===33779)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null}else if(i=t.get(`WEBGL_compressed_texture_s3tc`),i!==null){if(n===33776)return i.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===33777)return i.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===33778)return i.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===33779)return i.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null}if(n===35840||n===35841||n===35842||n===35843){if(i=t.get(`WEBGL_compressed_texture_pvrtc`),i!==null){if(n===35840)return i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===35841)return i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===35842)return i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===35843)return i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null}if(n===36196||n===37492||n===37496||n===37488||n===37489||n===37490||n===37491){if(i=t.get(`WEBGL_compressed_texture_etc`),i!==null){if(n===36196||n===37492)return a===`srgb`?i.COMPRESSED_SRGB8_ETC2:i.COMPRESSED_RGB8_ETC2;if(n===37496)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:i.COMPRESSED_RGBA8_ETC2_EAC;if(n===37488)return i.COMPRESSED_R11_EAC;if(n===37489)return i.COMPRESSED_SIGNED_R11_EAC;if(n===37490)return i.COMPRESSED_RG11_EAC;if(n===37491)return i.COMPRESSED_SIGNED_RG11_EAC}else return null}if(n===37808||n===37809||n===37810||n===37811||n===37812||n===37813||n===37814||n===37815||n===37816||n===37817||n===37818||n===37819||n===37820||n===37821){if(i=t.get(`WEBGL_compressed_texture_astc`),i!==null){if(n===37808)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:i.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===37809)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:i.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===37810)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:i.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===37811)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:i.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===37812)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:i.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===37813)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:i.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===37814)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:i.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===37815)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:i.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===37816)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:i.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===37817)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:i.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===37818)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:i.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===37819)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:i.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===37820)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:i.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===37821)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:i.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null}if(n===36492||n===36494||n===36495){if(i=t.get(`EXT_texture_compression_bptc`),i!==null){if(n===36492)return a===`srgb`?i.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:i.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===36494)return i.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===36495)return i.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null}if(n===36283||n===36284||n===36285||n===36286){if(i=t.get(`EXT_texture_compression_rgtc`),i!==null){if(n===36283)return i.COMPRESSED_RED_RGTC1_EXT;if(n===36284)return i.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===36285)return i.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===36286)return i.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null}return n===1020?e.UNSIGNED_INT_24_8:e[n]===void 0?null:e[n]}return{convert:n}}var Ih=` void main() { gl_Position = vec4( position, 1.0 ); -}`,bT=` +}`,Lh=` uniform sampler2DArray depthColor; uniform float depthWidth; uniform float depthHeight; @@ -4227,294 +4217,46 @@ void main() { } -}`,xT=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new My(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){let t=e.cameras[0].viewport,n=new Ob({vertexShader:yT,fragmentShader:bT,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Y(new hb(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},ST=class extends Ah{constructor(e,t){super();let n=this,r=null,i=1,a=null,o=`local-floor`,s=1,c=null,l=null,u=null,d=null,f=null,p=null,m=typeof XRWebGLBinding<`u`,h=new xT,g={},_=t.getContextAttributes(),v=null,y=null,b=[],x=[],S=new K,C=null,w=null,T=new Ox;T.viewport=new Sg;let E=new Ox;E.viewport=new Sg;let D=[T,E],O=new Hx,k=null,A=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=b[e];return t===void 0&&(t=new r_,b[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=b[e];return t===void 0&&(t=new r_,b[e]=t),t.getGripSpace()},this.getHand=function(e){let t=b[e];return t===void 0&&(t=new r_,b[e]=t),t.getHandSpace()};function j(e){let t=x.indexOf(e.inputSource);if(t===-1)return;let n=b[t];n!==void 0&&(n.update(e.inputSource,e.frame,c||a),n.dispatchEvent({type:e.type,data:e.inputSource}))}function ee(){r.removeEventListener(`select`,j),r.removeEventListener(`selectstart`,j),r.removeEventListener(`selectend`,j),r.removeEventListener(`squeeze`,j),r.removeEventListener(`squeezestart`,j),r.removeEventListener(`squeezeend`,j),r.removeEventListener(`end`,ee),r.removeEventListener(`inputsourceschange`,M);for(let e=0;e=0&&(x[r]=null,b[r].disconnect(n))}for(let t=0;t=x.length){x.push(n),r=e;break}else if(x[e]===null){x[e]=n,r=e;break}if(r===-1)break}let i=b[r];i&&i.connect(n)}}let te=new q,ne=new q;function re(e,t,n){te.setFromMatrixPosition(t.matrixWorld),ne.setFromMatrixPosition(n.matrixWorld);let r=te.distanceTo(ne),i=t.projectionMatrix.elements,a=n.projectionMatrix.elements,o=i[14]/(i[10]-1),s=i[14]/(i[10]+1),c=(i[9]+1)/i[5],l=(i[9]-1)/i[5],u=(i[8]-1)/i[0],d=(a[8]+1)/a[0],f=o*u,p=o*d,m=r/(-u+d),h=m*-u;if(t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(h),e.translateZ(m),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert(),i[10]===-1)e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse);else{let t=o+m,n=s+m,i=f-h,a=p+(r-h),u=c*s/n*t,d=l*s/n*t;e.projectionMatrix.makePerspective(i,a,u,d,t,n),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}}function ie(e,t){t===null?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(r===null)return;let t=e.near,n=e.far;h.texture!==null&&(h.depthNear>0&&(t=h.depthNear),h.depthFar>0&&(n=h.depthFar)),O.near=E.near=T.near=t,O.far=E.far=T.far=n,(k!==O.near||A!==O.far)&&(r.updateRenderState({depthNear:O.near,depthFar:O.far}),k=O.near,A=O.far),O.layers.mask=e.layers.mask|6,T.layers.mask=O.layers.mask&-5,E.layers.mask=O.layers.mask&-3;let i=e.parent,a=O.cameras;ie(O,i);for(let e=0;e0&&(e.alphaTest.value=r.alphaTest);let i=t.get(r),a=i.envMap,o=i.envMapRotation;a&&(e.envMap.value=a,e.envMapRotation.value.setFromMatrix4(CT.makeRotationFromEuler(o)).transpose(),a.isCubeTexture&&a.isRenderTargetTexture===!1&&e.envMapRotation.value.premultiply(wT),e.reflectivity.value=r.reflectivity,e.ior.value=r.ior,e.refractionRatio.value=r.refractionRatio),r.lightMap&&(e.lightMap.value=r.lightMap,e.lightMapIntensity.value=r.lightMapIntensity,n(r.lightMap,e.lightMapTransform)),r.aoMap&&(e.aoMap.value=r.aoMap,e.aoMapIntensity.value=r.aoMapIntensity,n(r.aoMap,e.aoMapTransform))}function o(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}function s(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}function c(e,t,r,i){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*r,e.scale.value=i*.5,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}function l(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}function u(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}function d(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}function f(e,t){e.metalness.value=t.metalness,t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap,n(t.metalnessMap,e.metalnessMapTransform)),e.roughness.value=t.roughness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap,n(t.roughnessMap,e.roughnessMapTransform)),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}function p(e,t,r){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform))),t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),t.side===1&&e.clearcoatNormalScale.value.negate())),t.dispersion>0&&(e.dispersion.value=t.dispersion),t.retroreflectivity>0&&(e.retroreflectivity.value=t.retroreflectivity),t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform))),t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=r.texture,e.transmissionSamplerSize.value.set(r.width,r.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor)),t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,n(t.anisotropyMap,e.anisotropyMapTransform))),e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform)),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}function m(e,t){t.matcap&&(e.matcap.value=t.matcap)}function h(e,n){let r=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(r.matrixWorld),e.nearDistance.value=r.shadow.camera.near,e.farDistance.value=r.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function ET(e,t,n,r){let i={},a={},o=[],s=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(e,t){let n=t.program;r.uniformBlockBinding(e,n)}function l(e,n){let o=i[e.id];o===void 0&&(g(e),o=u(e),i[e.id]=o,e.addEventListener(`dispose`,v));let s=n.program;r.updateUBOMapping(e,s);let c=t.render.frame;a[e.id]!==c&&(f(e),a[e.id]=c)}function u(t){let n=d();t.__bindingPointIndex=n;let r=e.createBuffer(),i=t.__size,a=t.usage;return e.bindBuffer(e.UNIFORM_BUFFER,r),e.bufferData(e.UNIFORM_BUFFER,i,a),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,n,r),r}function d(){for(let e=0;e0&&(n+=16-r),e.__size=n,e.__cache={},this}function _(e){let t={boundary:0,storage:0};return typeof e==`number`||typeof e==`boolean`?(t.boundary=4,t.storage=4):e.isVector2?(t.boundary=8,t.storage=8):e.isVector3||e.isColor?(t.boundary=16,t.storage=12):e.isVector4?(t.boundary=16,t.storage=16):e.isMatrix3?(t.boundary=48,t.storage=48):e.isMatrix4?(t.boundary=64,t.storage=64):e.isTexture?Th(`WebGLRenderer: Texture samplers can not be part of an uniforms group.`):ArrayBuffer.isView(e)?(t.boundary=16,t.storage=e.byteLength):Th(`WebGLRenderer: Unsupported uniform value type.`,e),t}function v(t){let n=t.target;n.removeEventListener(`dispose`,v);let r=o.indexOf(n.__bindingPointIndex);o.splice(r,1),e.deleteBuffer(i[n.id]),delete i[n.id],delete a[n.id]}function y(){for(let t in i)e.deleteBuffer(i[t]);o=[],i={},a={}}return{bind:c,update:l,dispose:y}}var DT=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),OT=null;function kT(){return OT===null&&(OT=new Wv(DT,16,16,gm,rm),OT.name=`DFG_LUT`,OT.minFilter=qp,OT.magFilter=qp,OT.wrapS=Hp,OT.wrapT=Hp,OT.generateMipmaps=!1,OT.needsUpdate=!0),OT}var AT=class{constructor(e={}){let{canvas:t=xh(),context:n=null,depth:r=!0,stencil:i=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:s=!0,preserveDrawingBuffer:c=!1,powerPreference:l=`default`,failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:f=Xp}=e;this.isWebGLRenderer=!0;let p;if(n!==null){if(typeof WebGLRenderingContext<`u`&&n instanceof WebGLRenderingContext)throw Error(`THREE.WebGLRenderer: WebGL 1 is not supported since r163.`);p=n.getContextAttributes().alpha}else p=a;let m=f,h=new Set([vm,_m,hm]),g=new Set([Xp,tm,$p,om,im,am]),_=new Uint32Array(4),v=new Int32Array(4),y=new q,b=null,x=null,S=[],C=[],w=null;this.domElement=t,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=0,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let T=this,E=!1,D=null,O=null,k=null,A=null;this._outputColorSpace=uh;let j=0,ee=0,M=null,te=-1,ne=null,re=new Sg,ie=new Sg,N=null,ae=new J(0),oe=0,se=t.width,ce=t.height,le=1,P=null,ue=null,de=new Sg(0,0,se,ce),fe=new Sg(0,0,se,ce),pe=!1,me=new oy,he=!1,ge=!1,_e=new Dg,ve=new q,ye=new Sg,be={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},xe=!1;function Se(){return M===null?le:1}let F=n;function Ce(e,n){return t.getContext(e,n)}let we,Te,I,Ee,De,Oe,ke,Ae,je,Me,Ne,Pe,Fe,Ie,Le,Re,ze,Be,Ve,He,Ue,We,Ge;try{let e={alpha:!0,depth:r,stencil:i,antialias:o,premultipliedAlpha:s,preserveDrawingBuffer:c,powerPreference:l,failIfMajorPerformanceCaveat:u};if(`setAttribute`in t&&t.setAttribute(`data-engine`,`three.js r186`),t.addEventListener(`webglcontextlost`,L,!1),t.addEventListener(`webglcontextrestored`,Je,!1),t.addEventListener(`webglcontextcreationerror`,Ye,!1),F===null){let t=`webgl2`;if(F=Ce(t,e),F===null)throw Ce(t)?Error(`THREE.WebGLRenderer: Error creating WebGL context with your selected attributes.`):Error(`THREE.WebGLRenderer: Error creating WebGL context.`)}Ke()}catch(e){throw t.removeEventListener(`webglcontextlost`,L,!1),t.removeEventListener(`webglcontextrestored`,Je,!1),t.removeEventListener(`webglcontextcreationerror`,Ye,!1),Eh(`WebGLRenderer: `+e.message),e}function Ke(){we=new JS(F),we.init(),Ue=new vT(F,we),Te=new CS(F,we,e,Ue),I=new gT(F,we),Te.reversedDepthBuffer&&d&&I.buffers.depth.setReversed(!0),O=F.createFramebuffer(),k=F.createFramebuffer(),A=F.createFramebuffer(),Ee=new ZS(F),De=new Xw,Oe=new _T(F,we,I,De,Te,Ue,Ee),ke=new qS(T),Ae=new mS(F),We=new xS(F,Ae),je=new YS(F,Ae,Ee,We),Me=new $S(F,je,Ae,We,Ee),Be=new QS(F,Te,Oe),Le=new wS(De),Ne=new Yw(T,ke,we,Te,We,Le),Pe=new TT(T,De),Fe=new eT,Ie=new sT(we),ze=new bS(T,ke,I,Me,p,s),Re=new hT(T,Me,Te),Ge=new ET(F,Ee,Te,I),Ve=new SS(F,we,Ee),He=new XS(F,we,Ee),Ee.programs=Ne.programs,T.capabilities=Te,T.extensions=we,T.properties=De,T.renderLists=Fe,T.shadowMap=Re,T.state=I,T.info=Ee}m!==1009&&(w=new tC(m,t.width,t.height,o,r,i));let qe=new ST(T,F);this.xr=qe,this.getContext=function(){return F},this.getContextAttributes=function(){return F.getContextAttributes()},this.forceContextLoss=function(){let e=we.get(`WEBGL_lose_context`);e&&e.loseContext()},this.forceContextRestore=function(){let e=we.get(`WEBGL_lose_context`);e&&e.restoreContext()},this.getPixelRatio=function(){return le},this.setPixelRatio=function(e){e!==void 0&&(le=e,this.setSize(se,ce,!1))},this.getSize=function(e){return e.set(se,ce)},this.setSize=function(e,n,r=!0){qe.isPresenting?Th(`WebGLRenderer: Can't change size while VR device is presenting.`):(se=e,ce=n,t.width=Math.floor(e*le),t.height=Math.floor(n*le),r===!0&&(t.style.width=e+`px`,t.style.height=n+`px`),w!==null&&w.setSize(t.width,t.height),this.setViewport(0,0,e,n))},this.getDrawingBufferSize=function(e){return e.set(se*le,ce*le).floor()},this.setDrawingBufferSize=function(e,n,r){se=e,ce=n,le=r,t.width=Math.floor(e*r),t.height=Math.floor(n*r),this.setViewport(0,0,e,n)},this.setEffects=function(e){if(m===1009)Eh(`WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.`);else{if(e){for(let t=0;t{function n(){r.forEach(function(e){let t=De.get(e).currentProgram;(t===void 0||t.isReady())&&r.delete(e)}),r.size===0?t(e):setTimeout(n,10)}we.get(`KHR_parallel_shader_compile`)===null?setTimeout(n,10):n()})};let et=null;function tt(e){et&&et(e)}function nt(){it.stop()}function rt(){it.start()}let it=new pS;it.setAnimationLoop(tt),typeof self<`u`&&it.setContext(self),this.setAnimationLoop=function(e){et=e,qe.setAnimationLoop(e),e===null?it.stop():it.start()},qe.addEventListener(`sessionstart`,nt),qe.addEventListener(`sessionend`,rt),this.render=function(e,t){if(t!==void 0&&t.isCamera!==!0){Eh(`WebGLRenderer.render: camera is not an instance of THREE.Camera.`);return}if(E===!0)return;D!==null&&D.renderStart(e,t);let n=qe.enabled===!0&&qe.isPresenting===!0,r=w!==null&&(M===null||n)&&w.begin(T,M);if(e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.parent===null&&t.matrixWorldAutoUpdate===!0&&t.updateMatrixWorld(),qe.enabled===!0&&qe.isPresenting===!0&&(w===null||w.isCompositing()===!1)&&(qe.cameraAutoUpdate===!0&&qe.updateCamera(t),t=qe.getCamera()),e.isScene===!0&&e.onBeforeRender(T,e,t,M),x=Ie.get(e,C.length),x.init(t),x.state.textureUnits=Oe.getTextureUnits(),C.push(x),_e.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),me.setFromProjectionMatrix(_e,_h,t.reversedDepth),ge=this.localClippingEnabled,he=Le.init(this.clippingPlanes,ge),b=Fe.get(e,S.length),b.init(),S.push(b),qe.enabled===!0&&qe.isPresenting===!0){let e=T.xr.getDepthSensingMesh();e!==null&&at(e,t,-1/0,T.sortObjects)}at(e,t,0,T.sortObjects),b.finish(),D!==null&&D.updateLights(x.state.lightsArray),T.sortObjects===!0&&b.sort(P,ue),xe=qe.enabled===!1||qe.isPresenting===!1||qe.hasDepthSensing()===!1,xe&&ze.addToRenderList(b,e),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),he===!0&&Le.beginShadows();let i=x.state.shadowsArray;if(Re.render(i,e,t),he===!0&&Le.endShadows(),(r&&w.hasRenderPass())===!1){let n=b.opaque,r=b.transmissive;if(x.setupLights(),t.isArrayCamera){let i=t.cameras;if(r.length>0)for(let t=0,a=i.length;t0&&st(n,r,e,t),xe&&ze.render(e),ot(b,e,t)}M!==null&&ee===0&&(Oe.updateMultisampleRenderTarget(M),Oe.updateRenderTargetMipmap(M)),r&&w.end(T),e.isScene===!0&&e.onAfterRender(T,e,t),We.resetDefaultState(),te=-1,ne=null,C.pop(),C.length>0?(x=C[C.length-1],Oe.setTextureUnits(x.state.textureUnits),he===!0&&Le.setGlobalState(T.clippingPlanes,x.state.camera)):x=null,S.pop(),b=S.length>0?S[S.length-1]:null,D!==null&&D.renderEnd()};function at(e,t,n,r){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)n=e.renderOrder;else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLightProbeGrid)x.pushLightProbeGrid(e);else if(e.isLight)x.pushLight(e),e.castShadow&&x.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||e.intersectsFrustum(me)){r&&ye.setFromMatrixPosition(e.matrixWorld).applyMatrix4(_e);let i=Me.update(e),a=e.material;a.visible&&b.push(e,i,a,n,ye.z,null,t)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||e.intersectsFrustum(me))){let i=Me.update(e),a=e.material;if(r&&(e.boundingSphere===void 0?(i.boundingSphere===null&&i.computeBoundingSphere(),ye.copy(i.boundingSphere.center)):(e.boundingSphere===null&&e.computeBoundingSphere(),ye.copy(e.boundingSphere.center)),ye.applyMatrix4(e.matrixWorld).applyMatrix4(_e)),Array.isArray(a)){let r=i.groups;for(let o=0,s=r.length;o0&&ct(i,t,n),a.length>0&&ct(a,t,n),o.length>0&&ct(o,t,n),I.buffers.depth.setTest(!0),I.buffers.depth.setMask(!0),I.buffers.color.setMask(!0),I.setPolygonOffset(!1)}function st(e,t,n,r){if((n.isScene===!0?n.overrideMaterial:null)!==null)return;if(x.state.transmissionRenderTarget[r.id]===void 0){let e=we.has(`EXT_color_buffer_half_float`)||we.has(`EXT_color_buffer_float`);x.state.transmissionRenderTarget[r.id]=new wg(1,1,{generateMipmaps:!0,type:e?rm:Xp,minFilter:Yp,samples:Math.max(4,Te.samples),stencilBuffer:i,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:dg.workingColorSpace})}let a=x.state.transmissionRenderTarget[r.id],o=r.viewport||re;a.setSize(o.z*T.transmissionResolutionScale,o.w*T.transmissionResolutionScale);let s=T.getRenderTarget(),c=T.getActiveCubeFace(),l=T.getActiveMipmapLevel();T.setRenderTarget(a),T.getClearColor(ae),oe=T.getClearAlpha(),oe<1&&T.setClearColor(16777215,.5),T.clear(),xe&&ze.render(n);let u=T.toneMapping;T.toneMapping=0;let d=r.viewport;if(r.viewport!==void 0&&(r.viewport=void 0),x.setupLightsView(r),he===!0&&Le.setGlobalState(T.clippingPlanes,r),ct(e,n,r),Oe.updateMultisampleRenderTarget(a),Oe.updateRenderTargetMipmap(a),we.has(`WEBGL_multisampled_render_to_texture`)===!1){let e=!1;for(let i=0,a=t.length;i0,r.currentProgram=d,r.uniformsList=null,d}function dt(e){if(e.uniformsList===null){let t=e.currentProgram.getUniforms();e.uniformsList=cw.seqWithValue(t.seq,e.uniforms)}return e.uniformsList}function ft(e,t){let n=De.get(e);n.outputColorSpace=t.outputColorSpace,n.batching=t.batching,n.batchingColor=t.batchingColor,n.instancing=t.instancing,n.instancingColor=t.instancingColor,n.instancingMorph=t.instancingMorph,n.skinning=t.skinning,n.morphTargets=t.morphTargets,n.morphNormals=t.morphNormals,n.morphColors=t.morphColors,n.morphTargetsCount=t.morphTargetsCount,n.numClippingPlanes=t.numClippingPlanes,n.numIntersection=t.numClipIntersection,n.vertexAlphas=t.vertexAlphas,n.vertexTangents=t.vertexTangents,n.toneMapping=t.toneMapping}function pt(e,t){if(e.length===0)return null;if(e.length===1)return e[0].texture===null?null:e[0];y.setFromMatrixPosition(t.matrixWorld);for(let t=0,n=e.length;t0),f=!!n.morphAttributes.position,p=!!n.morphAttributes.normal,m=!!n.morphAttributes.color,h=0;r.toneMapped&&(M===null||M.isXRRenderTarget===!0)&&(h=T.toneMapping);let g=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,_=g===void 0?0:g.length,v=De.get(r),y=x.state.lights;if(he===!0&&(ge===!0||e!==ne)){let t=e===ne&&r.id===te;Le.setState(r,e,t)}let b=!1;r.version===v.__version?v.needsLights&&v.lightsStateVersion!==y.state.version?b=!0:v.outputColorSpace===s?i.isBatchedMesh&&v.batching===!1||!i.isBatchedMesh&&v.batching===!0||i.isBatchedMesh&&v.batchingColor===!0&&i._colorsTexture===null||i.isBatchedMesh&&v.batchingColor===!1&&i._colorsTexture!==null||i.isInstancedMesh&&v.instancing===!1||!i.isInstancedMesh&&v.instancing===!0||i.isSkinnedMesh&&v.skinning===!1||!i.isSkinnedMesh&&v.skinning===!0||i.isInstancedMesh&&v.instancingColor===!0&&i.instanceColor===null||i.isInstancedMesh&&v.instancingColor===!1&&i.instanceColor!==null||i.isInstancedMesh&&v.instancingMorph===!0&&i.morphTexture===null||i.isInstancedMesh&&v.instancingMorph===!1&&i.morphTexture!==null?b=!0:v.envMap===l?r.fog===!0&&v.fog!==a||v.numClippingPlanes!==void 0&&(v.numClippingPlanes!==Le.numPlanes||v.numIntersection!==Le.numIntersection)?b=!0:v.vertexAlphas===u&&v.vertexTangents===d&&v.morphTargets===f&&v.morphNormals===p&&v.morphColors===m&&v.toneMapping===h&&v.morphTargetsCount===_?!!v.lightProbeGrid!=x.state.lightProbeGridArray.length>0&&(b=!0):b=!0:b=!0:b=!0:(b=!0,v.__version=r.version);let S=v.currentProgram;b===!0&&(S=ut(r,t,i),D&&r.isNodeMaterial&&D.onUpdateProgram(r,S,v));let C=!1,w=!1,E=!1,O=S.getUniforms(),k=v.uniforms;if(I.useProgram(S.program)&&(C=!0,w=!0,E=!0),r.id!==te&&(te=r.id,w=!0),v.needsLights){let e=pt(x.state.lightProbeGridArray,i);v.lightProbeGrid!==e&&(v.lightProbeGrid=e,w=!0)}if(C||ne!==e){I.buffers.depth.getReversed()&&e.reversedDepth!==!0&&(e._reversedDepth=!0,e.updateProjectionMatrix()),O.setValue(F,`projectionMatrix`,e.projectionMatrix),O.setValue(F,`viewMatrix`,e.matrixWorldInverse);let t=O.map.cameraPosition;t!==void 0&&t.setValue(F,ve.setFromMatrixPosition(e.matrixWorld)),Te.logarithmicDepthBuffer&&O.setValue(F,`logDepthBufFC`,2/(Math.log(e.far+1)/Math.LN2)),(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial)&&O.setValue(F,`isOrthographic`,e.isOrthographicCamera===!0),ne!==e&&(ne=e,w=!0,E=!0)}if(v.needsLights&&(y.state.sunShadowMap.length>0&&O.setValue(F,`sunShadowMap`,y.state.sunShadowMap,Oe),y.state.directionalShadowMap.length>0&&O.setValue(F,`directionalShadowMap`,y.state.directionalShadowMap,Oe),y.state.spotShadowMap.length>0&&O.setValue(F,`spotShadowMap`,y.state.spotShadowMap,Oe),y.state.pointShadowMap.length>0&&O.setValue(F,`pointShadowMap`,y.state.pointShadowMap,Oe)),i.isSkinnedMesh){O.setOptional(F,i,`bindMatrix`),O.setOptional(F,i,`bindMatrixInverse`);let e=i.skeleton;e&&(e.boneTexture===null&&e.computeBoneTexture(),O.setValue(F,`boneTexture`,e.boneTexture,Oe))}i.isBatchedMesh&&(O.setOptional(F,i,`batchingTexture`),O.setValue(F,`batchingTexture`,i._matricesTexture,Oe),O.setOptional(F,i,`batchingIdTexture`),O.setValue(F,`batchingIdTexture`,i._indirectTexture,Oe),O.setOptional(F,i,`batchingColorTexture`),i._colorsTexture!==null&&O.setValue(F,`batchingColorTexture`,i._colorsTexture,Oe));let A=n.morphAttributes;if((A.position!==void 0||A.normal!==void 0||A.color!==void 0)&&Be.update(i,n,S),(w||v.receiveShadow!==i.receiveShadow)&&(v.receiveShadow=i.receiveShadow,O.setValue(F,`receiveShadow`,i.receiveShadow)),(r.isMeshStandardMaterial||r.isMeshLambertMaterial||r.isMeshPhongMaterial)&&r.envMap===null&&t.environment!==null&&(k.envMapIntensity.value=t.environmentIntensity),k.dfgLUT!==void 0&&(k.dfgLUT.value=kT()),w){if(O.setValue(F,`toneMappingExposure`,T.toneMappingExposure),v.needsLights&&ht(k,E),a&&r.fog===!0&&Pe.refreshFogUniforms(k,a),Pe.refreshMaterialUniforms(k,r,le,ce,x.state.transmissionRenderTarget[e.id]),v.needsLights&&v.lightProbeGrid){let e=v.lightProbeGrid;k.probesSH.value=e.texture,k.probesMin.value.copy(e.boundingBox.min),k.probesMax.value.copy(e.boundingBox.max),k.probesResolution.value.copy(e.resolution)}cw.upload(F,dt(v),k,Oe)}if(r.isShaderMaterial&&r.uniformsNeedUpdate===!0&&(cw.upload(F,dt(v),k,Oe),r.uniformsNeedUpdate=!1),r.isSpriteMaterial&&O.setValue(F,`center`,i.center),O.setValue(F,`modelViewMatrix`,i.modelViewMatrix),O.setValue(F,`normalMatrix`,i.normalMatrix),O.setValue(F,`modelMatrix`,i.matrixWorld),r.uniformsGroups!==void 0){let e=r.uniformsGroups;for(let t=0,n=e.length;t0&&Oe.useMultisampledRTT(e)===!1?De.get(e).__webglMultisampledFramebuffer:Array.isArray(c)?c[n]:c,re.copy(e.viewport),ie.copy(e.scissor),N=e.scissorTest}else re.copy(de).multiplyScalar(le).floor(),ie.copy(fe).multiplyScalar(le).floor(),N=pe;if(n!==0&&(r=O),I.bindFramebuffer(F.FRAMEBUFFER,r)&&I.drawBuffers(e,r),I.viewport(re),I.scissor(ie),I.setScissorTest(N),i){let r=De.get(e.texture);F.framebufferTexture2D(F.FRAMEBUFFER,F.COLOR_ATTACHMENT0,F.TEXTURE_CUBE_MAP_POSITIVE_X+t,r.__webglTexture,n)}else if(a){let r=t;for(let t=0;t1&&F.readBuffer(F.COLOR_ATTACHMENT0+s);let u=_t(o);if(u.__formatReadable===!1){Eh(`WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.`);return}if(u.__typeReadable===!1){Eh(`WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.`);return}t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i&&F.readPixels(t,n,r,i,Ue.convert(c),Ue.convert(l),a)}finally{let e=M===null?null:De.get(M).__webglFramebuffer;I.bindFramebuffer(F.FRAMEBUFFER,e)}}},this.readRenderTargetPixelsAsync=async function(e,t,n,r,i,a,o,s=0){if(!(e&&e.isWebGLRenderTarget))throw Error(`THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.`);let c=De.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&o!==void 0&&(c=c[o]),c){if(t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i){I.bindFramebuffer(F.FRAMEBUFFER,c);let o=e.textures[s],l=o.format,u=o.type;e.textures.length>1&&F.readBuffer(F.COLOR_ATTACHMENT0+s);let d=_t(o);if(d.__formatReadable===!1)throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.`);if(d.__typeReadable===!1)throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.`);let f=F.createBuffer();F.bindBuffer(F.PIXEL_PACK_BUFFER,f),F.bufferData(F.PIXEL_PACK_BUFFER,a.byteLength,F.STREAM_READ),F.readPixels(t,n,r,i,Ue.convert(l),Ue.convert(u),0),F.bindBuffer(F.PIXEL_PACK_BUFFER,null);let p=M===null?null:De.get(M).__webglFramebuffer;I.bindFramebuffer(F.FRAMEBUFFER,p);let m=F.fenceSync(F.SYNC_GPU_COMMANDS_COMPLETE,0);return F.flush(),await Oh(F,m,4),F.bindBuffer(F.PIXEL_PACK_BUFFER,f),F.getBufferSubData(F.PIXEL_PACK_BUFFER,0,a),F.bindBuffer(F.PIXEL_PACK_BUFFER,null),F.deleteBuffer(f),F.deleteSync(m),a}throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.`)}},this.copyFramebufferToTexture=function(e,t=null,n=0){let r=2**-n,i=Math.floor(e.image.width*r),a=Math.floor(e.image.height*r),o=t===null?0:t.x,s=t===null?0:t.y;Oe.setTexture2D(e,0),F.copyTexSubImage2D(F.TEXTURE_2D,n,0,0,o,s,i,a),I.unbindTexture()},this.copyTextureToTexture=function(e,t,n=null,r=null,i=0,a=0){let o,s,c,l,u,d,f,p,m,h=e.isCompressedTexture?e.mipmaps[a]:e.image;if(n!==null)o=n.max.x-n.min.x,s=n.max.y-n.min.y,c=n.isBox3?n.max.z-n.min.z:1,l=n.min.x,u=n.min.y,d=n.isBox3?n.min.z:0;else{let t=2**-i;o=Math.floor(h.width*t),s=Math.floor(h.height*t),c=e.isDataArrayTexture?h.depth:e.isData3DTexture?Math.floor(h.depth*t):1,l=0,u=0,d=0}r===null?(f=0,p=0,m=0):(f=r.x,p=r.y,m=r.z);let g=Ue.convert(t.format),_=Ue.convert(t.type),v;t.isData3DTexture?(Oe.setTexture3D(t,0),v=F.TEXTURE_3D):t.isDataArrayTexture||t.isCompressedArrayTexture?(Oe.setTexture2DArray(t,0),v=F.TEXTURE_2D_ARRAY):(Oe.setTexture2D(t,0),v=F.TEXTURE_2D),I.activeTexture(F.TEXTURE0),I.pixelStorei(F.UNPACK_FLIP_Y_WEBGL,t.flipY),I.pixelStorei(F.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),I.pixelStorei(F.UNPACK_ALIGNMENT,t.unpackAlignment);let y=I.getParameter(F.UNPACK_ROW_LENGTH),b=I.getParameter(F.UNPACK_IMAGE_HEIGHT),x=I.getParameter(F.UNPACK_SKIP_PIXELS),S=I.getParameter(F.UNPACK_SKIP_ROWS),C=I.getParameter(F.UNPACK_SKIP_IMAGES);I.pixelStorei(F.UNPACK_ROW_LENGTH,h.width),I.pixelStorei(F.UNPACK_IMAGE_HEIGHT,h.height),I.pixelStorei(F.UNPACK_SKIP_PIXELS,l),I.pixelStorei(F.UNPACK_SKIP_ROWS,u),I.pixelStorei(F.UNPACK_SKIP_IMAGES,d);let w=e.isDataArrayTexture||e.isData3DTexture,T=t.isDataArrayTexture||t.isData3DTexture;if(e.isDepthTexture){let n=De.get(e),r=De.get(t),h=De.get(n.__renderTarget),g=De.get(r.__renderTarget);I.bindFramebuffer(F.READ_FRAMEBUFFER,h.__webglFramebuffer),I.bindFramebuffer(F.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let n=0;n - - varying vec2 vUv; - - uniform sampler2D colorTexture; - uniform vec2 invSize; - uniform vec2 direction; - uniform float centerWeight; - uniform float gaussianOffsets[KERNEL_PAIRS]; - uniform float gaussianWeights[KERNEL_PAIRS]; - - void main() { - - vec3 diffuseSum = texture2D( colorTexture, vUv ).rgb * centerWeight; - - for ( int i = 0; i < KERNEL_PAIRS; i ++ ) { - - vec2 uvOffset = direction * invSize * gaussianOffsets[ i ]; - vec3 sample1 = texture2D( colorTexture, vUv + uvOffset ).rgb; - vec3 sample2 = texture2D( colorTexture, vUv - uvOffset ).rgb; - diffuseSum += ( sample1 + sample2 ) * gaussianWeights[ i ]; - - } - - gl_FragColor = vec4( diffuseSum, 1.0 ); - - }`})}_getCompositeMaterial(e){return new Ob({defines:{NUM_MIPS:e},uniforms:{blurTexture1:{value:null},blurTexture2:{value:null},blurTexture3:{value:null},blurTexture4:{value:null},blurTexture5:{value:null},bloomStrength:{value:1},bloomFactors:{value:null},bloomTintColors:{value:null},bloomRadius:{value:0}},vertexShader:` - - varying vec2 vUv; - - void main() { - - vUv = uv; - gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); - - }`,fragmentShader:` - - varying vec2 vUv; - - uniform sampler2D blurTexture1; - uniform sampler2D blurTexture2; - uniform sampler2D blurTexture3; - uniform sampler2D blurTexture4; - uniform sampler2D blurTexture5; - uniform float bloomStrength; - uniform float bloomRadius; - uniform float bloomFactors[NUM_MIPS]; - uniform vec3 bloomTintColors[NUM_MIPS]; - - float lerpBloomFactor( const in float factor ) { - - float mirrorFactor = 1.2 - factor; - return mix( factor, mirrorFactor, bloomRadius ); - - } - - void main() { - - // 3.0 for backwards compatibility with previous alpha-based intensity - vec3 bloom = 3.0 * bloomStrength * ( - lerpBloomFactor( bloomFactors[ 0 ] ) * bloomTintColors[ 0 ] * texture2D( blurTexture1, vUv ).rgb + - lerpBloomFactor( bloomFactors[ 1 ] ) * bloomTintColors[ 1 ] * texture2D( blurTexture2, vUv ).rgb + - lerpBloomFactor( bloomFactors[ 2 ] ) * bloomTintColors[ 2 ] * texture2D( blurTexture3, vUv ).rgb + - lerpBloomFactor( bloomFactors[ 3 ] ) * bloomTintColors[ 3 ] * texture2D( blurTexture4, vUv ).rgb + - lerpBloomFactor( bloomFactors[ 4 ] ) * bloomTintColors[ 4 ] * texture2D( blurTexture5, vUv ).rgb - ); - - float bloomAlpha = max( bloom.r, max( bloom.g, bloom.b ) ); - gl_FragColor = vec4( bloom, bloomAlpha ); - - }`})}};HT.BlurDirectionX=new K(1,0),HT.BlurDirectionY=new K(0,1);var UT={name:`OutputShader`,uniforms:{tDiffuse:{value:null},toneMappingExposure:{value:1}},vertexShader:` - precision highp float; - - uniform mat4 modelViewMatrix; - uniform mat4 projectionMatrix; - - attribute vec3 position; - attribute vec2 uv; - - varying vec2 vUv; - - void main() { - - vUv = uv; - gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); - - }`,fragmentShader:` - - precision highp float; - - uniform sampler2D tDiffuse; - - #include - #include - - varying vec2 vUv; - - void main() { - - gl_FragColor = texture2D( tDiffuse, vUv ); - - // tone mapping - - #ifdef LINEAR_TONE_MAPPING - - gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb ); - - #elif defined( REINHARD_TONE_MAPPING ) - - gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb ); - - #elif defined( CINEON_TONE_MAPPING ) - - gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb ); - - #elif defined( ACES_FILMIC_TONE_MAPPING ) - - gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb ); - - #elif defined( AGX_TONE_MAPPING ) - - gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb ); - - #elif defined( NEUTRAL_TONE_MAPPING ) - - gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb ); - - #elif defined( CUSTOM_TONE_MAPPING ) - - gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb ); - - #endif - - // color space - - #ifdef SRGB_TRANSFER - - gl_FragColor = sRGBTransferOETF( gl_FragColor ); - - #endif - - }`},WT=class extends MT{constructor(){super(),this.isOutputPass=!0,this.uniforms=Tb.clone(UT.uniforms),this.material=new kb({name:UT.name,uniforms:this.uniforms,vertexShader:UT.vertexShader,fragmentShader:UT.fragmentShader}),this._fsQuad=new FT(this.material),this._outputColorSpace=null,this._toneMapping=null}render(e,t,n){this.uniforms.tDiffuse.value=n.texture,this.uniforms.toneMappingExposure.value=e.toneMappingExposure,(this._outputColorSpace!==e.outputColorSpace||this._toneMapping!==e.toneMapping)&&(this._outputColorSpace=e.outputColorSpace,this._toneMapping=e.toneMapping,this.material.defines={},dg.getTransfer(this._outputColorSpace)===`srgb`&&(this.material.defines.SRGB_TRANSFER=``),this._toneMapping===1?this.material.defines.LINEAR_TONE_MAPPING=``:this._toneMapping===2?this.material.defines.REINHARD_TONE_MAPPING=``:this._toneMapping===3?this.material.defines.CINEON_TONE_MAPPING=``:this._toneMapping===4?this.material.defines.ACES_FILMIC_TONE_MAPPING=``:this._toneMapping===6?this.material.defines.AGX_TONE_MAPPING=``:this._toneMapping===7?this.material.defines.NEUTRAL_TONE_MAPPING=``:this._toneMapping===5&&(this.material.defines.CUSTOM_TONE_MAPPING=``),this.material.needsUpdate=!0),this.renderToScreen===!0?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this._fsQuad.render(e))}dispose(){this.material.dispose(),this._fsQuad.dispose()}},GT=70,KT=1e3,qT=f*2;function JT(e,t){return Math.max(65,100-Math.floor((KT-e)/30)-Math.floor(t/50))}function YT(e,t,n){if(e.action===null||!T(e.action,t.class))return!1;let r=e.action_startup_ticks+e.action_active_ticks+e.action_recovery_ticks;return n-e.action_start_tick0||e.clinch_startup_ticks>0||e.taunt_ticks>0||e.is_foul_recovery_target}function $T(e,t,n={x:0,y:0,speed:0},r=0){let i=Math.max(2,Math.floor(g*JT(e.conditioning,e.trauma.body)/100)),a=e.stunned_ticks-r,o=i;a>1?o=Math.max(2,Math.floor(i*ie/100)):a<=0&&(t.defense===`guard_high`||t.defense===`guard_low`)&&!Ne(e.injuries)&&(o=Math.max(2,Math.floor(i*GT/100))),o=Ie(o*10*P(e.style).moveSpeedPercent,e.injuries)/1e3;let s=Math.hypot(t.moveX,t.moveY),c=s>1e3?1e3/s:1;return n.x=t.moveX*c*o/1e3,n.y=t.moveY*c*o/1e3,n.speed=o,n}function eE(e,t,n){return e.kind===`parry`&&e.target_id===t?Math.max(n,e.tick+e.amount):n}function tE(e,t,n){return e.kind===`defense`&&e.actor_id===t&&mE(e.detail)?Math.max(n??e.tick,e.tick):n}function nE(e,t){if(e.stunned_ticks>0||e.action_id!==null&&e.action_id===t.cutActionId)return!0;let n=t.evasionFrom;if(n===void 0||e.action===null)return!1;let r=e.action_start_tick+e.action_startup_ticks+e.action_active_ticks;return n>=r&&n=n&&t0?Math.min((n.rootedUntil??0)-t,e.stunned_ticks)-1:0;return Math.max(r,i)}function aE(e,t,n){if(!mE(e.defense))return 0;let r=n.evasionFrom;return t===void 0||r===void 0||r>t?null:Math.max(0,r+y+P(e.style).evasionTicks-t-1)}function oE(e,t,n){if(e.queued_actions===0)return 1/0;if(t===void 0)return 0;if(e.action!==null&&!nE(e,n)){let n=e.action_start_tick+e.action_startup_ticks+e.action_active_ticks+e.action_recovery_ticks-t-1;if(n>0)return n}return Math.max(0,e.stunned_ticks)}function sE(e,t,n,r,i={}){let a=aE(e,r,i);if(n<=0||QT(e)||a===null)return{dx:0,dy:0};let o=Math.max(a,r===void 0?e.action===null?0:1/0:iE(e,r,i)),s=oE(e,r,i),c=nE(e,i),l=(t,n)=>Math.min(n.share??1,r!==void 0&&!c&&rE(e,r+1+t)?v/100:1),u=e.velocity_x,d=e.velocity_y,f=0,p=0,m=Math.floor(n),h=n-m;for(let e=0;e=o&&er.speed*i&&(u=u/a*r.speed*i,d=d/a*r.speed*i),f+=u,p+=d}if(h>0){let e=m>=o&&m(e*(100-_)+t*_)/100,lE=1e3,uE=2.5,dE=class{history=[];offset={dx:0,dy:0};mean={x:0,y:0,speed:0,share:1};sample={x:0,y:0,speed:0};horizon=null;holds={rootedUntil:0,cutActionId:null,evasionFrom:void 0};observe(e,t){this.holds.rootedUntil=eE(e,t,this.holds.rootedUntil),this.holds.evasionFrom=tE(e,t,this.holds.evasionFrom)}update(e,t,n,r,i,a,o,s){for(this.history.push({at:r,held:n<=0?{...t,moveX:0,moveY:0}:t,share:n<=0?1:n});this.history.length>2&&this.history[1].at0&&e.action_id!==null&&(this.holds.cutActionId=e.action_id),e!==null){let t=1e3/s,n=this.horizon;c=sE(e,i=>this.meanIntent(e,i,r-(n-1-i)*t,t),n,a,this.holds)}let l=uE*g*s*o,u=c.dx-this.offset.dx,d=c.dy-this.offset.dy,f=Math.hypot(u,d),p=f>l?l/f:1;return this.offset.dx+=u*p,this.offset.dy+=d*p,{dx:this.offset.dx,dy:this.offset.dy}}meanIntent(e,t,n,r){let i=n-r/2,a=n+r/2,o=this.mean;o.x=0,o.y=0,o.speed=0,o.share=0;for(let n=0;nr?{x:i*(S-r),y:a*r}:m>n?{x:i*n,y:a*(S-n)}:{x:i*m,y:a*h}}function pE(e,t,n){let r=e.x+t.dx,i=e.y+t.dy;if(n!==null){let t=Math.min(qT,Math.hypot(e.x-n.x,e.y-n.y)),a=r-n.x,o=i-n.y,s=Math.hypot(a,o);s1e-9?(r=n.x+a/s*t,i=n.y+o/s*t):(r=e.x,i=e.y))}let a=fE(r,i);return{dx:a.x-e.x,dy:a.y-e.y}}function mE(e){return e===`slip_left`||e===`slip_right`||e===`weave`||e===`pull`}function hE(e,t,n,r=!1){return e.stunned_ticks>0||e.taunt_ticks>0||e.clinch_ticks>0?e.defense:n===null?mE(e.defense)&&!r?e.defense:Ne(e.injuries)?`none`:t.defense:n}var gE=class{kind=null;id=``;startsAt=0;endsAt=0;until=0;sequence=null;started=!1;press(e,t,n,r,i,a=y,o=n){this.kind=e,this.id=t,this.startsAt=o,this.endsAt=o+a*1e3/i,this.until=this.endsAt+Math.max(0,r)*1e3/i,this.sequence=null,this.started=!1}acknowledge(e,t,n){if(this.kind===null)return!1;this.sequence??=n?.(this.id)??null,e.defense===this.kind&&(this.started=!0);let r=!t||e.stunned_ticks>0||e.clinch_ticks>0,i=!this.started&&this.sequence!==null&&e.last_input_sequence>=this.sequence&&e.queued_actions===0;return(r||i)&&(this.kind=null),i}pose(e){return this.kind!==null&&e>=this.until&&(this.kind=null),this.kind!==null&&e>=this.startsAt&&e=this.startsAt&&e=this.startsAt&&e=this.startsAt?!1:(this.kind=null,!0)}};function _E(e,t=!1){let n=e[0].index!==null,r=new Set(Object.keys(e[0].attributes)),i=new Set(Object.keys(e[0].morphAttributes)),a={},o={},s=e[0].morphTargetsRelative,c=new iv,l=0;for(let u=0;u{let r=new e.array.constructor(e.count*e.itemSize);l[n][t]=new e.constructor(r,e.itemSize,e.normalized)}))}let p=t*.5,m=10**Math.log10(1/t),h=p*m;for(let t=0;te*t,z:e=>-e*n}}var OE={blue:1920728,red:12131356,neutral:15067115},kE=[{radius:8.2,y:-.55,count:120,scale:1},{radius:10.6,y:.35,count:150,scale:1.04},{radius:13.2,y:1.35,count:180,scale:1.08},{radius:16,y:2.45,count:210,scale:1.12}],AE=.95,jE=.42,ME=[3819104,5915960,3493980,6963002,4612159,5524835,7233348,9076852,4678266,7620714,10107450,11843778,3104688,11573822,2303534,2303534],NE=[13081462,9067067,7225640,14726287,5517341,11105359],PE=[1380364,2759442,4862496,7035464,9341572,11569742],FE=.9,IE=.235,LE=-.35,RE=.32,zE=.26,BE=6.2;function VE(e,t,n=BE){return t>0&&Math.hypot(e,t)>n&&Math.abs(Math.atan2(e,t))<.3}var HE=` -#ifdef USE_INSTANCING - vec4 crowdWorld = modelMatrix * instanceMatrix * vec4(transformed, 1.0); -#else - vec4 crowdWorld = modelMatrix * vec4(transformed, 1.0); -#endif -vCrowdLight = vec3(-crowdWorld.x, ${7.5.toFixed(1)} - crowdWorld.y, -crowdWorld.z); -`,UE=` -#ifdef USE_COLOR - totalEmissiveRadiance *= vColor.rgb * (0.22 + 0.78 * max(0.0, dot(inverseTransformDirection(normal, viewMatrix), normalize(vCrowdLight)))); -#endif -`,WE=(e,t,n)=>{let r=Math.min(1,Math.max(0,(n-e)/(t-e)));return r*r*(3-2*r)};function GE(e,t){let n=[];for(let[r,i]of e.entries())for(let e=0;e0&&Math.abs(Math.atan2(s,c))<.3})}return n}function KE(e,t,n,r={rise:0,armLeft:0,armRight:0,sway:0}){let i=.2+.7*(1-e.keen),a=WE(i-.12,i+.12,n),o=Math.abs(Math.sin(t*(2.3+n*3.2)+e.phase*1.7))*(.02+.1*a),s=Math.sin(t*6.2+e.phase)*.32*a,c=LE+-2.35*a;return r.rise=a*RE+o,r.armLeft=c+s,r.armRight=c-s*.8,r.sway=Math.sin(t*1.6+e.phase)*(.04+n*.05),r}function qE(e){let t=_E(e,!1);for(let t of e)t.dispose();if(t===null)throw Error(`crowd geometry could not be merged`);return t}function JE(){let e=new Py(.16,.28,2,8);e.scale(1.35,1,.8),e.translate(0,.64,0);let t=new Py(.078,.3,1,5);t.rotateZ(Math.PI/2),t.translate(0,.89,0);let n=new Py(.11,.26,1,5);return n.rotateX(Math.PI/2),n.scale(1.7,1,1),n.translate(0,.4,.17),qE([e,t,n])}function YE(){let e=new _b(.105,10,6);e.rotateY(-Math.PI/2),e.scale(.92,1.12,1),e.translate(0,1.12,.01);let t=new Iy(.048,.056,.1,5,1,!0);t.translate(0,.99,0);let n=t.getAttribute(`uv`);for(let e=0;e{e.vertexShader=e.vertexShader.replace(`#include `,`#include -varying vec3 vCrowdLight;`).replace(`#include `,`#include \n${HE}`),e.fragmentShader=e.fragmentShader.replace(`#include `,`#include -varying vec3 vCrowdLight;`).replace(`#include `,`#include \n${UE}`)},e.customProgramCacheKey=()=>`hands-crowd`;let u=new Ab({color:724501,roughness:.96,metalness:0,side:2}),d=new ny(o[0],s,i),f=new ny(o[1],c,i),p=new ny(o[2],l,i),m=new ny(o[3],s,i),h=new ny(o[3],s,i),g=[d,f,p,m,h],_=[d,f,p];for(let e of g)e.instanceMatrix.setUsage(gh),e.frustumCulled=!1;let v=new J;for(let t=0;t.12&&v.setHex(PE[Math.floor(e()*PE.length)]).multiplyScalar((.8+e()*.4)*n),p.setColorAt(t,v)}for(let e of g)e.instanceColor.needsUpdate=!0;let y=new Y(o[4],u);y.name=`stands`,y.receiveShadow=!1,n.add(y,...g);let b=new q(0,1,0),x=new q,S=new rg,C=new q,w=new Dg,T=new Dg,E=new Dg,D=new Dg,O={rise:0,armLeft:0,armRight:0,sway:0},k=(e,t,n,r)=>{E.makeTranslation(n*IE,FE,0),D.makeRotationX(r),T.multiplyMatrices(w,E).multiply(D),e.setMatrixAt(t,T)},A=0,j=!1,ee=!1,M=!1,te=0,ne=0,re=r.flatMap((e,t)=>e.platform?[t]:[]),ie=new Dg().makeScale(0,0,0),N=(e,t)=>{let n=r[e];if(M&&n.platform)for(let n of t?g:_)n.setMatrixAt(e,ie);else KE(n,te,ne,O),S.setFromAxisAngle(b,n.yaw+O.sway),w.compose(x.set(n.x,n.y+O.rise*n.scale,n.z),S,C.setScalar(n.scale)),d.setMatrixAt(e,w),f.setMatrixAt(e,w),p.setMatrixAt(e,w),t&&(k(m,e,1,O.armLeft),k(h,e,-1,O.armRight))},ae=(e,t,n=!1)=>{let r=n||ee;ee=!1;let a=r?1:j?4:2,o=Math.ceil(i/a),s=A%a*o,c=Math.min(i,s+o);A+=1,te=e,ne=t;let l=!j||r;for(let e=s;e{e!==j&&(j=e,m.visible=!e,h.visible=!e,e||(ee=!0))},makeRoomForCamera:e=>{let t=VE(e.x,e.z,M?5.9:BE);if(t!==M){M=t;for(let e of re)N(e,!0);for(let e of g)e.instanceMatrix.clearUpdateRanges(),e.instanceMatrix.needsUpdate=!0}},dispose:()=>{for(let e of o)e.dispose();for(let e of[s,c,l,u])e.dispose();a.dispose();for(let e of g)e.dispose()}}}var tD=.3,nD=.012,rD=e=>()=>(e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296);function iD(){let e=new t_;e.name=`arena`;let t=[],n=[],r=[],i=new Ab({color:`#05070c`,roughness:.95});n.push(i);let a=new Fy(30,40);t.push(a);let o=new Y(a,i);o.rotation.x=-Math.PI/2,o.position.y=-1,o.receiveShadow=!0,e.add(o);let s=rD(20260727),c=kE,l=eD(s);e.add(l.group);let u=document.createElement(`canvas`);u.width=1024,u.height=64;let d=u.getContext(`2d`);d!==null&&(d.fillStyle=`#070c1a`,d.fillRect(0,0,1024,64),d.fillStyle=`#13203f`,d.fillRect(0,0,1024,5),d.fillRect(0,59,1024,5),d.textBaseline=`middle`,d.font=`800 38px Inter, system-ui, sans-serif`,d.fillStyle=`#e9c46a`,d.fillText(`H A N D S`,28,33),d.fillStyle=`#c9d6f2`,d.font=`600 26px Inter, system-ui, sans-serif`,d.fillText(`CHAMPIONSHIP BOXING`,300,34),d.fillStyle=`#e9c46a`,d.font=`800 30px Inter, system-ui, sans-serif`,d.fillText(`FIGHT NIGHT`,700,34),d.fillStyle=`#b91c1c`,d.fillRect(948,22,22,22),d.fillStyle=`#1d4ed8`,d.fillRect(978,22,22,22));let f=new ky(u);f.colorSpace=uh,f.wrapS=Vp,f.repeat.set(-6,1),r.push(f);let p=new yv({map:f,side:1});n.push(p);let m=c[0].y+jE,h=new Iy(c[0].radius-AE-.03,c[0].radius-AE-.03,m- -1-.04,72,1,!0);t.push(h);let g=new Y(h,p);g.name=`boards`,g.position.y=(m+-1)/2+.02,e.add(g);let _=new Float32Array(270);for(let e=0;e<90;e+=1){let t=c[Math.floor(s()*c.length)],n=s()*Math.PI*2;_[e*3]=Math.sin(n)*t.radius,_[e*3+1]=t.y+.9+s()*.5,_[e*3+2]=Math.cos(n)*t.radius}let v=new iv;v.setAttribute(`position`,new U_(_,3)),t.push(v);let y=new xy({color:13623551,size:.09,transparent:!0,opacity:0,blending:2,depthWrite:!1});n.push(y);let b=new Ey(v,y);e.add(b);let x=new Ab({color:`#11151d`,roughness:.6,metalness:.4});n.push(x);let S=new Ab({color:`#1a2230`,emissive:`#dfe9ff`,emissiveIntensity:1.1,roughness:.4});n.push(S);let C=new yv({color:`#a8c4ff`,transparent:!0,opacity:.006,blending:2,depthWrite:!1,side:2});n.push(C);let w=new Ny(9,.18,.18);t.push(w);let T=new Iy(.09,.14,.22,10);t.push(T);let E=new Ly(1.7,6.6,20,1,!0);t.push(E);for(let t=0;t<2;t+=1){let n=new Y(w,x);n.position.set(0,7.6,t===0?-1.6:1.6),e.add(n);for(let t=0;t<5;t+=1){let r=-3.6+t*1.8,i=new Y(T,S);i.position.set(r,7.45,n.position.z),e.add(i);let a=new Y(E,C);a.position.set(r,4.1,n.position.z*.4),e.add(a)}}let D=new Ab({color:`#070a12`,roughness:1});n.push(D);let O=new Iy(24,24,14,32,1,!0);t.push(O);let k=new Y(O,D);k.position.y=5,k.material.side=1,e.add(k);let A=document.createElement(`canvas`);A.width=512,A.height=256;let j=A.getContext(`2d`);j!==null&&(j.fillStyle=`#04060c`,j.fillRect(0,0,512,256),j.strokeStyle=`#f1cc72`,j.lineWidth=6,j.strokeRect(14,14,484,228),j.fillStyle=`#f1cc72`,j.font=`800 84px Inter, system-ui, sans-serif`,j.textAlign=`center`,j.textBaseline=`middle`,j.fillText(`H A N D S`,256,104),j.fillStyle=`#8fa3c8`,j.font=`600 30px Inter, system-ui, sans-serif`,j.fillText(`CHAMPIONSHIP BOXING`,256,186));let ee=new ky(A);ee.colorSpace=uh;let M=new yv({map:ee});n.push(M);let te=new Ny(4.6,2.3,.3);t.push(te);let ne=new Y(te,M);ne.position.set(0,6.4,-14.5),e.add(ne);let re=new Y(te,x);re.position.set(0,6.4,-14.65),e.add(re),r.push(ee);let ie=0,N=0,ae=0,oe=!1;return{group:e,update:(e,t,n)=>{ae=Math.max(0,ae-t*tD),n&&!oe&&l.update(0,0,!0),oe=n,n||(l.update(e,ae),f.offset.x=e*nD%1,ie-=t,ie<=0&&(N=.09+Math.random()*.08,ie=(.25+Math.random()*1.6)/(1+ae*4)),N=Math.max(0,N-t),y.opacity=N>0?.85:0)},excite:e=>{ae=Math.min(1,ae+Math.max(0,e))},excitement:()=>ae,setLowTier:l.setLowTier,makeRoomForCamera:l.makeRoomForCamera,dispose:()=>{for(let e of t)e.dispose();for(let e of n)e.dispose();for(let e of r)e.dispose();l.dispose()}}}var aD=2.05,oD=5.5,sD=1.05,cD=1.78,lD=3.75,uD=.85,dD=.45,fD=1.18,pD=2.5,mD=5.5;function hD(e,t,n){return e<2.5||t<3?null:(n+Math.floor((e-pD)/mD))%2}function gD(e){return Math.max(0,e-pD)%mD}var _D=.95,vD=2.6,yD=-25;function bD(e,t,n,r,i){let a=e===0?-1:1,o=r*Math.PI/180,s=-a*Math.SQRT1_2,c=a*Math.SQRT1_2,l=s*Math.cos(o)+c*Math.sin(o),u=-s*Math.sin(o)+c*Math.cos(o);return i.set(a*t+l*n,0,-a*t+u*n)}function xD(e,t,n,r,i){bD(e,t,vD,yD+Math.min(1,n/mD)*5,r).setY(1.45),bD(e,t,.62,27,i).setY(1.05)}var SD={top:2.42,bottom:.95,width:2.4};function CD(e,t,n,r=.09){let i=Math.max(.2,1-n-r),a=Math.max((SD.top-SD.bottom)/i,SD.width/Math.max(.1,e)),o=(SD.top+SD.bottom)/2;return{distance:a/(2*Math.tan(G.degToRad(t)/2)),height:o-(.5-(r+i/2))*a}}var wD=class{current=new q(0,aD,oD);look=new q(0,sD,0);swayPhase=0;update(e,t,n,r,i,a,o,s,c=!1,l=null){this.swayPhase+=e;let u=a&&l!==null?uD:0,d=(n.x+r.x)/2+((l?.x??0)-(n.x+r.x)/2)*u,f=(n.z+r.z)/2+((l?.z??0)-(n.z+r.z)/2)*u,p=G.clamp(d,-1.4,1.4),m=G.clamp(f,-1.1,1.1),h=c?G.clamp(lD+i*.45-(a?.6:0),3.3,5.6):G.clamp(oD+i*.6-(a?.9:0),4.6,8.4),g=(c?cD:aD)+i*.08-(a?.45:0),_=s?0:Math.sin(this.swayPhase*.21)*.35,v=s?0:Math.sin(this.swayPhase*.13)*.3,y=p*.32+_,b=h+m*.2,x=g+v*.2;if(this.current.x+=(y-this.current.x)*(1-Math.exp(-2.6*e)),this.current.y+=(x-this.current.y)*(1-Math.exp(-2.6*e)),this.current.z+=(b-this.current.z)*(1-Math.exp(-2.6*e)),this.look.x+=(p-this.look.x)*(1-Math.exp(-3.2*e)),this.look.y+=((a?u>0?dD:.7:c?fD:sD)-this.look.y)*(1-Math.exp(-3.2*e)),this.look.z+=(m*.6-this.look.z)*(1-Math.exp(-3.2*e)),!s&&o>5e-4){let e=t*61;this.current.x+=Math.sin(e*1.31)*o,this.current.y+=Math.cos(e*1.97)*o*.6,this.look.x+=Math.sin(e*1.53)*o*.5,this.look.y+=Math.cos(e*2.11)*o*.35}return{position:this.current,lookAt:this.look}}},TD=2.45,ED=2.25,DD=1.35,OD=3.5,kD=1.25,AD=.45;function jD(e,t,n,r,i,a,o=31){let s=G.degToRad(o),c=Math.cos(s)*TD,l=Math.sin(s)*TD,u=-r,d=n,f=-n*c+u*l,p=-r*c+d*l,m=(e,t)=>Math.abs(t)<1e-9?1:G.clamp((Math.sign(t)*OD-e)/t,0,1),h=Math.min(m(e.x,f),m(e.z,p));i.set(G.clamp(e.x+f*h,-3.5,OD),ED,G.clamp(e.z+p*h,-3.5,OD)),a.set(t.x,DD,t.z)}var MD=class{angle=Math.PI;closeness=0;initialised=!1;target=new q;position=new q;look=new q;aim=new q;get forwardX(){return Math.sin(this.angle)}get forwardZ(){return Math.cos(this.angle)}reset(){this.initialised=!1}update(e,t,n,r,i,a,o=16/9){let s=r.x-n.x,c=r.z-n.z,l=Math.hypot(s,c),u=l>.05?Math.atan2(s,c):this.angle,d=G.clamp((1.3-l)/.8,0,1);if(!this.initialised)this.angle=u,this.closeness=d;else{let t=Math.atan2(Math.sin(u-this.angle),Math.cos(u-this.angle));this.angle+=t*(1-Math.exp(-4.5*e)),this.closeness+=(d-this.closeness)*(1-Math.exp(-3*e))}let f=G.clamp(o,AD,1);if(jD(n,r,this.forwardX,this.forwardZ,this.target,this.aim,G.lerp(31,60,this.closeness)*f),!this.initialised)this.position.copy(this.target),this.look.copy(this.aim),this.initialised=!0;else{let t=1-Math.exp(-10*e);this.position.lerp(this.target,t),this.look.lerp(this.aim,t)}let p={position:this.position,lookAt:this.look,tight:!0};if(a||i<=5e-4)return p;let m=t*61;return this.target.set(this.position.x+Math.sin(m*1.31)*i,this.position.y+Math.cos(m*1.97)*i*.6,this.position.z),this.aim.set(this.look.x+Math.sin(m*1.53)*i*.5,this.look.y+Math.cos(m*2.11)*i*.35,this.look.z),{position:this.target,lookAt:this.aim,tight:!0}}},ND=54,PD=136,FD=110,ID=168,LD=400,RD=74,zD=72,BD={right:220,wideTop:64,compactTop:120,height:34},VD=200,HD={reach:192,bottom:80},UD=`rgba(3,6,12,0.86)`,WD=`rgb(4,7,13)`,GD={play:`#f6d57a`,colour:`#9ec7ff`,announcer:`#f6d57a`},KD=[`#4f86d9`,`#d9483c`],qD=`Inter, system-ui, sans-serif`;function JD(e){let{width:t,height:n}=e,r=t<640,i=n<480,a=i?.78:r?.85:1,o=Math.min(680,t-24),s=e.resultTop,c=s===null&&e.touch&&e.phase!==`complete`,l=tr(t,n,c);if(c&&e.paused===!0&&e.phase===`countdown`)return null;if(s===null&&e.phase===`countdown`){let e=l.x+l.width/2,r=t-(c&&t>n?$n(t,n,l.y+l.height):12);return{x:e,y:l.y,maxWidth:Math.min(o,2*Math.min(e-12,r-e)),anchor:`top`,scale:a,cover:{width:l.width,height:l.height}}}let u=t-384;if(s===null&&!e.touch&&!i&&u>=LD){let r=n-(e.hint?ID:FD),i=e.cornerPanelTop===void 0||e.cornerPanelTop===null?r:Math.min(r,e.cornerPanelTop-8);if(i-RD*a>=n*.45)return{x:t/2,y:i,maxWidth:Math.min(o,u),anchor:`bottom`,scale:a,cover:null}}if(s===null&&e.viewerDown)return null;let d=s===null&&r?PD:ND;s===null&&(e.phase===`rest`||e.phase===`foul_recovery`||c&&e.paused===!0?d=Math.max(d,l.y+l.height+8):e.phase===`knockdown`?d=Math.max(d,hr(n,r)+zD):e.phase===`finish`&&(d=Math.max(d,Tr(t,n,c).bottom+8+(c?0:59))),e.replay&&t/2-o/2f)return null;let p=c&&e.lag===!0&&!r&&!e.replay&&dMath.round(8*e)+Math.round(10*e)+Math.round(4*e)+2*Math.round(Math.round(17*e)*1.3)+Math.round(5*e);function XD(e,t,n,r){let i=r?1:t.opacity;if(i<=.01)return;let a=r||n.cover!==null?0:t.entering*8*(n.anchor===`bottom`?1:-1);e.save(),e.globalAlpha=i,e.textBaseline=`alphabetic`;let o=i*i;t.line.card===null?$D(e,t.line,n,a,o):tO(e,t.line.card,n,a,o),e.restore()}function ZD(e,t,n){if(e.measureText(t).width<=n)return t;let r=t;for(;r.length>1&&e.measureText(`${r}…`).width>n;)r=r.slice(0,-1);return`${r}…`}function QD(e,t){let n=e.length/2,r=null,i=1/0;for(let a=e.indexOf(` `);a>=0;a=e.indexOf(` `,a+1)){let o=e.slice(0,a),s=e.slice(a+1),c=Math.abs(a-n);t(o)&&t(s)&&c0?[e.slice(0,a),e.slice(a+1)]:[e,``]}function $D(e,t,n,r,i){let a=n.scale,o=Math.round(14*a),s=Math.round(10*a),c=n.maxWidth-o*2-4,l=(t,n)=>(e.font=`700 ${n}px ${qD}`,e.measureText(t).width),u=un(e=>l(t.text,e),c,Math.round(17*a),Math.round(13*a)),d=l(t.text,u)<=c?[t.text]:QD(t.text,e=>l(e,u)<=c).filter(e=>e.length>0),f=Math.max(...d.map(e=>Math.min(c,l(e,u)))),p=zf[t.speaker];e.font=`800 ${s}px ${qD}`;let m=e.measureText(p).width,h=Math.min(n.maxWidth,Math.max(f,m)+o*2+4),g=Math.round(u*1.3),_=Math.round(8*a)+s,v=_+Math.round(4*a)+d.length*g+Math.round(5*a),y=(n.anchor===`bottom`?n.y-v:n.y)+r,b=n.x-h/2,x=GD[t.speaker];e.fillStyle=UD,e.fillRect(b,y,h,v),e.fillStyle=x,e.fillRect(b,y,4,v),e.globalAlpha=i,e.textAlign=`left`,e.font=`800 ${s}px ${qD}`,e.fillText(p,b+4+o,y+_),e.fillStyle=`#f6f7fb`,e.font=`700 ${u}px ${qD}`,d.forEach((t,n)=>e.fillText(ZD(e,t,c),b+4+o,y+_+Math.round(4*a)+g*(n+1)-Math.round(u*.28)))}function eO(e,t,n){let r=Math.round(11*e),i=Math.round(28*e),a=Math.round(6*e),o={pad:Math.round(10*e),gap:Math.round(7*e)},s={pad:Math.max(4,Math.round(6*e)),gap:Math.max(3,Math.round(4*e))},c=t?Math.round(10*e):0,l=[{...o,detail:c},{...s,detail:c},{...s,detail:0}],u=(e,t)=>e.pad*2+r+e.gap+t+(e.detail===0?0:a+e.detail);for(let e of l)if(n===null||u(e,i)<=n)return{kicker:r,title:i,...e,height:u(e,i)};let d=l[2],f=Math.max(12,Math.min(i,(n??1/0)-u(d,0)));return{kicker:r,title:f,...d,height:u(d,f)}}function tO(e,t,n,r,i){let a=n.scale,o=Math.round(18*a),s=n.maxWidth-o*2,c=eO(a,t.detail.length>0,n.cover?.height??null),l=c.kicker,u=c.detail,d=(t,n,r)=>(e.font=`${n} ${r}px ${qD}`,e.measureText(t).width),f=un(e=>d(t.title,900,e),s,c.title,Math.min(c.title,Math.round(15*a))),p=Math.max(d(t.kicker,800,l),Math.min(s,d(t.title,900,f)),u===0?0:d(t.detail,700,u)),m=Math.min(n.maxWidth,Math.max(240*a,p+o*2,n.cover?.width??0)),h=c.pad+l+c.gap+f+(u===0?0:Math.round(6*a)+u)+c.pad,g=Math.max(h,n.cover?.height??0),_=(n.anchor===`bottom`?n.y-g:n.y)+r,v=n.x-m/2,y=t.corner===null?GD.announcer:KD[t.corner];e.fillStyle=n.cover===null?UD:WD,e.fillRect(v,_,m,g),e.fillStyle=y,e.fillRect(v,_,m,3),e.globalAlpha=i,e.textAlign=`center`;let b=_+(g-h)/2+c.pad+l;e.font=`800 ${l}px ${qD}`,e.fillText(ZD(e,t.kicker,s),n.x,b),b+=c.gap+f,e.fillStyle=`#ffffff`,e.font=`900 ${f}px ${qD}`,e.fillText(ZD(e,t.title,s),n.x,b-Math.round(f*.12)),u>0&&(b+=Math.round(6*a)+u,e.fillStyle=`#93a3bd`,e.font=`700 ${u}px ${qD}`,e.fillText(ZD(e,t.detail,s),n.x,b))}var nO=128,rO=4,iO=.12,aO=.82,oO={edge:4851467,core:[`rgba(40,3,6,0.9)`,`rgba(58,5,9,0.65)`,`rgba(70,7,11,0)`]},sO=6,cO=.29,lO=14,uO=e=>()=>(e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296);function dO(e){let t=uO(e);return{lobes:Array.from({length:5+Math.floor(t()*4)},(e,n)=>{let r=t()*Math.PI*2,i=n===0?0:6+t()*12,a=n===0?16+t()*6:8+t()*9;return{x:64+Math.cos(r)*i,y:64+Math.sin(r)*i,rx:a,ry:a*(.55+t()*.45),turn:t()*Math.PI}}),fill:.55+t()*.2,rim:.95,satellites:6+Math.floor(t()*6)}}function fO(e){let t=document.createElement(`canvas`);t.width=nO,t.height=nO;let n=t.getContext(`2d`);if(n!==null){let t=dO(e),r=uO(e^1540483477);n.clearRect(0,0,nO,nO),n.fillStyle=`rgba(255,255,255,1)`,n.strokeStyle=`rgba(255,255,255,1)`,n.globalAlpha=t.rim,n.lineWidth=3.5;for(let e of t.lobes)n.beginPath(),n.ellipse(e.x,e.y,e.rx,e.ry,e.turn,0,Math.PI*2),n.stroke();let i=()=>{n.beginPath();for(let e of t.lobes){let t=Math.max(1,e.rx-1.5);n.moveTo(e.x+Math.cos(e.turn)*t,e.y+Math.sin(e.turn)*t),n.ellipse(e.x,e.y,t,Math.max(1,e.ry-1.5),e.turn,0,Math.PI*2)}n.fill()};n.globalCompositeOperation=`destination-out`,n.globalAlpha=1,i(),n.globalCompositeOperation=`source-over`,n.globalAlpha=t.fill,i();for(let e=0;e{let t=t=>Math.round((e>>t&255)*.8);return`rgb(${t(16)},${t(8)},${t(0)})`},mO=class{scene;size;mesh;canvas;context;texture;source;uploader=null;region=new iS;regionAt=new K;material;geometry;stamps=[];tinted=new Map;pixelsPerMetre;dirty=!1;sinceUpload=0;uploadInterval=iO;painted=0;streakSeed=0;constructor(e,t=1024){this.scene=e,this.size=t,this.canvas=document.createElement(`canvas`),this.canvas.width=t,this.canvas.height=t,this.context=this.canvas.getContext(`2d`),this.context?.clearRect(0,0,t,t);for(let e=0;e3.05||Math.abs(t)>3.05)return;let c=this.context;if(this.painted+=1,this.dirty=!0,this.mesh.visible=!0,c===null)return;let l=this.tintedStamp(o,s),u=this.pixel(e,t),d=Math.max(1,n*this.pixelsPerMetre),f=Math.max(1,r*this.pixelsPerMetre);this.grow(u.x,u.y,Math.hypot(d,f)/2),c.save(),c.globalAlpha=G.clamp(a,0,1),c.translate(u.x,u.y),c.rotate(Number.isFinite(i)?i:0),c.drawImage(l,-d/2,-f/2,d,f),c.restore()}tintedStamp(e,t){let n=this.tinted.get(e);return n===void 0&&(n=this.stamps.map(t=>{let n=document.createElement(`canvas`);n.width=nO,n.height=nO;let r=n.getContext(`2d`);return r!==null&&(r.drawImage(t,0,0),r.globalCompositeOperation=`source-in`,r.fillStyle=pO(e),r.fillRect(0,0,nO,nO)),n}),this.tinted.set(e,n)),n[Math.abs(Math.trunc(t))%rO]}pool(e,t,n,r,i,a=oO){this.stain(e,t,n*2.3,n*2,i*1.7,r*.8,a.edge,i);let o=this.context;if(o===null||Math.abs(e)>3.05||Math.abs(t)>3.05)return;let s=this.pixel(e,t),c=Math.max(1,n*1.15*this.pixelsPerMetre);this.grow(s.x,s.y,c);let l=o.createRadialGradient(s.x,s.y,0,s.x,s.y,c);l.addColorStop(0,a.core[0]),l.addColorStop(.65,a.core[1]),l.addColorStop(1,a.core[2]),o.save(),o.globalAlpha=G.clamp(r,0,1),o.fillStyle=l,o.beginPath(),o.ellipse(s.x,s.y,c,c*.86,i*.9,0,Math.PI*2),o.fill(),o.restore()}streakRandom(){return this.streakSeed=Math.imul(this.streakSeed^this.streakSeed>>>15,1|this.streakSeed),this.streakSeed^=this.streakSeed+Math.imul(this.streakSeed^this.streakSeed>>>7,61|this.streakSeed),((this.streakSeed^this.streakSeed>>>14)>>>0)/4294967296}smear(e,t,n,r,i,a,o){if(!Number.isFinite(e+t+n+r+i)||Math.abs(e)>3.05||Math.abs(t)>3.05)return;let s=this.context;if(this.painted+=1,this.dirty=!0,this.mesh.visible=!0,s===null)return;let c=(e+xE)*this.pixelsPerMetre,l=(t+xE)*this.pixelsPerMetre,u=(G.clamp(n,-xE,xE)+xE)*this.pixelsPerMetre,d=(G.clamp(r,-xE,xE)+xE)*this.pixelsPerMetre,f=Math.max(1,i*this.pixelsPerMetre);this.grow(c,l,f),this.grow(u,d,f);let p=Math.hypot(u-c,d-l),m=p>1e-6?(l-d)/p:1,h=p>1e-6?(u-c)/p:0;this.streakSeed=1374496523^Math.imul(this.painted,40503),s.save(),s.strokeStyle=pO(o),s.lineCap=`round`;for(let e=0;e3.05||Math.abs(t)>3.05)return;let o=this.context;if(this.painted+=1,this.dirty=!0,this.mesh.visible=!0,o===null)return;let s=(e+xE)*this.pixelsPerMetre,c=(t+xE)*this.pixelsPerMetre,l=Math.max(2,cO*this.pixelsPerMetre),u=l*.36;this.grow(s,c,l*.6);let d=(r?-1:1)*u*.06,f=l/lO;o.save(),o.globalAlpha=G.clamp(i,0,1),o.fillStyle=pO(a),o.translate(s,c),o.rotate(-n);for(let e=0;et.min.x&&t.max.y>t.min.y?this.uploader.copyTextureToTexture(this.source,this.texture,t,this.regionAt.copy(t.min)):this.texture.needsUpdate=!0,t.makeEmpty(),this.dirty=!1,this.sinceUpload=0}clear(){this.context?.clearRect(0,0,this.size,this.size),this.painted=0,this.dirty=!1,this.region.makeEmpty(),this.texture.needsUpdate=!0,this.mesh.visible=!1}dispose(){this.scene.remove(this.mesh),this.texture.dispose(),this.source.dispose(),this.material.dispose(),this.geometry.dispose()}};function hO(){let e=new fb(1,2);e.deleteAttribute(`normal`),e.deleteAttribute(`uv`);let t=yE(e,1e-4);e.dispose();let n=t.getAttribute(`position`),r=new q;for(let e=0;e=120?5:t>=90?3:t>=60?2:+(t>=40):e===`hit`?t>=130?4:t>=100?3:t>=75?2:+(t>=50):0:0}function vO(e,t){return Math.min(800,Math.round(Math.max(0,e)*4.5+Math.max(0,t)*2.8))}var yO=1.1,bO=.6,xO=.35,SO=1.2;function CO(){let e=new _b(1,8,6),t=e.getAttribute(`position`);for(let e=0;e1+(e-1)*28+t%28;for(let e=0;e<28;e+=1)a.push(0,o(1,e+1),o(1,e));for(let e=1;e<6;e+=1)for(let t=0;t<28;t+=1)a.push(o(e,t),o(e,t+1),o(e+1,t)),a.push(o(e,t+1),o(e+1,t+1),o(e+1,t));let s=new iv;return s.setAttribute(`position`,new K_(r,3)),s.setAttribute(`uv`,new K_(i,2)),s.setIndex(a),s.computeVertexNormals(),s}function AO(e,t){let n=e.getAttribute(`position`),r=e.getIndex();if(r===null)return[];let i=new Map,a=new Int32Array(n.count),o=new Uint8Array(n.count),s=new q;for(let e=0;eo[e]===1);for(let e=0;e<3;e+=1){let r=a[t[e]],o=a[t[(e+1)%3]],s=r=2&&l.push(Math.floor(e/n.count),e%n.count);return l}var jO=.5,MO=new q,NO=new q,PO=new q,FO=new q,IO=new q;function LO(e,t,n){IO.copy(e).addScaledVector(t,-e.dot(t)).multiplyScalar(jO/n).add(t).normalize()}function RO(e,t,n,r,i=.01,a){let o=Math.floor(t.length/6),s=e.getAttribute(`position`),c=e.getAttribute(`normal`),l=e.getAttribute(`uv`);(s===void 0||c===void 0||l===void 0||s.count!==o*3)&&(s=new U_(new Float32Array(o*9),3).setUsage(gh),c=new U_(new Float32Array(o*9),3).setUsage(gh),l=new U_(new Float32Array(o*6),2).setUsage(gh),e.setAttribute(`position`,s),e.setAttribute(`normal`,c),e.setAttribute(`uv`,l)),MO.set(1,0,0),Math.abs(r.x)>.9&&MO.set(0,0,1),a!==void 0&&a.lengthSq()>1e-8&&Math.abs(a.dot(r))<.95*a.length()&&MO.copy(a),NO.crossVectors(r,MO).normalize(),MO.crossVectors(NO,r).normalize();let u=1e-6;for(let e=0;e=0)continue;let i=`${Math.round(s.x*1e5)},${Math.round(s.y*1e5)},${Math.round(s.z*1e5)}`,l=a.get(i)??n;a.set(i,l),o[n]=l}c.multiplyScalar(1/Math.max(1,r.count));for(let e=0;e{let t=e;for(;u.has(t);)t=u.get(t);return t},f=[];for(let[e,t]of l){if(t!==1)continue;f.push(e);let n=d(Math.floor(e/i)),r=d(e%i);n!==r&&u.set(n,r)}let p=new Map;for(let e of f){let t=d(e%i),n=p.get(t)??[];n.push(e),p.set(t,n)}let m=[],h=[],g=[],_=new iv,v=new iv,y=new q,b=new q,x=[];for(let e of p.values()){if(e.length<3)continue;let r=new Float32Array(e.length*6);y.set(0,0,0);let a=0;for(let[o,c]of e.entries()){let e=Math.floor(c/i),l=c%i;y.add(s.fromBufferAttribute(t,e)),s.toArray(r,o*6),y.add(s.fromBufferAttribute(t,l)),s.toArray(r,o*6+3),a+=n===void 0?r[o*6+1]+r[o*6+4]:n.getY(e)+n.getY(l)}y.multiplyScalar(1/(e.length*2));let o=0;for(let e=0;e(n=Math.imul(n^n>>>15,1|n),n^=n+Math.imul(n^n>>>7,61|n),((n^n>>>14)>>>0)/4294967296);for(let e=0;e<46;e+=1){let e=r()*Math.PI*2,n=14+r()*42;t.fillStyle=r()<.5?`rgba(150,28,30,0.55)`:`rgba(40,4,8,0.5)`,t.beginPath(),t.ellipse(64+Math.cos(e)*n,64+Math.sin(e)*n,3+r()*6,2+r()*3,e,0,Math.PI*2),t.fill()}let i=(e,n,r,i)=>{t.fillStyle=i,t.beginPath(),t.arc(e,n,r,0,Math.PI*2),t.fill()};i(64,38,10,`#8f7c64`),i(61,36,4.5,`#6a2a25`),i(66,78,7,`#7a3c34`),i(66,78,4.5,`#150203`),i(41,64,3,`#1d0204`),i(90,69,2.6,`#1d0204`);for(let e=0;e<70;e+=1){let e=r()*Math.PI*2,t=r()*60;i(64+Math.cos(e)*t,64+Math.sin(e)*t,.6+r()*1.6,r()<.4?`rgba(190,60,50,0.5)`:`rgba(20,2,4,0.55)`)}HO(t)}let n=new ky(e);return n.colorSpace=uh,n}function HO(e){e.lineWidth=7,e.strokeStyle=`rgba(214,178,92,0.85)`,e.beginPath(),e.arc(64,64,55,0,Math.PI*2),e.stroke(),e.lineWidth=4,e.strokeStyle=`#b8775c`,e.beginPath(),e.arc(64,64,61,0,Math.PI*2),e.stroke()}function UO(){let e=document.createElement(`canvas`);e.width=128,e.height=128;let t=e.getContext(`2d`);if(t!==null){let e=t.createRadialGradient(64,64,6,64,64,64);e.addColorStop(0,`#741014`),e.addColorStop(.7,`#52090d`),e.addColorStop(1,`#300407`),t.fillStyle=e,t.fillRect(0,0,128,128);let n=(e,n,r,i)=>{t.fillStyle=i,t.beginPath(),t.arc(e,n,r,0,Math.PI*2),t.fill()};for(let[e,t,r]of[[46,60,13],[84,66,10]])n(e,t,r,`#e4d8c0`),n(e,t,r*.62,`#a4483c`),n(e-r*.2,t-r*.2,r*.25,`rgba(220,110,90,0.6)`);for(let e=0;e<9;e+=1){let t=Math.PI*(.15+e/8*.7);n(64+Math.cos(t)*34,64+Math.sin(t)*34,3.2,`#d9c9b3`)}n(30,84,3.4,`#1a0204`),n(98,46,3,`#1a0204`),n(66,30,2.6,`#1a0204`),HO(t)}let n=new ky(e);return n.colorSpace=uh,n}function WO(){let e=document.createElement(`canvas`);e.width=128,e.height=128;let t=e.getContext(`2d`);if(t!==null){let e=t.createRadialGradient(64,64,6,64,64,64);e.addColorStop(0,`#7c1218`),e.addColorStop(.7,`#560a0f`),e.addColorStop(1,`#2e0407`),t.fillStyle=e,t.fillRect(0,0,128,128);let n=2135587861,r=()=>(n=Math.imul(n^n>>>15,1|n),n^=n+Math.imul(n^n>>>7,61|n),((n^n>>>14)>>>0)/4294967296);for(let e=0;e<11;e+=1){let n=e/11*Math.PI*2+r()*.3,i=26+r()*12;t.fillStyle=r()<.5?`#8e1c20`:`#6c1016`,t.strokeStyle=`rgba(30,3,6,0.8)`,t.lineWidth=1.6,t.beginPath(),t.ellipse(64+Math.cos(n)*i,64+Math.sin(n)*i,13+r()*5,8+r()*4,n+Math.PI/2,0,Math.PI*2),t.fill(),t.stroke()}let i=(e,n,r,i)=>{t.fillStyle=i,t.beginPath(),t.arc(e,n,r,0,Math.PI*2),t.fill()};i(58,60,15,`#e8dcc4`),i(58,60,9.5,`#a8463a`),i(55,57,3.5,`rgba(226,116,96,0.65)`),i(82,70,4.2,`#170204`),i(80,80,3,`#3a0a2a`),i(88,62,2.2,`#e0d2a0`);for(let e=0;e<70;e+=1){let e=r()*Math.PI*2,t=18+r()*40;i(64+Math.cos(e)*t,64+Math.sin(e)*t,.6+r()*1.5,r()<.4?`rgba(200,70,56,0.5)`:`rgba(20,2,4,0.55)`)}HO(t)}let n=new ky(e);return n.colorSpace=uh,n}function GO(){let e=document.createElement(`canvas`);e.width=128,e.height=128;let t=e.getContext(`2d`);if(t!==null){t.fillStyle=`#3c060a`,t.fillRect(0,0,128,128);let e=461845907,n=()=>(e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296),r=(e,n,r,i,a,o,s)=>{t.fillStyle=o,t.beginPath(),t.ellipse(e,n,r,i,a,0,Math.PI*2),t.fill(),s!==void 0&&(t.strokeStyle=s,t.lineWidth=1.4,t.stroke())};t.strokeStyle=`#7c151a`,t.lineWidth=12,t.beginPath(),t.arc(64,64,46,0,Math.PI*2),t.stroke(),r(40,30,13,9,.5,`#8a1c20`,`rgba(30,3,6,0.8)`),r(88,30,13,9,-.5,`#8a1c20`,`rgba(30,3,6,0.8)`),r(40,58,15,10,.4,`#4a1410`);for(let e=0;e<15;e+=1){let e=n()*Math.PI*2,t=n()*25,i=68+Math.cos(e)*t,a=74+Math.sin(e)*t*.8,o=6+n()*4;r(i,a,o,o*(.7+n()*.3),n()*Math.PI,`#d49a98`,`rgba(110,30,36,0.9)`),r(i,a,o*.45,o*.35,n()*Math.PI,n()<.4?`#6a5a14`:`#3a070b`)}r(64,26,11,9,0,`#e6dac2`),r(64,26,7,5.5,0,`#b4594a`),r(64,13,4,3.4,0,`#efe6c8`,`#8a7c60`),r(57,40,4.4,4.4,0,`#160204`,`#a03038`),r(71,40,4,3.4,0,`#2a0a2c`);for(let e=0;e<80;e+=1){let e=n()*Math.PI*2,t=n()*54;r(64+Math.cos(e)*t,64+Math.sin(e)*t,.6+n()*1.6,.6+n()*1.6,0,n()<.3?`rgba(226,190,90,0.6)`:n()<.5?`rgba(190,50,44,0.5)`:`rgba(20,2,4,0.55)`)}HO(t)}let n=new ky(e);return n.colorSpace=uh,n}function KO(){let e=.09,t=[];for(let e=0;e<9;e+=1){let n=e/9*Math.PI*2,r=.32*(.62+.38*Math.abs(Math.sin(e*2.3+.4)));t.push([Math.cos(n)*r,Math.sin(n)*r])}let n=(t,n,r)=>{let i=Math.hypot(t,n,1);return[t/i*r,n/i*r,1/i*r-e]},r=[],i=[],a=[.07,.035,.025],o=[.78,.7,.58],s=[.42,.05,.05],c=(e,t,n,a)=>{r.push(...e,...t,...n);for(let e=0;e<3;e+=1)i.push(...a)};for(let r=0;r<9;r+=1){let[i,l]=t[r],[u,d]=t[(r+1)%9];c(n(0,0,e),n(i,l,e),n(u,d,e),a),c(n(0,0,.08299999999999999),n(u,d,.08299999999999999),n(i,l,.08299999999999999),r%3==0?o:s),c(n(i,l,e),n(i,l,.08299999999999999),n(u,d,e),o),c(n(u,d,e),n(i,l,.08299999999999999),n(u,d,.08299999999999999),o)}let l=new iv;return l.setAttribute(`position`,new K_(r,3)),l.setAttribute(`color`,new K_(i,3)),l.computeVertexNormals(),l.computeBoundingSphere(),l}function qO(){let e=document.createElement(`canvas`);e.width=128,e.height=128;let t=e.getContext(`2d`);if(t!==null){let e=t.createRadialGradient(64,60,6,64,64,66);e.addColorStop(0,`#7a1016`),e.addColorStop(.75,`#530a0e`),e.addColorStop(1,`#300408`),t.fillStyle=e,t.fillRect(0,0,128,128),t.fillStyle=`#8a2a2e`,t.beginPath(),t.ellipse(64,50,22,17,0,0,Math.PI*2),t.fill(),t.fillStyle=`rgba(220,120,120,0.35)`,t.beginPath(),t.ellipse(60,45,9,5,-.3,0,Math.PI*2),t.fill(),t.strokeStyle=`#a99c86`,t.lineWidth=5,t.beginPath(),t.ellipse(64,62,50,50,0,Math.PI*.08,Math.PI*.92),t.stroke();for(let e=0;e<12;e+=1){let n=Math.PI*(.14+e/11*.72);t.save(),t.translate(64+Math.cos(n)*42,62+Math.sin(n)*42),t.rotate(n+Math.PI/2),t.fillStyle=e%5==2?`#3a0508`:`#ece4cf`,t.fillRect(-3.5,-4.5,7,9),t.restore()}let n=625341585,r=()=>(n=Math.imul(n^n>>>15,1|n),n^=n+Math.imul(n^n>>>7,61|n),((n^n>>>14)>>>0)/4294967296);for(let e=0;e<60;e+=1)t.fillStyle=r()<.5?`rgba(150,20,24,0.6)`:`rgba(20,2,4,0.5)`,t.beginPath(),t.arc(r()*128,r()*128,.8+r()*2.2,0,Math.PI*2),t.fill();HO(t)}let n=new ky(e);return n.colorSpace=uh,n}function JO(){let e=document.createElement(`canvas`);e.width=128,e.height=64;let t=e.getContext(`2d`);if(t!==null){let e=t.createLinearGradient(0,0,128,0);e.addColorStop(0,`#e9ddd4`),e.addColorStop(.42,`#e9ddd4`),e.addColorStop(.62,`#8a2a2c`),e.addColorStop(.85,`#4a070b`),e.addColorStop(1,`#e9ddd4`),t.fillStyle=e,t.fillRect(0,0,128,64),t.strokeStyle=`rgba(170,20,26,0.75)`,t.lineWidth=.8;for(let e=0;e<14;e+=1){let n=e/14*Math.PI*2;t.beginPath(),t.moveTo(32+Math.cos(n)*30,32+Math.sin(n)*26),t.quadraticCurveTo(32+Math.cos(n+.3)*20,32+Math.sin(n+.3)*18,32+Math.cos(n)*11,32+Math.sin(n)*11),t.stroke()}let n=t.createRadialGradient(32,32,2,32,32,9);n.addColorStop(0,`#6b4524`),n.addColorStop(.8,`#4a2d14`),n.addColorStop(1,`#1e1208`),t.fillStyle=n,t.beginPath(),t.arc(32,32,9,0,Math.PI*2),t.fill(),t.fillStyle=`#050302`,t.beginPath(),t.arc(32,32,4,0,Math.PI*2),t.fill(),t.fillStyle=`rgba(255,255,255,0.85)`,t.beginPath(),t.arc(29.5,29.5,1.4,0,Math.PI*2),t.fill()}let n=new ky(e);return n.colorSpace=uh,n}function YO(e){let t=new Map,n=new Map,r=e.clone();return XO(e,r,function(e,r){t.set(r,e),n.set(e,r)}),r.traverse(function(e){if(!e.isSkinnedMesh)return;let r=e,i=t.get(e),a=i.skeleton.bones;r.skeleton=i.skeleton.clone(),r.bindMatrix.copy(i.bindMatrix),r.skeleton.bones=a.map(function(e){return n.get(e)}),r.bind(r.skeleton,r.bindMatrix)}),r}function XO(e,t,n){n(e,t);for(let r=0;r=2.0 are supported.`));return}let c=new Jk(i,{path:t||this.resourcePath||``,crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e=0&&o[t]===void 0&&console.warn(`THREE.GLTFLoader: Unknown extension "`+t+`".`)}}c.setExtensions(a),c.setPlugins(o),c.parse(n,r)}parseAsync(e,t){let n=this;return new Promise(function(r,i){n.parse(e,t,r,i)})}};function QO(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}function $O(e,t,n){let r=e.json.materials[t];return r.extensions&&r.extensions[n]?r.extensions[n]:null}var ek={KHR_BINARY_GLTF:`KHR_binary_glTF`,KHR_DRACO_MESH_COMPRESSION:`KHR_draco_mesh_compression`,KHR_LIGHTS_PUNCTUAL:`KHR_lights_punctual`,KHR_MATERIALS_CLEARCOAT:`KHR_materials_clearcoat`,KHR_MATERIALS_DISPERSION:`KHR_materials_dispersion`,KHR_MATERIALS_IOR:`KHR_materials_ior`,KHR_MATERIALS_SHEEN:`KHR_materials_sheen`,KHR_MATERIALS_SPECULAR:`KHR_materials_specular`,KHR_MATERIALS_TRANSMISSION:`KHR_materials_transmission`,KHR_MATERIALS_IRIDESCENCE:`KHR_materials_iridescence`,KHR_MATERIALS_ANISOTROPY:`KHR_materials_anisotropy`,KHR_MATERIALS_UNLIT:`KHR_materials_unlit`,KHR_MATERIALS_VOLUME:`KHR_materials_volume`,KHR_TEXTURE_BASISU:`KHR_texture_basisu`,KHR_TEXTURE_TRANSFORM:`KHR_texture_transform`,KHR_MESH_QUANTIZATION:`KHR_mesh_quantization`,KHR_MATERIALS_EMISSIVE_STRENGTH:`KHR_materials_emissive_strength`,EXT_MATERIALS_BUMP:`EXT_materials_bump`,EXT_TEXTURE_WEBP:`EXT_texture_webp`,EXT_TEXTURE_AVIF:`EXT_texture_avif`,EXT_MESHOPT_COMPRESSION:`EXT_meshopt_compression`,KHR_MESHOPT_COMPRESSION:`KHR_meshopt_compression`,EXT_MESH_GPU_INSTANCING:`EXT_mesh_gpu_instancing`},tk=class{constructor(e){this.parser=e,this.name=ek.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n=0)throw Error(`THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures`);return null}return t.loadTextureImage(e,i.source,a)}},hk=class{constructor(e){this.parser=e,this.name=ek.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let a=i.extensions[t],o=r.images[a.source],s=n.textureLoader;if(o.uri){let e=n.options.manager.getHandler(o.uri);e!==null&&(s=e)}return n.loadTextureImage(e,a.source,s)}},gk=class{constructor(e){this.parser=e,this.name=ek.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let a=i.extensions[t],o=r.images[a.source],s=n.textureLoader;if(o.uri){let e=n.options.manager.getHandler(o.uri);e!==null&&(s=e)}return n.loadTextureImage(e,a.source,s)}},_k=class{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let e=n.extensions[this.name],r=this.parser.getDependency(`buffer`,e.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw Error(`THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files`);return null}return r.then(function(t){let n=e.byteOffset||0,r=e.byteLength||0,a=e.count,o=e.byteStride,s=new Uint8Array(t,n,r);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(a,o,s,e.mode,e.filter).then(function(e){return e.buffer}):i.ready.then(function(){let t=new ArrayBuffer(a*o);return i.decodeGltfBuffer(new Uint8Array(t),a,o,s,e.mode,e.filter),t})})}return null}},vk=class{constructor(e){this.name=ek.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let r=t.meshes[n.mesh];for(let e of r.primitives)if(e.mode!==kk.TRIANGLES&&e.mode!==kk.TRIANGLE_STRIP&&e.mode!==kk.TRIANGLE_FAN&&e.mode!==void 0)return null;let i=n.extensions[this.name].attributes,a=[],o={};for(let e in i)a.push(this.parser.getDependency(`accessor`,i[e]).then(t=>(o[e]=t,o[e])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(e=>{let t=e.pop(),n=t.isGroup?t.children:[t],r=e[0].count,i=[];for(let e of n){let t=new Dg,n=new q,a=new rg,s=new q(1,1,1),c=new ny(e.geometry,e.material,r);for(let e=0;e0||e.search(/^data\:image\/jpeg/)===0?`image/jpeg`:e.search(/\.webp($|\?)/i)>0||e.search(/^data\:image\/webp/)===0?`image/webp`:e.search(/\.ktx2($|\?)/i)>0||e.search(/^data\:image\/ktx2/)===0?`image/ktx2`:`image/png`}var qk=new Dg,Jk=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new QO,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,r=-1,i=!1,a=-1;if(typeof navigator<`u`&&navigator.userAgent!==void 0){let e=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(e)===!0;let t=e.match(/Version\/(\d+)/);r=n&&t?parseInt(t[1],10):-1,i=e.indexOf(`Firefox`)>-1,a=i?e.match(/Firefox\/([0-9]+)\./)[1]:-1}this.textureLoader=typeof createImageBitmap>`u`||n&&r<17||i&&a<98?new mx(this.options.manager):new Rx(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new dx(this.options.manager),this.fileLoader.setResponseType(`arraybuffer`),this.options.crossOrigin===`use-credentials`&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,r=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(e){return e._markDefs&&e._markDefs()}),Promise.all(this._invokeAll(function(e){return e.beforeRoot&&e.beforeRoot()})).then(function(){return Promise.all([n.getDependencies(`scene`),n.getDependencies(`animation`),n.getDependencies(`camera`)])}).then(function(t){let a={scene:t[0][r.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:r.asset,parser:n,userData:{}};return zk(i,a,r),Bk(a,r),Promise.all(n._invokeAll(function(e){return e.afterRoot&&e.afterRoot(a)})).then(function(){for(let e of a.scenes)e.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,r=t.length;n{let n=this.associations.get(e);n!=null&&this.associations.set(t,n);for(let[n,r]of e.children.entries())i(r,t.children[n])};return i(n,r),r.name+=`_instance_`+e.uses[t]++,r}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n=2&&p.setY(t,u[e*a+1]),a>=3&&p.setZ(t,u[e*a+2]),a>=4&&p.setW(t,u[e*a+3]),a>=5)throw Error(`THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.`)}p.normalized=d}return p})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,i=t.images[r],a=this.textureLoader;if(i.uri){let e=n.manager.getHandler(i.uri);e!==null&&(a=e)}return this.loadTextureImage(e,r,a)}loadTextureImage(e,t,n){let r=this,i=this.json,a=i.textures[e],o=i.images[t],s=(o.uri||o.bufferView)+`:`+a.sampler;if(this.textureCache[s])return this.textureCache[s];let c=this.loadImageSource(t,n).then(function(t){t.flipY=!1,t.name=a.name||o.name||``,t.name===``&&typeof o.uri==`string`&&o.uri.startsWith(`data:image/`)===!1&&(t.name=o.uri);let n=(i.samplers||{})[a.sampler]||{};return t.magFilter=jk[n.magFilter]||1006,t.minFilter=jk[n.minFilter]||1008,t.wrapS=Mk[n.wrapS]||1e3,t.wrapT=Mk[n.wrapT]||1e3,t.generateMipmaps=!t.isCompressedTexture&&t.minFilter!==1003&&t.minFilter!==1006,r.associations.set(t,{textures:e}),t}).catch(function(){return null});return this.textureCache[s]=c,c}loadImageSource(e,t){let n=this,r=this.json,i=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(e=>e.clone());let a=r.images[e],o=self.URL||self.webkitURL,s=a.uri||``,c=!1;if(a.bufferView!==void 0)s=n.getDependency(`bufferView`,a.bufferView).then(function(e){c=!0;let t=new Blob([e],{type:a.mimeType});return s=o.createObjectURL(t),s});else if(a.uri===void 0)throw Error(`THREE.GLTFLoader: Image `+e+` is missing URI and bufferView`);let l=Promise.resolve(s).then(function(e){return new Promise(function(n,r){let a=n;t.isImageBitmapLoader===!0&&(a=function(e){let t=new xg(e);t.needsUpdate=!0,n(t)}),t.load(Ix.resolveURL(e,i.path),a,void 0,r)})}).then(function(e){return c===!0&&o.revokeObjectURL(s),Bk(e,a),e.userData.mimeType=a.mimeType||Kk(a.uri),e}).catch(function(e){throw console.error(`THREE.GLTFLoader: Couldn't load texture`,s),e});return this.sourceCache[e]=l,l}assignTexture(e,t,n,r){let i=this;return this.getDependency(`texture`,n.index).then(function(a){if(!a)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(a=a.clone(),a.channel=n.texCoord),i.extensions[ek.KHR_TEXTURE_TRANSFORM]){let e=n.extensions===void 0?void 0:n.extensions[ek.KHR_TEXTURE_TRANSFORM];if(e){let t=i.associations.get(a);a=i.extensions[ek.KHR_TEXTURE_TRANSFORM].extendTexture(a,e),i.associations.set(a,t)}}return r!==void 0&&(a.colorSpace=r),e[t]=a,a})}assignFinalMaterial(e){let t=e.geometry,n=e.material,r=t.attributes.tangent===void 0,i=t.attributes.color!==void 0,a=t.attributes.normal===void 0;if(e.isPoints){let e=`PointsMaterial:`+n.uuid,t=this.cache.get(e);t||(t=new xy,pv.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){let e=`LineBasicMaterial:`+n.uuid,t=this.cache.get(e);t||(t=new sy,pv.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(r||i||a){let e=`ClonedMaterial:`+n.uuid+`:`;r&&(e+=`derivative-tangents:`),i&&(e+=`vertex-colors:`),a&&(e+=`flat-shading:`);let t=this.cache.get(e);t||(t=n.clone(),i&&(t.vertexColors=!0),a&&(t.flatShading=!0),r&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return Ab}loadMaterial(e){let t=this,n=this.json,r=this.extensions,i=n.materials[e],a,o={},s=i.extensions||{},c=[];if(s[ek.KHR_MATERIALS_UNLIT]){let e=r[ek.KHR_MATERIALS_UNLIT];a=e.getMaterialType(),c.push(e.extendParams(o,i,t))}else{let n=i.pbrMetallicRoughness||{};if(o.color=new J(1,1,1),o.opacity=1,Array.isArray(n.baseColorFactor)){let e=n.baseColorFactor;o.color.setRGB(e[0],e[1],e[2],dh),o.opacity=e[3]}n.baseColorTexture!==void 0&&c.push(t.assignTexture(o,`map`,n.baseColorTexture,uh)),o.metalness=n.metallicFactor===void 0?1:n.metallicFactor,o.roughness=n.roughnessFactor===void 0?1:n.roughnessFactor,n.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(o,`metalnessMap`,n.metallicRoughnessTexture)),c.push(t.assignTexture(o,`roughnessMap`,n.metallicRoughnessTexture))),a=this._invokeOne(function(t){return t.getMaterialType&&t.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,o)})))}i.doubleSided===!0&&(o.side=2);let l=i.alphaMode||Lk.OPAQUE;if(l===Lk.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,l===Lk.MASK&&(o.alphaTest=i.alphaCutoff===void 0?.5:i.alphaCutoff)),i.normalTexture!==void 0&&a!==yv&&(c.push(t.assignTexture(o,`normalMap`,i.normalTexture)),o.normalScale=new K(1,1),i.normalTexture.scale!==void 0)){let e=i.normalTexture.scale;o.normalScale.set(e,e)}if(i.occlusionTexture!==void 0&&a!==yv&&(c.push(t.assignTexture(o,`aoMap`,i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&a!==yv){let e=i.emissiveFactor;o.emissive=new J().setRGB(e[0],e[1],e[2],dh)}return i.emissiveTexture!==void 0&&a!==yv&&c.push(t.assignTexture(o,`emissiveMap`,i.emissiveTexture,uh)),Promise.all(c).then(function(){let n=new a(o);return i.name&&(n.name=i.name),Bk(n,i),t.associations.set(n,{materials:e}),i.extensions&&zk(r,n,i),n})}createUniqueName(e){let t=nS.sanitizeNodeName(e||``);return t in this.nodeNamesUsed?t+`_`+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,n=this.extensions,r=this.primitiveCache;function i(e){return n[ek.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then(function(n){return Xk(n,e,t)})}let a=[];for(let n=0,o=e.length;nbE(e,1)):o.mode===kk.TRIANGLE_FAN&&(e=e.then(e=>bE(e,2))),r[s]={primitive:o,promise:e},a.push(e)}}return Promise.all(a)}loadMesh(e){let t=this,n=this.json,r=this.extensions,i=n.meshes[e],a=i.primitives,o=[];for(let e=0,t=a.length;e0&&Hk(d,i),d.name=t.createUniqueName(i.name||`mesh_`+e),Bk(d,i),u.extensions&&zk(r,d,u),t.assignFinalMaterial(d),c.push(d)}for(let n=0,r=c.length;n0){let e=t.userData.pivot,r=n[0];t.pivot=new q().fromArray(e),t.position.x-=e[0],t.position.y-=e[1],t.position.z-=e[2],r.position.set(0,0,0),delete t.userData.pivot}return t})}_loadNodeShallow(e){let t=this.json,n=this.extensions,r=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let i=t.nodes[e],a=i.name?r.createUniqueName(i.name):``,o=[],s=r._invokeOne(function(t){return t.createNodeMesh&&t.createNodeMesh(e)});return s&&o.push(s),i.camera!==void 0&&o.push(r.getDependency(`camera`,i.camera).then(function(e){return r._getNodeRef(r.cameraCache,i.camera,e)})),r._invokeAll(function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)}).forEach(function(e){o.push(e)}),this.nodeCache[e]=Promise.all(o).then(function(t){let o;if(o=i.isBone===!0?new Uv:t.length>1?new t_:t.length===1?t[0]:new e_,o!==t[0])for(let e=0,n=t.length;e1){let e=r.associations.get(o);r.associations.set(o,{...e})}return r.associations.get(o).nodes=e,o}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],r=this,i=new t_;n.name&&(i.name=r.createUniqueName(n.name)),Bk(i,n),n.extensions&&zk(t,i,n);let a=n.nodes||[],o=[];for(let e=0,t=a.length;e{let t=new Map;for(let[e,n]of r.associations)(e instanceof pv||e instanceof xg)&&t.set(e,n);return e.traverse(e=>{let n=r.associations.get(e);n!=null&&t.set(e,n)}),t})(i),i})}_createAnimationTracks(e,t,n,r,i){let a=[],o=e.name?e.name:e.uuid,s=[];function c(e){e.morphTargetInfluences&&s.push(e.name?e.name:e.uuid)}Fk[i.path]===Fk.weights?(c(e),e.isGroup&&e.children.forEach(c)):s.push(o);let l;switch(Fk[i.path]){case Fk.weights:l=Zb;break;case Fk.rotation:l=$b;break;case Fk.translation:case Fk.scale:l=tx;break;default:switch(n.itemSize){case 1:l=Zb;break;default:l=tx}}let u=r.interpolation===void 0?nh:Ik[r.interpolation],d=this._getArrayFromAccessor(n);for(let e=0,n=s.length;e{e.uniforms.uGearBlood=r,e.vertexShader=e.vertexShader.replace(`#include `,`#include \n${t?`attribute vec3 bindPosition;`:``}\n${eA}`).replace(`#include `,`#include \nvGearPos = ${t?`bindPosition`:`position`};`),e.fragmentShader=e.fragmentShader.replace(`#include `,`#include \n${eA}\nfloat gearSoaked = 0.0;\nfloat gearTrim = 0.0;`).replace(`#include `,`#include \n${tA}`).replace(`#include `,`#include \n${nA}`)},e.customProgramCacheKey=()=>`hands-gear-${t?`baked`:`live`}`,e.needsUpdate=!0,r}var iA=[{name:`leftEye`,position:[2.4,120,3.4],radius:3.4,cutHalfLength:0,bleeds:!1},{name:`rightEye`,position:[-2.8,120.1,3.2],radius:3.4,cutHalfLength:0,bleeds:!1},{name:`leftBrow`,position:[2.9,123.4,3],radius:2.2,cutHalfLength:1.1,bleeds:!0},{name:`rightBrow`,position:[-2.7,123,3.3],radius:2.2,cutHalfLength:1.1,bleeds:!0},{name:`nose`,position:[0,117,5.3],radius:1.6,cutHalfLength:0,bleeds:!0},{name:`mouth`,position:[0,114.3,4.6],radius:1.8,cutHalfLength:.9,bleeds:!0},{name:`leftCheek`,position:[3.4,117.8,3.4],radius:3,cutHalfLength:.8,bleeds:!0},{name:`rightCheek`,position:[-3.4,117.9,3.3],radius:3,cutHalfLength:.8,bleeds:!0},{name:`chin`,position:[0,110.8,4.2],radius:2.2,cutHalfLength:0,bleeds:!1},{name:`leftJaw`,position:[4.6,113,1.4],radius:2.6,cutHalfLength:0,bleeds:!1},{name:`rightJaw`,position:[-4.6,113,1.4],radius:2.6,cutHalfLength:0,bleeds:!1},{name:`forehead`,position:[0,125.5,3.5],radius:3.2,cutHalfLength:1.3,bleeds:!0}],aA=[{name:`leftRibs`,position:[13.5,98,1],radius:7.5,cutHalfLength:0,bleeds:!1},{name:`rightRibs`,position:[-13.5,98,1],radius:7.5,cutHalfLength:0,bleeds:!1},{name:`solarPlexus`,position:[.5,96.5,5.5],radius:6,cutHalfLength:0,bleeds:!1},{name:`leftPec`,position:[9,96.2,4.4],radius:6,cutHalfLength:0,bleeds:!1},{name:`rightPec`,position:[-8.8,96.2,4.4],radius:6,cutHalfLength:0,bleeds:!1},{name:`neckSmear`,position:[.4,105.5,5.8],radius:4,cutHalfLength:0,bleeds:!0},{name:`leftShoulderSmear`,position:[10.5,104,4.5],radius:3,cutHalfLength:0,bleeds:!0},{name:`rightShoulderSmear`,position:[-10.5,104,4.5],radius:3,cutHalfLength:0,bleeds:!0},{name:`unused0`,position:[0,-100,0],radius:0,cutHalfLength:0,bleeds:!1},{name:`unused1`,position:[0,-100,0],radius:0,cutHalfLength:0,bleeds:!1},{name:`unused2`,position:[0,-100,0],radius:0,cutHalfLength:0,bleeds:!1},{name:`unused3`,position:[0,-100,0],radius:0,cutHalfLength:0,bleeds:!1}],oA=112.4,sA=.3,cA=114.5,lA=1.8,uA=1e3,dA=` +}`,Rh=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new ql(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){let t=e.cameras[0].viewport,n=new Wu({vertexShader:Ih,fragmentShader:Lh,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new V(new Au(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},zh=class extends Wa{constructor(e,t){super();let n=this,r=null,i=1,a=null,o=`local-floor`,s=1,c=null,l=null,u=null,d=null,f=null,p=null,m=typeof XRWebGLBinding<`u`,h=new Rh,g={},_=t.getContextAttributes(),v=null,y=null,b=[],x=[],S=new R,C=null,w=null,T=new Wd;T.viewport=new Lo;let E=new Wd;E.viewport=new Lo;let D=[T,E],O=new af,k=null,A=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=b[e];return t===void 0&&(t=new vs,b[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=b[e];return t===void 0&&(t=new vs,b[e]=t),t.getGripSpace()},this.getHand=function(e){let t=b[e];return t===void 0&&(t=new vs,b[e]=t),t.getHandSpace()};function j(e){let t=x.indexOf(e.inputSource);if(t===-1)return;let n=b[t];n!==void 0&&(n.update(e.inputSource,e.frame,c||a),n.dispatchEvent({type:e.type,data:e.inputSource}))}function ee(){r.removeEventListener(`select`,j),r.removeEventListener(`selectstart`,j),r.removeEventListener(`selectend`,j),r.removeEventListener(`squeeze`,j),r.removeEventListener(`squeezestart`,j),r.removeEventListener(`squeezeend`,j),r.removeEventListener(`end`,ee),r.removeEventListener(`inputsourceschange`,M);for(let e=0;e=0&&(x[r]=null,b[r].disconnect(n))}for(let t=0;t=x.length){x.push(n),r=e;break}else if(x[e]===null){x[e]=n,r=e;break}if(r===-1)break}let i=b[r];i&&i.connect(n)}}let te=new z,ne=new z;function re(e,t,n){te.setFromMatrixPosition(t.matrixWorld),ne.setFromMatrixPosition(n.matrixWorld);let r=te.distanceTo(ne),i=t.projectionMatrix.elements,a=n.projectionMatrix.elements,o=i[14]/(i[10]-1),s=i[14]/(i[10]+1),c=(i[9]+1)/i[5],l=(i[9]-1)/i[5],u=(i[8]-1)/i[0],d=(a[8]+1)/a[0],f=o*u,p=o*d,m=r/(-u+d),h=m*-u;if(t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(h),e.translateZ(m),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert(),i[10]===-1)e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse);else{let t=o+m,n=s+m,i=f-h,a=p+(r-h),u=c*s/n*t,d=l*s/n*t;e.projectionMatrix.makePerspective(i,a,u,d,t,n),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}}function ie(e,t){t===null?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(r===null)return;let t=e.near,n=e.far;h.texture!==null&&(h.depthNear>0&&(t=h.depthNear),h.depthFar>0&&(n=h.depthFar)),O.near=E.near=T.near=t,O.far=E.far=T.far=n,(k!==O.near||A!==O.far)&&(r.updateRenderState({depthNear:O.near,depthFar:O.far}),k=O.near,A=O.far),O.layers.mask=e.layers.mask|6,T.layers.mask=O.layers.mask&-5,E.layers.mask=O.layers.mask&-3;let i=e.parent,a=O.cameras;ie(O,i);for(let e=0;e0&&(e.alphaTest.value=r.alphaTest);let i=t.get(r),a=i.envMap,o=i.envMapRotation;a&&(e.envMap.value=a,e.envMapRotation.value.setFromMatrix4(Bh.makeRotationFromEuler(o)).transpose(),a.isCubeTexture&&a.isRenderTargetTexture===!1&&e.envMapRotation.value.premultiply(Vh),e.reflectivity.value=r.reflectivity,e.ior.value=r.ior,e.refractionRatio.value=r.refractionRatio),r.lightMap&&(e.lightMap.value=r.lightMap,e.lightMapIntensity.value=r.lightMapIntensity,n(r.lightMap,e.lightMapTransform)),r.aoMap&&(e.aoMap.value=r.aoMap,e.aoMapIntensity.value=r.aoMapIntensity,n(r.aoMap,e.aoMapTransform))}function o(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}function s(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}function c(e,t,r,i){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*r,e.scale.value=i*.5,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}function l(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}function u(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}function d(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}function f(e,t){e.metalness.value=t.metalness,t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap,n(t.metalnessMap,e.metalnessMapTransform)),e.roughness.value=t.roughness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap,n(t.roughnessMap,e.roughnessMapTransform)),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}function p(e,t,r){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform))),t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),t.side===1&&e.clearcoatNormalScale.value.negate())),t.dispersion>0&&(e.dispersion.value=t.dispersion),t.retroreflectivity>0&&(e.retroreflectivity.value=t.retroreflectivity),t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform))),t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=r.texture,e.transmissionSamplerSize.value.set(r.width,r.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor)),t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,n(t.anisotropyMap,e.anisotropyMapTransform))),e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform)),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}function m(e,t){t.matcap&&(e.matcap.value=t.matcap)}function h(e,n){let r=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(r.matrixWorld),e.nearDistance.value=r.shadow.camera.near,e.farDistance.value=r.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function Uh(e,t,n,r){let i={},a={},o=[],s=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(e,t){let n=t.program;r.uniformBlockBinding(e,n)}function l(e,n){let o=i[e.id];o===void 0&&(g(e),o=u(e),i[e.id]=o,e.addEventListener(`dispose`,v));let s=n.program;r.updateUBOMapping(e,s);let c=t.render.frame;a[e.id]!==c&&(f(e),a[e.id]=c)}function u(t){let n=d();t.__bindingPointIndex=n;let r=e.createBuffer(),i=t.__size,a=t.usage;return e.bindBuffer(e.UNIFORM_BUFFER,r),e.bufferData(e.UNIFORM_BUFFER,i,a),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,n,r),r}function d(){for(let e=0;e0&&(n+=16-r),e.__size=n,e.__cache={},this}function _(e){let t={boundary:0,storage:0};return typeof e==`number`||typeof e==`boolean`?(t.boundary=4,t.storage=4):e.isVector2?(t.boundary=8,t.storage=8):e.isVector3||e.isColor?(t.boundary=16,t.storage=12):e.isVector4?(t.boundary=16,t.storage=16):e.isMatrix3?(t.boundary=48,t.storage=48):e.isMatrix4?(t.boundary=64,t.storage=64):e.isTexture?za(`WebGLRenderer: Texture samplers can not be part of an uniforms group.`):ArrayBuffer.isView(e)?(t.boundary=16,t.storage=e.byteLength):za(`WebGLRenderer: Unsupported uniform value type.`,e),t}function v(t){let n=t.target;n.removeEventListener(`dispose`,v);let r=o.indexOf(n.__bindingPointIndex);o.splice(r,1),e.deleteBuffer(i[n.id]),delete i[n.id],delete a[n.id]}function y(){for(let t in i)e.deleteBuffer(i[t]);o=[],i={},a={}}return{bind:c,update:l,dispose:y}}var Wh=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),Gh=null;function Kh(){return Gh===null&&(Gh=new al(Wh,16,16,Ai,_i),Gh.name=`DFG_LUT`,Gh.minFilter=si,Gh.magFilter=si,Gh.wrapS=ni,Gh.wrapT=ni,Gh.generateMipmaps=!1,Gh.needsUpdate=!0),Gh}var qh=class{constructor(e={}){let{canvas:t=Fa(),context:n=null,depth:r=!0,stencil:i=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:s=!0,preserveDrawingBuffer:c=!1,powerPreference:l=`default`,failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:f=ui}=e;this.isWebGLRenderer=!0;let p;if(n!==null){if(typeof WebGLRenderingContext<`u`&&n instanceof WebGLRenderingContext)throw Error(`THREE.WebGLRenderer: WebGL 1 is not supported since r163.`);p=n.getContextAttributes().alpha}else p=a;let m=f,h=new Set([Mi,ji,ki]),g=new Set([ui,hi,pi,bi,vi,yi]),_=new Uint32Array(4),v=new Int32Array(4),y=new z,b=null,x=null,S=[],C=[],w=null;this.domElement=t,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=0,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let T=this,E=!1,D=null,O=null,k=null,A=null;this._outputColorSpace=wa;let j=0,ee=0,M=null,te=-1,ne=null,re=new Lo,ie=new Lo,ae=null,oe=new B(0),se=0,ce=t.width,le=t.height,ue=1,de=null,fe=null,pe=new Lo(0,0,ce,le),me=new Lo(0,0,ce,le),he=!1,ge=new xl,_e=!1,ve=!1,ye=new Ho,be=new z,xe=new Lo,Se={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},Ce=!1;function we(){return M===null?ue:1}let N=n;function Te(e,n){return t.getContext(e,n)}let Ee,P,F,De,Oe,ke,Ae,je,Me,Ne,Pe,Fe,Ie,Le,Re,ze,Be,Ve,He,Ue,We,Ge,Ke;try{let e={alpha:!0,depth:r,stencil:i,antialias:o,premultipliedAlpha:s,preserveDrawingBuffer:c,powerPreference:l,failIfMajorPerformanceCaveat:u};if(`setAttribute`in t&&t.setAttribute(`data-engine`,`three.js r186`),t.addEventListener(`webglcontextlost`,I,!1),t.addEventListener(`webglcontextrestored`,Ye,!1),t.addEventListener(`webglcontextcreationerror`,Xe,!1),N===null){let t=`webgl2`;if(N=Te(t,e),N===null)throw Te(t)?Error(`THREE.WebGLRenderer: Error creating WebGL context with your selected attributes.`):Error(`THREE.WebGLRenderer: Error creating WebGL context.`)}qe()}catch(e){throw t.removeEventListener(`webglcontextlost`,I,!1),t.removeEventListener(`webglcontextrestored`,Ye,!1),t.removeEventListener(`webglcontextcreationerror`,Xe,!1),Ba(`WebGLRenderer: `+e.message),e}function qe(){Ee=new dp(N),Ee.init(),We=new Fh(N,Ee),P=new Bf(N,Ee,e,We),F=new Nh(N,Ee),P.reversedDepthBuffer&&d&&F.buffers.depth.setReversed(!0),O=N.createFramebuffer(),k=N.createFramebuffer(),A=N.createFramebuffer(),De=new mp(N),Oe=new ph,ke=new Ph(N,Ee,F,Oe,P,We,De),Ae=new up(T),je=new jf(N),Ge=new Rf(N,je),Me=new fp(N,je,De,Ge),Ne=new gp(N,Me,je,Ge,De),Ve=new hp(N,P,ke),Re=new Vf(Oe),Pe=new fh(T,Ae,Ee,P,Ge,Re),Fe=new Hh(T,Oe),Ie=new _h,Le=new wh(Ee),Be=new Lf(T,Ae,F,Ne,p,s),ze=new Mh(T,Ne,P),Ke=new Uh(N,De,P,F),He=new zf(N,Ee,De),Ue=new pp(N,Ee,De),De.programs=Pe.programs,T.capabilities=P,T.extensions=Ee,T.properties=Oe,T.renderLists=Ie,T.shadowMap=ze,T.state=F,T.info=De}m!==1009&&(w=new vp(m,t.width,t.height,o,r,i));let Je=new zh(T,N);this.xr=Je,this.getContext=function(){return N},this.getContextAttributes=function(){return N.getContextAttributes()},this.forceContextLoss=function(){let e=Ee.get(`WEBGL_lose_context`);e&&e.loseContext()},this.forceContextRestore=function(){let e=Ee.get(`WEBGL_lose_context`);e&&e.restoreContext()},this.getPixelRatio=function(){return ue},this.setPixelRatio=function(e){e!==void 0&&(ue=e,this.setSize(ce,le,!1))},this.getSize=function(e){return e.set(ce,le)},this.setSize=function(e,n,r=!0){Je.isPresenting?za(`WebGLRenderer: Can't change size while VR device is presenting.`):(ce=e,le=n,t.width=Math.floor(e*ue),t.height=Math.floor(n*ue),r===!0&&(t.style.width=e+`px`,t.style.height=n+`px`),w!==null&&w.setSize(t.width,t.height),this.setViewport(0,0,e,n))},this.getDrawingBufferSize=function(e){return e.set(ce*ue,le*ue).floor()},this.setDrawingBufferSize=function(e,n,r){ce=e,le=n,ue=r,t.width=Math.floor(e*r),t.height=Math.floor(n*r),this.setViewport(0,0,e,n)},this.setEffects=function(e){if(m===1009)Ba(`WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.`);else{if(e){for(let t=0;t{function n(){r.forEach(function(e){let t=Oe.get(e).currentProgram;(t===void 0||t.isReady())&&r.delete(e)}),r.size===0?t(e):setTimeout(n,10)}Ee.get(`KHR_parallel_shader_compile`)===null?setTimeout(n,10):n()})};let tt=null;function nt(e){tt&&tt(e)}function rt(){at.stop()}function it(){at.start()}let at=new Af;at.setAnimationLoop(nt),typeof self<`u`&&at.setContext(self),this.setAnimationLoop=function(e){tt=e,Je.setAnimationLoop(e),e===null?at.stop():at.start()},Je.addEventListener(`sessionstart`,rt),Je.addEventListener(`sessionend`,it),this.render=function(e,t){if(t!==void 0&&t.isCamera!==!0){Ba(`WebGLRenderer.render: camera is not an instance of THREE.Camera.`);return}if(E===!0)return;D!==null&&D.renderStart(e,t);let n=Je.enabled===!0&&Je.isPresenting===!0,r=w!==null&&(M===null||n)&&w.begin(T,M);if(e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.parent===null&&t.matrixWorldAutoUpdate===!0&&t.updateMatrixWorld(),Je.enabled===!0&&Je.isPresenting===!0&&(w===null||w.isCompositing()===!1)&&(Je.cameraAutoUpdate===!0&&Je.updateCamera(t),t=Je.getCamera()),e.isScene===!0&&e.onBeforeRender(T,e,t,M),x=Le.get(e,C.length),x.init(t),x.state.textureUnits=ke.getTextureUnits(),C.push(x),ye.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),ge.setFromProjectionMatrix(ye,ja,t.reversedDepth),ve=this.localClippingEnabled,_e=Re.init(this.clippingPlanes,ve),b=Ie.get(e,S.length),b.init(),S.push(b),Je.enabled===!0&&Je.isPresenting===!0){let e=T.xr.getDepthSensingMesh();e!==null&&ot(e,t,-1/0,T.sortObjects)}ot(e,t,0,T.sortObjects),b.finish(),D!==null&&D.updateLights(x.state.lightsArray),T.sortObjects===!0&&b.sort(de,fe),Ce=Je.enabled===!1||Je.isPresenting===!1||Je.hasDepthSensing()===!1,Ce&&Be.addToRenderList(b,e),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),_e===!0&&Re.beginShadows();let i=x.state.shadowsArray;if(ze.render(i,e,t),_e===!0&&Re.endShadows(),(r&&w.hasRenderPass())===!1){let n=b.opaque,r=b.transmissive;if(x.setupLights(),t.isArrayCamera){let i=t.cameras;if(r.length>0)for(let t=0,a=i.length;t0&&ct(n,r,e,t),Ce&&Be.render(e),st(b,e,t)}M!==null&&ee===0&&(ke.updateMultisampleRenderTarget(M),ke.updateRenderTargetMipmap(M)),r&&w.end(T),e.isScene===!0&&e.onAfterRender(T,e,t),Ge.resetDefaultState(),te=-1,ne=null,C.pop(),C.length>0?(x=C[C.length-1],ke.setTextureUnits(x.state.textureUnits),_e===!0&&Re.setGlobalState(T.clippingPlanes,x.state.camera)):x=null,S.pop(),b=S.length>0?S[S.length-1]:null,D!==null&&D.renderEnd()};function ot(e,t,n,r){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)n=e.renderOrder;else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLightProbeGrid)x.pushLightProbeGrid(e);else if(e.isLight)x.pushLight(e),e.castShadow&&x.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||e.intersectsFrustum(ge)){r&&xe.setFromMatrixPosition(e.matrixWorld).applyMatrix4(ye);let i=Ne.update(e),a=e.material;a.visible&&b.push(e,i,a,n,xe.z,null,t)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||e.intersectsFrustum(ge))){let i=Ne.update(e),a=e.material;if(r&&(e.boundingSphere===void 0?(i.boundingSphere===null&&i.computeBoundingSphere(),xe.copy(i.boundingSphere.center)):(e.boundingSphere===null&&e.computeBoundingSphere(),xe.copy(e.boundingSphere.center)),xe.applyMatrix4(e.matrixWorld).applyMatrix4(ye)),Array.isArray(a)){let r=i.groups;for(let o=0,s=r.length;o0&<(i,t,n),a.length>0&<(a,t,n),o.length>0&<(o,t,n),F.buffers.depth.setTest(!0),F.buffers.depth.setMask(!0),F.buffers.color.setMask(!0),F.setPolygonOffset(!1)}function ct(e,t,n,r){if((n.isScene===!0?n.overrideMaterial:null)!==null)return;if(x.state.transmissionRenderTarget[r.id]===void 0){let e=Ee.has(`EXT_color_buffer_half_float`)||Ee.has(`EXT_color_buffer_float`);x.state.transmissionRenderTarget[r.id]=new zo(1,1,{generateMipmaps:!0,type:e?_i:ui,minFilter:li,samples:Math.max(4,P.samples),stencilBuffer:i,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:Eo.workingColorSpace})}let a=x.state.transmissionRenderTarget[r.id],o=r.viewport||re;a.setSize(o.z*T.transmissionResolutionScale,o.w*T.transmissionResolutionScale);let s=T.getRenderTarget(),c=T.getActiveCubeFace(),l=T.getActiveMipmapLevel();T.setRenderTarget(a),T.getClearColor(oe),se=T.getClearAlpha(),se<1&&T.setClearColor(16777215,.5),T.clear(),Ce&&Be.render(n);let u=T.toneMapping;T.toneMapping=0;let d=r.viewport;if(r.viewport!==void 0&&(r.viewport=void 0),x.setupLightsView(r),_e===!0&&Re.setGlobalState(T.clippingPlanes,r),lt(e,n,r),ke.updateMultisampleRenderTarget(a),ke.updateRenderTargetMipmap(a),Ee.has(`WEBGL_multisampled_render_to_texture`)===!1){let e=!1;for(let i=0,a=t.length;i0,r.currentProgram=d,r.uniformsList=null,d}function ft(e){if(e.uniformsList===null){let t=e.currentProgram.getUniforms();e.uniformsList=Tm.seqWithValue(t.seq,e.uniforms)}return e.uniformsList}function pt(e,t){let n=Oe.get(e);n.outputColorSpace=t.outputColorSpace,n.batching=t.batching,n.batchingColor=t.batchingColor,n.instancing=t.instancing,n.instancingColor=t.instancingColor,n.instancingMorph=t.instancingMorph,n.skinning=t.skinning,n.morphTargets=t.morphTargets,n.morphNormals=t.morphNormals,n.morphColors=t.morphColors,n.morphTargetsCount=t.morphTargetsCount,n.numClippingPlanes=t.numClippingPlanes,n.numIntersection=t.numClipIntersection,n.vertexAlphas=t.vertexAlphas,n.vertexTangents=t.vertexTangents,n.toneMapping=t.toneMapping}function mt(e,t){if(e.length===0)return null;if(e.length===1)return e[0].texture===null?null:e[0];y.setFromMatrixPosition(t.matrixWorld);for(let t=0,n=e.length;t0),f=!!n.morphAttributes.position,p=!!n.morphAttributes.normal,m=!!n.morphAttributes.color,h=0;r.toneMapped&&(M===null||M.isXRRenderTarget===!0)&&(h=T.toneMapping);let g=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,_=g===void 0?0:g.length,v=Oe.get(r),y=x.state.lights;if(_e===!0&&(ve===!0||e!==ne)){let t=e===ne&&r.id===te;Re.setState(r,e,t)}let b=!1;r.version===v.__version?v.needsLights&&v.lightsStateVersion!==y.state.version?b=!0:v.outputColorSpace===s?i.isBatchedMesh&&v.batching===!1||!i.isBatchedMesh&&v.batching===!0||i.isBatchedMesh&&v.batchingColor===!0&&i._colorsTexture===null||i.isBatchedMesh&&v.batchingColor===!1&&i._colorsTexture!==null||i.isInstancedMesh&&v.instancing===!1||!i.isInstancedMesh&&v.instancing===!0||i.isSkinnedMesh&&v.skinning===!1||!i.isSkinnedMesh&&v.skinning===!0||i.isInstancedMesh&&v.instancingColor===!0&&i.instanceColor===null||i.isInstancedMesh&&v.instancingColor===!1&&i.instanceColor!==null||i.isInstancedMesh&&v.instancingMorph===!0&&i.morphTexture===null||i.isInstancedMesh&&v.instancingMorph===!1&&i.morphTexture!==null?b=!0:v.envMap===l?r.fog===!0&&v.fog!==a||v.numClippingPlanes!==void 0&&(v.numClippingPlanes!==Re.numPlanes||v.numIntersection!==Re.numIntersection)?b=!0:v.vertexAlphas===u&&v.vertexTangents===d&&v.morphTargets===f&&v.morphNormals===p&&v.morphColors===m&&v.toneMapping===h&&v.morphTargetsCount===_?!!v.lightProbeGrid!=x.state.lightProbeGridArray.length>0&&(b=!0):b=!0:b=!0:b=!0:(b=!0,v.__version=r.version);let S=v.currentProgram;b===!0&&(S=dt(r,t,i),D&&r.isNodeMaterial&&D.onUpdateProgram(r,S,v));let C=!1,w=!1,E=!1,O=S.getUniforms(),k=v.uniforms;if(F.useProgram(S.program)&&(C=!0,w=!0,E=!0),r.id!==te&&(te=r.id,w=!0),v.needsLights){let e=mt(x.state.lightProbeGridArray,i);v.lightProbeGrid!==e&&(v.lightProbeGrid=e,w=!0)}if(C||ne!==e){F.buffers.depth.getReversed()&&e.reversedDepth!==!0&&(e._reversedDepth=!0,e.updateProjectionMatrix()),O.setValue(N,`projectionMatrix`,e.projectionMatrix),O.setValue(N,`viewMatrix`,e.matrixWorldInverse);let t=O.map.cameraPosition;t!==void 0&&t.setValue(N,be.setFromMatrixPosition(e.matrixWorld)),P.logarithmicDepthBuffer&&O.setValue(N,`logDepthBufFC`,2/(Math.log(e.far+1)/Math.LN2)),(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial)&&O.setValue(N,`isOrthographic`,e.isOrthographicCamera===!0),ne!==e&&(ne=e,w=!0,E=!0)}if(v.needsLights&&(y.state.sunShadowMap.length>0&&O.setValue(N,`sunShadowMap`,y.state.sunShadowMap,ke),y.state.directionalShadowMap.length>0&&O.setValue(N,`directionalShadowMap`,y.state.directionalShadowMap,ke),y.state.spotShadowMap.length>0&&O.setValue(N,`spotShadowMap`,y.state.spotShadowMap,ke),y.state.pointShadowMap.length>0&&O.setValue(N,`pointShadowMap`,y.state.pointShadowMap,ke)),i.isSkinnedMesh){O.setOptional(N,i,`bindMatrix`),O.setOptional(N,i,`bindMatrixInverse`);let e=i.skeleton;e&&(e.boneTexture===null&&e.computeBoneTexture(),O.setValue(N,`boneTexture`,e.boneTexture,ke))}i.isBatchedMesh&&(O.setOptional(N,i,`batchingTexture`),O.setValue(N,`batchingTexture`,i._matricesTexture,ke),O.setOptional(N,i,`batchingIdTexture`),O.setValue(N,`batchingIdTexture`,i._indirectTexture,ke),O.setOptional(N,i,`batchingColorTexture`),i._colorsTexture!==null&&O.setValue(N,`batchingColorTexture`,i._colorsTexture,ke));let A=n.morphAttributes;if((A.position!==void 0||A.normal!==void 0||A.color!==void 0)&&Ve.update(i,n,S),(w||v.receiveShadow!==i.receiveShadow)&&(v.receiveShadow=i.receiveShadow,O.setValue(N,`receiveShadow`,i.receiveShadow)),(r.isMeshStandardMaterial||r.isMeshLambertMaterial||r.isMeshPhongMaterial)&&r.envMap===null&&t.environment!==null&&(k.envMapIntensity.value=t.environmentIntensity),k.dfgLUT!==void 0&&(k.dfgLUT.value=Kh()),w){if(O.setValue(N,`toneMappingExposure`,T.toneMappingExposure),v.needsLights&>(k,E),a&&r.fog===!0&&Fe.refreshFogUniforms(k,a),Fe.refreshMaterialUniforms(k,r,ue,le,x.state.transmissionRenderTarget[e.id]),v.needsLights&&v.lightProbeGrid){let e=v.lightProbeGrid;k.probesSH.value=e.texture,k.probesMin.value.copy(e.boundingBox.min),k.probesMax.value.copy(e.boundingBox.max),k.probesResolution.value.copy(e.resolution)}Tm.upload(N,ft(v),k,ke)}if(r.isShaderMaterial&&r.uniformsNeedUpdate===!0&&(Tm.upload(N,ft(v),k,ke),r.uniformsNeedUpdate=!1),r.isSpriteMaterial&&O.setValue(N,`center`,i.center),O.setValue(N,`modelViewMatrix`,i.modelViewMatrix),O.setValue(N,`normalMatrix`,i.normalMatrix),O.setValue(N,`modelMatrix`,i.matrixWorld),r.uniformsGroups!==void 0){let e=r.uniformsGroups;for(let t=0,n=e.length;t0&&ke.useMultisampledRTT(e)===!1?Oe.get(e).__webglMultisampledFramebuffer:Array.isArray(c)?c[n]:c,re.copy(e.viewport),ie.copy(e.scissor),ae=e.scissorTest}else re.copy(pe).multiplyScalar(ue).floor(),ie.copy(me).multiplyScalar(ue).floor(),ae=he;if(n!==0&&(r=O),F.bindFramebuffer(N.FRAMEBUFFER,r)&&F.drawBuffers(e,r),F.viewport(re),F.scissor(ie),F.setScissorTest(ae),i){let r=Oe.get(e.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_CUBE_MAP_POSITIVE_X+t,r.__webglTexture,n)}else if(a){let r=t;for(let t=0;t1&&N.readBuffer(N.COLOR_ATTACHMENT0+s);let u=vt(o);if(u.__formatReadable===!1){Ba(`WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.`);return}if(u.__typeReadable===!1){Ba(`WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.`);return}t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i&&N.readPixels(t,n,r,i,We.convert(c),We.convert(l),a)}finally{let e=M===null?null:Oe.get(M).__webglFramebuffer;F.bindFramebuffer(N.FRAMEBUFFER,e)}}},this.readRenderTargetPixelsAsync=async function(e,t,n,r,i,a,o,s=0){if(!(e&&e.isWebGLRenderTarget))throw Error(`THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.`);let c=Oe.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&o!==void 0&&(c=c[o]),c){if(t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i){F.bindFramebuffer(N.FRAMEBUFFER,c);let o=e.textures[s],l=o.format,u=o.type;e.textures.length>1&&N.readBuffer(N.COLOR_ATTACHMENT0+s);let d=vt(o);if(d.__formatReadable===!1)throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.`);if(d.__typeReadable===!1)throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.`);let f=N.createBuffer();N.bindBuffer(N.PIXEL_PACK_BUFFER,f),N.bufferData(N.PIXEL_PACK_BUFFER,a.byteLength,N.STREAM_READ),N.readPixels(t,n,r,i,We.convert(l),We.convert(u),0),N.bindBuffer(N.PIXEL_PACK_BUFFER,null);let p=M===null?null:Oe.get(M).__webglFramebuffer;F.bindFramebuffer(N.FRAMEBUFFER,p);let m=N.fenceSync(N.SYNC_GPU_COMMANDS_COMPLETE,0);return N.flush(),await Ha(N,m,4),N.bindBuffer(N.PIXEL_PACK_BUFFER,f),N.getBufferSubData(N.PIXEL_PACK_BUFFER,0,a),N.bindBuffer(N.PIXEL_PACK_BUFFER,null),N.deleteBuffer(f),N.deleteSync(m),a}throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.`)}},this.copyFramebufferToTexture=function(e,t=null,n=0){let r=2**-n,i=Math.floor(e.image.width*r),a=Math.floor(e.image.height*r),o=t===null?0:t.x,s=t===null?0:t.y;ke.setTexture2D(e,0),N.copyTexSubImage2D(N.TEXTURE_2D,n,0,0,o,s,i,a),F.unbindTexture()},this.copyTextureToTexture=function(e,t,n=null,r=null,i=0,a=0){let o,s,c,l,u,d,f,p,m,h=e.isCompressedTexture?e.mipmaps[a]:e.image;if(n!==null)o=n.max.x-n.min.x,s=n.max.y-n.min.y,c=n.isBox3?n.max.z-n.min.z:1,l=n.min.x,u=n.min.y,d=n.isBox3?n.min.z:0;else{let t=2**-i;o=Math.floor(h.width*t),s=Math.floor(h.height*t),c=e.isDataArrayTexture?h.depth:e.isData3DTexture?Math.floor(h.depth*t):1,l=0,u=0,d=0}r===null?(f=0,p=0,m=0):(f=r.x,p=r.y,m=r.z);let g=We.convert(t.format),_=We.convert(t.type),v;t.isData3DTexture?(ke.setTexture3D(t,0),v=N.TEXTURE_3D):t.isDataArrayTexture||t.isCompressedArrayTexture?(ke.setTexture2DArray(t,0),v=N.TEXTURE_2D_ARRAY):(ke.setTexture2D(t,0),v=N.TEXTURE_2D),F.activeTexture(N.TEXTURE0),F.pixelStorei(N.UNPACK_FLIP_Y_WEBGL,t.flipY),F.pixelStorei(N.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),F.pixelStorei(N.UNPACK_ALIGNMENT,t.unpackAlignment);let y=F.getParameter(N.UNPACK_ROW_LENGTH),b=F.getParameter(N.UNPACK_IMAGE_HEIGHT),x=F.getParameter(N.UNPACK_SKIP_PIXELS),S=F.getParameter(N.UNPACK_SKIP_ROWS),C=F.getParameter(N.UNPACK_SKIP_IMAGES);F.pixelStorei(N.UNPACK_ROW_LENGTH,h.width),F.pixelStorei(N.UNPACK_IMAGE_HEIGHT,h.height),F.pixelStorei(N.UNPACK_SKIP_PIXELS,l),F.pixelStorei(N.UNPACK_SKIP_ROWS,u),F.pixelStorei(N.UNPACK_SKIP_IMAGES,d);let w=e.isDataArrayTexture||e.isData3DTexture,T=t.isDataArrayTexture||t.isData3DTexture;if(e.isDepthTexture){let n=Oe.get(e),r=Oe.get(t),h=Oe.get(n.__renderTarget),g=Oe.get(r.__renderTarget);F.bindFramebuffer(N.READ_FRAMEBUFFER,h.__webglFramebuffer),F.bindFramebuffer(N.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let n=0;n{let r=new e.array.constructor(e.count*e.itemSize);l[n][t]=new e.constructor(r,e.itemSize,e.normalized)}))}let p=t*.5,m=10**Math.log10(1/t),h=p*m;for(let t=0;tNumber.isInteger(e)?e.toFixed(1):String(e);function yA(e,t,n,r){let i=Math.atan2(t-fA.y,n-fA.z);return r*e-fA.x-.45*Math.sin(i*5+r)-.25*Math.sin(i*11+1.3)}function bA(e,t,n,r){let i=Math.atan2(t-pA.y,n-pA.z),a=r*e-pA.x+pA.lean*(t-pA.y)-.4*Math.sin(i*4+r)-.25*Math.sin(i*9+2.1);return Math.min(a,Math.max(t-pA.armpit,a-3))}function xA(e,t,n){let r=Math.atan2(n-mA.z,e);return t-mA.y-.7*Math.sin(r*5)-.4*Math.sin(r*12+.9)}function SA(e,t,n){let r=t-hA.y,i=Math.atan2(r,e);return hA.radius+.5*Math.sin(i*5+.4)+.3*Math.sin(i*11)-Math.sqrt(e*e+r*r)}function CA(e,t,n){let r=gA.top+.25*Math.sin(e*2.3)-t,i=t-gA.under,a=n-gA.back+gA.curve*e*e;return Math.min(r,Math.min(i,a))}var wA=` +`,og={x:31,y:102.8,z:-5.2},sg={x:15,y:103.5,z:-5.5,lean:.25,armpit:97.5},cg={y:81.5,z:-1},lg={y:99.5,radius:4.6},ug={top:114.9,under:111.2,back:.8,curve:.12},dg={y:125.2,z:-3},fg=e=>Number.isInteger(e)?e.toFixed(1):String(e);function pg(e,t,n,r){let i=Math.atan2(t-og.y,n-og.z);return r*e-og.x-.45*Math.sin(i*5+r)-.25*Math.sin(i*11+1.3)}function mg(e,t,n,r){let i=Math.atan2(t-sg.y,n-sg.z),a=r*e-sg.x+sg.lean*(t-sg.y)-.4*Math.sin(i*4+r)-.25*Math.sin(i*9+2.1);return Math.min(a,Math.max(t-sg.armpit,a-3))}function hg(e,t,n){let r=Math.atan2(n-cg.z,e);return t-cg.y-.7*Math.sin(r*5)-.4*Math.sin(r*12+.9)}function gg(e,t,n){let r=t-lg.y,i=Math.atan2(r,e);return lg.radius+.5*Math.sin(i*5+.4)+.3*Math.sin(i*11)-Math.sqrt(e*e+r*r)}function _g(e,t,n){let r=ug.top+.25*Math.sin(e*2.3)-t,i=t-ug.under,a=n-ug.back+ug.curve*e*e;return Math.min(r,Math.min(i,a))}var vg=` float injuryElbowCut(vec3 p, float side) { - float around = atan(p.y - ${vA(fA.y)}, p.z - ${vA(fA.z)}); - return side * p.x - ${vA(fA.x)} - 0.45 * sin(around * 5.0 + side) - 0.25 * sin(around * 11.0 + 1.3); + float around = atan(p.y - ${fg(og.y)}, p.z - ${fg(og.z)}); + return side * p.x - ${fg(og.x)} - 0.45 * sin(around * 5.0 + side) - 0.25 * sin(around * 11.0 + 1.3); } float injuryShoulderCut(vec3 p, float side) { - float around = atan(p.y - ${vA(pA.y)}, p.z - ${vA(pA.z)}); - float across = side * p.x - ${vA(pA.x)} + ${vA(pA.lean)} * (p.y - ${vA(pA.y)}) - 0.4 * sin(around * 4.0 + side) - 0.25 * sin(around * 9.0 + 2.1); - return min(across, max(p.y - ${vA(pA.armpit)}, across - 3.0)); + float around = atan(p.y - ${fg(sg.y)}, p.z - ${fg(sg.z)}); + float across = side * p.x - ${fg(sg.x)} + ${fg(sg.lean)} * (p.y - ${fg(sg.y)}) - 0.4 * sin(around * 4.0 + side) - 0.25 * sin(around * 9.0 + 2.1); + return min(across, max(p.y - ${fg(sg.armpit)}, across - 3.0)); } float injuryWaistCut(vec3 p) { - float around = atan(p.z - ${vA(mA.z)}, p.x); - return p.y - ${vA(mA.y)} - 0.7 * sin(around * 5.0) - 0.4 * sin(around * 12.0 + 0.9); + float around = atan(p.z - ${fg(cg.z)}, p.x); + return p.y - ${fg(cg.y)} - 0.7 * sin(around * 5.0) - 0.4 * sin(around * 12.0 + 0.9); } float injuryChestHoleCut(vec3 p) { - float dy = p.y - ${vA(hA.y)}; + float dy = p.y - ${fg(lg.y)}; float around = atan(dy, p.x); - return ${vA(hA.radius)} + 0.5 * sin(around * 5.0 + 0.4) + 0.3 * sin(around * 11.0) - sqrt(p.x * p.x + dy * dy); + return ${fg(lg.radius)} + 0.5 * sin(around * 5.0 + 0.4) + 0.3 * sin(around * 11.0) - sqrt(p.x * p.x + dy * dy); } -`,TA=` +`,yg=` float injuryJawCut(vec3 p) { - float top = ${vA(gA.top)} + 0.25 * sin(p.x * 2.3) - p.y; - float under = p.y - ${vA(gA.under)}; - float front = p.z - ${vA(gA.back)} + ${vA(gA.curve)} * p.x * p.x; + float top = ${fg(ug.top)} + 0.25 * sin(p.x * 2.3) - p.y; + float under = p.y - ${fg(ug.under)}; + float front = p.z - ${fg(ug.back)} + ${fg(ug.curve)} * p.x * p.x; return min(top, min(under, front)); } float injurySkullCut(vec3 p) { - float around = atan(p.z - ${vA(_A.z)}, p.x); - return p.y - ${vA(_A.y)} - 0.55 * sin(around * 7.0) - 0.3 * sin(around * 15.0 + 1.0); + float around = atan(p.z - ${fg(dg.z)}, p.x); + return p.y - ${fg(dg.y)} - 0.55 * sin(around * 7.0) - 0.3 * sin(around * 15.0 + 1.0); } -`,EA=[`nose`,`leftEar`,`rightEar`,`leftFace`,`rightFace`],DA=[`leftShoulder`,`rightShoulder`,`leftElbow`,`rightElbow`,`leftRibs`,`rightRibs`,`liver`,`belly`,`leftKnee`,`rightKnee`],OA=[`jaw`,`skull`],kA=[`leftArm`,`rightArm`,`waist`,`chestHole`],AA=DA.length,jA=kA.length,MA=[6.3,117.6,-3],NA=[[11.3,97.9,2],[10.6,95.6,2.3],[10.1,93.3,1.9]],PA=[31.2,105.9,-3.4],FA=[12.3,34.4,-5],IA=[0,86,6.5],LA=e=>` -uniform float uInjuryGone[${jA}]; -${e?wA:TA} +`,bg=[`nose`,`leftEar`,`rightEar`,`leftFace`,`rightFace`],xg=[`leftShoulder`,`rightShoulder`,`leftElbow`,`rightElbow`,`leftRibs`,`rightRibs`,`liver`,`belly`,`leftKnee`,`rightKnee`],Sg=[`jaw`,`skull`],Cg=[`leftArm`,`rightArm`,`waist`,`chestHole`],wg=xg.length,Tg=Cg.length,Eg=[6.3,117.6,-3],Dg=[[11.3,97.9,2],[10.6,95.6,2.3],[10.1,93.3,1.9]],Og=[31.2,105.9,-3.4],kg=[12.3,34.4,-5],Ag=[0,86,6.5],jg=e=>` +uniform float uInjuryGone[${Tg}]; +${e?vg:yg} float injuryGone(vec3 p) { float gone = -1000.0; ${e?` @@ -4528,14 +4270,14 @@ ${e?` if (uInjuryGone[1] > 0.5) gone = max(gone, injurySkullCut(p));`} return gone; } -`,RA=` +`,Mg=` float injuryBellyGape(vec3 p) { float along = p.x / 9.4; float reach = 2.1 * pow(max(0.0, 1.0 - along * along), 0.6) * (1.0 + 0.18 * sin(p.x * 2.9) + 0.1 * sin(p.x * 6.7 + 1.0)); - float line = ${vA(IA[1])} - 0.014 * p.x * p.x + 0.3 * sin(p.x * 1.1 + 0.5); + float line = ${fg(Ag[1])} - 0.014 * p.x * p.x + 0.3 * sin(p.x * 1.1 + 0.5); return p.z < 0.0 || reach <= 0.0 ? 9.0 : abs(p.y - line) / reach; } -`,zA=[0,119,-3.5,0],BA=[0,0,-2,1],VA=[[2.65,120.65,3.6],[-2.75,120.75,3.4]],HA=`HANDS_INJURY_WOUNDS`,UA=`HANDS_INJURY_OPEN`,WA=e=>` +`,Ng=[0,119,-3.5,0],Pg=[0,0,-2,1],Fg=[[2.65,120.65,3.6],[-2.75,120.75,3.4]],Ig=`HANDS_INJURY_WOUNDS`,Lg=`HANDS_INJURY_OPEN`,Rg=e=>` uniform vec4 uInjurySite[12]; uniform float uInjurySwell[12]; uniform vec4 uInjuryCore; @@ -4548,13 +4290,13 @@ uniform vec3 uInjuryImpactPush; uniform vec4 uInjuryNose; uniform mat3 uInjuryBindToPart; varying vec3 vInjuryPos; -#ifdef ${HA} -uniform float uInjuryWound[${AA}]; +#ifdef ${Ig} +uniform float uInjuryWound[${wg}]; uniform float uInjuryExplicit; -${e?RA:``} +${e?Mg:``} #endif -`,GA=` -#ifdef ${HA} +`,zg=` +#ifdef ${Ig} { float crushed = uInjuryWound[0] * uInjuryExplicit; if (crushed > 0.0) { @@ -4568,13 +4310,13 @@ ${e?RA:``} float torn = (s == 0 ? uInjuryWound[1] : uInjuryWound[2]) * uInjuryExplicit; if (torn <= 0.0) continue; float side = s == 0 ? 1.0 : -1.0; - float w = 1.0 - smoothstep(0.8, 2.8, distance(injuryBind, vec3(side * ${vA(MA[0])}, ${vA(MA[1])}, ${vA(MA[2])}))); + float w = 1.0 - smoothstep(0.8, 2.8, distance(injuryBind, vec3(side * ${fg(Eg[0])}, ${fg(Eg[1])}, ${fg(Eg[2])}))); injuryMoved.x -= side * torn * w * max(0.0, side * injuryBind.x - 5.3) * 0.9; } } #endif -`,KA=` -#ifdef ${HA} +`,Bg=` +#ifdef ${Ig} { float side = injuryBind.x < 0.0 ? -1.0 : 1.0; float slipped = (side > 0.0 ? uInjuryWound[0] : uInjuryWound[1]) * uInjuryExplicit; @@ -4586,7 +4328,7 @@ ${e?RA:``} } float caved = (side > 0.0 ? uInjuryWound[4] : uInjuryWound[5]) * uInjuryExplicit; if (caved > 0.0) { - float w = 1.0 - smoothstep(0.0, 8.0, distance(injuryBind, vec3(side * ${vA(NA[1][0])}, ${vA(NA[1][1])}, ${vA(NA[1][2])}))); + float w = 1.0 - smoothstep(0.0, 8.0, distance(injuryBind, vec3(side * ${fg(Dg[1][0])}, ${fg(Dg[1][1])}, ${fg(Dg[1][2])}))); injuryMoved -= normalize(injuryBind - vec3(0.0, injuryBind.y, -2.0) + vec3(0.0, 0.0, 0.001)) * caved * 2.4 * w * w; } float gutted = uInjuryWound[7] * uInjuryExplicit; @@ -4599,7 +4341,7 @@ ${e?RA:``} } } #endif -`,qA=(e,t)=>` +`,Vg=(e,t)=>` { vec3 injuryBind = ${e?`bindPosition`:`transformed`}; vInjuryPos = injuryBind; @@ -4634,10 +4376,10 @@ ${e?RA:``} injuryMoved.x += uInjuryJaw * 1.7 * jawMask; injuryMoved.y -= uInjuryJaw * 0.9 * jawMask; injuryMoved.z -= uInjuryJaw * 0.4 * jawMask; - ${t?KA:GA} + ${t?Bg:zg} ${e?`transformed += uInjuryBindToPart * (injuryMoved - injuryBind);`:`transformed = injuryMoved;`} } -`,JA=e=>` +`,Hg=e=>` uniform vec4 uInjurySite[12]; uniform vec4 uInjuryCut[12]; uniform float uInjuryBruise[12]; @@ -4647,15 +4389,20 @@ uniform float uInjuryWash; uniform float uInjuryRaw; uniform vec4 uInjuryLid[2]; uniform vec2 uInjuryEyeOut; +uniform vec4 uInjuryXray; +uniform float uInjuryXrayShown; +uniform float uInjuryRun; varying vec3 vInjuryPos; float injuryWet = 0.0; -${dA} +${ag} float injuryHash(float n) { return fract(sin(n) * 43758.5453123); } -#ifdef ${HA} -uniform float uInjuryWound[${AA}]; +#ifdef ${Ig} +uniform float uInjuryWound[${wg}]; uniform float uInjuryExplicit; uniform float uInjuryPallor; +uniform vec4 uInjuryMark[6]; +uniform float uInjurySpatter; /** A cell's value. The cells repeat every 24, so what is hashed stays small enough for a phone's medium precision. */ float injuryCell(vec2 cell) { cell = mod(cell, 24.0); @@ -4672,13 +4419,13 @@ vec3 injuryBruised(vec3 skin, float depth) { vec3 tone = mix(vec3(0.4, 0.08, 0.2), vec3(0.05, 0.012, 0.05), clamp(depth, 0.0, 1.0)); return mix(skin * tone / vec3(0.6, 0.32, 0.19), tone, 0.35); } -${e?RA:``} +${e?Mg:``} #endif -#ifdef ${UA} -${LA(e)} +#ifdef ${Lg} +${jg(e)} #endif -`,YA=e=>` -#ifdef ${HA} +`,Ug=e=>` +#ifdef ${Ig} if (uInjuryPallor > 0.0) { float luma = dot(diffuseColor.rgb, vec3(0.3, 0.55, 0.15)); vec3 drained = (vec3(luma) * 1.3 + 0.04) * vec3(0.97, 1.0, 1.05); @@ -4694,8 +4441,8 @@ ${e?` diffuseColor.rgb = mix(diffuseColor.rgb, vec3(0.3, 0.33, 0.47) * (0.5 + luma), lips * uInjuryPallor * 0.85);`} } #endif -`,XA=` -#ifdef ${HA} +`,Wg=` +#ifdef ${Ig} { float graphic = uInjuryExplicit; float mottle = 0.7 + 0.3 * injuryNoise(injuryPos.xy * 2.1 + injuryPos.z); @@ -4723,7 +4470,7 @@ ${e?` float ear = s == 0 ? uInjuryWound[1] : uInjuryWound[2]; if (ear > 0.0 && sx > 3.0) { // Where the ear was: a ragged raw wound round the dark hole of the ear, running down the neck. - vec3 q = injuryPos - vec3(side * ${vA(MA[0])}, ${vA(MA[1])}, ${vA(MA[2])}); + vec3 q = injuryPos - vec3(side * ${fg(Eg[0])}, ${fg(Eg[1])}, ${fg(Eg[2])}); float around = atan(q.y, q.z); float reach = length(vec2(q.z / 1.4, q.y / 2.1)) / (1.0 + 0.16 * sin(around * 5.0 + side) + 0.08 * sin(around * 11.0)); float bruise = (1.0 - smoothstep(0.8, 1.9, reach)) * mottle; @@ -4816,8 +4563,8 @@ ${e?` } } #endif -`,ZA=` -#ifdef ${HA} +`,Gg=` +#ifdef ${Ig} { float graphic = uInjuryExplicit; float side = injuryPos.x < 0.0 ? -1.0 : 1.0; @@ -4835,12 +4582,12 @@ ${e?` float elbow = side > 0.0 ? uInjuryWound[2] : uInjuryWound[3]; if (elbow > 0.0 && sx > 22.0) { // Black round the joint, the hole the bone came out of, and blood down the forearm to the glove. - vec3 q = vec3(sx, injuryPos.y, injuryPos.z) - vec3(${vA(fA.x)}, ${vA(fA.y)}, ${vA(fA.z)}); + vec3 q = vec3(sx, injuryPos.y, injuryPos.z) - vec3(${fg(og.x)}, ${fg(og.y)}, ${fg(og.z)}); float bruise = (1.0 - smoothstep(2.0, 7.0, abs(q.x))) * mottle; diffuseColor.rgb = mix(diffuseColor.rgb, injuryBruised(diffuseColor.rgb, 0.4 + 0.5 * (1.0 - smoothstep(0.0, 3.0, abs(q.x)))), bruise * elbow * 0.9); float around = atan(q.y, q.z); float sleeve = smoothstep(-1.5, 1.0, q.x) * (0.5 + 0.5 * sin(around * 7.0 + 1.5 * sin(q.x * 0.9))) * (1.0 - 0.5 * smoothstep(7.0, 13.0, q.x)); - vec3 exit = vec3(sx, injuryPos.y, injuryPos.z) - vec3(${vA(PA[0])}, ${vA(PA[1])}, ${vA(PA[2])}); + vec3 exit = vec3(sx, injuryPos.y, injuryPos.z) - vec3(${fg(Og[0])}, ${fg(Og[1])}, ${fg(Og[2])}); float hole = (1.0 - smoothstep(0.75, 1.1, length(exit / vec3(2.1, 1.3, 1.3)) * (1.0 + 0.15 * sin(atan(exit.z, exit.x) * 6.0)))) * graphic; float blood = max(sleeve * mix(0.3, 0.9, graphic), hole) * elbow; diffuseColor.rgb = mix(diffuseColor.rgb, mix(running, mix(raw, gore, smoothstep(0.3, 0.8, hole)), hole), blood); @@ -4849,13 +4596,13 @@ ${e?` float ribs = side > 0.0 ? uInjuryWound[4] : uInjuryWound[5]; if (ribs > 0.0 && injuryPos.y > 80.0 && sx < 16.0) { // Black with bruising, banded where the ribs lie under it, and a raw hole where each broken end comes through. - vec3 q = vec3(sx, injuryPos.y, injuryPos.z) - vec3(${vA(NA[1][0])}, ${vA(NA[1][1])}, ${vA(NA[1][2])}); + vec3 q = vec3(sx, injuryPos.y, injuryPos.z) - vec3(${fg(Dg[1][0])}, ${fg(Dg[1][1])}, ${fg(Dg[1][2])}); float spread = length(vec3(q.x, q.y * 0.85, q.z * 0.6)); float bands = 0.72 + 0.28 * sin((injuryPos.y + 0.3 * sx - 0.25 * injuryPos.z) * 2.8); float bruise = (1.0 - smoothstep(2.5, 9.5, spread)) * mottle * bands; diffuseColor.rgb = mix(diffuseColor.rgb, injuryBruised(diffuseColor.rgb, 0.7 + 0.3 * (1.0 - smoothstep(0.0, 5.0, spread))), bruise * ribs * 0.95); - for (int k = 0; k < ${NA.length}; k++) { - vec3 end = k == 0 ? vec3(${NA[0].map(vA).join(`, `)}) : k == 1 ? vec3(${NA[1].map(vA).join(`, `)}) : vec3(${NA[2].map(vA).join(`, `)}); + for (int k = 0; k < ${Dg.length}; k++) { + vec3 end = k == 0 ? vec3(${Dg[0].map(fg).join(`, `)}) : k == 1 ? vec3(${Dg[1].map(fg).join(`, `)}) : vec3(${Dg[2].map(fg).join(`, `)}); vec3 at = vec3(sx, injuryPos.y, injuryPos.z) - end; float hole = (1.0 - smoothstep(0.6, 1.0, length(at / vec3(1.7, 1.0, 1.7)))) * graphic; float drop = -at.y; @@ -4880,7 +4627,7 @@ ${e?` if (gutted > 0.0 && injuryPos.y > 74.0 && injuryPos.y < 92.0) { // Torn open from side to side: a dark wet cavity between lips of raw muscle and yellow fat, and everything below it red. float gape = injuryBellyGape(injuryPos) * (1.0 + 0.45 * (injuryNoise(injuryPos.xy * 2.4 + 9.0) - 0.5)); - float line = ${vA(IA[1])} - 0.014 * injuryPos.x * injuryPos.x; + float line = ${fg(Ag[1])} - 0.014 * injuryPos.x * injuryPos.x; float below = line - injuryPos.y; float sheet = smoothstep(-0.5, 1.5, below) * (1.0 - smoothstep(8.6, 9.9, abs(injuryPos.x) + 0.6 * sin(injuryPos.y * 1.7))) * step(0.0, injuryPos.z) * (0.82 + 0.18 * sin(injuryPos.x * 4.3 + sin(injuryPos.y * 0.9))); float bruise = (1.0 - smoothstep(1.2, 3.2, gape)) * mottle; @@ -4894,9 +4641,9 @@ ${e?` injuryWet = max(injuryWet, max(open, sheet * gutted * graphic)); } float knee = side > 0.0 ? uInjuryWound[8] : uInjuryWound[9]; - if (knee > 0.0 && injuryPos.y < ${vA(60)}) { + if (knee > 0.0 && injuryPos.y < ${fg(60)}) { // Swollen black below the trunks, a raw hole in the side of the knee where the bone shows, and blood down the shin to the boot. - vec3 q = vec3(sx, injuryPos.y, injuryPos.z) - vec3(${FA.map(vA).join(`, `)}); + vec3 q = vec3(sx, injuryPos.y, injuryPos.z) - vec3(${kg.map(fg).join(`, `)}); float bruise = (1.0 - smoothstep(27.0, 34.0, 62.0 - injuryPos.y)) * smoothstep(25.0, 31.0, injuryPos.y) * mottle; diffuseColor.rgb = mix(diffuseColor.rgb, injuryBruised(diffuseColor.rgb, 0.4 + 0.5 * smoothstep(30.0, 36.0, injuryPos.y)), bruise * knee * 0.9); float hole = (1.0 - smoothstep(0.7, 1.05, length(q / vec3(1.8, 2.0, 1.8)) * (1.0 + 0.15 * sin(atan(q.y, q.z) * 5.0)))) * graphic; @@ -4909,7 +4656,7 @@ ${e?` } } #endif -`,QA=` +`,Kg=` if (uInjuryGone[1] > 0.5) { // A skull broken open: the bone of its rim under the torn scalp, and cracks running down from it. float rim = -injurySkullCut(injuryPos); @@ -4926,7 +4673,7 @@ ${e?` diffuseColor.rgb = mix(diffuseColor.rgb, vec3(0.28, 0.008, 0.012), sheet * 0.93); injuryWet = max(injuryWet, sheet); } -`,$A=` +`,qg=` { // A stump runs with blood back from its cut, and a hole through the chest down the front and the back. float side = injuryPos.x < 0.0 ? -1.0 : 1.0; @@ -4936,18 +4683,18 @@ ${e?` if (uInjuryGone[2] > 0.5) soaked = max(soaked, (1.0 - smoothstep(0.5, 3.5, -injuryWaistCut(injuryPos))) * 0.9); if (uInjuryGone[3] > 0.5) { float hole = -injuryChestHoleCut(injuryPos); - float below = ${vA(hA.y)} - injuryPos.y; + float below = ${fg(lg.y)} - injuryPos.y; float sheet = smoothstep(0.0, 3.0, below) * (1.0 - smoothstep(3.5, 6.5, abs(injuryPos.x) - below * 0.08)) * (0.65 + 0.35 * sin(injuryPos.x * 4.1 + sin(injuryPos.y * 0.8))) * (1.0 - 0.5 * smoothstep(8.0, 20.0, below)); soaked = max(soaked, max(sheet * step(-30.0, -abs(injuryPos.x)), (1.0 - smoothstep(0.5, 3.0, hole)) * 0.85)); } diffuseColor.rgb = mix(diffuseColor.rgb, vec3(0.28, 0.008, 0.012), soaked * 0.93); injuryWet = max(injuryWet, soaked); } -`,ej=e=>` +`,Jg=e=>` { vec3 injuryPos = vInjuryPos; -${YA(e)} -#ifdef ${UA} +${Ug(e)} +#ifdef ${Lg} { float below = injuryCutLine(injuryPos) - injuryPos.y; if (below < 0.0) discard; @@ -4957,7 +4704,7 @@ ${YA(e)} diffuseColor.rgb = mix(diffuseColor.rgb, vec3(0.2, 0.008, 0.012), torn * 0.94); injuryWet = max(injuryWet, torn); } -${e?$A:QA} +${e?qg:Kg} #endif vec3 hematomaFresh = vec3(0.42, 0.09, 0.11); vec3 hematomaDeep = vec3(0.2, 0.04, 0.07); @@ -5017,7 +4764,7 @@ ${e?$A:QA} diffuseColor.rgb = mix(diffuseColor.rgb, mix(puffed, vec3(0.03, 0.006, 0.01), crease * 0.92), closed); injuryWet = max(injuryWet, closed * 0.35 * (1.0 - crease)); } -${e?ZA:XA} +${e?Gg:Wg} // An empty socket: a raw red rim round a dark hollow where the eye was. for (int e = 0; e < 2; e++) { float gone = e == 0 ? uInjuryEyeOut.x : uInjuryEyeOut.y; @@ -5045,7 +4792,7 @@ ${e?ZA:XA} if (fk > 0.5 && blood < 0.3) break; if (fk > 1.5 && blood < 0.7) break; float seed = fract(sin(float(i) * 12.9898 + fk * 78.233) * 43758.5453); - float reach = (4.0 + blood * 18.0) * (fk < 0.5 ? 1.0 : 0.55 + 0.3 * seed); + float reach = (4.0 + blood * 18.0) * uInjuryRun * (fk < 0.5 ? 1.0 : 0.55 + 0.3 * seed); float start = (fk < 0.5 ? -0.3 : fk < 1.5 ? 0.4 : 0.05) * (0.6 + 0.6 * seed) * radius * 0.35; float t = clamp(drop / reach, 0.0, 1.0); float wander = (0.35 * sin(injuryPos.y * 1.3 + float(i) * 1.7 + fk * 2.1) + 0.15 * sin(injuryPos.y * 3.7 + fk)) * t; @@ -5071,7 +4818,56 @@ ${e?ZA:XA} } injuryWet = max(injuryWet, w); } -#ifdef ${UA} +#ifdef ${Ig} + // Where punches landed: a red welt the shape of the glove, a bruise that darkens under it, and, hit again and again, a split that runs. + for (int m = 0; m < 6; m++) { + vec4 mark = uInjuryMark[m]; + if (mark.w <= 0.0) continue; + vec3 away = injuryPos - mark.xyz; + float ragged = 1.0 + 0.2 * sin(atan(away.y, away.x) * 4.0 + float(m) * 1.9); + float reach = length(away) / (${e?`4.4`:`2.6`} * ragged); + if (reach > 1.6) continue; + float depth = min(mark.w, 1.0); + float welt = 1.0 - smoothstep(0.5, 1.0, reach); + float ring = smoothstep(0.45, 0.75, reach) * (1.0 - smoothstep(0.85, 1.15, reach)); + vec3 fresh = diffuseColor.rgb * vec3(1.0, 0.42, 0.4) + vec3(0.1, 0.0, 0.0); + vec3 marked = mix(fresh, injuryBruised(diffuseColor.rgb, depth), smoothstep(0.3, 0.9, depth)); + diffuseColor.rgb = mix(diffuseColor.rgb, marked, clamp(welt * (0.4 + 0.5 * depth) + ring * 0.4 * (1.0 - depth), 0.0, 0.9)); + float split = smoothstep(1.0, 1.5, mark.w) * uInjuryRaw * uInjuryExplicit; + if (split > 0.0) { + float slit = abs(away.y - 0.25 * sin(away.x * 2.4 + float(m))) + max(0.0, abs(away.x) - 1.3) * 2.0 + abs(away.z) * 0.2; + float gash = 1.0 - smoothstep(0.05, 0.16, slit); + float lip = (1.0 - smoothstep(0.12, 0.42, slit)) * (1.0 - gash); + float below = -away.y; + float run = (1.0 - smoothstep(0.1, 0.26, abs(away.x - 0.3 * sin(injuryPos.y * 1.7 + float(m))))) * step(0.0, below) * (1.0 - smoothstep(2.0, 2.0 + 6.0 * split * uInjuryRun, below)); + diffuseColor.rgb = mix(diffuseColor.rgb, rawFlesh, lip * split * 0.75); + diffuseColor.rgb = mix(diffuseColor.rgb, bloodColor, run * split * 0.92); + diffuseColor.rgb = mix(diffuseColor.rgb, cutColor, gash * split); + injuryWet = max(injuryWet, split * max(max(gash, lip * 0.6), run)); + } + } + // The other man's blood, where it flew onto him: a fine spray, fat drops that have run a little, and smears. + if (uInjurySpatter > 0.001) { + vec2 across = vec2(injuryPos.x + injuryPos.z * 0.6, injuryPos.y); + float amount = uInjurySpatter * smoothstep(-7.0, 1.0, injuryPos.z); + vec2 fineCell = floor(across * 2.6); + float fineSeed = injuryCell(fineCell); + vec2 fineAt = (vec2(injuryCell(fineCell + 7.0), injuryCell(fineCell + 13.0)) - 0.5) * 0.6; + float fine = (1.0 - smoothstep(0.08, 0.2, length(fract(across * 2.6) - 0.5 - fineAt))) * step(1.0 - amount * 0.5, fineSeed); + vec2 fatScale = vec2(0.7, 0.45); + vec2 fatCell = floor(across * fatScale); + float fatSeed = injuryCell(fatCell + 3.0); + vec2 fatAt = (vec2(injuryCell(fatCell + 17.0), injuryCell(fatCell + 5.0)) - 0.5) * 0.5; + vec2 off = (fract(across * fatScale) - 0.5 - fatAt) / fatScale; + float drop = 1.0 - smoothstep(0.2, 0.4, length(off * vec2(1.0, 0.8))); + float tail = (1.0 - smoothstep(0.05, 0.15, abs(off.x + 0.05 * sin(off.y * 9.0)))) * step(off.y, 0.0) * (1.0 - smoothstep(0.2, 0.3 + 0.8 * fatSeed, -off.y)); + float smear = smoothstep(0.74 - 0.2 * amount, 0.86, injuryNoise(across * 0.33 + 9.0)) * amount; + float spat = max(max(fine * 0.85, max(drop, tail) * step(1.0 - amount * 0.45, fatSeed)), smear * 0.6); + diffuseColor.rgb = mix(diffuseColor.rgb, mix(bloodColor, bloodEdge, 0.25 + 0.5 * fineSeed), spat * 0.92); + injuryWet = max(injuryWet, spat * 0.8); + } +#endif +#ifdef ${Lg} // Where a cut or a burst opens the head, its inside shows as raw flesh rather than nothing. if (!gl_FrontFacing) { diffuseColor.rgb = vec3(0.2, 0.012, 0.022); @@ -5079,12 +4875,46 @@ ${e?ZA:XA} } #endif injuryWet *= uInjuryWetness; + // Under the X-ray of a breaking bone the skin goes dark and glassy, and the bones are drawn through it. + if (uInjuryXrayShown > 0.0) { + float seen = (1.0 - smoothstep(uInjuryXray.w * 0.78, uInjuryXray.w, distance(injuryPos, uInjuryXray.xyz))) * uInjuryXrayShown; + diffuseColor.rgb = mix(diffuseColor.rgb, vec3(0.015, 0.045, 0.1), seen * 0.93); + injuryWet = max(injuryWet, seen * 0.6); + } } -`,tj=` +`,Yg=` roughnessFactor = mix(roughnessFactor, 0.18, injuryWet); -`,nj=class{material;sites;uniforms={uInjurySite:{value:[]},uInjuryCut:{value:[]},uInjurySwell:{value:new Float32Array(12)},uInjuryBruise:{value:new Float32Array(12)},uInjuryBlood:{value:new Float32Array(12)},uInjuryJaw:{value:0},uInjuryJawLevel:{value:114.5},uInjuryImpact:{value:new Sg(0,-1e3,0,1)},uInjuryImpactPush:{value:new q},uInjuryNose:{value:new Sg(0,-1e3,0,0)},uInjuryWetness:{value:1},uInjuryRaw:{value:1},uInjurySever:{value:uA},uInjurySeverShape:{value:new K(sA,1)},uInjuryCore:{value:new Sg(...zA)},uInjuryWash:{value:0},uInjuryLid:{value:[new Sg(0,-1e3,0,0),new Sg(0,-1e3,0,0)]},uInjuryEyeOut:{value:new K},uInjuryBindToPart:{value:new og},uInjuryWound:{value:new Float32Array(AA)},uInjuryGone:{value:new Float32Array(jA)},uInjuryExplicit:{value:1},uInjuryPallor:{value:0}};index=new Map;wounds;cuts;body;shadow=null;shadowSideSet=!1;constructor(e,t,n={core:zA}){if(this.material=e,this.sites=t,t.length!==12)throw Error(`injury shading requires 12 sites`);let r=n.wash===!0;this.body=r,this.wounds=r?DA:EA,this.cuts=r?kA:OA,this.uniforms.uInjuryCore.value.set(...n.core),this.uniforms.uInjuryWash.value=+(n.wash===!0);for(let[e,t]of(n.lids??[]).slice(0,2).entries())this.uniforms.uInjuryLid.value[e].set(t[0],t[1],t[2],0);for(let[e,n]of t.entries())this.index.set(n.name,e),this.uniforms.uInjurySite.value.push(new Sg(n.position[0],n.position[1],n.position[2],n.radius)),this.uniforms.uInjuryCut.value.push(new Sg(n.cutHalfLength,0,0,0));if(e===null)return;let i=this.uniforms,a=n.baked===!0;e.onBeforeCompile=e=>{Object.assign(e.uniforms,i),e.vertexShader=e.vertexShader.replace(`#include `,`#include \n${WA(r)}`).replace(`#include `,`#include \n${qA(a,r)}`),e.fragmentShader=e.fragmentShader.replace(`#include `,`#include \n${JA(r)}`).replace(`#include `,`#include \n${ej(r)}`).replace(`#include `,`#include \n${tj}`)},e.customProgramCacheKey=()=>`hands-injury-12${r?`-body`:``}${a?`-baked`:``}`,e.needsUpdate=!0}slot(e){let t=this.index.get(e);if(t===void 0)throw Error(`unknown injury site ${e}`);return t}set(e,t){let n=this.slot(e);t.bruise!==void 0&&(this.uniforms.uInjuryBruise.value[n]=G.clamp(t.bruise,0,1.2)),t.swell!==void 0&&(this.uniforms.uInjurySwell.value[n]=G.clamp(t.swell,0,2.2)),t.cut!==void 0&&(this.uniforms.uInjuryCut.value[n].y=G.clamp(t.cut,0,1)),t.blood!==void 0&&(this.uniforms.uInjuryBlood.value[n]=G.clamp(t.blood,0,1.4))}impact(e,t,n){let r=this.uniforms.uInjurySite.value[this.slot(e)];this.uniforms.uInjuryImpact.value.set(r.x,r.y,r.z,n),this.uniforms.uInjuryImpactPush.value.set(t[0],t[1],t[2])}setNoseShift(e){let t=this.index.get(`nose`);if(t===void 0)return;let n=this.uniforms.uInjurySite.value[t];this.uniforms.uInjuryNose.value.set(n.x,n.y,n.z,G.clamp(e,-1.4,1.4)||0)}update(e){let t=this.uniforms.uInjuryImpactPush.value;t.lengthSq()<1e-6||(t.multiplyScalar(Math.exp(-9*e)),t.lengthSq()<1e-4&&t.set(0,0,0))}get impactDepth(){return this.uniforms.uInjuryImpactPush.value.length()}setSevered(e){this.uniforms.uInjurySever.value=e?oA:uA,this.uniforms.uInjurySeverShape.value.set(sA,1),this.refresh()}setBurst(e){this.uniforms.uInjurySever.value=e?cA:uA,this.uniforms.uInjurySeverShape.value.set(e?0:sA,e?lA:1),this.refresh()}get open(){return this.material?.defines?.[UA]!==void 0}get wounded(){return this.material?.defines?.[HA]!==void 0}setOpen(e){this.switchTo(e||this.painted,e)}get painted(){let e=this.uniforms.uInjuryWound.value;for(let t=0;t0)return!0;return this.uniforms.uInjuryPallor.value>0}refresh(){let e=this.uniforms.uInjurySever.value!==uA,t=this.uniforms.uInjuryGone.value;for(let n=0;n0&&(e=!0);this.switchTo(e||this.painted,e)}switchTo(e,t){let n=this.material;n===null||e===this.wounded&&t===this.open||(t!==this.open&&this.shadow!==null&&(this.shadow.defines=t?{[UA]:``}:{},this.shadow.needsUpdate=!0),ij(n,e,t),t&&n.shadowSide===null?(n.shadowSide=1,this.shadowSideSet=!0):!t&&this.shadowSideSet&&(n.shadowSide=null,this.shadowSideSet=!1))}variant(e){let t=this.material;if(t===null)return null;let n=t.clone();return n.defines={...t.defines},n.onBeforeCompile=t.onBeforeCompile,n.customProgramCacheKey=t.customProgramCacheKey,ij(n,!0,e),n.shadowSide=t.shadowSide??(e?1:null),n}shadowMaterial(){return this.shadow=this.depthMaterial(this.open),this.shadow}shadowVariant(){return this.depthMaterial(!0)}depthMaterial(e){let t=new Mb,n={uInjurySever:this.uniforms.uInjurySever,uInjurySeverShape:this.uniforms.uInjurySeverShape,uInjuryGone:this.uniforms.uInjuryGone},r=this.body;return t.onBeforeCompile=e=>{Object.assign(e.uniforms,n),e.vertexShader=e.vertexShader.replace(`#include `,`#include +`,Xg=2.4,Zg=.85,Qg=.02,$g=1.6,e_=class{material;sites;uniforms={uInjurySite:{value:[]},uInjuryCut:{value:[]},uInjurySwell:{value:new Float32Array(12)},uInjuryBruise:{value:new Float32Array(12)},uInjuryBlood:{value:new Float32Array(12)},uInjuryJaw:{value:0},uInjuryJawLevel:{value:114.5},uInjuryImpact:{value:new Lo(0,-1e3,0,1)},uInjuryImpactPush:{value:new z},uInjuryNose:{value:new Lo(0,-1e3,0,0)},uInjuryWetness:{value:1},uInjuryRaw:{value:1},uInjurySever:{value:ig},uInjurySeverShape:{value:new R(tg,1)},uInjuryCore:{value:new Lo(...Ng)},uInjuryWash:{value:0},uInjuryLid:{value:[new Lo(0,-1e3,0,0),new Lo(0,-1e3,0,0)]},uInjuryEyeOut:{value:new R},uInjuryBindToPart:{value:new xo},uInjuryWound:{value:new Float32Array(wg)},uInjuryGone:{value:new Float32Array(Tg)},uInjuryExplicit:{value:1},uInjuryPallor:{value:0},uInjuryXray:{value:new Lo(0,0,0,0)},uInjuryXrayShown:{value:0},uInjuryRun:{value:1},uInjuryMark:{value:Array.from({length:6},()=>new Lo(0,0,0,0))},uInjurySpatter:{value:0}};index=new Map;wounds;cuts;body;shadow=null;shadowSideSet=!1;constructor(e,t,n={core:Ng}){if(this.material=e,this.sites=t,t.length!==12)throw Error(`injury shading requires 12 sites`);let r=n.wash===!0;this.body=r,this.wounds=r?xg:bg,this.cuts=r?Cg:Sg,this.uniforms.uInjuryCore.value.set(...n.core),this.uniforms.uInjuryWash.value=+(n.wash===!0);for(let[e,t]of(n.lids??[]).slice(0,2).entries())this.uniforms.uInjuryLid.value[e].set(t[0],t[1],t[2],0);for(let[e,n]of t.entries())this.index.set(n.name,e),this.uniforms.uInjurySite.value.push(new Lo(n.position[0],n.position[1],n.position[2],n.radius)),this.uniforms.uInjuryCut.value.push(new Lo(n.cutHalfLength,0,0,0));if(e===null)return;let i=this.uniforms,a=n.baked===!0;e.onBeforeCompile=e=>{Object.assign(e.uniforms,i),e.vertexShader=e.vertexShader.replace(`#include `,`#include \n${Rg(r)}`).replace(`#include `,`#include \n${Vg(a,r)}`),e.fragmentShader=e.fragmentShader.replace(`#include `,`#include \n${Hg(r)}`).replace(`#include `,`#include \n${Jg(r)}`).replace(`#include `,`#include \n${Yg}`)},e.customProgramCacheKey=()=>`hands-injury-12${r?`-body`:``}${a?`-baked`:``}`,e.needsUpdate=!0}slot(e){let t=this.index.get(e);if(t===void 0)throw Error(`unknown injury site ${e}`);return t}set(e,t){let n=this.slot(e);t.bruise!==void 0&&(this.uniforms.uInjuryBruise.value[n]=L.clamp(t.bruise,0,1.2)),t.swell!==void 0&&(this.uniforms.uInjurySwell.value[n]=L.clamp(t.swell,0,2.2)),t.cut!==void 0&&(this.uniforms.uInjuryCut.value[n].y=L.clamp(t.cut,0,1)),t.blood!==void 0&&(this.uniforms.uInjuryBlood.value[n]=L.clamp(t.blood,0,1.4))}impact(e,t,n){let r=this.uniforms.uInjurySite.value[this.slot(e)];this.uniforms.uInjuryImpact.value.set(r.x,r.y,r.z,n),this.uniforms.uInjuryImpactPush.value.set(t[0],t[1],t[2])}setNoseShift(e){let t=this.index.get(`nose`);if(t===void 0)return;let n=this.uniforms.uInjurySite.value[t];this.uniforms.uInjuryNose.value.set(n.x,n.y,n.z,L.clamp(e,-1.4,1.4)||0)}update(e){let t=this.uniforms.uInjuryMark.value;for(let n=0;n0&&r.w0&&(s.x-e)**2+(s.y-t)**2+(s.z-n)**20,t.w=0;e&&this.refresh()}setSpatter(e){let t=L.clamp(e,0,1)||0;t!==this.uniforms.uInjurySpatter.value&&(this.uniforms.uInjurySpatter.value=t,this.refresh())}get spatter(){return this.uniforms.uInjurySpatter.value}setRun(e){this.uniforms.uInjuryRun.value=L.clamp(e,.3,2)||1}setXray(e,t,n,r,i){this.uniforms.uInjuryXray.value.set(e,t,n,r),this.uniforms.uInjuryXrayShown.value=i}get impactDepth(){return this.uniforms.uInjuryImpactPush.value.length()}setSevered(e){this.uniforms.uInjurySever.value=e?eg:ig,this.uniforms.uInjurySeverShape.value.set(tg,1),this.refresh()}setBurst(e){this.uniforms.uInjurySever.value=e?ng:ig,this.uniforms.uInjurySeverShape.value.set(e?0:tg,e?rg:1),this.refresh()}get open(){return this.material?.defines?.[Lg]!==void 0}get wounded(){return this.material?.defines?.[Ig]!==void 0}setOpen(e){this.switchTo(e||this.painted,e)}get painted(){let e=this.uniforms.uInjuryWound.value;for(let t=0;t0)return!0;for(let e of this.uniforms.uInjuryMark.value)if(e.w>0)return!0;return this.uniforms.uInjuryPallor.value>0||this.uniforms.uInjurySpatter.value>0}refresh(){let e=this.uniforms.uInjurySever.value!==ig,t=this.uniforms.uInjuryGone.value;for(let n=0;n0&&(e=!0);this.switchTo(e||this.painted,e)}switchTo(e,t){let n=this.material;n===null||e===this.wounded&&t===this.open||(t!==this.open&&this.shadow!==null&&(this.shadow.defines=t?{[Lg]:``}:{},this.shadow.needsUpdate=!0),n_(n,e,t),t&&n.shadowSide===null?(n.shadowSide=1,this.shadowSideSet=!0):!t&&this.shadowSideSet&&(n.shadowSide=null,this.shadowSideSet=!1))}variant(e){let t=this.material;if(t===null)return null;let n=t.clone();return n.defines={...t.defines},n.onBeforeCompile=t.onBeforeCompile,n.customProgramCacheKey=t.customProgramCacheKey,n_(n,!0,e),n.shadowSide=t.shadowSide??(e?1:null),n}shadowMaterial(){return this.shadow=this.depthMaterial(this.open),this.shadow}shadowVariant(){return this.depthMaterial(!0)}depthMaterial(e){let t=new Ju,n={uInjurySever:this.uniforms.uInjurySever,uInjurySeverShape:this.uniforms.uInjurySeverShape,uInjuryGone:this.uniforms.uInjuryGone},r=this.body;return t.onBeforeCompile=e=>{Object.assign(e.uniforms,n),e.vertexShader=e.vertexShader.replace(`#include `,`#include varying vec3 vInjuryPos;`).replace(`#include `,`#include -vInjuryPos = transformed;`),e.fragmentShader=e.fragmentShader.replace(`#include `,`#include \nvarying vec3 vInjuryPos;\n${dA}\n#ifdef ${UA}\n${LA(r)}\n#endif`).replace(`#include `,`#include \n#ifdef ${UA}\nif (vInjuryPos.y > injuryCutLine(vInjuryPos)) discard;\nif (injuryGone(vInjuryPos) > 0.0) discard;\n#endif`)},t.customProgramCacheKey=()=>`hands-injury-shadow${r?`-body`:``}`,e&&(t.defines={[UA]:``}),t}setWound(e,t){this.uniforms.uInjuryWound.value[rj(this.wounds,e)]=G.clamp(t,0,1)||0,this.refresh()}wound(e){return this.uniforms.uInjuryWound.value[rj(this.wounds,e)]}setGone(e,t){this.uniforms.uInjuryGone.value[rj(this.cuts,e)]=G.clamp(t,0,2)||0,this.refresh()}gone(e){return this.uniforms.uInjuryGone.value[rj(this.cuts,e)]}setExplicit(e){this.uniforms.uInjuryExplicit.value=+!!e}get explicit(){return this.uniforms.uInjuryExplicit.value>0}setPallor(e){let t=G.clamp(e,0,1)||0;t!==this.uniforms.uInjuryPallor.value&&(this.uniforms.uInjuryPallor.value=t,this.refresh())}get pallor(){return this.uniforms.uInjuryPallor.value}raise(e,t,n=0,r=0){let i=this.slot(e),a=this.uniforms;a.uInjuryBruise.value[i]=Math.max(a.uInjuryBruise.value[i],Math.min(t,1.2)),a.uInjuryBlood.value[i]=Math.max(a.uInjuryBlood.value[i],Math.min(n,1.4));let o=a.uInjuryCut.value[i];o.y=Math.max(o.y,Math.min(r,1))}copyFrom(e){let t=e.uniforms,n=this.uniforms;n.uInjuryBruise.value.set(t.uInjuryBruise.value),n.uInjurySwell.value.set(t.uInjurySwell.value),n.uInjuryBlood.value.set(t.uInjuryBlood.value);for(let[e,r]of n.uInjuryCut.value.entries())r.y=t.uInjuryCut.value[e]?.y??0;for(let[e,r]of n.uInjuryLid.value.entries())r.w=t.uInjuryLid.value[e]?.w??0;n.uInjuryEyeOut.value.copy(t.uInjuryEyeOut.value),n.uInjuryNose.value.copy(t.uInjuryNose.value),n.uInjuryJaw.value=t.uInjuryJaw.value,n.uInjuryWetness.value=t.uInjuryWetness.value,n.uInjuryRaw.value=t.uInjuryRaw.value,n.uInjuryImpactPush.value.set(0,0,0),n.uInjuryWound.value.set(t.uInjuryWound.value),n.uInjuryGone.value.set(t.uInjuryGone.value),n.uInjuryExplicit.value=t.uInjuryExplicit.value,n.uInjuryPallor.value=t.uInjuryPallor.value,this.refresh()}setBindToPart(e){this.uniforms.uInjuryBindToPart.value.copy(e)}setRawCuts(e){this.uniforms.uInjuryRaw.value=G.clamp(e,0,1)||0}setJaw(e){this.uniforms.uInjuryJaw.value=G.clamp(e,0,1)}setEyesShut(e,t){let[n,r]=this.uniforms.uInjuryLid.value;n.y>-500&&(n.w=G.clamp(e,0,1)||0),r.y>-500&&(r.w=G.clamp(t,0,1)||0)}setEyeOut(e){let t=this.uniforms.uInjuryLid.value,n=(e===`left`||e===`both`)&&t[0].y>-500,r=(e===`right`||e===`both`)&&t[1].y>-500;this.uniforms.uInjuryEyeOut.value.set(+!!n,+!!r),this.index.has(`leftEye`)&&this.set(`leftEye`,{blood:n?1.3:0}),this.index.has(`rightEye`)&&this.set(`rightEye`,{blood:r?1.3:0})}get eyeOut(){let e=this.uniforms.uInjuryEyeOut.value;return e.x>0&&e.y>0?`both`:e.x>0?`left`:e.y>0?`right`:null}get eyesShut(){return[this.uniforms.uInjuryLid.value[0].w,this.uniforms.uInjuryLid.value[1].w]}clear(){this.uniforms.uInjuryBruise.value.fill(0),this.uniforms.uInjurySwell.value.fill(0),this.uniforms.uInjuryBlood.value.fill(0);for(let e of this.uniforms.uInjuryCut.value)e.y=0;this.uniforms.uInjuryJaw.value=0;for(let e of this.uniforms.uInjuryLid.value)e.w=0;this.uniforms.uInjuryEyeOut.value.set(0,0),this.uniforms.uInjuryNose.value.w=0,this.uniforms.uInjuryImpactPush.value.set(0,0,0),this.uniforms.uInjuryWound.value.fill(0),this.uniforms.uInjuryGone.value.fill(0),this.uniforms.uInjuryPallor.value=0,this.refresh()}level(e){let t=this.slot(e);return{bruise:this.uniforms.uInjuryBruise.value[t],swell:this.uniforms.uInjurySwell.value[t],cut:this.uniforms.uInjuryCut.value[t].y,blood:this.uniforms.uInjuryBlood.value[t]}}};function rj(e,t){let n=e.indexOf(t);if(n<0)throw Error(`unknown injury ${t}`);return n}function ij(e,t,n){let r=e.defines??={};delete r[HA],delete r[UA],t&&(r[HA]=``),n&&(r[UA]=``),e.side=n?2:0,e.needsUpdate=!0}var aj=e=>e===`off`?0:e===`reduced`?.2:1.5,oj=330;function sj(e,t){return G.clamp((e-oj)/(p-oj)+Math.max(0,t-200)/1600,0,1)}var cj=1.8,lj=150,uj=240;function dj(e,t,n){let r=aj(n),i=n===`full`?1:.6;e.setRawCuts(n===`full`?1:n===`reduced`?.6:0);let a=e=>Math.min(1.2,e/380+t.swelling/900),o=e=>Math.min(2,(e/600+t.swelling/900)*i);e.set(`leftEye`,{bruise:a(t.left_eye),swell:o(t.left_eye)}),e.set(`rightEye`,{bruise:a(t.right_eye),swell:o(t.right_eye)}),e.setEyesShut(sj(t.left_eye,t.swelling),sj(t.right_eye,t.swelling));let s=e=>Math.min(1,e/120),c=e=>Math.min(1.4,(e/120+t.bleeding/240)*r);e.set(`leftBrow`,{bruise:Math.min(1,t.left_eye/700),swell:Math.min(1.2,t.left_eye/900)*i,cut:s(t.left_cut),blood:c(t.left_cut)}),e.set(`rightBrow`,{bruise:Math.min(1,t.right_eye/700),swell:Math.min(1.2,t.right_eye/900)*i,cut:s(t.right_cut),blood:c(t.right_cut)});let l=Math.min(1,t.head/950+t.swelling/1100),u=Math.min(cj,t.swelling/520)*i,d=e=>Math.min(1,Math.max(0,e-lj)/350),f=e=>Math.min(1.2,Math.max(0,e-lj+30)/240)*r;e.set(`leftCheek`,{bruise:l*.9,swell:u,cut:d(t.left_cut),blood:f(t.left_cut)}),e.set(`rightCheek`,{bruise:l*.85,swell:u,cut:d(t.right_cut),blood:f(t.right_cut)}),e.set(`nose`,{bruise:Math.min(1,t.head/800),swell:Math.min(.8,t.head/1400)*i,blood:Math.min(1.4,(Math.max(0,t.head-60)/300+t.bleeding/220)*r)}),e.set(`mouth`,{bruise:Math.min(.8,t.head/1100),cut:Math.min(1,Math.max(0,t.head-250)/500),blood:Math.min(1.3,(Math.max(0,t.head-120)/360+t.bleeding/260)*r)}),e.set(`chin`,{bruise:Math.min(.7,t.head/1300)});let p=t.left_eye>=t.right_eye?-1:1;e.setNoseShift(p*Math.min(1.1,Math.max(0,t.head-520)/450)*i),e.set(`leftJaw`,{bruise:Math.min(.9,t.left_eye/900+t.head/1600)}),e.set(`rightJaw`,{bruise:Math.min(.9,t.right_eye/900+t.head/1600)}),e.set(`forehead`,{bruise:Math.min(.6,t.swelling/1200),cut:Math.min(1,Math.max(0,t.swelling-uj)/300),blood:Math.min(1.2,Math.max(0,t.swelling-uj)/220)*r})}function fj(e,t){return Math.min(1,(Math.max(0,e.bleeding-10)/220+Math.max(0,e.left_cut+e.right_cut-60)/650)*aj(t))}function pj(e,t,n){let r=aj(n),i=Math.min(1.1,t.body/620);e.set(`leftRibs`,{bruise:i,swell:Math.min(1,t.body/1300)}),e.set(`rightRibs`,{bruise:i*.9,swell:Math.min(1,t.body/1400)}),e.set(`solarPlexus`,{bruise:Math.min(1,t.body/800)}),e.set(`leftPec`,{bruise:Math.min(.8,t.body/1100)}),e.set(`rightPec`,{bruise:Math.min(.8,t.body/1150)});let a=Math.min(1.4,(t.bleeding/200+(t.left_cut+t.right_cut)/450)*r);e.set(`neckSmear`,{blood:a}),e.set(`leftShoulderSmear`,{blood:Math.min(1.2,t.left_cut/300)*r}),e.set(`rightShoulderSmear`,{blood:Math.min(1.2,t.right_cut/300)*r})}var mj={tint:16777215,hair:4862755,shaved:0,beard:0,jaw:0,nose:0,brow:0,skull:0},hj={referee:{tint:15916235,hair:9210502,shaved:0,beard:0,jaw:-.4,nose:.3,brow:-.2,skull:.2},blueCorner:{tint:11109480,hair:1380364,shaved:1,beard:.8,jaw:.7,nose:.5,brow:.6,skull:.4},redCorner:{tint:16772829,hair:8007452,shaved:0,beard:.6,jaw:.2,nose:-.5,brow:.1,skull:-.3},blueCutman:{tint:14202008,hair:2234128,shaved:0,beard:0,jaw:-.6,nose:.8,brow:-.5,skull:-.5},redCutman:{tint:9070160,hair:1380364,shaved:1,beard:.45,jaw:.5,nose:.2,brow:.8,skull:.6}},gj=[16777215,16047307,14268057,12555896,10717820,9071708,7296328],_j=[1380364,2234128,3810326,5913120,9071164,11045976,7222304,9210502];function vj(e){let t=2166136261;for(let n=0;n>>0}function yj(e){return()=>(e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296)}function bj(e){let t=yj(vj(e)||1),n=e=>e[Math.floor(t()*e.length)],r=()=>Math.round((t()*2-1)*100)/100;return{tint:n(gj),hair:n(_j),shaved:+(t()<.28),beard:t()<.45?0:Math.round((.35+t()*.65)*100)/100,jaw:r(),nose:r(),brow:r(),skull:r()}}var xj=`vec3(0.84, 0.39, 0.175)`,Sj=` +vInjuryPos = transformed;`),e.fragmentShader=e.fragmentShader.replace(`#include `,`#include \nvarying vec3 vInjuryPos;\n${ag}\n#ifdef ${Lg}\n${jg(r)}\n#endif`).replace(`#include `,`#include \n#ifdef ${Lg}\nif (vInjuryPos.y > injuryCutLine(vInjuryPos)) discard;\nif (injuryGone(vInjuryPos) > 0.0) discard;\n#endif`)},t.customProgramCacheKey=()=>`hands-injury-shadow${r?`-body`:``}`,e&&(t.defines={[Lg]:``}),t}setWound(e,t){this.uniforms.uInjuryWound.value[t_(this.wounds,e)]=L.clamp(t,0,1)||0,this.refresh()}wound(e){return this.uniforms.uInjuryWound.value[t_(this.wounds,e)]}setGone(e,t){this.uniforms.uInjuryGone.value[t_(this.cuts,e)]=L.clamp(t,0,2)||0,this.refresh()}gone(e){return this.uniforms.uInjuryGone.value[t_(this.cuts,e)]}setExplicit(e){this.uniforms.uInjuryExplicit.value=+!!e}get explicit(){return this.uniforms.uInjuryExplicit.value>0}setPallor(e){let t=L.clamp(e,0,1)||0;t!==this.uniforms.uInjuryPallor.value&&(this.uniforms.uInjuryPallor.value=t,this.refresh())}get pallor(){return this.uniforms.uInjuryPallor.value}raise(e,t,n=0,r=0){let i=this.slot(e),a=this.uniforms;a.uInjuryBruise.value[i]=Math.max(a.uInjuryBruise.value[i],Math.min(t,1.2)),a.uInjuryBlood.value[i]=Math.max(a.uInjuryBlood.value[i],Math.min(n,1.4));let o=a.uInjuryCut.value[i];o.y=Math.max(o.y,Math.min(r,1))}copyFrom(e){let t=e.uniforms,n=this.uniforms;n.uInjuryBruise.value.set(t.uInjuryBruise.value),n.uInjurySwell.value.set(t.uInjurySwell.value),n.uInjuryBlood.value.set(t.uInjuryBlood.value);for(let[e,r]of n.uInjuryCut.value.entries())r.y=t.uInjuryCut.value[e]?.y??0;for(let[e,r]of n.uInjuryLid.value.entries())r.w=t.uInjuryLid.value[e]?.w??0;n.uInjuryEyeOut.value.copy(t.uInjuryEyeOut.value),n.uInjuryNose.value.copy(t.uInjuryNose.value),n.uInjuryJaw.value=t.uInjuryJaw.value,n.uInjuryWetness.value=t.uInjuryWetness.value,n.uInjuryRaw.value=t.uInjuryRaw.value,n.uInjuryImpactPush.value.set(0,0,0),n.uInjuryWound.value.set(t.uInjuryWound.value),n.uInjuryGone.value.set(t.uInjuryGone.value),n.uInjuryExplicit.value=t.uInjuryExplicit.value,n.uInjuryPallor.value=t.uInjuryPallor.value;for(let[e,r]of n.uInjuryMark.value.entries())r.copy(t.uInjuryMark.value[e]);n.uInjurySpatter.value=t.uInjurySpatter.value,n.uInjuryRun.value=t.uInjuryRun.value,this.refresh()}setBindToPart(e){this.uniforms.uInjuryBindToPart.value.copy(e)}setRawCuts(e){this.uniforms.uInjuryRaw.value=L.clamp(e,0,1)||0}setJaw(e){this.uniforms.uInjuryJaw.value=L.clamp(e,0,1)}setEyesShut(e,t){let[n,r]=this.uniforms.uInjuryLid.value;n.y>-500&&(n.w=L.clamp(e,0,1)||0),r.y>-500&&(r.w=L.clamp(t,0,1)||0)}setEyeOut(e){let t=this.uniforms.uInjuryLid.value,n=(e===`left`||e===`both`)&&t[0].y>-500,r=(e===`right`||e===`both`)&&t[1].y>-500;this.uniforms.uInjuryEyeOut.value.set(+!!n,+!!r),this.index.has(`leftEye`)&&this.set(`leftEye`,{blood:n?1.3:0}),this.index.has(`rightEye`)&&this.set(`rightEye`,{blood:r?1.3:0})}get eyeOut(){let e=this.uniforms.uInjuryEyeOut.value;return e.x>0&&e.y>0?`both`:e.x>0?`left`:e.y>0?`right`:null}get eyesShut(){return[this.uniforms.uInjuryLid.value[0].w,this.uniforms.uInjuryLid.value[1].w]}clear(){this.uniforms.uInjuryBruise.value.fill(0),this.uniforms.uInjurySwell.value.fill(0),this.uniforms.uInjuryBlood.value.fill(0);for(let e of this.uniforms.uInjuryCut.value)e.y=0;this.uniforms.uInjuryJaw.value=0;for(let e of this.uniforms.uInjuryLid.value)e.w=0;this.uniforms.uInjuryEyeOut.value.set(0,0),this.uniforms.uInjuryNose.value.w=0,this.uniforms.uInjuryImpactPush.value.set(0,0,0),this.uniforms.uInjuryWound.value.fill(0),this.uniforms.uInjuryGone.value.fill(0),this.uniforms.uInjuryPallor.value=0;for(let e of this.uniforms.uInjuryMark.value)e.set(0,0,0,0);this.uniforms.uInjurySpatter.value=0,this.uniforms.uInjuryRun.value=1,this.refresh()}level(e){let t=this.slot(e);return{bruise:this.uniforms.uInjuryBruise.value[t],swell:this.uniforms.uInjurySwell.value[t],cut:this.uniforms.uInjuryCut.value[t].y,blood:this.uniforms.uInjuryBlood.value[t]}}};function t_(e,t){let n=e.indexOf(t);if(n<0)throw Error(`unknown injury ${t}`);return n}function n_(e,t,n){let r=e.defines??={};delete r[Ig],delete r[Lg],t&&(r[Ig]=``),n&&(r[Lg]=``),e.side=n?2:0,e.needsUpdate=!0}var r_=e=>e===`off`?0:e===`reduced`?.2:1.5,i_=330;function a_(e,t){return L.clamp((e-i_)/(p-i_)+Math.max(0,t-200)/1600,0,1)}var o_=1.8,s_=150,c_=240;function l_(e,t,n){let r=r_(n),i=n===`full`?1:.6;e.setRawCuts(n===`full`?1:n===`reduced`?.6:0);let a=e=>Math.min(1.2,e/380+t.swelling/900),o=e=>Math.min(2,(e/600+t.swelling/900)*i);e.set(`leftEye`,{bruise:a(t.left_eye),swell:o(t.left_eye)}),e.set(`rightEye`,{bruise:a(t.right_eye),swell:o(t.right_eye)}),e.setEyesShut(a_(t.left_eye,t.swelling),a_(t.right_eye,t.swelling));let s=e=>Math.min(1,e/120),c=e=>Math.min(1.4,(e/120+t.bleeding/240)*r);e.set(`leftBrow`,{bruise:Math.min(1,t.left_eye/700),swell:Math.min(1.2,t.left_eye/900)*i,cut:s(t.left_cut),blood:c(t.left_cut)}),e.set(`rightBrow`,{bruise:Math.min(1,t.right_eye/700),swell:Math.min(1.2,t.right_eye/900)*i,cut:s(t.right_cut),blood:c(t.right_cut)});let l=Math.min(1,t.head/950+t.swelling/1100),u=Math.min(o_,t.swelling/520)*i,d=e=>Math.min(1,Math.max(0,e-s_)/350),f=e=>Math.min(1.2,Math.max(0,e-s_+30)/240)*r;e.set(`leftCheek`,{bruise:l*.9,swell:u,cut:d(t.left_cut),blood:f(t.left_cut)}),e.set(`rightCheek`,{bruise:l*.85,swell:u,cut:d(t.right_cut),blood:f(t.right_cut)}),e.set(`nose`,{bruise:Math.min(1,t.head/800),swell:Math.min(.8,t.head/1400)*i,blood:Math.min(1.4,(Math.max(0,t.head-60)/300+t.bleeding/220)*r)}),e.set(`mouth`,{bruise:Math.min(.8,t.head/1100),cut:Math.min(1,Math.max(0,t.head-250)/500),blood:Math.min(1.3,(Math.max(0,t.head-120)/360+t.bleeding/260)*r)}),e.set(`chin`,{bruise:Math.min(.7,t.head/1300)});let p=t.left_eye>=t.right_eye?-1:1;e.setNoseShift(p*Math.min(1.1,Math.max(0,t.head-520)/450)*i),e.set(`leftJaw`,{bruise:Math.min(.9,t.left_eye/900+t.head/1600)}),e.set(`rightJaw`,{bruise:Math.min(.9,t.right_eye/900+t.head/1600)}),e.set(`forehead`,{bruise:Math.min(.6,t.swelling/1200),cut:Math.min(1,Math.max(0,t.swelling-c_)/300),blood:Math.min(1.2,Math.max(0,t.swelling-c_)/220)*r})}function u_(e,t){return Math.min(1,(Math.max(0,e.bleeding-10)/220+Math.max(0,e.left_cut+e.right_cut-60)/650)*r_(t))}function d_(e,t,n){let r=r_(n),i=Math.min(1.1,t.body/620);e.set(`leftRibs`,{bruise:i,swell:Math.min(1,t.body/1300)}),e.set(`rightRibs`,{bruise:i*.9,swell:Math.min(1,t.body/1400)}),e.set(`solarPlexus`,{bruise:Math.min(1,t.body/800)}),e.set(`leftPec`,{bruise:Math.min(.8,t.body/1100)}),e.set(`rightPec`,{bruise:Math.min(.8,t.body/1150)});let a=Math.min(1.4,(t.bleeding/200+(t.left_cut+t.right_cut)/450)*r);e.set(`neckSmear`,{blood:a}),e.set(`leftShoulderSmear`,{blood:Math.min(1.2,t.left_cut/300)*r}),e.set(`rightShoulderSmear`,{blood:Math.min(1.2,t.right_cut/300)*r})}var f_=3.05,p_=3.85,m_=4.05,h_=3.42,g_=h_*.72,__=[.5,.88,1.26];function v_(e){let t=f_/Math.max(1,e.ring_half_width),n=f_/Math.max(1,e.ring_half_height);return{x:e=>e*t,z:e=>-e*n}}var y_={blue:1920728,red:12131356,neutral:15067115},b_=128,x_=4,S_=.12,C_=.82,w_={edge:4851467,core:[`rgba(40,3,6,0.9)`,`rgba(58,5,9,0.65)`,`rgba(70,7,11,0)`]},T_=6,E_=.29,D_=14,O_=e=>()=>(e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296);function k_(e){let t=O_(e);return{lobes:Array.from({length:5+Math.floor(t()*4)},(e,n)=>{let r=t()*Math.PI*2,i=n===0?0:6+t()*12,a=n===0?16+t()*6:8+t()*9;return{x:64+Math.cos(r)*i,y:64+Math.sin(r)*i,rx:a,ry:a*(.55+t()*.45),turn:t()*Math.PI}}),fill:.55+t()*.2,rim:.95,satellites:6+Math.floor(t()*6)}}function A_(e){let t=document.createElement(`canvas`);t.width=b_,t.height=b_;let n=t.getContext(`2d`);if(n!==null){let t=k_(e),r=O_(e^1540483477);n.clearRect(0,0,b_,b_),n.fillStyle=`rgba(255,255,255,1)`,n.strokeStyle=`rgba(255,255,255,1)`,n.globalAlpha=t.rim,n.lineWidth=3.5;for(let e of t.lobes)n.beginPath(),n.ellipse(e.x,e.y,e.rx,e.ry,e.turn,0,Math.PI*2),n.stroke();let i=()=>{n.beginPath();for(let e of t.lobes){let t=Math.max(1,e.rx-1.5);n.moveTo(e.x+Math.cos(e.turn)*t,e.y+Math.sin(e.turn)*t),n.ellipse(e.x,e.y,t,Math.max(1,e.ry-1.5),e.turn,0,Math.PI*2)}n.fill()};n.globalCompositeOperation=`destination-out`,n.globalAlpha=1,i(),n.globalCompositeOperation=`source-over`,n.globalAlpha=t.fill,i();for(let e=0;e{let t=t=>Math.round((e>>t&255)*.8);return`rgb(${t(16)},${t(8)},${t(0)})`},M_=class{scene;size;mesh;canvas;context;texture;source;uploader=null;region=new xf;regionAt=new R;material;geometry;stamps=[];tinted=new Map;pixelsPerMetre;dirty=!1;sinceUpload=0;uploadInterval=S_;painted=0;streakSeed=0;constructor(e,t=1024){this.scene=e,this.size=t,this.canvas=document.createElement(`canvas`),this.canvas.width=t,this.canvas.height=t,this.context=this.canvas.getContext(`2d`),this.context?.clearRect(0,0,t,t);for(let e=0;e3.05||Math.abs(t)>3.05)return;let c=this.context;if(this.painted+=1,this.dirty=!0,this.mesh.visible=!0,c===null)return;let l=this.tintedStamp(o,s),u=this.pixel(e,t),d=Math.max(1,n*this.pixelsPerMetre),f=Math.max(1,r*this.pixelsPerMetre);this.grow(u.x,u.y,Math.hypot(d,f)/2),c.save(),c.globalAlpha=L.clamp(a,0,1),c.translate(u.x,u.y),c.rotate(Number.isFinite(i)?i:0),c.drawImage(l,-d/2,-f/2,d,f),c.restore()}tintedStamp(e,t){let n=this.tinted.get(e);return n===void 0&&(n=this.stamps.map(t=>{let n=document.createElement(`canvas`);n.width=b_,n.height=b_;let r=n.getContext(`2d`);return r!==null&&(r.drawImage(t,0,0),r.globalCompositeOperation=`source-in`,r.fillStyle=j_(e),r.fillRect(0,0,b_,b_)),n}),this.tinted.set(e,n)),n[Math.abs(Math.trunc(t))%x_]}pool(e,t,n,r,i,a=w_){this.stain(e,t,n*2.3,n*2,i*1.7,r*.8,a.edge,i);let o=this.context;if(o===null||Math.abs(e)>3.05||Math.abs(t)>3.05)return;let s=this.pixel(e,t),c=Math.max(1,n*1.15*this.pixelsPerMetre);this.grow(s.x,s.y,c);let l=o.createRadialGradient(s.x,s.y,0,s.x,s.y,c);l.addColorStop(0,a.core[0]),l.addColorStop(.65,a.core[1]),l.addColorStop(1,a.core[2]),o.save(),o.globalAlpha=L.clamp(r,0,1),o.fillStyle=l,o.beginPath(),o.ellipse(s.x,s.y,c,c*.86,i*.9,0,Math.PI*2),o.fill(),o.restore()}streakRandom(){return this.streakSeed=Math.imul(this.streakSeed^this.streakSeed>>>15,1|this.streakSeed),this.streakSeed^=this.streakSeed+Math.imul(this.streakSeed^this.streakSeed>>>7,61|this.streakSeed),((this.streakSeed^this.streakSeed>>>14)>>>0)/4294967296}smear(e,t,n,r,i,a,o){if(!Number.isFinite(e+t+n+r+i)||Math.abs(e)>3.05||Math.abs(t)>3.05)return;let s=this.context;if(this.painted+=1,this.dirty=!0,this.mesh.visible=!0,s===null)return;let c=(e+f_)*this.pixelsPerMetre,l=(t+f_)*this.pixelsPerMetre,u=(L.clamp(n,-f_,f_)+f_)*this.pixelsPerMetre,d=(L.clamp(r,-f_,f_)+f_)*this.pixelsPerMetre,f=Math.max(1,i*this.pixelsPerMetre);this.grow(c,l,f),this.grow(u,d,f);let p=Math.hypot(u-c,d-l),m=p>1e-6?(l-d)/p:1,h=p>1e-6?(u-c)/p:0;this.streakSeed=1374496523^Math.imul(this.painted,40503),s.save(),s.strokeStyle=j_(o),s.lineCap=`round`;for(let e=0;e3.05||Math.abs(t)>3.05)return;let o=this.context;if(this.painted+=1,this.dirty=!0,this.mesh.visible=!0,o===null)return;let s=(e+f_)*this.pixelsPerMetre,c=(t+f_)*this.pixelsPerMetre,l=Math.max(2,E_*this.pixelsPerMetre),u=l*.36;this.grow(s,c,l*.6);let d=(r?-1:1)*u*.06,f=l/D_;o.save(),o.globalAlpha=L.clamp(i,0,1),o.fillStyle=j_(a),o.translate(s,c),o.rotate(-n);for(let e=0;et.min.x&&t.max.y>t.min.y?this.uploader.copyTextureToTexture(this.source,this.texture,t,this.regionAt.copy(t.min)):this.texture.needsUpdate=!0,t.makeEmpty(),this.dirty=!1,this.sinceUpload=0}clear(){this.context?.clearRect(0,0,this.size,this.size),this.painted=0,this.dirty=!1,this.region.makeEmpty(),this.texture.needsUpdate=!0,this.mesh.visible=!1}dispose(){this.scene.remove(this.mesh),this.texture.dispose(),this.source.dispose(),this.material.dispose(),this.geometry.dispose()}};function N_(){let e=new Du(1,2);e.deleteAttribute(`normal`),e.deleteAttribute(`uv`);let t=Xh(e,1e-4);e.dispose();let n=t.getAttribute(`position`),r=new z;for(let e=0;e=120?5:t>=90?3:t>=60?2:+(t>=40):e===`hit`?t>=130?4:t>=100?3:t>=75?2:+(t>=50):0:0}function I_(e,t){return Math.min(800,Math.round(Math.max(0,e)*4.5+Math.max(0,t)*2.8))}var L_=1.1,R_=.6,z_=.35,B_=1.2;function V_(){let e=new Mu(1,8,6),t=e.getAttribute(`position`);for(let e=0;e1+(e-1)*28+t%28;for(let e=0;e<28;e+=1)a.push(0,o(1,e+1),o(1,e));for(let e=1;e<6;e+=1)for(let t=0;t<28;t+=1)a.push(o(e,t),o(e,t+1),o(e+1,t)),a.push(o(e,t+1),o(e+1,t+1),o(e+1,t));let s=new yc;return s.setAttribute(`position`,new sc(r,3)),s.setAttribute(`uv`,new sc(i,2)),s.setIndex(a),s.computeVertexNormals(),s}function J_(e,t){let n=e.getAttribute(`position`),r=e.getIndex();if(r===null)return[];let i=new Map,a=new Int32Array(n.count),o=new Uint8Array(n.count),s=new z;for(let e=0;eo[e]===1);for(let e=0;e<3;e+=1){let r=a[t[e]],o=a[t[(e+1)%3]],s=r=2&&l.push(Math.floor(e/n.count),e%n.count);return l}var Y_=.5,X_=new z,Z_=new z,Q_=new z,$_=new z,ev=new z;function tv(e,t,n){ev.copy(e).addScaledVector(t,-e.dot(t)).multiplyScalar(Y_/n).add(t).normalize()}function nv(e,t,n,r,i=.01,a){let o=Math.floor(t.length/6),s=e.getAttribute(`position`),c=e.getAttribute(`normal`),l=e.getAttribute(`uv`);(s===void 0||c===void 0||l===void 0||s.count!==o*3)&&(s=new ic(new Float32Array(o*9),3).setUsage(Aa),c=new ic(new Float32Array(o*9),3).setUsage(Aa),l=new ic(new Float32Array(o*6),2).setUsage(Aa),e.setAttribute(`position`,s),e.setAttribute(`normal`,c),e.setAttribute(`uv`,l)),X_.set(1,0,0),Math.abs(r.x)>.9&&X_.set(0,0,1),a!==void 0&&a.lengthSq()>1e-8&&Math.abs(a.dot(r))<.95*a.length()&&X_.copy(a),Z_.crossVectors(r,X_).normalize(),X_.crossVectors(Z_,r).normalize();let u=1e-6;for(let e=0;e=0)continue;let i=`${Math.round(s.x*1e5)},${Math.round(s.y*1e5)},${Math.round(s.z*1e5)}`,l=a.get(i)??n;a.set(i,l),o[n]=l}c.multiplyScalar(1/Math.max(1,r.count));for(let e=0;e{let t=e;for(;u.has(t);)t=u.get(t);return t},f=[];for(let[e,t]of l){if(t!==1)continue;f.push(e);let n=d(Math.floor(e/i)),r=d(e%i);n!==r&&u.set(n,r)}let p=new Map;for(let e of f){let t=d(e%i),n=p.get(t)??[];n.push(e),p.set(t,n)}let m=[],h=[],g=[],_=new yc,v=new yc,y=new z,b=new z,x=[];for(let e of p.values()){if(e.length<3)continue;let r=new Float32Array(e.length*6);y.set(0,0,0);let a=0;for(let[o,c]of e.entries()){let e=Math.floor(c/i),l=c%i;y.add(s.fromBufferAttribute(t,e)),s.toArray(r,o*6),y.add(s.fromBufferAttribute(t,l)),s.toArray(r,o*6+3),a+=n===void 0?r[o*6+1]+r[o*6+4]:n.getY(e)+n.getY(l)}y.multiplyScalar(1/(e.length*2));let o=0;for(let e=0;e(n=Math.imul(n^n>>>15,1|n),n^=n+Math.imul(n^n>>>7,61|n),((n^n>>>14)>>>0)/4294967296);for(let e=0;e<46;e+=1){let e=r()*Math.PI*2,n=14+r()*42;t.fillStyle=r()<.5?`rgba(150,28,30,0.55)`:`rgba(40,4,8,0.5)`,t.beginPath(),t.ellipse(64+Math.cos(e)*n,64+Math.sin(e)*n,3+r()*6,2+r()*3,e,0,Math.PI*2),t.fill()}let i=(e,n,r,i)=>{t.fillStyle=i,t.beginPath(),t.arc(e,n,r,0,Math.PI*2),t.fill()};i(64,38,10,`#8f7c64`),i(61,36,4.5,`#6a2a25`),i(66,78,7,`#7a3c34`),i(66,78,4.5,`#150203`),i(41,64,3,`#1d0204`),i(90,69,2.6,`#1d0204`);for(let e=0;e<70;e+=1){let e=r()*Math.PI*2,t=r()*60;i(64+Math.cos(e)*t,64+Math.sin(e)*t,.6+r()*1.6,r()<.4?`rgba(190,60,50,0.5)`:`rgba(20,2,4,0.55)`)}ov(t)}let n=new Wl(e);return n.colorSpace=wa,n}function ov(e){e.lineWidth=7,e.strokeStyle=`rgba(214,178,92,0.85)`,e.beginPath(),e.arc(64,64,55,0,Math.PI*2),e.stroke(),e.lineWidth=4,e.strokeStyle=`#b8775c`,e.beginPath(),e.arc(64,64,61,0,Math.PI*2),e.stroke()}function sv(){let e=document.createElement(`canvas`);e.width=128,e.height=128;let t=e.getContext(`2d`);if(t!==null){let e=t.createRadialGradient(64,64,6,64,64,64);e.addColorStop(0,`#741014`),e.addColorStop(.7,`#52090d`),e.addColorStop(1,`#300407`),t.fillStyle=e,t.fillRect(0,0,128,128);let n=(e,n,r,i)=>{t.fillStyle=i,t.beginPath(),t.arc(e,n,r,0,Math.PI*2),t.fill()};for(let[e,t,r]of[[46,60,13],[84,66,10]])n(e,t,r,`#e4d8c0`),n(e,t,r*.62,`#a4483c`),n(e-r*.2,t-r*.2,r*.25,`rgba(220,110,90,0.6)`);for(let e=0;e<9;e+=1){let t=Math.PI*(.15+e/8*.7);n(64+Math.cos(t)*34,64+Math.sin(t)*34,3.2,`#d9c9b3`)}n(30,84,3.4,`#1a0204`),n(98,46,3,`#1a0204`),n(66,30,2.6,`#1a0204`),ov(t)}let n=new Wl(e);return n.colorSpace=wa,n}function cv(){let e=document.createElement(`canvas`);e.width=128,e.height=128;let t=e.getContext(`2d`);if(t!==null){let e=t.createRadialGradient(64,64,6,64,64,64);e.addColorStop(0,`#7c1218`),e.addColorStop(.7,`#560a0f`),e.addColorStop(1,`#2e0407`),t.fillStyle=e,t.fillRect(0,0,128,128);let n=2135587861,r=()=>(n=Math.imul(n^n>>>15,1|n),n^=n+Math.imul(n^n>>>7,61|n),((n^n>>>14)>>>0)/4294967296);for(let e=0;e<11;e+=1){let n=e/11*Math.PI*2+r()*.3,i=26+r()*12;t.fillStyle=r()<.5?`#8e1c20`:`#6c1016`,t.strokeStyle=`rgba(30,3,6,0.8)`,t.lineWidth=1.6,t.beginPath(),t.ellipse(64+Math.cos(n)*i,64+Math.sin(n)*i,13+r()*5,8+r()*4,n+Math.PI/2,0,Math.PI*2),t.fill(),t.stroke()}let i=(e,n,r,i)=>{t.fillStyle=i,t.beginPath(),t.arc(e,n,r,0,Math.PI*2),t.fill()};i(58,60,15,`#e8dcc4`),i(58,60,9.5,`#a8463a`),i(55,57,3.5,`rgba(226,116,96,0.65)`),i(82,70,4.2,`#170204`),i(80,80,3,`#3a0a2a`),i(88,62,2.2,`#e0d2a0`);for(let e=0;e<70;e+=1){let e=r()*Math.PI*2,t=18+r()*40;i(64+Math.cos(e)*t,64+Math.sin(e)*t,.6+r()*1.5,r()<.4?`rgba(200,70,56,0.5)`:`rgba(20,2,4,0.55)`)}ov(t)}let n=new Wl(e);return n.colorSpace=wa,n}function lv(){let e=document.createElement(`canvas`);e.width=128,e.height=128;let t=e.getContext(`2d`);if(t!==null){t.fillStyle=`#3c060a`,t.fillRect(0,0,128,128);let e=461845907,n=()=>(e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296),r=(e,n,r,i,a,o,s)=>{t.fillStyle=o,t.beginPath(),t.ellipse(e,n,r,i,a,0,Math.PI*2),t.fill(),s!==void 0&&(t.strokeStyle=s,t.lineWidth=1.4,t.stroke())};t.strokeStyle=`#7c151a`,t.lineWidth=12,t.beginPath(),t.arc(64,64,46,0,Math.PI*2),t.stroke(),r(40,30,13,9,.5,`#8a1c20`,`rgba(30,3,6,0.8)`),r(88,30,13,9,-.5,`#8a1c20`,`rgba(30,3,6,0.8)`),r(40,58,15,10,.4,`#4a1410`);for(let e=0;e<15;e+=1){let e=n()*Math.PI*2,t=n()*25,i=68+Math.cos(e)*t,a=74+Math.sin(e)*t*.8,o=6+n()*4;r(i,a,o,o*(.7+n()*.3),n()*Math.PI,`#d49a98`,`rgba(110,30,36,0.9)`),r(i,a,o*.45,o*.35,n()*Math.PI,n()<.4?`#6a5a14`:`#3a070b`)}r(64,26,11,9,0,`#e6dac2`),r(64,26,7,5.5,0,`#b4594a`),r(64,13,4,3.4,0,`#efe6c8`,`#8a7c60`),r(57,40,4.4,4.4,0,`#160204`,`#a03038`),r(71,40,4,3.4,0,`#2a0a2c`);for(let e=0;e<80;e+=1){let e=n()*Math.PI*2,t=n()*54;r(64+Math.cos(e)*t,64+Math.sin(e)*t,.6+n()*1.6,.6+n()*1.6,0,n()<.3?`rgba(226,190,90,0.6)`:n()<.5?`rgba(190,50,44,0.5)`:`rgba(20,2,4,0.55)`)}ov(t)}let n=new Wl(e);return n.colorSpace=wa,n}function uv(){let e=.09,t=[];for(let e=0;e<9;e+=1){let n=e/9*Math.PI*2,r=.32*(.62+.38*Math.abs(Math.sin(e*2.3+.4)));t.push([Math.cos(n)*r,Math.sin(n)*r])}let n=(t,n,r)=>{let i=Math.hypot(t,n,1);return[t/i*r,n/i*r,1/i*r-e]},r=[],i=[],a=[.07,.035,.025],o=[.78,.7,.58],s=[.42,.05,.05],c=(e,t,n,a)=>{r.push(...e,...t,...n);for(let e=0;e<3;e+=1)i.push(...a)};for(let r=0;r<9;r+=1){let[i,l]=t[r],[u,d]=t[(r+1)%9];c(n(0,0,e),n(i,l,e),n(u,d,e),a),c(n(0,0,.08299999999999999),n(u,d,.08299999999999999),n(i,l,.08299999999999999),r%3==0?o:s),c(n(i,l,e),n(i,l,.08299999999999999),n(u,d,e),o),c(n(u,d,e),n(i,l,.08299999999999999),n(u,d,.08299999999999999),o)}let l=new yc;return l.setAttribute(`position`,new sc(r,3)),l.setAttribute(`color`,new sc(i,3)),l.computeVertexNormals(),l.computeBoundingSphere(),l}function dv(){let e=document.createElement(`canvas`);e.width=128,e.height=128;let t=e.getContext(`2d`);if(t!==null){let e=t.createRadialGradient(64,60,6,64,64,66);e.addColorStop(0,`#7a1016`),e.addColorStop(.75,`#530a0e`),e.addColorStop(1,`#300408`),t.fillStyle=e,t.fillRect(0,0,128,128),t.fillStyle=`#8a2a2e`,t.beginPath(),t.ellipse(64,50,22,17,0,0,Math.PI*2),t.fill(),t.fillStyle=`rgba(220,120,120,0.35)`,t.beginPath(),t.ellipse(60,45,9,5,-.3,0,Math.PI*2),t.fill(),t.strokeStyle=`#a99c86`,t.lineWidth=5,t.beginPath(),t.ellipse(64,62,50,50,0,Math.PI*.08,Math.PI*.92),t.stroke();for(let e=0;e<12;e+=1){let n=Math.PI*(.14+e/11*.72);t.save(),t.translate(64+Math.cos(n)*42,62+Math.sin(n)*42),t.rotate(n+Math.PI/2),t.fillStyle=e%5==2?`#3a0508`:`#ece4cf`,t.fillRect(-3.5,-4.5,7,9),t.restore()}let n=625341585,r=()=>(n=Math.imul(n^n>>>15,1|n),n^=n+Math.imul(n^n>>>7,61|n),((n^n>>>14)>>>0)/4294967296);for(let e=0;e<60;e+=1)t.fillStyle=r()<.5?`rgba(150,20,24,0.6)`:`rgba(20,2,4,0.5)`,t.beginPath(),t.arc(r()*128,r()*128,.8+r()*2.2,0,Math.PI*2),t.fill();ov(t)}let n=new Wl(e);return n.colorSpace=wa,n}function fv(){let e=document.createElement(`canvas`);e.width=128,e.height=64;let t=e.getContext(`2d`);if(t!==null){let e=t.createLinearGradient(0,0,128,0);e.addColorStop(0,`#e9ddd4`),e.addColorStop(.42,`#e9ddd4`),e.addColorStop(.62,`#8a2a2c`),e.addColorStop(.85,`#4a070b`),e.addColorStop(1,`#e9ddd4`),t.fillStyle=e,t.fillRect(0,0,128,64),t.strokeStyle=`rgba(170,20,26,0.75)`,t.lineWidth=.8;for(let e=0;e<14;e+=1){let n=e/14*Math.PI*2;t.beginPath(),t.moveTo(32+Math.cos(n)*30,32+Math.sin(n)*26),t.quadraticCurveTo(32+Math.cos(n+.3)*20,32+Math.sin(n+.3)*18,32+Math.cos(n)*11,32+Math.sin(n)*11),t.stroke()}let n=t.createRadialGradient(32,32,2,32,32,9);n.addColorStop(0,`#6b4524`),n.addColorStop(.8,`#4a2d14`),n.addColorStop(1,`#1e1208`),t.fillStyle=n,t.beginPath(),t.arc(32,32,9,0,Math.PI*2),t.fill(),t.fillStyle=`#050302`,t.beginPath(),t.arc(32,32,4,0,Math.PI*2),t.fill(),t.fillStyle=`rgba(255,255,255,0.85)`,t.beginPath(),t.arc(29.5,29.5,1.4,0,Math.PI*2),t.fill()}let n=new Wl(e);return n.colorSpace=wa,n}function pv(e){let t=new Map,n=new Map,r=e.clone();return mv(e,r,function(e,r){t.set(r,e),n.set(e,r)}),r.traverse(function(e){if(!e.isSkinnedMesh)return;let r=e,i=t.get(e),a=i.skeleton.bones;r.skeleton=i.skeleton.clone(),r.bindMatrix.copy(i.bindMatrix),r.skeleton.bones=a.map(function(e){return n.get(e)}),r.bind(r.skeleton,r.bindMatrix)}),r}function mv(e,t,n){n(e,t);for(let r=0;r=2.0 are supported.`));return}let c=new fy(i,{path:t||this.resourcePath||``,crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e=0&&o[t]===void 0&&console.warn(`THREE.GLTFLoader: Unknown extension "`+t+`".`)}}c.setExtensions(a),c.setPlugins(o),c.parse(n,r)}parseAsync(e,t){let n=this;return new Promise(function(r,i){n.parse(e,t,r,i)})}};function gv(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}function _v(e,t,n){let r=e.json.materials[t];return r.extensions&&r.extensions[n]?r.extensions[n]:null}var vv={KHR_BINARY_GLTF:`KHR_binary_glTF`,KHR_DRACO_MESH_COMPRESSION:`KHR_draco_mesh_compression`,KHR_LIGHTS_PUNCTUAL:`KHR_lights_punctual`,KHR_MATERIALS_CLEARCOAT:`KHR_materials_clearcoat`,KHR_MATERIALS_DISPERSION:`KHR_materials_dispersion`,KHR_MATERIALS_IOR:`KHR_materials_ior`,KHR_MATERIALS_SHEEN:`KHR_materials_sheen`,KHR_MATERIALS_SPECULAR:`KHR_materials_specular`,KHR_MATERIALS_TRANSMISSION:`KHR_materials_transmission`,KHR_MATERIALS_IRIDESCENCE:`KHR_materials_iridescence`,KHR_MATERIALS_ANISOTROPY:`KHR_materials_anisotropy`,KHR_MATERIALS_UNLIT:`KHR_materials_unlit`,KHR_MATERIALS_VOLUME:`KHR_materials_volume`,KHR_TEXTURE_BASISU:`KHR_texture_basisu`,KHR_TEXTURE_TRANSFORM:`KHR_texture_transform`,KHR_MESH_QUANTIZATION:`KHR_mesh_quantization`,KHR_MATERIALS_EMISSIVE_STRENGTH:`KHR_materials_emissive_strength`,EXT_MATERIALS_BUMP:`EXT_materials_bump`,EXT_TEXTURE_WEBP:`EXT_texture_webp`,EXT_TEXTURE_AVIF:`EXT_texture_avif`,EXT_MESHOPT_COMPRESSION:`EXT_meshopt_compression`,KHR_MESHOPT_COMPRESSION:`KHR_meshopt_compression`,EXT_MESH_GPU_INSTANCING:`EXT_mesh_gpu_instancing`},yv=class{constructor(e){this.parser=e,this.name=vv.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n=0)throw Error(`THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures`);return null}return t.loadTextureImage(e,i.source,a)}},Nv=class{constructor(e){this.parser=e,this.name=vv.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let a=i.extensions[t],o=r.images[a.source],s=n.textureLoader;if(o.uri){let e=n.options.manager.getHandler(o.uri);e!==null&&(s=e)}return n.loadTextureImage(e,a.source,s)}},Pv=class{constructor(e){this.parser=e,this.name=vv.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let a=i.extensions[t],o=r.images[a.source],s=n.textureLoader;if(o.uri){let e=n.options.manager.getHandler(o.uri);e!==null&&(s=e)}return n.loadTextureImage(e,a.source,s)}},Fv=class{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let e=n.extensions[this.name],r=this.parser.getDependency(`buffer`,e.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw Error(`THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files`);return null}return r.then(function(t){let n=e.byteOffset||0,r=e.byteLength||0,a=e.count,o=e.byteStride,s=new Uint8Array(t,n,r);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(a,o,s,e.mode,e.filter).then(function(e){return e.buffer}):i.ready.then(function(){let t=new ArrayBuffer(a*o);return i.decodeGltfBuffer(new Uint8Array(t),a,o,s,e.mode,e.filter),t})})}return null}},Iv=class{constructor(e){this.name=vv.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let r=t.meshes[n.mesh];for(let e of r.primitives)if(e.mode!==qv.TRIANGLES&&e.mode!==qv.TRIANGLE_STRIP&&e.mode!==qv.TRIANGLE_FAN&&e.mode!==void 0)return null;let i=n.extensions[this.name].attributes,a=[],o={};for(let e in i)a.push(this.parser.getDependency(`accessor`,i[e]).then(t=>(o[e]=t,o[e])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(e=>{let t=e.pop(),n=t.isGroup?t.children:[t],r=e[0].count,i=[];for(let e of n){let t=new Ho,n=new z,a=new vo,s=new z(1,1,1),c=new _l(e.geometry,e.material,r);for(let e=0;e0||e.search(/^data\:image\/jpeg/)===0?`image/jpeg`:e.search(/\.webp($|\?)/i)>0||e.search(/^data\:image\/webp/)===0?`image/webp`:e.search(/\.ktx2($|\?)/i)>0||e.search(/^data\:image\/ktx2/)===0?`image/ktx2`:`image/png`}var dy=new Ho,fy=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new gv,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,r=-1,i=!1,a=-1;if(typeof navigator<`u`&&navigator.userAgent!==void 0){let e=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(e)===!0;let t=e.match(/Version\/(\d+)/);r=n&&t?parseInt(t[1],10):-1,i=e.indexOf(`Firefox`)>-1,a=i?e.match(/Firefox\/([0-9]+)\./)[1]:-1}this.textureLoader=typeof createImageBitmap>`u`||n&&r<17||i&&a<98?new Ad(this.options.manager):new ef(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Dd(this.options.manager),this.fileLoader.setResponseType(`arraybuffer`),this.options.crossOrigin===`use-credentials`&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,r=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(e){return e._markDefs&&e._markDefs()}),Promise.all(this._invokeAll(function(e){return e.beforeRoot&&e.beforeRoot()})).then(function(){return Promise.all([n.getDependencies(`scene`),n.getDependencies(`animation`),n.getDependencies(`camera`)])}).then(function(t){let a={scene:t[0][r.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:r.asset,parser:n,userData:{}};return ry(i,a,r),iy(a,r),Promise.all(n._invokeAll(function(e){return e.afterRoot&&e.afterRoot(a)})).then(function(){for(let e of a.scenes)e.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,r=t.length;n{let n=this.associations.get(e);n!=null&&this.associations.set(t,n);for(let[n,r]of e.children.entries())i(r,t.children[n])};return i(n,r),r.name+=`_instance_`+e.uses[t]++,r}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n=2&&p.setY(t,u[e*a+1]),a>=3&&p.setZ(t,u[e*a+2]),a>=4&&p.setW(t,u[e*a+3]),a>=5)throw Error(`THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.`)}p.normalized=d}return p})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,i=t.images[r],a=this.textureLoader;if(i.uri){let e=n.manager.getHandler(i.uri);e!==null&&(a=e)}return this.loadTextureImage(e,r,a)}loadTextureImage(e,t,n){let r=this,i=this.json,a=i.textures[e],o=i.images[t],s=(o.uri||o.bufferView)+`:`+a.sampler;if(this.textureCache[s])return this.textureCache[s];let c=this.loadImageSource(t,n).then(function(t){t.flipY=!1,t.name=a.name||o.name||``,t.name===``&&typeof o.uri==`string`&&o.uri.startsWith(`data:image/`)===!1&&(t.name=o.uri);let n=(i.samplers||{})[a.sampler]||{};return t.magFilter=Yv[n.magFilter]||1006,t.minFilter=Yv[n.minFilter]||1008,t.wrapS=Xv[n.wrapS]||1e3,t.wrapT=Xv[n.wrapT]||1e3,t.generateMipmaps=!t.isCompressedTexture&&t.minFilter!==1003&&t.minFilter!==1006,r.associations.set(t,{textures:e}),t}).catch(function(){return null});return this.textureCache[s]=c,c}loadImageSource(e,t){let n=this,r=this.json,i=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(e=>e.clone());let a=r.images[e],o=self.URL||self.webkitURL,s=a.uri||``,c=!1;if(a.bufferView!==void 0)s=n.getDependency(`bufferView`,a.bufferView).then(function(e){c=!0;let t=new Blob([e],{type:a.mimeType});return s=o.createObjectURL(t),s});else if(a.uri===void 0)throw Error(`THREE.GLTFLoader: Image `+e+` is missing URI and bufferView`);let l=Promise.resolve(s).then(function(e){return new Promise(function(n,r){let a=n;t.isImageBitmapLoader===!0&&(a=function(e){let t=new Io(e);t.needsUpdate=!0,n(t)}),t.load(Qd.resolveURL(e,i.path),a,void 0,r)})}).then(function(e){return c===!0&&o.revokeObjectURL(s),iy(e,a),e.userData.mimeType=a.mimeType||uy(a.uri),e}).catch(function(e){throw console.error(`THREE.GLTFLoader: Couldn't load texture`,s),e});return this.sourceCache[e]=l,l}assignTexture(e,t,n,r){let i=this;return this.getDependency(`texture`,n.index).then(function(a){if(!a)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(a=a.clone(),a.channel=n.texCoord),i.extensions[vv.KHR_TEXTURE_TRANSFORM]){let e=n.extensions===void 0?void 0:n.extensions[vv.KHR_TEXTURE_TRANSFORM];if(e){let t=i.associations.get(a);a=i.extensions[vv.KHR_TEXTURE_TRANSFORM].extendTexture(a,e),i.associations.set(a,t)}}return r!==void 0&&(a.colorSpace=r),e[t]=a,a})}assignFinalMaterial(e){let t=e.geometry,n=e.material,r=t.attributes.tangent===void 0,i=t.attributes.color!==void 0,a=t.attributes.normal===void 0;if(e.isPoints){let e=`PointsMaterial:`+n.uuid,t=this.cache.get(e);t||(t=new Il,Oc.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){let e=`LineBasicMaterial:`+n.uuid,t=this.cache.get(e);t||(t=new Sl,Oc.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(r||i||a){let e=`ClonedMaterial:`+n.uuid+`:`;r&&(e+=`derivative-tangents:`),i&&(e+=`vertex-colors:`),a&&(e+=`flat-shading:`);let t=this.cache.get(e);t||(t=n.clone(),i&&(t.vertexColors=!0),a&&(t.flatShading=!0),r&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return Ku}loadMaterial(e){let t=this,n=this.json,r=this.extensions,i=n.materials[e],a,o={},s=i.extensions||{},c=[];if(s[vv.KHR_MATERIALS_UNLIT]){let e=r[vv.KHR_MATERIALS_UNLIT];a=e.getMaterialType(),c.push(e.extendParams(o,i,t))}else{let n=i.pbrMetallicRoughness||{};if(o.color=new B(1,1,1),o.opacity=1,Array.isArray(n.baseColorFactor)){let e=n.baseColorFactor;o.color.setRGB(e[0],e[1],e[2],Ta),o.opacity=e[3]}n.baseColorTexture!==void 0&&c.push(t.assignTexture(o,`map`,n.baseColorTexture,wa)),o.metalness=n.metallicFactor===void 0?1:n.metallicFactor,o.roughness=n.roughnessFactor===void 0?1:n.roughnessFactor,n.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(o,`metalnessMap`,n.metallicRoughnessTexture)),c.push(t.assignTexture(o,`roughnessMap`,n.metallicRoughnessTexture))),a=this._invokeOne(function(t){return t.getMaterialType&&t.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,o)})))}i.doubleSided===!0&&(o.side=2);let l=i.alphaMode||ty.OPAQUE;if(l===ty.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,l===ty.MASK&&(o.alphaTest=i.alphaCutoff===void 0?.5:i.alphaCutoff)),i.normalTexture!==void 0&&a!==Pc&&(c.push(t.assignTexture(o,`normalMap`,i.normalTexture)),o.normalScale=new R(1,1),i.normalTexture.scale!==void 0)){let e=i.normalTexture.scale;o.normalScale.set(e,e)}if(i.occlusionTexture!==void 0&&a!==Pc&&(c.push(t.assignTexture(o,`aoMap`,i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&a!==Pc){let e=i.emissiveFactor;o.emissive=new B().setRGB(e[0],e[1],e[2],Ta)}return i.emissiveTexture!==void 0&&a!==Pc&&c.push(t.assignTexture(o,`emissiveMap`,i.emissiveTexture,wa)),Promise.all(c).then(function(){let n=new a(o);return i.name&&(n.name=i.name),iy(n,i),t.associations.set(n,{materials:e}),i.extensions&&ry(r,n,i),n})}createUniqueName(e){let t=yf.sanitizeNodeName(e||``);return t in this.nodeNamesUsed?t+`_`+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,n=this.extensions,r=this.primitiveCache;function i(e){return n[vv.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then(function(n){return my(n,e,t)})}let a=[];for(let n=0,o=e.length;nZh(e,1)):o.mode===qv.TRIANGLE_FAN&&(e=e.then(e=>Zh(e,2))),r[s]={primitive:o,promise:e},a.push(e)}}return Promise.all(a)}loadMesh(e){let t=this,n=this.json,r=this.extensions,i=n.meshes[e],a=i.primitives,o=[];for(let e=0,t=a.length;e0&&oy(d,i),d.name=t.createUniqueName(i.name||`mesh_`+e),iy(d,i),u.extensions&&ry(r,d,u),t.assignFinalMaterial(d),c.push(d)}for(let n=0,r=c.length;n0){let e=t.userData.pivot,r=n[0];t.pivot=new z().fromArray(e),t.position.x-=e[0],t.position.y-=e[1],t.position.z-=e[2],r.position.set(0,0,0),delete t.userData.pivot}return t})}_loadNodeShallow(e){let t=this.json,n=this.extensions,r=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let i=t.nodes[e],a=i.name?r.createUniqueName(i.name):``,o=[],s=r._invokeOne(function(t){return t.createNodeMesh&&t.createNodeMesh(e)});return s&&o.push(s),i.camera!==void 0&&o.push(r.getDependency(`camera`,i.camera).then(function(e){return r._getNodeRef(r.cameraCache,i.camera,e)})),r._invokeAll(function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)}).forEach(function(e){o.push(e)}),this.nodeCache[e]=Promise.all(o).then(function(t){let o;if(o=i.isBone===!0?new il:t.length>1?new gs:t.length===1?t[0]:new hs,o!==t[0])for(let e=0,n=t.length;e1){let e=r.associations.get(o);r.associations.set(o,{...e})}return r.associations.get(o).nodes=e,o}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],r=this,i=new gs;n.name&&(i.name=r.createUniqueName(n.name)),iy(i,n),n.extensions&&ry(t,i,n);let a=n.nodes||[],o=[];for(let e=0,t=a.length;e{let t=new Map;for(let[e,n]of r.associations)(e instanceof Oc||e instanceof Io)&&t.set(e,n);return e.traverse(e=>{let n=r.associations.get(e);n!=null&&t.set(e,n)}),t})(i),i})}_createAnimationTracks(e,t,n,r,i){let a=[],o=e.name?e.name:e.uuid,s=[];function c(e){e.morphTargetInfluences&&s.push(e.name?e.name:e.uuid)}$v[i.path]===$v.weights?(c(e),e.isGroup&&e.children.forEach(c)):s.push(o);let l;switch($v[i.path]){case $v.weights:l=pd;break;case $v.rotation:l=hd;break;case $v.translation:case $v.scale:l=_d;break;default:switch(n.itemSize){case 1:l=pd;break;default:l=_d}}let u=r.interpolation===void 0?ga:ey[r.interpolation],d=this._getArrayFromAccessor(n);for(let e=0,n=s.length;e{e.uniforms.uGearBlood=r,e.vertexShader=e.vertexShader.replace(`#include `,`#include \n${t?`attribute vec3 bindPosition;`:``}\n${vy}`).replace(`#include `,`#include \nvGearPos = ${t?`bindPosition`:`position`};`),e.fragmentShader=e.fragmentShader.replace(`#include `,`#include \n${vy}\nfloat gearSoaked = 0.0;\nfloat gearTrim = 0.0;`).replace(`#include `,`#include \n${yy}`).replace(`#include `,`#include \n${by}`)},e.customProgramCacheKey=()=>`hands-gear-${t?`baked`:`live`}`,e.needsUpdate=!0,r}var Sy={tint:16777215,hair:4862755,shaved:0,beard:0,jaw:0,nose:0,brow:0,skull:0},Cy={referee:{tint:15916235,hair:9210502,shaved:0,beard:0,jaw:-.4,nose:.3,brow:-.2,skull:.2},blueCorner:{tint:11109480,hair:1380364,shaved:1,beard:.8,jaw:.7,nose:.5,brow:.6,skull:.4},redCorner:{tint:16772829,hair:8007452,shaved:0,beard:.6,jaw:.2,nose:-.5,brow:.1,skull:-.3},blueCutman:{tint:14202008,hair:2234128,shaved:0,beard:0,jaw:-.6,nose:.8,brow:-.5,skull:-.5},redCutman:{tint:9070160,hair:1380364,shaved:1,beard:.45,jaw:.5,nose:.2,brow:.8,skull:.6}},wy=[16777215,16047307,14268057,12555896,10717820,9071708,7296328],Ty=[1380364,2234128,3810326,5913120,9071164,11045976,7222304,9210502];function Ey(e){let t=2166136261;for(let n=0;n>>0}function Dy(e){return()=>(e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296)}function Oy(e){let t=Dy(Ey(e)||1),n=e=>e[Math.floor(t()*e.length)],r=()=>Math.round((t()*2-1)*100)/100;return{tint:n(wy),hair:n(Ty),shaved:+(t()<.28),beard:t()<.45?0:Math.round((.35+t()*.65)*100)/100,jaw:r(),nose:r(),brow:r(),skull:r()}}var ky=`vec3(0.84, 0.39, 0.175)`,Ay=` uniform vec3 uLookHair; uniform vec4 uLookFace; uniform vec2 uLookGroom; @@ -5097,7 +4927,7 @@ float lookHairZone(vec3 p) { float reach = mix(3.8, 9.0, nape); return smoothstep(line - 0.5, line + 0.5, p.y) * (1.0 - smoothstep(reach, reach + 1.0, abs(p.x)) * (1.0 - nape)); } -`,Cj=` +`,jy=` { vec3 p = position; vLookPos = p; @@ -5118,26 +4948,65 @@ float lookHairZone(vec3 p) { transformed.y -= crownAway.y * crownDepth; transformed.z -= crownAway.z * crownDepth; } -`,wj=(e,t,n)=>{let r=Math.min(1,Math.max(0,(n-e)/(t-e)));return r*r*(3-2*r)},Tj=(e,t,n)=>e+(t-e)*n;function Ej(e,t,n){let r=Tj(Tj(115.3,120.6,wj(-6.8,-4.6,n)),125.5,wj(-4.6,1.6,n)),i=wj(116,121,t),a=Tj(3.8,9,i);return wj(r-.5,r+.5,t)*(1-wj(a,a+1,Math.abs(e))*(1-i))}function Dj(e,t,n){let{x:r,y:i,z:a}=e,o=(1-wj(113.5,118,i))*wj(108.5,112,i)*wj(-7,-2,a),s=1-wj(0,2.6,Math.hypot(r,i-117.2,a-5)),c=(1-wj(0,2.2,Math.abs(i-123.2)))*wj(1.5,3.5,a),l=r*.12*t.jaw*o+r*.4*t.nose*s+r*.06*t.skull*wj(112,116,i),u=0,d=.5*t.nose*s+.55*t.brow*c,f=Tj(.9,1.9,wj(-1,3,a)*wj(123.5,126,i))*Ej(r,i,a)*t.shaved,p=r,m=(i-120)*1.1,h=a+2.5,g=Math.hypot(p,m,h)||1;return l-=p/g*f,u-=m/g*f,d-=h/g*f,n.set(r+l,i+u,a+d)}var Oj=` +`,My=(e,t,n)=>{let r=Math.min(1,Math.max(0,(n-e)/(t-e)));return r*r*(3-2*r)},Ny=(e,t,n)=>e+(t-e)*n;function Py(e,t,n){let r=Ny(Ny(115.3,120.6,My(-6.8,-4.6,n)),125.5,My(-4.6,1.6,n)),i=My(116,121,t),a=Ny(3.8,9,i);return My(r-.5,r+.5,t)*(1-My(a,a+1,Math.abs(e))*(1-i))}function Fy(e,t,n){let{x:r,y:i,z:a}=e,o=(1-My(113.5,118,i))*My(108.5,112,i)*My(-7,-2,a),s=1-My(0,2.6,Math.hypot(r,i-117.2,a-5)),c=(1-My(0,2.2,Math.abs(i-123.2)))*My(1.5,3.5,a),l=r*.12*t.jaw*o+r*.4*t.nose*s+r*.06*t.skull*My(112,116,i),u=0,d=.5*t.nose*s+.55*t.brow*c,f=Ny(.9,1.9,My(-1,3,a)*My(123.5,126,i))*Py(r,i,a)*t.shaved,p=r,m=(i-120)*1.1,h=a+2.5,g=Math.hypot(p,m,h)||1;return l-=p/g*f,u-=m/g*f,d-=h/g*f,n.set(r+l,i+u,a+d)}var Iy=` vLookPos = bindPosition; -`,kj=` +`,Ly=` #ifdef USE_MAP { vec3 p = vLookPos; float scanned = dot(sampledDiffuseColor.rgb, vec3(0.2126, 0.7152, 0.0722)); float hair = lookHairZone(p) * max(1.0 - smoothstep(0.13, 0.26, scanned), smoothstep(126.2, 127.4, p.y)); vec3 dyed = uLookHair * clamp(scanned / 0.075, 0.45, 1.7); - vec3 scalp = mix(${xj}, uLookHair, 0.1) * clamp(scanned / 0.075, 0.85, 1.12) * 0.9; + vec3 scalp = mix(${ky}, uLookHair, 0.1) * clamp(scanned / 0.075, 0.85, 1.12) * 0.9; diffuseColor.rgb = mix(diffuseColor.rgb, mix(dyed, scalp * diffuse, uLookGroom.x), hair); // The beard covers the chin and runs back along the jaw to the ear, clear of the neck beneath it. float front = mix(1.4, -4.8, smoothstep(111.2, 114.6, p.y)); float jaw = (1.0 - smoothstep(115.4, 116.8, p.y)) * smoothstep(109.6, 110.6, p.y) * smoothstep(front - 0.6, front + 0.6, p.z); float lips = 1.0 - smoothstep(0.8, 2.0, length(vec3(p.x * 0.55, p.y - 114.3, (p.z - 4.8) * 0.4))); float grain = 0.8 + 0.2 * sin(p.x * 41.0 + p.z * 13.0) * sin(p.y * 47.0 + p.z * 29.0); - diffuseColor.rgb = mix(diffuseColor.rgb, mix(uLookHair * 0.8, ${xj} * diffuse, 0.12), jaw * (1.0 - lips) * uLookGroom.y * grain * 0.88); + diffuseColor.rgb = mix(diffuseColor.rgb, mix(uLookHair * 0.8, ${ky} * diffuse, 0.12), jaw * (1.0 - lips) * uLookGroom.y * grain * 0.88); +} +#endif +`,Ry=` +uniform vec3 uLookExpression; +varying float vLookJaw; +`,zy=` +{ + vec3 p = position; + // Everything of the face under the seam of the lips drops with the jaw and swings back; the lips part between. + float jawDrop = (1.0 - smoothstep(115.1, 115.44, p.y)) * smoothstep(107.5, 110.0, p.y) * smoothstep(-5.5, 0.5, p.z); + vLookJaw = jawDrop; + transformed.y -= 1.3 * uLookExpression.y * jawDrop; + transformed.z -= 0.45 * uLookExpression.y * jawDrop; + float frown = (1.0 - smoothstep(0.0, 1.7, abs(p.y - 122.4))) * smoothstep(1.5, 3.5, p.z) * (1.0 - smoothstep(3.2, 5.6, abs(p.x))); + transformed.y -= 0.4 * uLookExpression.z * frown; + transformed.x -= sign(p.x) * 0.18 * uLookExpression.z * frown; +} +`,By=` +#ifdef USE_MAP +{ + vec3 p = vLookPos; + // The skin stretched between the parted lips, neither with the jaw nor with the skull, is the dark inside of + // the mouth, closing to its corners, with the teeth showing under the upper lip. + float parted = smoothstep(0.03, 0.3, uLookExpression.y) * (1.0 - smoothstep(1.6, 2.2, abs(p.x))) * smoothstep(2.6, 3.8, p.z) * smoothstep(114.2, 114.6, p.y); + float corner = 0.42 * smoothstep(0.7, 2.1, abs(p.x)); + float between = smoothstep(0.04 + corner, 0.12 + corner, vLookJaw) * (1.0 - smoothstep(0.88 - corner, 0.96 - corner, vLookJaw)); + float teeth = (1.0 - smoothstep(0.14, 0.22, vLookJaw)) * (1.0 - smoothstep(0.8, 1.3, abs(p.x))); + diffuseColor.rgb = mix(diffuseColor.rgb, mix(vec3(0.035, 0.006, 0.008), vec3(0.5, 0.44, 0.36), teeth), parted * between); + // The upper lid comes down over the eye along its own curve, a dark lash line at its edge. + vec3 lidSkin = ${ky} * diffuse * 0.72; + for (int e = 0; e < 2; e++) { + vec3 q = p - (e == 0 ? vec3(2.65, 120.65, 3.6) : vec3(-2.75, 120.75, 3.4)); + float across = q.x / 1.35; + float opening = (1.0 - smoothstep(0.8, 1.0, length(vec2(across, (q.y + 0.2) / 0.46)))) * smoothstep(-1.6, -0.8, q.z); + float edge = mix(0.3, -0.52, uLookExpression.x) - 0.2 * across * across; + float lid = opening * smoothstep(edge - 0.05, edge + 0.05, q.y); + float lash = opening * (1.0 - smoothstep(0.0, 0.09, abs(q.y - edge))) * smoothstep(0.0, 0.2, uLookExpression.x); + diffuseColor.rgb = mix(mix(diffuseColor.rgb, lidSkin, lid), vec3(0.03, 0.02, 0.018), lash * 0.7); + } } #endif -`,Aj=class{material;uniforms={uLookHair:{value:new J(mj.hair)},uLookFace:{value:new Sg},uLookGroom:{value:new K}};current=mj;constructor(e,t=!1){this.material=e;let n=this.uniforms,r=e.onBeforeCompile,i=Object.hasOwn(e,`customProgramCacheKey`)?e.customProgramCacheKey():`plain`;e.onBeforeCompile=(i,a)=>{r.call(e,i,a),Object.assign(i.uniforms,n),i.vertexShader=i.vertexShader.replace(`#include `,`#include \n${t?`attribute vec3 bindPosition;`:``}\n${Sj}`).replace(`#include `,`${t?Oj:Cj}\n#include `),i.fragmentShader=i.fragmentShader.replace(`#include `,`#include \n${Sj}`).replace(`#include `,`#include \n${kj}`)},e.customProgramCacheKey=()=>`${i}-look-${t?`baked`:`live`}`,e.needsUpdate=!0}set(e){this.current=e,this.material.color.setHex(e.tint),this.uniforms.uLookHair.value.setHex(e.hair),this.uniforms.uLookFace.value.set(e.jaw,e.nose,e.brow,e.skull),this.uniforms.uLookGroom.value.set(e.shaved,e.beard)}get look(){return this.current}},jj=new q;function Mj(e,t,n,r,i,a){let o=2*Math.PI*i/4,s=Math.max(a-2*i,0),c=Math.PI/4;jj.copy(t),jj[r]=0,jj.normalize();let l=.5*o/(o+s),u=1-jj.angleTo(e)/c;return Math.sign(jj[n])===1?u*l:s/(o+s)+l+l*(1-u)}var Nj=class e extends Ny{constructor(e=1,t=1,n=1,r=2,i=.1){let a=r*2+1;if(i=Math.min(e/2,t/2,n/2,i),super(1,1,1,a,a,a),this.type=`RoundedBoxGeometry`,this.parameters={width:e,height:t,depth:n,segments:r,radius:i},a===1)return;let o=this.toNonIndexed();this.index=null,this.attributes.position=o.attributes.position,this.attributes.normal=o.attributes.normal,this.attributes.uv=o.attributes.uv;let s=new q,c=new q,l=new q(e,t,n).divideScalar(2).subScalar(i),u=this.attributes.position.array,d=this.attributes.normal.array,f=this.attributes.uv.array,p=u.length/6,m=new q,h=.5/a;for(let r=0,a=0;r{r.call(e,i,a),Object.assign(i.uniforms,n),i.vertexShader=i.vertexShader.replace(`#include `,`#include \n${t?`attribute vec3 bindPosition;`:Ry}\n${Ay}`).replace(`#include `,`${t?Iy:jy+zy}\n#include `),i.fragmentShader=i.fragmentShader.replace(`#include `,`#include \n${t?``:Ry}${Ay}`).replace(`#include `,`#include \n${Ly}${t?``:By}`)},e.customProgramCacheKey=()=>`${i}-look-${t?`baked`:`live`}`,e.needsUpdate=!0}set(e){this.current=e,this.material.color.setHex(e.tint),this.uniforms.uLookHair.value.setHex(e.hair),this.uniforms.uLookFace.value.set(e.jaw,e.nose,e.brow,e.skull),this.uniforms.uLookGroom.value.set(e.shaved,e.beard)}setExpression(e,t,n){this.uniforms.uLookExpression.value.set(e,t,n)}get look(){return this.current}},Hy=new z;function Uy(e,t,n,r,i,a){let o=2*Math.PI*i/4,s=Math.max(a-2*i,0),c=Math.PI/4;Hy.copy(t),Hy[r]=0,Hy.normalize();let l=.5*o/(o+s),u=1-Hy.angleTo(e)/c;return Math.sign(Hy[n])===1?u*l:s/(o+s)+l+l*(1-u)}var Wy=class e extends Jl{constructor(e=1,t=1,n=1,r=2,i=.1){let a=r*2+1;if(i=Math.min(e/2,t/2,n/2,i),super(1,1,1,a,a,a),this.type=`RoundedBoxGeometry`,this.parameters={width:e,height:t,depth:n,segments:r,radius:i},a===1)return;let o=this.toNonIndexed();this.index=null,this.attributes.position=o.attributes.position,this.attributes.normal=o.attributes.normal,this.attributes.uv=o.attributes.uv;let s=new z,c=new z,l=new z(e,t,n).divideScalar(2).subScalar(i),u=this.attributes.position.array,d=this.attributes.normal.array,f=this.attributes.uv.array,p=u.length/6,m=new z,h=.5/a;for(let r=0,a=0;r` -${Vj} +`,$y={head:`1.0 - smoothstep(outfitCollar(p) - 0.3, outfitCollar(p) + 0.3, p.y)`,body:`p.y < 60.0 ? 1.0 : 1.0 - smoothstep(uOutfitShape.x - 0.4, uOutfitShape.x + 0.4, abs(p.x))`,shoes:`smoothstep(9.0, 11.0, p.y)`,pants:`1.0`},eb=e=>` +${Qy} varying vec3 vOutfitPos; vec3 outfitBindNormal = vec3(0.0, 1.0, 0.0); -float outfitClothAt(vec3 p) { return ${Hj[e]}; } +float outfitClothAt(vec3 p) { return ${$y[e]}; } vec3 outfitRounded(vec3 p, vec3 n) { if (p.y < 60.0) { vec2 radial = normalize(p.xz - outfitLegAxis(p.y, sign(p.x)) + vec2(1e-4)); @@ -5201,20 +5070,20 @@ vec3 outfitDraped(vec3 p, vec3 at, float cloth) { at.yz += around / span * (max(span, sleeve) - span) * arm; return at; } -`,Wj=` +`,tb=` { vec3 p = position; float cloth = outfitClothAt(p); objectNormal = normalize(mix(objectNormal, outfitRounded(p, objectNormal), 0.97 * cloth)); outfitBindNormal = objectNormal; } -`,Gj=` +`,nb=` float side = sign(p.x); vec2 axis = outfitLegAxis(p.y, side); vec2 offset = transformed.xz - axis; float reach = max(length(offset), 1e-3); float tube = mix(5.2, 6.0, smoothstep(12.0, 40.0, p.y)); -`,Kj={head:` +`,rb={head:` { vec3 p = position; vOutfitPos = p; @@ -5226,7 +5095,7 @@ vec3 outfitDraped(vec3 p, vec3 at, float cloth) { vec3 p = position; vOutfitPos = p; if (p.y < 60.0) { - ${Gj} + ${nb} float weight = 1.0 - smoothstep(40.5, 45.0, p.y); transformed.xz = axis + offset / reach * mix(reach, max(reach, tube), weight); } else { @@ -5238,7 +5107,7 @@ vec3 outfitDraped(vec3 p, vec3 at, float cloth) { { vec3 p = position; vOutfitPos = p; - ${Gj} + ${nb} float weight = smoothstep(9.0, 11.5, p.y); transformed.xz = axis + offset / reach * mix(reach, max(reach, tube), weight); } @@ -5251,8 +5120,8 @@ vec3 outfitDraped(vec3 p, vec3 at, float cloth) { vec2 narrow = vec2(mix(0.76, 1.0, slim), mix(0.62, 1.0, slim)); transformed.xz = mix(transformed.xz, axis + (transformed.xz - axis) * narrow, smoothstep(0.5, 4.0, abs(p.x))); } -`},qj=` -${Vj} +`},ib=` +${Qy} uniform vec3 uOutfitShirt; uniform vec3 uOutfitTrousers; uniform vec3 uOutfitAccent; @@ -5276,7 +5145,7 @@ vec3 outfitShirtTone(vec3 p) { float band = (1.0 - smoothstep(7.0, 7.2, reach)) * step(104.0, p.y); vec3 tone = uOutfitShirt * mix(mix(0.9, 1.0, fold), 1.07, band); tone *= 1.0 - 0.4 * (1.0 - smoothstep(0.0, 0.3, abs(reach - 7.25))) * step(104.0, p.y); - float hem = min(uOutfitShape.x, ${Rj.toFixed(1)}) - 2.4; + float hem = min(uOutfitShape.x, ${Yy.toFixed(1)}) - 2.4; tone *= mix(1.0, 0.86, smoothstep(hem - 0.1, hem + 0.1, along)); if (along < 1.0 && p.z > 0.5 && p.y < 106.0) { tone *= 0.92; @@ -5287,7 +5156,7 @@ vec3 outfitShirtTone(vec3 p) { outfitGloss = tie * 0.4; return mix(tone, uOutfitAccent, tie); } -`,Jj={head:` +`,ab={head:` { vec3 p = vOutfitPos; float collar = outfitCollar(p); @@ -5323,19 +5192,31 @@ vec3 outfitShirtTone(vec3 p) { outfitCloth = 1.0 - belt; outfitGloss = belt; } -`},Yj=` +`},ob=` roughnessFactor = mix(mix(roughnessFactor, 0.88, outfitCloth), 0.32, outfitGloss); -`,Xj=` +`,sb=` #ifdef USE_CLEARCOAT material.clearcoat *= 1.0 - outfitCloth; #endif -`;function Zj(e,t,n){let r={uOutfitShirt:{value:new J(n.shirt)},uOutfitTrousers:{value:new J(n.trousers)},uOutfitAccent:{value:new J(n.accent)},uOutfitShape:{value:new Sg(n.sleeves===`long`?63.4:zj,+!!n.bowTie,Bj,0)}},i=e.onBeforeCompile,a=Object.hasOwn(e,`customProgramCacheKey`)?e.customProgramCacheKey():`plain`;e.onBeforeCompile=(n,a)=>{i.call(e,n,a),Object.assign(n.uniforms,r),n.vertexShader=n.vertexShader.replace(`#include `,`#include \n${Uj(t)}`).replace(`#include `,`#include \n${Wj}`).replace(`#include `,`#include \n${Kj[t]}`),n.fragmentShader=n.fragmentShader.replace(`#include `,`#include \n${qj}`).replace(`#include `,`#include \n${Jj[t]}`).replace(`#include `,`#include \n${Yj}`).replace(`#include `,`#include \n${Xj}`)},e.customProgramCacheKey=()=>`${a}-outfit-${t}`,e.needsUpdate=!0}var Qj=new q(0,1,0);function $j(e,t,n,r){let i=new Py(r,n,1,6);return i.applyQuaternion(new rg().setFromUnitVectors(Qj,t)),i.translate(e.x+t.x*n*.5,e.y+t.y*n*.5,e.z+t.z*n*.5),i}function eM(e){let t=e===`left`?-1:1,n=[],r=new Nj(8.4,9.2,2.8,1,1.25);r.translate(0,5.2,0),n.push(r);let i=new Py(2.2,2.2,1,6);i.scale(1.3,1,.9),i.translate(0,.4,0),n.push(i);let a=[{x:3.2*t,y:9.1,scale:.95,curl:.22,splay:.12*t},{x:1.08*t,y:9.5,scale:1.05,curl:.34,splay:.03*t},{x:-1.05*t,y:9.3,scale:.98,curl:.46,splay:-.05*t},{x:-3.05*t,y:8.7,scale:.8,curl:.6,splay:-.16*t}];for(let e of a){let t=new q(e.x,e.y,0),r=e.curl;for(let[i,a,o]of[[4.3,1.04,.55],[2.7,.95,.5],[2.2,.86,0]]){let s=new q(Math.sin(e.splay)*Math.cos(r),Math.cos(e.splay)*Math.cos(r),Math.sin(r)),c=i*e.scale;n.push($j(t,s,c,a*(.88+.12*e.scale))),t.addScaledVector(s,c),r+=o}}let o=new _b(1.9,6,4);o.scale(1.15,1.5,.95),o.translate(2.7*t,3.3,.9),n.push(o);let s=new q(3.7*t,3.4,.9),c=new q(.62*t,.64,.45).normalize();n.push($j(s,c,3.9,1.2)),s.addScaledVector(c,3.9),n.push($j(s,new q(.3*t,.82,.48).normalize(),3,1.05));let l=n.map(e=>{let t=e.index===null?e:e.toNonIndexed();return t.deleteAttribute(`uv`),t}),u=_E(l,!1);for(let e of new Set([...n,...l]))e.dispose();if(u===null)throw Error(`hand geometry could not be merged`);return u}function tM(){let e=new Iy(3.9,6,9.2,20,1,!1);return e.scale(1,1,.96),e.translate(0,21.1,0),e}var nM={hips:Qk.hips,spine:Qk.spine,chest:`Spine1_024`,upperChest:Qk.chest,neck:`Neck_012`,head:Qk.head,clavicleL:`LeftShoulder_09`,shoulderL:Qk.shoulderL,elbowL:Qk.elbowL,gloveL:Qk.gloveL,clavicleR:`RightShoulder_020`,shoulderR:Qk.shoulderR,elbowR:Qk.elbowR,gloveR:Qk.gloveR,hipL:Qk.hipL,kneeL:Qk.kneeL,ankleL:Qk.ankleL,toeL:`LeftToeBase_011`,hipR:Qk.hipR,kneeR:Qk.kneeR,ankleR:Qk.ankleR,toeR:`RightToeBase_022`},rM=new q,iM=new q,aM=new q,oM=new Dg,sM=new rg,cM=new rg,lM=new q,uM=new q,dM=new q,fM=new q,pM=new q,mM=new q,hM=new q,gM=new q,_M=new q,vM=new q;function yM(e,t){return t.setFromMatrixPosition(e.matrixWorld)}function bM(e,t){return e.matrixWorld.decompose(lM,t,uM),t}function xM(e,t,n,r){return iM.copy(e).normalize(),n===`z`?(aM.copy(t).addScaledVector(iM,-t.dot(iM)),aM.lengthSq()<1e-8&&aM.set(0,0,1).addScaledVector(iM,-iM.z),aM.normalize(),rM.crossVectors(iM,aM).normalize()):(rM.copy(t).addScaledVector(iM,-t.dot(iM)),rM.lengthSq()<1e-8&&rM.set(1,0,0).addScaledVector(iM,-iM.x),rM.normalize(),aM.crossVectors(rM,iM).normalize()),oM.makeBasis(rM,iM,aM),r.setFromRotationMatrix(oM)}var SM=class{bones;metrics;restLocal=new Map;restPositions=new Map;limb={reached:!1,joint:new q};constructor(e){let t=new Map;e.traverse(e=>{e instanceof Uv&&t.set(e.name,e)});let n={};for(let[e,r]of Object.entries(nM)){let i=t.get(r);if(i===void 0)throw Error(`fighter rig missing bone ${r} (${e})`);n[e]=i}this.bones=n,e.updateMatrixWorld(!0);for(let e of t.values())this.restLocal.set(e,e.quaternion.clone()),this.restPositions.set(e,e.position.clone());let r=(e,t)=>yM(n[e],dM).distanceTo(yM(n[t],fM)),i=yM(n.hips,dM).clone(),a=yM(n.hips.parent??e,fM).clone(),o=n.hips.position.length(),s=i.distanceTo(a);this.metrics={hipsHeight:i.y,headHeight:yM(n.head,dM).y,chestHeight:yM(n.upperChest,dM).y,ankleHeight:yM(n.ankleL,dM).y,armL:{upper:r(`shoulderL`,`elbowL`),lower:r(`elbowL`,`gloveL`)},armR:{upper:r(`shoulderR`,`elbowR`),lower:r(`elbowR`,`gloveR`)},legL:{upper:r(`hipL`,`kneeL`),lower:r(`kneeL`,`ankleL`)},legR:{upper:r(`hipR`,`kneeR`),lower:r(`kneeR`,`ankleR`)},footLength:r(`ankleL`,`toeL`),unitsPerMeter:s>1e-6?o/s:1}}resetToRest(){for(let[e,t]of this.restLocal){e.quaternion.copy(t);let n=this.restPositions.get(e);n!==void 0&&e.position.copy(n)}}restLocalQuaternion(e){return this.restLocal.get(e)??e.quaternion}restLocalPosition(e){return this.restPositions.get(e)??e.position}position(e,t){return yM(this.bones[e],t)}setWorldRotation(e,t){let n=e.parent;n===null?e.quaternion.copy(t):(bM(n,cM),e.quaternion.copy(cM.invert().multiply(t)).normalize()),e.updateWorldMatrix(!1,!1)}setWorldFrame(e,t,n,r){this.setWorldRotation(e,xM(t,n,r,sM))}setWorldPosition(e,t){let n=e.parent;n===null?e.position.copy(t):(e.position.copy(t),n.worldToLocal(e.position)),e.updateWorldMatrix(!1,!1)}aimAt(e,t,n){if(e.updateWorldMatrix(!1,!1),yM(e,dM),pM.subVectors(t,dM),pM.lengthSq()<1e-10)return;bM(e,sM);let r=n===`z`?vM.set(0,0,1):vM.set(1,0,0);this.setWorldFrame(e,pM,r.applyQuaternion(sM),n)}solveLimb(e,t,n,r,i,a,o,s=.01){e.updateWorldMatrix(!1,!1);let c=yM(e,dM);pM.subVectors(r,c);let l=n.upper+n.lower-s,u=G.clamp(pM.length(),Math.abs(n.upper-n.lower)+.005,l),d=pM.length()<=l;pM.lengthSq()<1e-10&&pM.set(0,-1,0),pM.normalize(),mM.copy(i).addScaledVector(pM,-i.dot(pM)),mM.lengthSq()<1e-8&&(mM.set(0,0,1).addScaledVector(pM,-pM.z),mM.lengthSq()<1e-8&&mM.set(1,0,0)),mM.normalize();let f=G.clamp((n.upper*n.upper+u*u-n.lower*n.lower)/(2*n.upper*u),-1,1),p=n.upper*f,m=n.upper*Math.sqrt(Math.max(0,1-f*f));hM.copy(c).addScaledVector(pM,p).addScaledVector(mM,m),gM.crossVectors(mM,pM).multiplyScalar(o).normalize(),_M.copy(hM).sub(c),this.setWorldFrame(e,_M,gM,a),t.updateWorldMatrix(!1,!1);let h=yM(t,fM);return _M.copy(c).addScaledVector(pM,u).sub(h),this.setWorldFrame(t,_M,gM,a),this.limb.reached=d,this.limb.joint.copy(h),this.limb}},CM=new q(.2018,.081,-.027),wM=new q(-.2018,.081,-.027),TM=(e,t,n)=>new q(e,t,n),EM=(e,t,n)=>{let r=G.clamp((n-e)/Math.max(1e-6,t-e),0,1);return r*r*(3-2*r)},DM=(e,t=1.7)=>G.clamp(e,0,1)**+t,OM=(e,t=2)=>1-(1-G.clamp(e,0,1))**t,kM=new rg,AM=new q,jM=new q,MM=new q,NM=new q,PM=new q,FM=new rg,IM=new rg,LM=new Lg,RM=new q(0,1,0),zM=[[`spine`,.25,.2],[`chest`,.55,.5],[`upperChest`,1,1]],BM=class{rig;chestLocal=new q;constructor(e){this.rig=e}toWorld(e,t){return t.copy(e).applyQuaternion(kM).add(AM)}dirToWorld(e,t){return t.copy(e).applyQuaternion(kM)}setYawPitchRoll(e,t,n,r){LM.set(n,t,r,`YXZ`),FM.setFromEuler(LM),IM.copy(kM).multiply(FM),this.rig.setWorldRotation(e,IM)}apply(e,t){let n=this.rig,r=n.bones;n.resetToRest(),e.updateMatrixWorld(!0),bM(e,kM),yM(e,AM);let i=t.torso;this.toWorld(i.hips,jM),n.setWorldPosition(r.hips,jM),this.setYawPitchRoll(r.hips,i.hipsYaw,i.hipsPitch,i.hipsRoll);let a=i.shouldersYaw-i.hipsYaw;for(let e=0;e0&&(yM(r.head,jM),this.dirToWorld(i.headOffset,MM),jM.add(MM),n.setWorldPosition(r.head,jM)),this.solveArm(`L`,t.handL,t.shrugL),this.solveArm(`R`,t.handR,t.shrugR),this.solveLeg(`L`,t.footL),this.solveLeg(`R`,t.footR)}solveArm(e,t,n){let r=this.rig,i=r.bones,a=e===`L`?i.clavicleL:i.clavicleR,o=e===`L`?i.shoulderL:i.shoulderR,s=e===`L`?i.elbowL:i.elbowR,c=e===`L`?i.gloveL:i.gloveR,l=e===`L`?r.metrics.armL:r.metrics.armR,u=e===`L`?CM:wM;this.chestLocal.copy(u),this.chestLocal.z+=n*.06,this.chestLocal.y+=n*.035,this.chestLocal.x*=1-n*.08,NM.copy(this.chestLocal).multiplyScalar(r.metrics.unitsPerMeter),i.upperChest.localToWorld(NM),r.aimAt(a,NM,`z`),o.updateWorldMatrix(!1,!1),this.toWorld(t.position,jM),this.dirToWorld(t.pole,MM),r.solveLimb(o,s,l,jM,MM,`z`,e===`L`?1:-1,.012),c.updateWorldMatrix(!1,!1),this.dirToWorld(t.knuckles,NM),this.dirToWorld(t.palm,PM),r.setWorldFrame(c,NM,PM,`z`)}solveLeg(e,t){let n=this.rig,r=n.bones,i=e===`L`?r.hipL:r.hipR,a=e===`L`?r.kneeL:r.kneeR,o=e===`L`?r.ankleL:r.ankleR,s=e===`L`?r.toeL:r.toeR,c=e===`L`?n.metrics.legL:n.metrics.legR;this.toWorld(t.position,jM),this.dirToWorld(t.toe,NM).normalize();let l=n.metrics.footLength;PM.copy(NM).multiplyScalar(l).addScaledVector(RM,-n.metrics.ankleHeight).normalize(),t.heel!==0&&(jM.addScaledVector(PM,l),FM.setFromAxisAngle(MM.crossVectors(NM,RM).normalize(),-t.heel),PM.applyQuaternion(FM),jM.addScaledVector(PM,-l)),this.dirToWorld(t.pole,MM),n.solveLimb(i,a,c,jM,MM,`x`,-1,.02),o.updateWorldMatrix(!1,!1),n.setWorldFrame(o,PM,RM,`z`),s.updateWorldMatrix(!1,!1),n.setWorldFrame(s,NM,RM,`z`)}},VM={bladeYaw:-1.05,hipsHeight:.8,leadFoot:TM(.12,0,.24),rearFoot:TM(-.1,0,-.34),leadToe:TM(-.34,0,.94),rearToe:TM(-.77,0,.64),relaxedLead:TM(.11,-.22,.36),relaxedRear:TM(-.11,-.16,.1),guardHighLead:TM(.14,-.02,.17),guardHighRear:TM(-.1,-.02,.11),guardLowLead:TM(.15,-.36,.22),guardLowRear:TM(-.13,-.34,.12),leadPole:TM(.45,-1,.2),rearPole:TM(-.5,-1,-.05),leadKnuckles:TM(.1,.55,.8),leadPalm:TM(-.9,.15,-.35),rearKnuckles:TM(-.05,.7,.7),rearPalm:TM(.95,.1,-.25)};function HM(e,t,n=new q){return n.set(e.x*t,e.y,e.z)}var Z={pelvis:0,hipL:1,hipR:2,belly:3,chest:4,upper:5,neck:6,shoulderL:7,shoulderR:8,head:9,crown:10,face:11,elbowL:12,wristL:13,fistL:14,elbowR:15,wristR:16,fistR:17,kneeL:18,ankleL:19,toeL:20,heelL:21,kneeR:22,ankleR:23,toeR:24,heelR:25},UM=[9,4,4,2,10,7,2,3.5,3.5,2.5,1.5,1,1.6,1,1,1.6,1,1,3.6,1.6,.4,.6,3.6,1.6,.4,.6],WM=[.12,.09,.09,.11,.14,.13,.06,.07,.07,.09,.085,.055,.05,.065,.08,.05,.065,.08,.06,.05,.035,.04,.06,.05,.035,.04],GM=.12,KM=.16,qM=.09,JM=.06,YM=.11,XM=[[Z.pelvis,Z.hipL],[Z.pelvis,Z.hipR],[Z.hipL,Z.hipR],[Z.belly,Z.hipL],[Z.belly,Z.hipR],[Z.belly,Z.pelvis],[Z.pelvis,Z.chest],[Z.chest,Z.upper],[Z.upper,Z.neck],[Z.upper,Z.shoulderL],[Z.upper,Z.shoulderR],[Z.neck,Z.shoulderL],[Z.neck,Z.shoulderR],[Z.shoulderL,Z.shoulderR],[Z.neck,Z.head],[Z.head,Z.crown],[Z.head,Z.face],[Z.crown,Z.face],[Z.shoulderL,Z.elbowL],[Z.elbowL,Z.wristL],[Z.wristL,Z.fistL],[Z.shoulderR,Z.elbowR],[Z.elbowR,Z.wristR],[Z.wristR,Z.fistR],[Z.hipL,Z.kneeL],[Z.kneeL,Z.ankleL],[Z.ankleL,Z.toeL],[Z.ankleL,Z.heelL],[Z.toeL,Z.heelL],[Z.hipR,Z.kneeR],[Z.kneeR,Z.ankleR],[Z.ankleR,Z.toeR],[Z.ankleR,Z.heelR],[Z.toeR,Z.heelR]],ZM=[[Z.hipL,Z.shoulderL,.8,1.05],[Z.hipR,Z.shoulderR,.8,1.05],[Z.hipL,Z.shoulderR,.84,1.08],[Z.hipR,Z.shoulderL,.84,1.08],[Z.belly,Z.upper,.7,1.06],[Z.pelvis,Z.upper,.86,1],[Z.hipL,Z.chest,.84,1.08],[Z.hipR,Z.chest,.84,1.08],[Z.shoulderL,Z.face,.76,1.2],[Z.shoulderR,Z.face,.76,1.2],[Z.kneeL,Z.hipR,.8,1.3],[Z.kneeR,Z.hipL,.8,1.3],[Z.kneeL,Z.belly,.5,1.12],[Z.kneeR,Z.belly,.5,1.12]],QM=8,$M=[[Z.kneeL,Z.kneeR,.13],[Z.ankleL,Z.ankleR,.11],[Z.kneeL,Z.ankleR,.1],[Z.kneeR,Z.ankleL,.1],[Z.hipL,Z.ankleL,.2],[Z.hipR,Z.ankleR,.2],[Z.shoulderL,Z.wristL,.14],[Z.shoulderR,Z.wristR,.14],[Z.face,Z.chest,.2],[Z.crown,Z.chest,.24],[Z.kneeL,Z.upper,.3],[Z.kneeR,Z.upper,.3]],eN=[Z.elbowL,Z.wristL,Z.fistL,Z.elbowR,Z.wristR,Z.fistR],tN=[.7,.6,.6,.7,.9,1,1,1,1,1,1,1,.9,.8,.8,.9,.8,.8,.35,.1,0,0,.35,.1,0,0],nN=[[Z.pelvis,Z.chest,.12],[Z.chest,Z.upper,.13]],rN=Int32Array.from(XM.flat()),iN=Int32Array.from(ZM.flatMap(([e,t])=>[e,t])),aN=Int32Array.from($M.flatMap(([e,t])=>[e,t])),oN=Float64Array.from($M.map(([,,e])=>e)),sN=Int32Array.from(nN.flatMap(([e,t])=>[e,t])),cN=Float64Array.from(nN.map(([,,e])=>e)),lN=Float64Array.from([Z.head,1,Z.crown,.9,Z.face,1,Z.neck,.45]),uN=Float64Array.from([Z.belly,1,Z.chest,.6,Z.pelvis,.4,Z.hipL,.3,Z.hipR,.3]),dN=[Z.head,Z.crown,Z.face],fN=[Z.crown,Z.face],pN=[[Z.toeL,Z.heelL],[Z.toeR,Z.heelR]],mN=[[Z.heelL],[Z.heelR]],hN=[Z.head,Z.crown,Z.face],gN=[Z.fistL],_N=[Z.fistR],vN=1/120,yN=12,bN=9.81,xN=.998,SN=.5,CN=.03,wN=.35,TN=.12,EN=[Z.pelvis,Z.hipL,Z.hipR,Z.belly,Z.chest,Z.upper],DN=[Z.upper,Z.neck,Z.shoulderL,Z.shoulderR,Z.head,Z.crown,Z.face,Z.elbowL,Z.wristL,Z.fistL,Z.elbowR,Z.wristR,Z.fistR],ON=[Z.pelvis,Z.hipL,Z.hipR,Z.belly,Z.kneeL,Z.ankleL,Z.toeL,Z.heelL,Z.kneeR,Z.ankleR,Z.toeR,Z.heelR],kN=40*Math.PI/180,AN=[[Z.kneeL,Z.ankleL,Z.toeL,Z.heelL],[Z.kneeR,Z.ankleR,Z.toeR,Z.heelR]],jN=[[Z.ankleL,Z.toeL,Z.heelL],[Z.ankleR,Z.toeR,Z.heelR]],MN=.08,NN=.35,PN=new Set(EN),FN=xE+.45,IN=.24,LN=1.75,RN=.012,zN=1,BN=.35,VN=.15,HN=1.1,UN=.4,WN=1.2,GN=1200,KN=3,qN=7,JN=.08,YN=.97,XN=2.55,ZN=.5,QN=30*Math.PI/180,$N=32*Math.PI/180,eP=28*Math.PI/180,tP=35*Math.PI/180,nP=20*Math.PI/180,rP=.5,iP=.01,aP=.04,oP=.4,sP=.02,cP=.25,lP={timber:{knee:.12,spine:.2,seconds:.55},crumple:{knee:XN,spine:1,seconds:0},sag:{knee:.55,spine:.6,seconds:.3},fold:{knee:.9,spine:1,seconds:.5}},uP=2.5,dP=35*Math.PI/180,fP=50*Math.PI/180,pP=135*Math.PI/180,mP=[[Z.kneeL,Z.ankleL,Z.toeL,fP,pP],[Z.kneeR,Z.ankleR,Z.toeR,fP,pP],[Z.elbowL,Z.wristL,Z.fistL,0,dP],[Z.elbowR,Z.wristR,Z.fistR,0,dP]],hP=Int32Array.from(mP.flatMap(([e,,t])=>[e,t]));function gP(e,t,n,r){if(t===`body`)return`fold`;if(n<90)return`sag`;let i=Math.abs(Math.floor(r))%3;return e===`hook`?i===0?`timber`:`crumple`:i===0?`crumple`:`timber`}var _P=(e,t,n)=>n.set(e[t*3],e[t*3+1],e[t*3+2]),vP=e=>e-Math.round(e/(Math.PI*2))*Math.PI*2,yP=(e,t,n)=>{e[t*3]=n.x,e[t*3+1]=n.y,e[t*3+2]=n.z},bP=class{position=new Float64Array(78);previous=new Float64Array(78);before=new Float64Array(78);invMass=new Float64Array(26);rigidLength=new Float64Array(XM.length);rangeMin=new Float64Array(ZM.length);rangeMax=new Float64Array(ZM.length);restRange=new Float64Array(ZM.length);rangeStart=new Float64Array(ZM.length);kneeStart=new Float64Array(2);footSign=new Float64Array(2);turnAxis=new q;turnQuaternion=new rg;turnPoint=new q;angleRanges=new Float64Array(mP.length*2);elbowAxes=new Float64Array(6);kneeAxes=new Float64Array(6);hingeStart=new Float64Array(24);hingeNow=new Float64Array(24);swing=new rg;local=new q;localAxis=new q;ropeLines=new Float64Array(4);style=`crumple`;steps=0;stillSeconds=0;torsoStillSeconds=0;fallSeconds=0;landedSeconds=-1;asleep=!1;obstacleActive=!1;obstacleX=0;obstacleZ=0;obstacleTrack=null;obstacleTrackLive=!1;pull=null;pullShare=0;trackObstacle(e,t){this.obstacleTrack=e,this.obstacleTrackLive=e!==null&&!t}a=new q;b=new q;c=new q;d=new q;e=new q;fx=new q;fy=new q;fz=new q;gx=new q;gy=new q;gz=new q;pivot=new q;segmentA=new q;segmentB=new q;constructor(){for(let e=0;e<26;e+=1)this.invMass[e]=1/UM[e]}calibrate(e){for(let[t,[n,r]]of ZM.entries())this.restRange[t]=this.distance(e,n,r)}start(e,t,n){this.position.set(e),this.before.set(e);for(let n=0;n<78;n+=1)this.previous[n]=e[n]-t[n]*vN;for(let[t,[n,r]]of XM.entries())this.rigidLength[t]=this.distance(e,n,r);for(let[t,[n,r,i,a,o]]of mP.entries()){let s=this.distance(e,n,r),c=this.distance(e,r,i),l=this.distance(e,n,i),u=e=>Math.sqrt(s*s+c*c+2*s*c*Math.cos(e));this.angleRanges[t*2]=Math.min(u(o),l),this.angleRanges[t*2+1]=Math.max(u(a),l)}for(let[t,[n,r,i,a]]of ZM.entries()){let o=this.distance(e,n,r),s=this.restRange[t]>0?this.restRange[t]:o;this.rangeMin[t]=Math.min(s*i,o*.98),this.rangeMax[t]=Math.max(s*a,o*1.02),this.rangeStart[t]=o}this.style=n,this.steps=0,this.stillSeconds=0,this.torsoStillSeconds=0,this.fallSeconds=0,this.landedSeconds=-1,this.asleep=!1,this.upperFrame(this.position),this.pelvisFrame(this.position);for(let e of[0,1]){this.startHinge(this.elbowAxes,e,e===0?Z.shoulderL:Z.shoulderR,e===0?Z.elbowL:Z.elbowR,e===0?Z.wristL:Z.wristR,this.gx,-1),this.startHinge(this.kneeAxes,e,e===0?Z.hipL:Z.hipR,e===0?Z.kneeL:Z.kneeR,e===0?Z.ankleL:Z.ankleR,this.fx,1),this.storeHingeStart(e,e===0?Z.hipL:Z.hipR,e===0?Z.kneeL:Z.kneeR,this.kneeAxes,this.fx,this.fy,this.fz),this.storeHingeStart(2+e,e===0?Z.shoulderL:Z.shoulderR,e===0?Z.elbowL:Z.elbowR,this.elbowAxes,this.gx,this.gy,this.gz);let t=this.dir(e===0?Z.hipL:Z.hipR,e===0?Z.kneeL:Z.kneeR,this.a),n=this.dir(e===0?Z.kneeL:Z.kneeR,e===0?Z.ankleL:Z.ankleR,this.b);this.kneeStart[e]=Math.acos(Math.min(1,Math.max(-1,t.dot(n))));let r=this.c.set(this.kneeAxes[e*3],this.kneeAxes[e*3+1],this.kneeAxes[e*3+2]);this.footSign[e]=this.footNormal(e,this.d).dot(r)>=0?1:-1}for(let t=0;t<4;t+=1){let n=t<2?0:2,r=t%2==0?1:-1,i=0;for(let t of EN)i=Math.max(i,r*e[t*3+n]+WM[t]);this.ropeLines[t]=Math.max(TE,i+.04)}}startHinge(e,t,n,r,i,a,o){let s=this.dir(n,r,this.a),c=this.dir(r,i,this.b),l=this.c.crossVectors(s,c);l.length()<.2&&l.copy(a).multiplyScalar(o),l.addScaledVector(s,-l.dot(s)),l.lengthSq()<1e-8&&l.copy(a).multiplyScalar(o).addScaledVector(s,-o*a.dot(s)),l.normalize(),e[t*3]=l.x,e[t*3+1]=l.y,e[t*3+2]=l.z}storeHingeStart(e,t,n,r,i,a,o){let s=e%2,c=this.dir(t,n,this.a),l=this.b.set(r[s*3],r[s*3+1],r[s*3+2]),u=e*6;this.hingeStart[u]=c.dot(i),this.hingeStart[u+1]=c.dot(a),this.hingeStart[u+2]=c.dot(o),this.hingeStart[u+3]=l.dot(i),this.hingeStart[u+4]=l.dot(a),this.hingeStart[u+5]=l.dot(o);for(let e=0;e<6;e+=1)this.hingeNow[u+e]=this.hingeStart[u+e]}hingeAxis(e,t,n,r,i,a){let o=e*6,s=this.hingeNow;return this.local.set(t.dot(n),t.dot(r),t.dot(i)).normalize(),this.localAxis.set(s[o],s[o+1],s[o+2]),this.swing.setFromUnitVectors(this.localAxis,this.local),this.localAxis.set(s[o+3],s[o+4],s[o+5]).applyQuaternion(this.swing),a.copy(n).multiplyScalar(this.localAxis.x).addScaledVector(r,this.localAxis.y).addScaledVector(i,this.localAxis.z),a.addScaledVector(t,-a.dot(t)).normalize()}carryHinges(){this.pelvisFrame(this.position),this.upperFrame(this.position);for(let e=0;e<4;e+=1){let t=e%2,n=e<2,r=n?t===0?Z.hipL:Z.hipR:t===0?Z.shoulderL:Z.shoulderR,i=n?t===0?Z.kneeL:Z.kneeR:t===0?Z.elbowL:Z.elbowR,a=n?this.fx:this.gx,o=n?this.fy:this.gy,s=n?this.fz:this.gz,c=this.dir(r,i,this.a),l=this.hingeAxis(e,c,a,o,s,this.b),u=e*6;this.hingeNow[u]=c.dot(a),this.hingeNow[u+1]=c.dot(o),this.hingeNow[u+2]=c.dot(s),this.hingeNow[u+3]=l.dot(a),this.hingeNow[u+4]=l.dot(o),this.hingeNow[u+5]=l.dot(s)}}get holding(){return this.steps*vN0&&(this.landedSeconds=0)}setLimp(e,t){for(let n=0;n0){let e=Math.min(this.steps,t.steps-1)*3;this.obstacleActive=t.data[e]===1,this.obstacleX=t.data[e+1],this.obstacleZ=t.data[e+2]}let n=vN,r=this.position,i=this.previous,a=this.landedSeconds<0?xN:xN+-.02300000000000002*Math.min(1,this.landedSeconds/UN);this.before.set(r);for(let e=0;e<26;e+=1)for(let t=0;t<3;t+=1){let o=e*3+t,s=r[o],c=(s-i[o])*a;i[o]=s,r[o]=s+c-(t===1?bN*n*n:0)}let o=this.pull;if(o!==null)for(let e=0;e<26;e+=1){let t=(o[e*3]-r[e*3])*this.pullShare,n=(o[e*3+1]-r[e*3+1])*this.pullShare,a=(o[e*3+2]-r[e*3+2])*this.pullShare,s=Math.sqrt(t*t+n*n+a*a),c=this.pullShare<1&&s>MP?MP/s:1;for(let o=0;o<3;o+=1){let s=(o===0?t:o===1?n:a)*c;r[e*3+o]=r[e*3+o]+s,i[e*3+o]=i[e*3+o]+s}}this.carryHinges();for(let e=0;e=0&&o===null&&this.toppleLegs(),this.applyFriction(),this.limitSpeed(),this.steps+=1;let s=0,c=0;for(let e=0;e<26;e+=1){let t=r[e*3]-i[e*3],a=r[e*3+1]-i[e*3+1],o=r[e*3+2]-i[e*3+2],l=Math.sqrt(t*t+a*a+o*o)/n;s=Math.max(s,l),PN.has(e)&&(c=Math.max(c,l))}this.stillSeconds=s=0?this.landedSeconds+=n:(this.torsoStillSeconds=c=VN||this.fallSeconds>=HN)&&(this.landedSeconds=0)),o===null&&(this.stillSeconds>=zN||this.landedSeconds>=WN)&&(this.asleep=!0)}solveRigid(){for(let e=0;er?r:c;if(l===c)return;let u=this.invMass[e],d=this.invMass[t],f=u+d;if(f<=0)return;let p=(c-l)/(c*f);i[e*3]=i[e*3]+a*p*u,i[e*3+1]=i[e*3+1]+o*p*u,i[e*3+2]=i[e*3+2]+s*p*u,i[t*3]=i[t*3]-a*p*d,i[t*3+1]=i[t*3+1]-o*p*d,i[t*3+2]=i[t*3+2]-s*p*d}solveKnees(){this.pelvisFrame(this.position);for(let e=0;e<2;e+=1){let t=e===0?Z.hipL:Z.hipR,n=e===0?Z.kneeL:Z.kneeR,r=this.dir(t,n,this.a),i=this.hingeAxis(e,r,this.fx,this.fy,this.fz,this.b),a=this.holding?Math.min(XN,this.kneeStart[e]+lP[this.style].knee):XN;this.hinge(n,e===0?Z.ankleL:Z.ankleR,r,i,-.12,a)}}solveElbows(){this.upperFrame(this.position);for(let e=0;e<2;e+=1){let t=e===0?Z.shoulderL:Z.shoulderR,n=e===0?Z.elbowL:Z.elbowR,r=this.dir(t,n,this.a),i=this.hingeAxis(2+e,r,this.gx,this.gy,this.gz,this.b);this.hinge(n,e===0?Z.wristL:Z.wristR,r,i,-.12,uP)}}toppleLegs(){let e=this.position;for(let t=0;t<2;t+=1){let n=t===0?Z.hipL:Z.hipR,r=t===0?Z.kneeL:Z.kneeR,i=t===0?Z.ankleL:Z.ankleR,a=this.dir(n,r,this.a);if(a.y>NN){let i=this.dir(Z.hipR,Z.hipL,this.b),o=this.c.crossVectors(i,this.d.set(e[r*3]-e[n*3],e[r*3+1]-e[n*3+1],e[r*3+2]-e[n*3+2])).y>0?-1:1;this.rotateAbout(AN[t],n,i,o*MN*(a.y-NN))}let o=this.dir(r,i,this.a);if(o.y>NN){let n=this.kneeAxis(t===0?0:1,e,this.b),a=this.c.crossVectors(n,this.d.set(e[i*3]-e[r*3],e[i*3+1]-e[r*3+1],e[i*3+2]-e[r*3+2])).y>0?-1:1;this.rotateAbout(jN[t],r,n,a*MN*(o.y-NN))}}}solveTwist(){let e=this.dir(Z.pelvis,Z.upper,this.e),t=this.dir(Z.hipR,Z.hipL,this.a);t.addScaledVector(e,-t.dot(e));let n=this.dir(Z.shoulderR,Z.shoulderL,this.c);if(n.addScaledVector(e,-n.dot(e)),t.lengthSq()<1e-8||n.lengthSq()<1e-8)return;let r=Math.atan2(this.d.crossVectors(t,n).dot(e),t.dot(n)),i=Math.abs(r)-kN;if(i<=0)return;let a=this.spinInertia(DN,e),o=this.spinInertia(ON,e),s=Math.sign(r)*i*oP;this.rotateAbout(DN,Z.chest,e,-s*(o/(a+o))),this.rotateAbout(ON,Z.chest,e,s*(a/(a+o)))}spinInertia(e,t){let n=this.position,r=1e-6;for(let i=0;iMath.abs(p)+1e-6){let n=Math.atan2(r,u),a=Math.acos(p/i),c=vP(n-a),l=vP(n+a),d=(Math.abs(c)<=Math.abs(l)?c:l)*s;this.rotateAbout(mN[t],o,e,Math.min(aP,Math.max(-.04,d)))}}let m=this.dir(i,a,this.a),h=this.hingeAxis(t,m,this.fx,this.fy,this.fz,this.b),g=this.footNormal(t===0?0:1,this.d).multiplyScalar(this.footSign[t]);if(h.addScaledVector(c,-h.dot(c)),g.addScaledVector(c,-g.dot(c)),h.lengthSq()<.09||g.lengthSq()<.09)continue;h.normalize(),g.normalize();let _=Math.atan2(this.e.crossVectors(h,g).dot(c),h.dot(g)),v=Math.min(eP,Math.max(-eP,_));v!==_&&this.rotateAbout(pN[t],o,c,Math.min(iP,Math.max(-.01,(v-_)*s)))}}footNormal(e,t){let n=this.position,r=e===0?Z.ankleL:Z.ankleR,i=e===0?Z.toeL:Z.toeR,a=e===0?Z.heelL:Z.heelR;return t.set(n[i*3]-n[a*3],n[i*3+1]-n[a*3+1],n[i*3+2]-n[a*3+2]),this.turnPoint.set(n[r*3]-n[a*3],n[r*3+1]-n[a*3+1],n[r*3+2]-n[a*3+2]),t.cross(this.turnPoint).normalize()}cone(e,t,n,r,i,a){let o=this.dir(t,n,this.turnPoint),s=Math.acos(Math.min(1,Math.max(-1,o.dot(e))));if(s<=r)return;let c=this.turnAxis.crossVectors(o,e);if(c.lengthSq()<1e-10)return;c.normalize();let l=this.pressed(a,i,c)?sP*cP:sP;this.rotateAbout(a,i,c,Math.min(l,(s-r)*oP))}pressed(e,t,n){let r=this.position;for(let i=0;iWM[a]+.005)&&n.z*(r[a*3]-r[t*3])-n.x*(r[a*3+2]-r[t*3+2])<-1e-9)return!0}return!1}rotateAbout(e,t,n,r){let i=this.position;this.turnQuaternion.setFromAxisAngle(n,r);let a=i[t*3],o=i[t*3+1],s=i[t*3+2];for(let t=0;t=u||l<1e-6||(o.addScaledVector(c,(u-l)/l),yP(e,n,o))}}}closestOnSegment(e,t,n,r){let i=this.segmentA.subVectors(t,e),a=i.lengthSq(),o=a<1e-12?0:Math.min(1,Math.max(0,this.segmentB.subVectors(n,e).dot(i)/a));return r.copy(e).addScaledVector(i,o)}solveEnvironment(){let e=this.position;for(let t=0;t<26;t+=1){let n=WM[t],r=e[t*3],i=e[t*3+1],a=e[t*3+2];i=p||f<1e-9)continue;let m=(p-f)/f*wN,h=u*m,g=d*m;t?r+=s*h:a+=s*h,i+=g}let u=o?c-n*.6:FN;s*(t?r:a)>u&&(t?r=s*u:a=s*u)}for(let e=0;e<4;e+=1){let t=e<2?-TE:TE,o=e%2==0?-TE:TE,s=r-t,c=a-o,l=Math.sqrt(s*s+c*c),u=TN+n;l>=u||l<1e-9||i>1.45||(r=t+s/l*u,a=o+c/l*u)}if(this.obstacleActive&&i1e-9&&(r=this.obstacleX+e/i*o,a=this.obstacleZ+t/i*o)}e[t*3]=r,e[t*3+1]=i,e[t*3+2]=a}}limitSpeed(){let e=this.position,t=this.previous,n=qN*vN,r=JN*vN;for(let i=0;i<26;i+=1){let a=e[i*3]-t[i*3],o=e[i*3+1]-t[i*3+1],s=e[i*3+2]-t[i*3+2],c=Math.sqrt(a*a+o*o+s*s);if(c>n||cn?n/c:YN;t[i*3]=e[i*3]-a*r,t[i*3+1]=e[i*3+1]-o*r,t[i*3+2]=e[i*3+2]-s*r}}}applyFriction(){let e=this.position,t=this.previous;for(let n=0;n<26;n+=1)e[n*3+1]>WM[n]+.004||(t[n*3]=t[n*3]+(e[n*3]-t[n*3])*SN,t[n*3+2]=t[n*3+2]+(e[n*3+2]-t[n*3+2])*SN,t[n*3+1]>e[n*3+1]&&(t[n*3+1]=e[n*3+1]))}settle(e=4,t){let n=this.steps+Math.ceil(e/vN);for(;!this.asleep&&this.steps1e-9?n.divideScalar(i):n.set(0,1,0)}pelvisFrame(e){this.fx.set(e[Z.hipL*3]-e[Z.hipR*3],e[Z.hipL*3+1]-e[Z.hipR*3+1],e[Z.hipL*3+2]-e[Z.hipR*3+2]).normalize(),this.fz.set(e[Z.belly*3]-(e[Z.hipL*3]+e[Z.hipR*3])/2,e[Z.belly*3+1]-(e[Z.hipL*3+1]+e[Z.hipR*3+1])/2,e[Z.belly*3+2]-(e[Z.hipL*3+2]+e[Z.hipR*3+2])/2),this.fz.addScaledVector(this.fx,-this.fz.dot(this.fx)).normalize(),this.fy.crossVectors(this.fz,this.fx).normalize()}upperFrame(e){this.gx.set(e[Z.shoulderL*3]-e[Z.shoulderR*3],e[Z.shoulderL*3+1]-e[Z.shoulderR*3+1],e[Z.shoulderL*3+2]-e[Z.shoulderR*3+2]).normalize(),this.gy.set(e[Z.neck*3]-e[Z.upper*3],e[Z.neck*3+1]-e[Z.upper*3+1],e[Z.neck*3+2]-e[Z.upper*3+2]),this.gy.addScaledVector(this.gx,-this.gy.dot(this.gx)).normalize(),this.gz.crossVectors(this.gx,this.gy).normalize()}pelvisForward(e){return this.pelvisFrame(this.position),e.copy(this.fz)}};function xP(e,t){e.setLimp(hN,!!(t&1)),e.setLimp(gN,!!(t&2)),e.setLimp(_N,!!(t&4))}var SP=[`hips`,`spine`,`chest`,`upperChest`,`neck`,`head`,`shoulderL`,`elbowL`,`gloveL`,`shoulderR`,`elbowR`,`gloveR`,`hipL`,`kneeL`,`ankleL`,`hipR`,`kneeR`,`ankleR`],CP=SP.map(e=>({shoulderL:[Z.shoulderL,Z.elbowL],elbowL:[Z.elbowL,Z.wristL],gloveL:[Z.wristL,Z.fistL],shoulderR:[Z.shoulderR,Z.elbowR],elbowR:[Z.elbowR,Z.wristR],gloveR:[Z.wristR,Z.fistR],hipL:[Z.hipL,Z.kneeL],kneeL:[Z.kneeL,Z.ankleL],hipR:[Z.hipR,Z.kneeR],kneeR:[Z.kneeR,Z.ankleR]})[e]??null),wP=SP.map(e=>({chest:Z.chest,shoulderL:Z.shoulderL,shoulderR:Z.shoulderR,hipL:Z.hipL,hipR:Z.hipR})[e]??-1),TP=.1,EP=.35,DP=.6,OP=10,kP=.35,AP=6,jP=.25,MP=.05,NP=.3,PP=6;function FP(e){let t=e.lateral;if(e.target===`body`){let n=Math.min(2.6,Math.max(1,.9+e.amount/90));return{x:.3*t*n,y:-.05*n,z:-n,driveX:.1*t*n,driveY:-.2*n,driveZ:.45*n,twist:0}}let n=Math.min(3.2,Math.max(1.4,1.2+e.amount/70)),r=n/3.2;switch(e.punchClass){case`hook`:return{x:t*n,y:.05*n,z:-.25*n,driveX:.55*t*r,driveY:-.1*r,driveZ:.85*r,twist:.6};case`uppercut`:return{x:0,y:.8*n,z:-.65*n,driveX:0,driveY:.25*r,driveZ:-1.1*r,twist:.4};case`straight`:return{x:.12*t*n,y:.1*n,z:-n,driveX:.1*t*r,driveY:0,driveZ:-1.25*r,twist:.3};default:return{x:.12*t*n,y:.1*n,z:-.85*n,driveX:.08*t*r,driveY:0,driveZ:-1*r,twist:.2}}}var IP=class{rig;root;body=new bP;ahead=new bP;aheadOf=null;aheadBlows=0;ragdolling=!1;age=0;accumulator=0;sampleNow=new Float64Array(78);sampleBefore=new Float64Array(78);sampleRoot=new q;sampleSeconds=0;samples=0;drawn=new Float64Array(78);velocities=new Float64Array(78);offsets=SP.map(()=>new rg);fromLocal=SP.map(()=>new rg);fromPositions=SP.map(()=>new q);fromHips=new q;riseLocal=SP.map(()=>new rg);riseHips=new q;riseTurns=SP.map(()=>new rg);solvedTurns=SP.map(()=>new rg);rootTurn=new rg;turn=new rg;riseCaptured=!1;lastFall=null;recordPositions=new Float64Array(78);recordVelocities=new Float64Array(78);recordOffsets=SP.map(()=>new rg);recordImpulses=[];recordObstacles={data:new Float64Array(GN*3),steps:0};recordLosses=[];recordRest={position:new Float64Array(78),previous:new Float64Array(78),steps:-1};replaying=null;followTargets=new Float64Array(78);followOffsets=SP.map(()=>new rg);blendedOffsets=SP.map(()=>new rg);following=!1;followAge=0;primed=!1;pending=null;lost=0;clock=0;bones;frame=new rg;world=new rg;axisX=new q;axisY=new q;axisZ=new q;hint=new q;point=new q;other=new q;pelvisX=new q;pelvisY=new q;upperX=new q;headX=new q;kneeAxes=[new q(1,0,0),new q(1,0,0)];elbowAxes=[new q,new q];spineLength;tiltJoint=new q;tiltChest=new q;tiltAcross=new q;tiltTurn=new rg;constructor(e,t){this.rig=e,this.root=t,this.bones=SP.map(t=>e.bones[t]);let n=new Map;t.traverse(e=>{e instanceof Uv&&n.set(e,[e.quaternion.clone(),e.position.clone()])}),e.resetToRest(),t.updateMatrixWorld(!0);let r=new Float64Array(78);this.read(r),this.body.calibrate(r),this.ahead.calibrate(r),this.spineLength=this.tiltJoint.setFromMatrixPosition(e.bones.spine.matrixWorld).distanceTo(this.tiltChest.setFromMatrixPosition(e.bones.chest.matrixWorld));for(let[e,[t,r]]of n)e.quaternion.copy(t),e.position.copy(r);t.updateMatrixWorld(!0)}get active(){return this.ragdolling}get record(){return this.lastFall}sample(e){this.ragdolling||e<=0||(this.sampleBefore.set(this.sampleNow),this.read(this.sampleNow),this.sampleRoot.setFromMatrixPosition(this.root.matrixWorld),this.sampleSeconds=e,this.samples=Math.min(2,this.samples+1))}tick(e){this.clock+=e}takeBlow(e,t,n,r,i){let a={step:0,x:e.x,y:e.y,z:e.z,driveX:t.x,driveY:t.y,driveZ:t.z,target:n,twist:r,style:i};if(this.ragdolling){if(this.age>EP)return;if(this.replaying!==null){this.replaying.impulses.length===0&&this.replaying.impulses.push({...a,step:this.body.steps});return}this.lastFall?.impulses.push(this.body.impulse(a))}else this.pending={...a,at:this.clock}}dropBlow(){this.pending=null}twitch(e,t,n){this.ragdolling&&!this.following&&(this.body.twitch(e,t,n),this.replaying===null&&this.lastFall!==null&&(this.lastFall.rest.steps=-1))}prime(){this.primed=this.lastFall!==null}forget(){this.lastFall=null,this.primed=!1}start(e){let t=this.primed?this.lastFall:null;if(this.primed=!1,this.root.updateMatrixWorld(!0),this.captureLocals(this.fromLocal,this.fromHips),t!==null){this.replaying=t,this.body.start(t.positions,t.velocities,t.style),this.body.trackObstacle(t.obstacles,!0),this.replayLosses(this.body,t,0);for(let[e,n]of t.offsets.entries())this.offsets[e].copy(n);this.aheadOf=null,t.rest.steps<0&&this.runAhead(t,0)}else{this.replaying=null;let t=this.point.setFromMatrixPosition(this.root.matrixWorld).sub(this.sampleRoot),n=this.samples>0&&t.lengthSq()<=kP*kP;if(!n)this.read(this.sampleNow);else for(let e=0;e<26;e+=1)for(let n of[this.sampleNow,this.sampleBefore])n[e*3]=n[e*3]+t.x,n[e*3+1]=n[e*3+1]+t.y,n[e*3+2]=n[e*3+2]+t.z;let r=n&&this.samples>=2&&this.sampleSeconds>0?this.sampleSeconds:0;this.samples=0;for(let e=0;e<78;e+=1){let t=r>0?(this.sampleNow[e]-this.sampleBefore[e])/r:0;this.velocities[e]=Math.max(-3,Math.min(KN,t))}let i=this.rig.bones.neck,a=this.rig.bones.head;this.point.copy(this.rig.restLocalPosition(a)).applyMatrix4(i.matrixWorld).sub(this.other.setFromMatrixPosition(a.matrixWorld));for(let e of dN)this.sampleNow[e*3]=this.sampleNow[e*3]+this.point.x,this.sampleNow[e*3+1]=this.sampleNow[e*3+1]+this.point.y,this.sampleNow[e*3+2]=this.sampleNow[e*3+2]+this.point.z;let o=this.pending!==null&&this.clock-this.pending.at<=DP?this.pending:null;this.body.start(this.sampleNow,this.velocities,o?.style??e),this.computeOffsets();let s=this.recordImpulses;s.length=0,o!==null&&s.push(this.body.impulse({step:0,x:o.x,y:o.y,z:o.z,driveX:o.driveX,driveY:o.driveY,driveZ:o.driveZ,target:o.target,twist:o.twist}));let c=this.recordObstacles;c.steps=0,this.body.trackObstacle(c,!1),this.recordPositions.set(this.sampleNow),this.recordVelocities.set(this.velocities);for(let e=0;e=.008333333333333333&&i=.008333333333333333&&n=0)this.body.restore(t);else{let t=this.body.steps+Math.ceil(PP/vN);for(;!this.body.asleep&&this.body.steps=1)return;let t=Math.min(1,Math.max(0,e));this.bodyTurns(this.solvedTurns),this.rig.bones.hips.position.lerpVectors(this.riseHips,this.rig.bones.hips.position,t);for(let e=0;eyP(e,t,n),r=e=>this.point.setFromMatrixPosition(e.matrixWorld),i=(e,t,n)=>n.setFromMatrixColumn(e.matrixWorld,t).normalize();n(Z.pelvis,r(t.hips)),n(Z.hipL,r(t.hipL)),n(Z.hipR,r(t.hipR)),n(Z.belly,r(t.hips).addScaledVector(i(t.hips,2,this.axisZ),GM)),n(Z.chest,r(t.chest)),n(Z.upper,r(t.upperChest)),n(Z.neck,r(t.neck)),n(Z.shoulderL,r(t.shoulderL)),n(Z.shoulderR,r(t.shoulderR)),n(Z.head,r(t.head)),n(Z.crown,r(t.head).addScaledVector(i(t.head,1,this.axisY),KM)),n(Z.face,r(t.head).addScaledVector(i(t.head,2,this.axisZ),qM).addScaledVector(i(t.head,1,this.axisY),JM)),n(Z.elbowL,r(t.elbowL)),n(Z.wristL,r(t.gloveL)),n(Z.fistL,r(t.gloveL).addScaledVector(i(t.gloveL,1,this.axisY),YM)),n(Z.elbowR,r(t.elbowR)),n(Z.wristR,r(t.gloveR)),n(Z.fistR,r(t.gloveR).addScaledVector(i(t.gloveR,1,this.axisY),YM)),n(Z.kneeL,r(t.kneeL)),n(Z.ankleL,r(t.ankleL)),n(Z.toeL,r(t.toeL)),n(Z.heelL,r(t.ankleL).addScaledVector(i(t.toeL,1,this.axisY),-.07).addScaledVector(i(t.toeL,2,this.axisZ),-.09)),n(Z.kneeR,r(t.kneeR)),n(Z.ankleR,r(t.ankleR)),n(Z.toeR,r(t.toeR)),n(Z.heelR,r(t.ankleR).addScaledVector(i(t.toeR,1,this.axisY),-.07).addScaledVector(i(t.toeR,2,this.axisZ),-.09))}computeOffsets(){this.prepareFrames(this.body.position);for(let e=0;e=0&&this.rig.setWorldPosition(i,_P(e,a,this.point)),SP[r]===`upperChest`&&(this.rig.bones.clavicleL.updateWorldMatrix(!1,!1),this.rig.bones.clavicleR.updateWorldMatrix(!1,!1))}this.root.updateMatrixWorld(!0)}tiltHips(e){let t=this.rig.bones.hips,n=this.point.setFromMatrixPosition(t.matrixWorld),r=this.tiltJoint.copy(this.rig.restLocalPosition(this.rig.bones.spine)).applyMatrix4(t.matrixWorld).sub(n),i=_P(e,Z.chest,this.tiltChest).sub(n),a=this.pelvisX,o=a.dot(r),s=this.tiltAcross.copy(r).addScaledVector(a,-o),c=(r.lengthSq()+i.lengthSq()-this.spineLength*this.spineLength)/2-o*a.dot(i),l=s.dot(i),u=this.other.crossVectors(a,s).dot(i),d=Math.hypot(l,u);if(d<1e-9)return;let f=Math.atan2(u,l),p=Math.acos(Math.min(1,Math.max(-1,c/d))),m=vP(f-p),h=vP(f+p),g=Math.abs(m)<=Math.abs(h)?m:h;Math.abs(g)<1e-5||(t.getWorldQuaternion(this.world).premultiply(this.tiltTurn.setFromAxisAngle(a,g)),this.rig.setWorldRotation(t,this.world))}prepareFrames(e){this.segment(e,Z.hipR,Z.hipL,this.pelvisX),this.axisZ.set(e[Z.belly*3]-(e[Z.hipL*3]+e[Z.hipR*3])/2,e[Z.belly*3+1]-(e[Z.hipL*3+1]+e[Z.hipR*3+1])/2,e[Z.belly*3+2]-(e[Z.hipL*3+2]+e[Z.hipR*3+2])/2),this.axisZ.addScaledVector(this.pelvisX,-this.axisZ.dot(this.pelvisX)).normalize(),this.pelvisY.crossVectors(this.axisZ,this.pelvisX).normalize(),this.segment(e,Z.shoulderR,Z.shoulderL,this.upperX),this.segment(e,Z.head,Z.crown,this.axisX),this.segment(e,Z.head,Z.face,this.other),this.headX.crossVectors(this.axisX,this.other).normalize()}segment(e,t,n,r){return r.set(e[n*3]-e[t*3],e[n*3+1]-e[t*3+1],e[n*3+2]-e[t*3+2]),r.lengthSq()>1e-12?r.normalize():r.set(0,1,0)}frameFor(e,t,n){let r=SP[e];switch(r){case`hips`:return xM(this.pelvisY,this.pelvisX,`x`,n);case`spine`:{let r=this.bones[e];return r.updateWorldMatrix(!1,!1),this.axisY.setFromMatrixPosition(r.matrixWorld),this.axisY.set(t[Z.chest*3]-this.axisY.x,t[Z.chest*3+1]-this.axisY.y,t[Z.chest*3+2]-this.axisY.z),this.axisY.lengthSq()>1e-12?this.axisY.normalize():this.segment(t,Z.pelvis,Z.chest,this.axisY),xM(this.axisY,this.hint.copy(this.pelvisX).multiplyScalar(.75).addScaledVector(this.upperX,.25),`x`,n)}case`chest`:return this.segment(t,Z.chest,Z.upper,this.axisY),xM(this.axisY,this.hint.copy(this.pelvisX).multiplyScalar(.4).addScaledVector(this.upperX,.6),`x`,n);case`upperChest`:return this.segment(t,Z.upper,Z.neck,this.axisY),xM(this.axisY,this.upperX,`x`,n);case`neck`:return this.segment(t,Z.neck,Z.head,this.axisY),xM(this.axisY,this.hint.copy(this.upperX).add(this.headX),`x`,n);case`head`:return this.segment(t,Z.head,Z.crown,this.axisY),xM(this.axisY,this.segment(t,Z.head,Z.face,this.hint),`z`,n);case`shoulderL`:case`elbowL`:case`gloveL`:case`shoulderR`:case`elbowR`:case`gloveR`:{let i=+!r.endsWith(`L`),a=CP[e],o=this.body.elbowAxis(i,t,this.elbowAxes[i]);return this.segment(t,a[0],a[1],this.axisY),xM(this.axisY,o,`x`,n)}case`hipL`:case`kneeL`:case`hipR`:case`kneeR`:{let i=+!r.endsWith(`L`),a=CP[e],o=this.body.kneeAxis(i,t,this.kneeAxes[i]);return this.segment(t,a[0],a[1],this.axisY),xM(this.axisY,o,`x`,n)}default:{let e=r===`ankleL`,i=e?Z.ankleL:Z.ankleR,a=e?Z.toeL:Z.toeR,o=e?Z.heelL:Z.heelR;return this.segment(t,i,a,this.axisY),this.segment(t,o,a,this.hint),this.other.set(t[i*3]-t[o*3],t[i*3+1]-t[o*3+1],t[i*3+2]-t[o*3+2]),this.hint.cross(this.other),xM(this.axisY,this.hint,`x`,n)}}}};function LP(e,t,n){let r=Math.min(1,Math.max(0,(n-e)/(t-e)));return r*r*(3-2*r)}var RP=3,zP=5;function BP(e){return 1-.74*LP(-.6,1.4,e)}var VP=.23,HP=.22,UP=.22,WP=1.15,GP=.5,KP=.9,qP=.045,JP=[.33,.66],YP=qP*2*.33*.67,XP=.04;function ZP(e,t){return{pressX:Math.min(HP,Math.max(0,Math.abs(e)+VP-TE)),pressZ:Math.min(HP,Math.max(0,Math.abs(t)+VP-TE))}}function QP(e,t,n){return n.x=Math.sign(e)*Math.max(0,Math.abs(e)+VP-TE-HP),n.z=Math.sign(t)*Math.max(0,Math.abs(t)+VP-TE-HP),n}var $P=` +`;function cb(e,t,n){let r={uOutfitShirt:{value:new B(n.shirt)},uOutfitTrousers:{value:new B(n.trousers)},uOutfitAccent:{value:new B(n.accent)},uOutfitShape:{value:new Lo(n.sleeves===`long`?63.4:Xy,+!!n.bowTie,Zy,0)}},i=e.onBeforeCompile,a=Object.hasOwn(e,`customProgramCacheKey`)?e.customProgramCacheKey():`plain`;e.onBeforeCompile=(n,a)=>{i.call(e,n,a),Object.assign(n.uniforms,r),n.vertexShader=n.vertexShader.replace(`#include `,`#include \n${eb(t)}`).replace(`#include `,`#include \n${tb}`).replace(`#include `,`#include \n${rb[t]}`),n.fragmentShader=n.fragmentShader.replace(`#include `,`#include \n${ib}`).replace(`#include `,`#include \n${ab[t]}`).replace(`#include `,`#include \n${ob}`).replace(`#include `,`#include \n${sb}`)},e.customProgramCacheKey=()=>`${a}-outfit-${t}`,e.needsUpdate=!0}var lb=new z(0,1,0);function ub(e,t,n,r){let i=new Yl(r,n,1,6);return i.applyQuaternion(new vo().setFromUnitVectors(lb,t)),i.translate(e.x+t.x*n*.5,e.y+t.y*n*.5,e.z+t.z*n*.5),i}function db(e){let t=e===`left`?-1:1,n=[],r=new Wy(8.4,9.2,2.8,1,1.25);r.translate(0,5.2,0),n.push(r);let i=new Yl(2.2,2.2,1,6);i.scale(1.3,1,.9),i.translate(0,.4,0),n.push(i);let a=[{x:3.2*t,y:9.1,scale:.95,curl:.22,splay:.12*t},{x:1.08*t,y:9.5,scale:1.05,curl:.34,splay:.03*t},{x:-1.05*t,y:9.3,scale:.98,curl:.46,splay:-.05*t},{x:-3.05*t,y:8.7,scale:.8,curl:.6,splay:-.16*t}];for(let e of a){let t=new z(e.x,e.y,0),r=e.curl;for(let[i,a,o]of[[4.3,1.04,.55],[2.7,.95,.5],[2.2,.86,0]]){let s=new z(Math.sin(e.splay)*Math.cos(r),Math.cos(e.splay)*Math.cos(r),Math.sin(r)),c=i*e.scale;n.push(ub(t,s,c,a*(.88+.12*e.scale))),t.addScaledVector(s,c),r+=o}}let o=new Mu(1.9,6,4);o.scale(1.15,1.5,.95),o.translate(2.7*t,3.3,.9),n.push(o);let s=new z(3.7*t,3.4,.9),c=new z(.62*t,.64,.45).normalize();n.push(ub(s,c,3.9,1.2)),s.addScaledVector(c,3.9),n.push(ub(s,new z(.3*t,.82,.48).normalize(),3,1.05));let l=n.map(e=>{let t=e.index===null?e:e.toNonIndexed();return t.deleteAttribute(`uv`),t}),u=Jh(l,!1);for(let e of new Set([...n,...l]))e.dispose();if(u===null)throw Error(`hand geometry could not be merged`);return u}function fb(){let e=new Zl(3.9,6,9.2,20,1,!1);return e.scale(1,1,.96),e.translate(0,21.1,0),e}var pb=` +void RE_Direct_Skin( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + RE_Direct_Physical( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + float facing = dot( geometryNormal, directLight.direction ); + float scattered = saturate( ( facing + 0.45 ) / 1.45 ) - saturate( facing ); + reflectedLight.directDiffuse += directLight.color * BRDF_Lambert( material.diffuseColor ) * vec3( 1.0, 0.34, 0.2 ) * scattered; + float grazing = 1.0 - saturate( dot( geometryNormal, geometryViewDir ) ); + grazing *= grazing * grazing; + reflectedLight.directSpecular += directLight.color * saturate( facing + 0.15 ) * grazing * 0.05; +} +#undef RE_Direct +#define RE_Direct RE_Direct_Skin +`,mb=.35;function hb(e){e.bumpMap=e.map,e.bumpScale=mb;let t=e.onBeforeCompile,n=Object.hasOwn(e,`customProgramCacheKey`)?e.customProgramCacheKey():`plain`;e.onBeforeCompile=(n,r)=>{t.call(e,n,r),n.fragmentShader=n.fragmentShader.replace(`#include `,`#include \n${pb}`)},e.customProgramCacheKey=()=>`${n}-skin`,e.needsUpdate=!0}var gb={x:7,y:66.1,z:-3},_b={x:8.4,y:39.4,z:-4.7},vb=62,yb=58,bb=72,xb=.78,Sb=.85,Cb=.66,wb=(e,t,n)=>{let r=L.clamp((n-e)/(t-e),0,1);return r*r*(3-2*r)},Tb=L.lerp;function Eb(e,t){let n=e.clone(),r=n.getAttribute(`position`),i=n.getAttribute(`skinIndex`),a=new Map([[t.indexOf(gy.kneeL),t.indexOf(gy.hipL)],[t.indexOf(gy.kneeR),t.indexOf(gy.hipR)]]);for(let e=0;e0&&(t=Math.sign(t)*(l+d*Tb(1,xb,s))),o=u+(o-u)*Tb(1,o>u?Sb:Cb,s),r.setXYZ(e,t,n,o);for(let t=0;t>>0||1,this.blinkIn=this.nextBlink()}nextBlink(){return this.seed=Math.imul(this.seed,1664525)+1013904223>>>0,Ob[0]+this.seed/4294967296*(Ob[1]-Ob[0])}flinch(e,t){let n=Math.min(1,Math.max(0,e));this.wince=Math.max(this.wince,t?.55+.45*n:.3+.4*n),this.gape=Math.max(this.gape,t?.25+.6*n:.5+.5*n)}update(e,t,n,r,i,a){let o=Math.max(0,e);this.wince=Math.max(0,this.wince-this.wince*kb*o-.2*o),this.gape=Math.max(0,this.gape-this.gape*kb*.6*o-.15*o),!t&&!a&&(this.blinkIn-=o,this.blinkIn<=0&&(this.blink=Db,this.blinkIn=this.nextBlink()),this.breath+=o*Ab*Math.PI*2),this.blink=Math.max(0,this.blink-o);let s=this.blink>0?Math.sin(this.blink/Db*Math.PI):0,c=t?.3:.3+.25*Math.sin(this.breath),l=a?1:Math.max(s,this.wince,n?.4:0,i*.55),u=a?.45:Math.max(this.gape,n?.3:0,r*c,i*.35),d=a?0:Math.max(+!!n,this.wince*.8),f=1-Math.exp(-14*o);this.lids=Math.max(s,this.wince,this.lids+(l-this.lids)*f),this.mouth+=(u-this.mouth)*f,this.brow+=(d-this.brow)*f}},Mb={hips:gy.hips,spine:gy.spine,chest:`Spine1_024`,upperChest:gy.chest,neck:`Neck_012`,head:gy.head,clavicleL:`LeftShoulder_09`,shoulderL:gy.shoulderL,elbowL:gy.elbowL,gloveL:gy.gloveL,clavicleR:`RightShoulder_020`,shoulderR:gy.shoulderR,elbowR:gy.elbowR,gloveR:gy.gloveR,hipL:gy.hipL,kneeL:gy.kneeL,ankleL:gy.ankleL,toeL:`LeftToeBase_011`,hipR:gy.hipR,kneeR:gy.kneeR,ankleR:gy.ankleR,toeR:`RightToeBase_022`},Nb=new z,Pb=new z,Fb=new z,Ib=new Ho,Lb=new vo,Rb=new vo,zb=new z,Bb=new z,Vb=new z,Hb=new z,Ub=new z,Wb=new z,Gb=new z,Kb=new z,qb=new z,Jb=new z;function Yb(e,t){return t.setFromMatrixPosition(e.matrixWorld)}function Xb(e,t){return e.matrixWorld.decompose(zb,t,Bb),t}function Zb(e,t,n,r){return Pb.copy(e).normalize(),n===`z`?(Fb.copy(t).addScaledVector(Pb,-t.dot(Pb)),Fb.lengthSq()<1e-8&&Fb.set(0,0,1).addScaledVector(Pb,-Pb.z),Fb.normalize(),Nb.crossVectors(Pb,Fb).normalize()):(Nb.copy(t).addScaledVector(Pb,-t.dot(Pb)),Nb.lengthSq()<1e-8&&Nb.set(1,0,0).addScaledVector(Pb,-Pb.x),Nb.normalize(),Fb.crossVectors(Nb,Pb).normalize()),Ib.makeBasis(Nb,Pb,Fb),r.setFromRotationMatrix(Ib)}var Qb=class{bones;metrics;restLocal=new Map;restPositions=new Map;limb={reached:!1,joint:new z};constructor(e){let t=new Map;e.traverse(e=>{e instanceof il&&t.set(e.name,e)});let n={};for(let[e,r]of Object.entries(Mb)){let i=t.get(r);if(i===void 0)throw Error(`fighter rig missing bone ${r} (${e})`);n[e]=i}this.bones=n,e.updateMatrixWorld(!0);for(let e of t.values())this.restLocal.set(e,e.quaternion.clone()),this.restPositions.set(e,e.position.clone());let r=(e,t)=>Yb(n[e],Vb).distanceTo(Yb(n[t],Hb)),i=Yb(n.hips,Vb).clone(),a=Yb(n.hips.parent??e,Hb).clone(),o=n.hips.position.length(),s=i.distanceTo(a);this.metrics={hipsHeight:i.y,headHeight:Yb(n.head,Vb).y,chestHeight:Yb(n.upperChest,Vb).y,ankleHeight:Yb(n.ankleL,Vb).y,armL:{upper:r(`shoulderL`,`elbowL`),lower:r(`elbowL`,`gloveL`)},armR:{upper:r(`shoulderR`,`elbowR`),lower:r(`elbowR`,`gloveR`)},legL:{upper:r(`hipL`,`kneeL`),lower:r(`kneeL`,`ankleL`)},legR:{upper:r(`hipR`,`kneeR`),lower:r(`kneeR`,`ankleR`)},footLength:r(`ankleL`,`toeL`),unitsPerMeter:s>1e-6?o/s:1}}resetToRest(){for(let[e,t]of this.restLocal){e.quaternion.copy(t);let n=this.restPositions.get(e);n!==void 0&&e.position.copy(n)}}restLocalQuaternion(e){return this.restLocal.get(e)??e.quaternion}restLocalPosition(e){return this.restPositions.get(e)??e.position}position(e,t){return Yb(this.bones[e],t)}setWorldRotation(e,t){let n=e.parent;n===null?e.quaternion.copy(t):(Xb(n,Rb),e.quaternion.copy(Rb.invert().multiply(t)).normalize()),e.updateWorldMatrix(!1,!1)}setWorldFrame(e,t,n,r){this.setWorldRotation(e,Zb(t,n,r,Lb))}setWorldPosition(e,t){let n=e.parent;n===null?e.position.copy(t):(e.position.copy(t),n.worldToLocal(e.position)),e.updateWorldMatrix(!1,!1)}aimAt(e,t,n){if(e.updateWorldMatrix(!1,!1),Yb(e,Vb),Ub.subVectors(t,Vb),Ub.lengthSq()<1e-10)return;Xb(e,Lb);let r=n===`z`?Jb.set(0,0,1):Jb.set(1,0,0);this.setWorldFrame(e,Ub,r.applyQuaternion(Lb),n)}solveLimb(e,t,n,r,i,a,o,s=.01){e.updateWorldMatrix(!1,!1);let c=Yb(e,Vb);Ub.subVectors(r,c);let l=n.upper+n.lower-s,u=L.clamp(Ub.length(),Math.abs(n.upper-n.lower)+.005,l),d=Ub.length()<=l;Ub.lengthSq()<1e-10&&Ub.set(0,-1,0),Ub.normalize(),Wb.copy(i).addScaledVector(Ub,-i.dot(Ub)),Wb.lengthSq()<1e-8&&(Wb.set(0,0,1).addScaledVector(Ub,-Ub.z),Wb.lengthSq()<1e-8&&Wb.set(1,0,0)),Wb.normalize();let f=L.clamp((n.upper*n.upper+u*u-n.lower*n.lower)/(2*n.upper*u),-1,1),p=n.upper*f,m=n.upper*Math.sqrt(Math.max(0,1-f*f));Gb.copy(c).addScaledVector(Ub,p).addScaledVector(Wb,m),Kb.crossVectors(Wb,Ub).multiplyScalar(o).normalize(),qb.copy(Gb).sub(c),this.setWorldFrame(e,qb,Kb,a),t.updateWorldMatrix(!1,!1);let h=Yb(t,Hb);return qb.copy(c).addScaledVector(Ub,u).sub(h),this.setWorldFrame(t,qb,Kb,a),this.limb.reached=d,this.limb.joint.copy(h),this.limb}},$b={x:.1059,y:.0253,z:-.0026},ex=new z(.2018,.081,-.027),tx=new z(-.2018,.081,-.027),nx=(e,t,n)=>new z(e,t,n),rx=(e,t,n)=>{let r=L.clamp((n-e)/Math.max(1e-6,t-e),0,1);return r*r*(3-2*r)},ix=(e,t=1.7)=>L.clamp(e,0,1)**+t,ax=(e,t=2)=>1-(1-L.clamp(e,0,1))**t,ox=new vo,sx=new z,cx=new z,lx=new z,ux=new z,dx=new z,fx=new vo,px=new vo,mx=new Qo,hx=new z(0,1,0),gx=[[`spine`,.25,.2],[`chest`,.55,.5],[`upperChest`,1,1]],_x=class{rig;chestLocal=new z;constructor(e){this.rig=e}toWorld(e,t){return t.copy(e).applyQuaternion(ox).add(sx)}dirToWorld(e,t){return t.copy(e).applyQuaternion(ox)}setYawPitchRoll(e,t,n,r){mx.set(n,t,r,`YXZ`),fx.setFromEuler(mx),px.copy(ox).multiply(fx),this.rig.setWorldRotation(e,px)}apply(e,t){let n=this.rig,r=n.bones;n.resetToRest(),e.updateMatrixWorld(!0),Xb(e,ox),Yb(e,sx);let i=t.torso;this.toWorld(i.hips,cx),n.setWorldPosition(r.hips,cx),this.setYawPitchRoll(r.hips,i.hipsYaw,i.hipsPitch,i.hipsRoll);let a=i.shouldersYaw-i.hipsYaw;for(let e=0;e0&&(Yb(r.head,cx),this.dirToWorld(i.headOffset,lx),cx.add(lx),n.setWorldPosition(r.head,cx)),this.solveArm(`L`,t.handL,t.shrugL),this.solveArm(`R`,t.handR,t.shrugR),this.solveLeg(`L`,t.footL),this.solveLeg(`R`,t.footR)}solveArm(e,t,n){let r=this.rig,i=r.bones,a=e===`L`?i.clavicleL:i.clavicleR,o=e===`L`?i.shoulderL:i.shoulderR,s=e===`L`?i.elbowL:i.elbowR,c=e===`L`?i.gloveL:i.gloveR,l=e===`L`?r.metrics.armL:r.metrics.armR,u=e===`L`?ex:tx;this.chestLocal.copy(u),this.chestLocal.z+=n*.06,this.chestLocal.y+=n*.035,this.chestLocal.x*=1-n*.08,ux.copy(this.chestLocal).multiplyScalar(r.metrics.unitsPerMeter),i.upperChest.localToWorld(ux),r.aimAt(a,ux,`z`),o.updateWorldMatrix(!1,!1),this.toWorld(t.position,cx),this.dirToWorld(t.pole,lx),r.solveLimb(o,s,l,cx,lx,`z`,e===`L`?1:-1,.012),c.updateWorldMatrix(!1,!1),this.dirToWorld(t.knuckles,ux),this.dirToWorld(t.palm,dx),r.setWorldFrame(c,ux,dx,`z`)}solveLeg(e,t){let n=this.rig,r=n.bones,i=e===`L`?r.hipL:r.hipR,a=e===`L`?r.kneeL:r.kneeR,o=e===`L`?r.ankleL:r.ankleR,s=e===`L`?r.toeL:r.toeR,c=e===`L`?n.metrics.legL:n.metrics.legR;this.toWorld(t.position,cx),this.dirToWorld(t.toe,ux).normalize();let l=n.metrics.footLength;dx.copy(ux).multiplyScalar(l).addScaledVector(hx,-n.metrics.ankleHeight).normalize(),t.heel!==0&&(cx.addScaledVector(dx,l),fx.setFromAxisAngle(lx.crossVectors(ux,hx).normalize(),-t.heel),dx.applyQuaternion(fx),cx.addScaledVector(dx,-l)),this.dirToWorld(t.pole,lx),n.solveLimb(i,a,c,cx,lx,`x`,-1,.02),o.updateWorldMatrix(!1,!1),n.setWorldFrame(o,dx,hx,`z`),s.updateWorldMatrix(!1,!1),n.setWorldFrame(s,ux,hx,`z`)}},vx={bladeYaw:-.68,shoulderBlade:1.18,hipsHeight:.875,leadFoot:nx(.13,0,.2),rearFoot:nx(-.15,0,-.25),leadToe:nx(-.26,0,.97),rearToe:nx(-.68,0,.73),leadHeel:.05,rearHeel:.3,lean:.09,hunch:.15,chinTuck:.24,leadShrug:.45,rearShrug:.25,relaxedLead:nx(.12,-.15,.44),relaxedRear:nx(-.07,-.11,.18),tightLead:nx(.13,-.11,.29),tightRear:nx(-.08,-.1,.15),guardHighLead:nx(.1,-.12,.33),guardHighRear:nx(-.1,-.11,.24),guardLowLead:nx(.11,-.3,.27),guardLowRear:nx(-.11,-.3,.25),guardHighLeadPole:nx(.15,-1,.35),guardHighRearPole:nx(-.15,-1,.35),guardLowLeadPole:nx(.3,-1,-.1),guardLowRearPole:nx(-.3,-1,-.1),guardKnuckles:nx(-.05,1,.15),guardPalm:nx(-.6,0,-.8),leadPole:nx(.3,-1,.1),rearPole:nx(-.35,-1,-.15),leadKnuckles:nx(.05,.75,.65),leadPalm:nx(-.9,.15,-.35),rearKnuckles:nx(-.05,.85,.5),rearPalm:nx(.95,.1,-.25)},yx=e=>({rise:0,length:1,width:1,weight:0,lean:0,lead:nx(0,0,0),rear:nx(0,0,0),flare:0,shrug:0,shell:0,spring:1,tempo:1,rock:1,bob:1,heel:1,paw:1,...e}),bx={balanced:yx({}),boxer:yx({rise:.022,width:.9,length:1.04,lean:-.03,lead:nx(0,.02,.07),flare:-.1,spring:.7,tempo:1.25,rock:1.7,bob:.8,heel:1.3,paw:1.4}),slugger:yx({rise:-.015,width:1.22,length:.94,weight:-.035,lead:nx(.04,-.07,-.05),rear:nx(-.04,-.06,0),flare:.3,shrug:-.15,spring:.3,tempo:.8,rock:.5,bob:.6,heel:.3,paw:.5}),swarmer:yx({rise:-.045,width:1.06,length:.9,weight:.035,lean:.06,lead:nx(-.03,.05,-.14),rear:nx(0,.03,-.02),flare:-.3,spring:.9,tempo:1.1,rock:.8,bob:2.6,paw:.3}),counter_puncher:yx({rise:.005,width:.94,length:1.05,weight:-.04,lean:-.05,lead:nx(-.11,-.3,-.2),rear:nx(.01,.01,-.02),shrug:.45,shell:1,spring:.3,tempo:.8,rock:.4,bob:.4,heel:.8,paw:.2})};function xx(e,t,n=new z){return n.set(e.x*t,e.y,e.z)}var U={pelvis:0,hipL:1,hipR:2,belly:3,chest:4,upper:5,neck:6,shoulderL:7,shoulderR:8,head:9,crown:10,face:11,elbowL:12,wristL:13,fistL:14,elbowR:15,wristR:16,fistR:17,kneeL:18,ankleL:19,toeL:20,heelL:21,kneeR:22,ankleR:23,toeR:24,heelR:25},Sx=[9,4,4,2,10,7,2,3.5,3.5,2.5,1.5,1,1.6,1,1,1.6,1,1,3.6,1.6,.4,.6,3.6,1.6,.4,.6],Cx=[.12,.09,.09,.11,.14,.13,.06,.07,.07,.09,.085,.055,.05,.065,.08,.05,.065,.08,.06,.05,.035,.04,.06,.05,.035,.04],wx=.12,Tx=.16,Ex=.09,Dx=.06,Ox=.11,kx=[[U.pelvis,U.hipL],[U.pelvis,U.hipR],[U.hipL,U.hipR],[U.belly,U.hipL],[U.belly,U.hipR],[U.belly,U.pelvis],[U.pelvis,U.chest],[U.chest,U.upper],[U.upper,U.neck],[U.upper,U.shoulderL],[U.upper,U.shoulderR],[U.neck,U.shoulderL],[U.neck,U.shoulderR],[U.shoulderL,U.shoulderR],[U.neck,U.head],[U.head,U.crown],[U.head,U.face],[U.crown,U.face],[U.shoulderL,U.elbowL],[U.elbowL,U.wristL],[U.wristL,U.fistL],[U.shoulderR,U.elbowR],[U.elbowR,U.wristR],[U.wristR,U.fistR],[U.hipL,U.kneeL],[U.kneeL,U.ankleL],[U.ankleL,U.toeL],[U.ankleL,U.heelL],[U.toeL,U.heelL],[U.hipR,U.kneeR],[U.kneeR,U.ankleR],[U.ankleR,U.toeR],[U.ankleR,U.heelR],[U.toeR,U.heelR]],Ax=[[U.hipL,U.shoulderL,.8,1.05],[U.hipR,U.shoulderR,.8,1.05],[U.hipL,U.shoulderR,.84,1.08],[U.hipR,U.shoulderL,.84,1.08],[U.belly,U.upper,.7,1.06],[U.pelvis,U.upper,.86,1],[U.hipL,U.chest,.84,1.08],[U.hipR,U.chest,.84,1.08],[U.shoulderL,U.face,.76,1.2],[U.shoulderR,U.face,.76,1.2],[U.kneeL,U.hipR,.8,1.3],[U.kneeR,U.hipL,.8,1.3],[U.kneeL,U.belly,.5,1.12],[U.kneeR,U.belly,.5,1.12]],jx=8,Mx=[[U.kneeL,U.kneeR,.13],[U.ankleL,U.ankleR,.11],[U.kneeL,U.ankleR,.1],[U.kneeR,U.ankleL,.1],[U.hipL,U.ankleL,.2],[U.hipR,U.ankleR,.2],[U.shoulderL,U.wristL,.14],[U.shoulderR,U.wristR,.14],[U.face,U.chest,.2],[U.crown,U.chest,.24],[U.kneeL,U.upper,.3],[U.kneeR,U.upper,.3]],Nx=[U.elbowL,U.wristL,U.fistL,U.elbowR,U.wristR,U.fistR],Px=[.7,.6,.6,.7,.9,1,1,1,1,1,1,1,.9,.8,.8,.9,.8,.8,.35,.1,0,0,.35,.1,0,0],Fx=[[U.pelvis,U.chest,.12],[U.chest,U.upper,.13]],Ix=Int32Array.from(kx.flat()),Lx=Int32Array.from(Ax.flatMap(([e,t])=>[e,t])),Rx=Int32Array.from(Mx.flatMap(([e,t])=>[e,t])),zx=Float64Array.from(Mx.map(([,,e])=>e)),Bx=Int32Array.from(Fx.flatMap(([e,t])=>[e,t])),Vx=Float64Array.from(Fx.map(([,,e])=>e)),Hx=Float64Array.from([U.head,1,U.crown,.9,U.face,1,U.neck,.45]),Ux=Float64Array.from([U.belly,1,U.chest,.6,U.pelvis,.4,U.hipL,.3,U.hipR,.3]),Wx=[U.head,U.crown,U.face],Gx=[U.crown,U.face],Kx=[[U.toeL,U.heelL],[U.toeR,U.heelR]],qx=[[U.heelL],[U.heelR]],Jx=[U.head,U.crown,U.face],Yx=[U.fistL],Xx=[U.fistR],Zx=1/120,Qx=12,$x=9.81,eS=.998,tS=.5,nS=.03,rS=.35,iS=.12,aS=[U.pelvis,U.hipL,U.hipR,U.belly,U.chest,U.upper],oS=[U.upper,U.neck,U.shoulderL,U.shoulderR,U.head,U.crown,U.face,U.elbowL,U.wristL,U.fistL,U.elbowR,U.wristR,U.fistR],sS=[U.pelvis,U.hipL,U.hipR,U.belly,U.kneeL,U.ankleL,U.toeL,U.heelL,U.kneeR,U.ankleR,U.toeR,U.heelR],cS=40*Math.PI/180,lS=[[U.kneeL,U.ankleL,U.toeL,U.heelL],[U.kneeR,U.ankleR,U.toeR,U.heelR]],uS=[[U.ankleL,U.toeL,U.heelL],[U.ankleR,U.toeR,U.heelR]],dS=.08,fS=.35,pS=new Set(aS),mS=f_+.45,hS=.24,gS=1.75,_S=.012,vS=1,yS=.35,bS=.15,xS=1.1,SS=.4,CS=1.2,wS=1200,TS=3,ES=7,DS=.08,OS=.97,kS=2.55,AS=.5,jS=30*Math.PI/180,MS=32*Math.PI/180,NS=28*Math.PI/180,PS=35*Math.PI/180,FS=20*Math.PI/180,IS=.5,LS=.01,RS=.04,zS=.4,BS=.02,VS=.25,HS={timber:{knee:.12,spine:.2,seconds:.55},crumple:{knee:kS,spine:1,seconds:0},sag:{knee:.55,spine:.6,seconds:.3},fold:{knee:.9,spine:1,seconds:.5}},US=2.5,WS=35*Math.PI/180,GS=50*Math.PI/180,KS=135*Math.PI/180,qS=[[U.kneeL,U.ankleL,U.toeL,GS,KS],[U.kneeR,U.ankleR,U.toeR,GS,KS],[U.elbowL,U.wristL,U.fistL,0,WS],[U.elbowR,U.wristR,U.fistR,0,WS]],JS=Int32Array.from(qS.flatMap(([e,,t])=>[e,t]));function YS(e,t,n,r){if(t===`body`)return`fold`;if(n<90)return`sag`;let i=Math.abs(Math.floor(r))%3;return e===`hook`?i===0?`timber`:`crumple`:i===0?`crumple`:`timber`}var XS=(e,t,n)=>n.set(e[t*3],e[t*3+1],e[t*3+2]),ZS=e=>e-Math.round(e/(Math.PI*2))*Math.PI*2,QS=(e,t,n)=>{e[t*3]=n.x,e[t*3+1]=n.y,e[t*3+2]=n.z},$S=class{position=new Float64Array(78);previous=new Float64Array(78);before=new Float64Array(78);invMass=new Float64Array(26);rigidLength=new Float64Array(kx.length);rangeMin=new Float64Array(Ax.length);rangeMax=new Float64Array(Ax.length);restRange=new Float64Array(Ax.length);rangeStart=new Float64Array(Ax.length);kneeStart=new Float64Array(2);footSign=new Float64Array(2);turnAxis=new z;turnQuaternion=new vo;turnPoint=new z;angleRanges=new Float64Array(qS.length*2);elbowAxes=new Float64Array(6);kneeAxes=new Float64Array(6);hingeStart=new Float64Array(24);hingeNow=new Float64Array(24);swing=new vo;local=new z;localAxis=new z;ropeLines=new Float64Array(4);style=`crumple`;steps=0;stillSeconds=0;torsoStillSeconds=0;fallSeconds=0;landedSeconds=-1;asleep=!1;obstacleActive=!1;obstacleX=0;obstacleZ=0;obstacleTrack=null;obstacleTrackLive=!1;pull=null;pullShare=0;trackObstacle(e,t){this.obstacleTrack=e,this.obstacleTrackLive=e!==null&&!t}a=new z;b=new z;c=new z;d=new z;e=new z;fx=new z;fy=new z;fz=new z;gx=new z;gy=new z;gz=new z;pivot=new z;segmentA=new z;segmentB=new z;constructor(){for(let e=0;e<26;e+=1)this.invMass[e]=1/Sx[e]}calibrate(e){for(let[t,[n,r]]of Ax.entries())this.restRange[t]=this.distance(e,n,r)}start(e,t,n){this.position.set(e),this.before.set(e);for(let n=0;n<78;n+=1)this.previous[n]=e[n]-t[n]*Zx;for(let[t,[n,r]]of kx.entries())this.rigidLength[t]=this.distance(e,n,r);for(let[t,[n,r,i,a,o]]of qS.entries()){let s=this.distance(e,n,r),c=this.distance(e,r,i),l=this.distance(e,n,i),u=e=>Math.sqrt(s*s+c*c+2*s*c*Math.cos(e));this.angleRanges[t*2]=Math.min(u(o),l),this.angleRanges[t*2+1]=Math.max(u(a),l)}for(let[t,[n,r,i,a]]of Ax.entries()){let o=this.distance(e,n,r),s=this.restRange[t]>0?this.restRange[t]:o;this.rangeMin[t]=Math.min(s*i,o*.98),this.rangeMax[t]=Math.max(s*a,o*1.02),this.rangeStart[t]=o}this.style=n,this.steps=0,this.stillSeconds=0,this.torsoStillSeconds=0,this.fallSeconds=0,this.landedSeconds=-1,this.asleep=!1,this.upperFrame(this.position),this.pelvisFrame(this.position);for(let e of[0,1]){this.startHinge(this.elbowAxes,e,e===0?U.shoulderL:U.shoulderR,e===0?U.elbowL:U.elbowR,e===0?U.wristL:U.wristR,this.gx,-1),this.startHinge(this.kneeAxes,e,e===0?U.hipL:U.hipR,e===0?U.kneeL:U.kneeR,e===0?U.ankleL:U.ankleR,this.fx,1),this.storeHingeStart(e,e===0?U.hipL:U.hipR,e===0?U.kneeL:U.kneeR,this.kneeAxes,this.fx,this.fy,this.fz),this.storeHingeStart(2+e,e===0?U.shoulderL:U.shoulderR,e===0?U.elbowL:U.elbowR,this.elbowAxes,this.gx,this.gy,this.gz);let t=this.dir(e===0?U.hipL:U.hipR,e===0?U.kneeL:U.kneeR,this.a),n=this.dir(e===0?U.kneeL:U.kneeR,e===0?U.ankleL:U.ankleR,this.b);this.kneeStart[e]=Math.acos(Math.min(1,Math.max(-1,t.dot(n))));let r=this.c.set(this.kneeAxes[e*3],this.kneeAxes[e*3+1],this.kneeAxes[e*3+2]);this.footSign[e]=this.footNormal(e,this.d).dot(r)>=0?1:-1}for(let t=0;t<4;t+=1){let n=t<2?0:2,r=t%2==0?1:-1,i=0;for(let t of aS)i=Math.max(i,r*e[t*3+n]+Cx[t]);this.ropeLines[t]=Math.max(g_,i+.04)}}startHinge(e,t,n,r,i,a,o){let s=this.dir(n,r,this.a),c=this.dir(r,i,this.b),l=this.c.crossVectors(s,c);l.length()<.2&&l.copy(a).multiplyScalar(o),l.addScaledVector(s,-l.dot(s)),l.lengthSq()<1e-8&&l.copy(a).multiplyScalar(o).addScaledVector(s,-o*a.dot(s)),l.normalize(),e[t*3]=l.x,e[t*3+1]=l.y,e[t*3+2]=l.z}storeHingeStart(e,t,n,r,i,a,o){let s=e%2,c=this.dir(t,n,this.a),l=this.b.set(r[s*3],r[s*3+1],r[s*3+2]),u=e*6;this.hingeStart[u]=c.dot(i),this.hingeStart[u+1]=c.dot(a),this.hingeStart[u+2]=c.dot(o),this.hingeStart[u+3]=l.dot(i),this.hingeStart[u+4]=l.dot(a),this.hingeStart[u+5]=l.dot(o);for(let e=0;e<6;e+=1)this.hingeNow[u+e]=this.hingeStart[u+e]}hingeAxis(e,t,n,r,i,a){let o=e*6,s=this.hingeNow;return this.local.set(t.dot(n),t.dot(r),t.dot(i)).normalize(),this.localAxis.set(s[o],s[o+1],s[o+2]),this.swing.setFromUnitVectors(this.localAxis,this.local),this.localAxis.set(s[o+3],s[o+4],s[o+5]).applyQuaternion(this.swing),a.copy(n).multiplyScalar(this.localAxis.x).addScaledVector(r,this.localAxis.y).addScaledVector(i,this.localAxis.z),a.addScaledVector(t,-a.dot(t)).normalize()}carryHinges(){this.pelvisFrame(this.position),this.upperFrame(this.position);for(let e=0;e<4;e+=1){let t=e%2,n=e<2,r=n?t===0?U.hipL:U.hipR:t===0?U.shoulderL:U.shoulderR,i=n?t===0?U.kneeL:U.kneeR:t===0?U.elbowL:U.elbowR,a=n?this.fx:this.gx,o=n?this.fy:this.gy,s=n?this.fz:this.gz,c=this.dir(r,i,this.a),l=this.hingeAxis(e,c,a,o,s,this.b),u=e*6;this.hingeNow[u]=c.dot(a),this.hingeNow[u+1]=c.dot(o),this.hingeNow[u+2]=c.dot(s),this.hingeNow[u+3]=l.dot(a),this.hingeNow[u+4]=l.dot(o),this.hingeNow[u+5]=l.dot(s)}}get holding(){return this.steps*Zx0&&(this.landedSeconds=0)}setLimp(e,t){for(let n=0;n0){let e=Math.min(this.steps,t.steps-1)*3;this.obstacleActive=t.data[e]===1,this.obstacleX=t.data[e+1],this.obstacleZ=t.data[e+2]}let n=Zx,r=this.position,i=this.previous,a=this.landedSeconds<0?eS:eS+-.02300000000000002*Math.min(1,this.landedSeconds/SS);this.before.set(r);for(let e=0;e<26;e+=1)for(let t=0;t<3;t+=1){let o=e*3+t,s=r[o],c=(s-i[o])*a;i[o]=s,r[o]=s+c-(t===1?$x*n*n:0)}let o=this.pull;if(o!==null)for(let e=0;e<26;e+=1){let t=(o[e*3]-r[e*3])*this.pullShare,n=(o[e*3+1]-r[e*3+1])*this.pullShare,a=(o[e*3+2]-r[e*3+2])*this.pullShare,s=Math.sqrt(t*t+n*n+a*a),c=this.pullShare<1&&s>dC?dC/s:1;for(let o=0;o<3;o+=1){let s=(o===0?t:o===1?n:a)*c;r[e*3+o]=r[e*3+o]+s,i[e*3+o]=i[e*3+o]+s}}this.carryHinges();for(let e=0;e=0&&o===null&&this.toppleLegs(),this.applyFriction(),this.limitSpeed(),this.steps+=1;let s=0,c=0;for(let e=0;e<26;e+=1){let t=r[e*3]-i[e*3],a=r[e*3+1]-i[e*3+1],o=r[e*3+2]-i[e*3+2],l=Math.sqrt(t*t+a*a+o*o)/n;s=Math.max(s,l),pS.has(e)&&(c=Math.max(c,l))}this.stillSeconds=s<_S?this.stillSeconds+n:0,this.fallSeconds+=n,this.landedSeconds>=0?this.landedSeconds+=n:(this.torsoStillSeconds=c=bS||this.fallSeconds>=xS)&&(this.landedSeconds=0)),o===null&&(this.stillSeconds>=vS||this.landedSeconds>=CS)&&(this.asleep=!0)}solveRigid(){for(let e=0;er?r:c;if(l===c)return;let u=this.invMass[e],d=this.invMass[t],f=u+d;if(f<=0)return;let p=(c-l)/(c*f);i[e*3]=i[e*3]+a*p*u,i[e*3+1]=i[e*3+1]+o*p*u,i[e*3+2]=i[e*3+2]+s*p*u,i[t*3]=i[t*3]-a*p*d,i[t*3+1]=i[t*3+1]-o*p*d,i[t*3+2]=i[t*3+2]-s*p*d}solveKnees(){this.pelvisFrame(this.position);for(let e=0;e<2;e+=1){let t=e===0?U.hipL:U.hipR,n=e===0?U.kneeL:U.kneeR,r=this.dir(t,n,this.a),i=this.hingeAxis(e,r,this.fx,this.fy,this.fz,this.b),a=this.holding?Math.min(kS,this.kneeStart[e]+HS[this.style].knee):kS;this.hinge(n,e===0?U.ankleL:U.ankleR,r,i,-.12,a)}}solveElbows(){this.upperFrame(this.position);for(let e=0;e<2;e+=1){let t=e===0?U.shoulderL:U.shoulderR,n=e===0?U.elbowL:U.elbowR,r=this.dir(t,n,this.a),i=this.hingeAxis(2+e,r,this.gx,this.gy,this.gz,this.b);this.hinge(n,e===0?U.wristL:U.wristR,r,i,-.12,US)}}toppleLegs(){let e=this.position;for(let t=0;t<2;t+=1){let n=t===0?U.hipL:U.hipR,r=t===0?U.kneeL:U.kneeR,i=t===0?U.ankleL:U.ankleR,a=this.dir(n,r,this.a);if(a.y>fS){let i=this.dir(U.hipR,U.hipL,this.b),o=this.c.crossVectors(i,this.d.set(e[r*3]-e[n*3],e[r*3+1]-e[n*3+1],e[r*3+2]-e[n*3+2])).y>0?-1:1;this.rotateAbout(lS[t],n,i,o*dS*(a.y-fS))}let o=this.dir(r,i,this.a);if(o.y>fS){let n=this.kneeAxis(t===0?0:1,e,this.b),a=this.c.crossVectors(n,this.d.set(e[i*3]-e[r*3],e[i*3+1]-e[r*3+1],e[i*3+2]-e[r*3+2])).y>0?-1:1;this.rotateAbout(uS[t],r,n,a*dS*(o.y-fS))}}}solveTwist(){let e=this.dir(U.pelvis,U.upper,this.e),t=this.dir(U.hipR,U.hipL,this.a);t.addScaledVector(e,-t.dot(e));let n=this.dir(U.shoulderR,U.shoulderL,this.c);if(n.addScaledVector(e,-n.dot(e)),t.lengthSq()<1e-8||n.lengthSq()<1e-8)return;let r=Math.atan2(this.d.crossVectors(t,n).dot(e),t.dot(n)),i=Math.abs(r)-cS;if(i<=0)return;let a=this.spinInertia(oS,e),o=this.spinInertia(sS,e),s=Math.sign(r)*i*zS;this.rotateAbout(oS,U.chest,e,-s*(o/(a+o))),this.rotateAbout(sS,U.chest,e,s*(a/(a+o)))}spinInertia(e,t){let n=this.position,r=1e-6;for(let i=0;iMath.abs(p)+1e-6){let n=Math.atan2(r,u),a=Math.acos(p/i),c=ZS(n-a),l=ZS(n+a),d=(Math.abs(c)<=Math.abs(l)?c:l)*s;this.rotateAbout(qx[t],o,e,Math.min(RS,Math.max(-.04,d)))}}let m=this.dir(i,a,this.a),h=this.hingeAxis(t,m,this.fx,this.fy,this.fz,this.b),g=this.footNormal(t===0?0:1,this.d).multiplyScalar(this.footSign[t]);if(h.addScaledVector(c,-h.dot(c)),g.addScaledVector(c,-g.dot(c)),h.lengthSq()<.09||g.lengthSq()<.09)continue;h.normalize(),g.normalize();let _=Math.atan2(this.e.crossVectors(h,g).dot(c),h.dot(g)),v=Math.min(NS,Math.max(-NS,_));v!==_&&this.rotateAbout(Kx[t],o,c,Math.min(LS,Math.max(-.01,(v-_)*s)))}}footNormal(e,t){let n=this.position,r=e===0?U.ankleL:U.ankleR,i=e===0?U.toeL:U.toeR,a=e===0?U.heelL:U.heelR;return t.set(n[i*3]-n[a*3],n[i*3+1]-n[a*3+1],n[i*3+2]-n[a*3+2]),this.turnPoint.set(n[r*3]-n[a*3],n[r*3+1]-n[a*3+1],n[r*3+2]-n[a*3+2]),t.cross(this.turnPoint).normalize()}cone(e,t,n,r,i,a){let o=this.dir(t,n,this.turnPoint),s=Math.acos(Math.min(1,Math.max(-1,o.dot(e))));if(s<=r)return;let c=this.turnAxis.crossVectors(o,e);if(c.lengthSq()<1e-10)return;c.normalize();let l=this.pressed(a,i,c)?BS*VS:BS;this.rotateAbout(a,i,c,Math.min(l,(s-r)*zS))}pressed(e,t,n){let r=this.position;for(let i=0;iCx[a]+.005)&&n.z*(r[a*3]-r[t*3])-n.x*(r[a*3+2]-r[t*3+2])<-1e-9)return!0}return!1}rotateAbout(e,t,n,r){let i=this.position;this.turnQuaternion.setFromAxisAngle(n,r);let a=i[t*3],o=i[t*3+1],s=i[t*3+2];for(let t=0;t=u||l<1e-6||(o.addScaledVector(c,(u-l)/l),QS(e,n,o))}}}closestOnSegment(e,t,n,r){let i=this.segmentA.subVectors(t,e),a=i.lengthSq(),o=a<1e-12?0:Math.min(1,Math.max(0,this.segmentB.subVectors(n,e).dot(i)/a));return r.copy(e).addScaledVector(i,o)}solveEnvironment(){let e=this.position;for(let t=0;t<26;t+=1){let n=Cx[t],r=e[t*3],i=e[t*3+1],a=e[t*3+2];i=p||f<1e-9)continue;let m=(p-f)/f*rS,h=u*m,g=d*m;t?r+=s*h:a+=s*h,i+=g}let u=o?c-n*.6:mS;s*(t?r:a)>u&&(t?r=s*u:a=s*u)}for(let e=0;e<4;e+=1){let t=e<2?-g_:g_,o=e%2==0?-g_:g_,s=r-t,c=a-o,l=Math.sqrt(s*s+c*c),u=iS+n;l>=u||l<1e-9||i>1.45||(r=t+s/l*u,a=o+c/l*u)}if(this.obstacleActive&&i1e-9&&(r=this.obstacleX+e/i*o,a=this.obstacleZ+t/i*o)}e[t*3]=r,e[t*3+1]=i,e[t*3+2]=a}}limitSpeed(){let e=this.position,t=this.previous,n=ES*Zx,r=DS*Zx;for(let i=0;i<26;i+=1){let a=e[i*3]-t[i*3],o=e[i*3+1]-t[i*3+1],s=e[i*3+2]-t[i*3+2],c=Math.sqrt(a*a+o*o+s*s);if(c>n||cn?n/c:OS;t[i*3]=e[i*3]-a*r,t[i*3+1]=e[i*3+1]-o*r,t[i*3+2]=e[i*3+2]-s*r}}}applyFriction(){let e=this.position,t=this.previous;for(let n=0;n<26;n+=1)e[n*3+1]>Cx[n]+.004||(t[n*3]=t[n*3]+(e[n*3]-t[n*3])*tS,t[n*3+2]=t[n*3+2]+(e[n*3+2]-t[n*3+2])*tS,t[n*3+1]>e[n*3+1]&&(t[n*3+1]=e[n*3+1]))}settle(e=4,t){let n=this.steps+Math.ceil(e/Zx);for(;!this.asleep&&this.steps1e-9?n.divideScalar(i):n.set(0,1,0)}pelvisFrame(e){this.fx.set(e[U.hipL*3]-e[U.hipR*3],e[U.hipL*3+1]-e[U.hipR*3+1],e[U.hipL*3+2]-e[U.hipR*3+2]).normalize(),this.fz.set(e[U.belly*3]-(e[U.hipL*3]+e[U.hipR*3])/2,e[U.belly*3+1]-(e[U.hipL*3+1]+e[U.hipR*3+1])/2,e[U.belly*3+2]-(e[U.hipL*3+2]+e[U.hipR*3+2])/2),this.fz.addScaledVector(this.fx,-this.fz.dot(this.fx)).normalize(),this.fy.crossVectors(this.fz,this.fx).normalize()}upperFrame(e){this.gx.set(e[U.shoulderL*3]-e[U.shoulderR*3],e[U.shoulderL*3+1]-e[U.shoulderR*3+1],e[U.shoulderL*3+2]-e[U.shoulderR*3+2]).normalize(),this.gy.set(e[U.neck*3]-e[U.upper*3],e[U.neck*3+1]-e[U.upper*3+1],e[U.neck*3+2]-e[U.upper*3+2]),this.gy.addScaledVector(this.gx,-this.gy.dot(this.gx)).normalize(),this.gz.crossVectors(this.gx,this.gy).normalize()}pelvisForward(e){return this.pelvisFrame(this.position),e.copy(this.fz)}};function eC(e,t){e.setLimp(Jx,!!(t&1)),e.setLimp(Yx,!!(t&2)),e.setLimp(Xx,!!(t&4))}var tC=[`hips`,`spine`,`chest`,`upperChest`,`neck`,`head`,`shoulderL`,`elbowL`,`gloveL`,`shoulderR`,`elbowR`,`gloveR`,`hipL`,`kneeL`,`ankleL`,`hipR`,`kneeR`,`ankleR`],nC=tC.map(e=>({shoulderL:[U.shoulderL,U.elbowL],elbowL:[U.elbowL,U.wristL],gloveL:[U.wristL,U.fistL],shoulderR:[U.shoulderR,U.elbowR],elbowR:[U.elbowR,U.wristR],gloveR:[U.wristR,U.fistR],hipL:[U.hipL,U.kneeL],kneeL:[U.kneeL,U.ankleL],hipR:[U.hipR,U.kneeR],kneeR:[U.kneeR,U.ankleR]})[e]??null),rC=tC.map(e=>({chest:U.chest,shoulderL:U.shoulderL,shoulderR:U.shoulderR,hipL:U.hipL,hipR:U.hipR})[e]??-1),iC=.1,aC=.35,oC=.6,sC=10,cC=.35,lC=6,uC=.25,dC=.05,fC=.3,pC=6;function mC(e){let t=e.lateral;if(e.target===`body`){let n=Math.min(2.6,Math.max(1,.9+e.amount/90));return{x:.3*t*n,y:-.05*n,z:-n,driveX:.1*t*n,driveY:-.2*n,driveZ:.45*n,twist:0}}let n=Math.min(3.2,Math.max(1.4,1.2+e.amount/70)),r=n/3.2;switch(e.punchClass){case`hook`:return{x:t*n,y:.05*n,z:-.25*n,driveX:.55*t*r,driveY:-.1*r,driveZ:.85*r,twist:.6};case`uppercut`:return{x:0,y:.8*n,z:-.65*n,driveX:0,driveY:.25*r,driveZ:-1.1*r,twist:.4};case`straight`:return{x:.12*t*n,y:.1*n,z:-n,driveX:.1*t*r,driveY:0,driveZ:-1.25*r,twist:.3};default:return{x:.12*t*n,y:.1*n,z:-.85*n,driveX:.08*t*r,driveY:0,driveZ:-1*r,twist:.2}}}var hC=class{rig;root;body=new $S;ahead=new $S;aheadOf=null;aheadBlows=0;ragdolling=!1;age=0;accumulator=0;sampleNow=new Float64Array(78);sampleBefore=new Float64Array(78);sampleRoot=new z;sampleSeconds=0;samples=0;drawn=new Float64Array(78);velocities=new Float64Array(78);offsets=tC.map(()=>new vo);fromLocal=tC.map(()=>new vo);fromPositions=tC.map(()=>new z);fromHips=new z;riseLocal=tC.map(()=>new vo);riseHips=new z;riseTurns=tC.map(()=>new vo);solvedTurns=tC.map(()=>new vo);rootTurn=new vo;turn=new vo;riseCaptured=!1;lastFall=null;recordPositions=new Float64Array(78);recordVelocities=new Float64Array(78);recordOffsets=tC.map(()=>new vo);recordImpulses=[];recordObstacles={data:new Float64Array(wS*3),steps:0};recordLosses=[];recordRest={position:new Float64Array(78),previous:new Float64Array(78),steps:-1};replaying=null;followTargets=new Float64Array(78);followOffsets=tC.map(()=>new vo);blendedOffsets=tC.map(()=>new vo);following=!1;followAge=0;primed=!1;pending=null;lost=0;clock=0;bones;frame=new vo;world=new vo;axisX=new z;axisY=new z;axisZ=new z;hint=new z;point=new z;other=new z;pelvisX=new z;pelvisY=new z;upperX=new z;headX=new z;kneeAxes=[new z(1,0,0),new z(1,0,0)];elbowAxes=[new z,new z];spineLength;tiltJoint=new z;tiltChest=new z;tiltAcross=new z;tiltTurn=new vo;constructor(e,t){this.rig=e,this.root=t,this.bones=tC.map(t=>e.bones[t]);let n=new Map;t.traverse(e=>{e instanceof il&&n.set(e,[e.quaternion.clone(),e.position.clone()])}),e.resetToRest(),t.updateMatrixWorld(!0);let r=new Float64Array(78);this.read(r),this.body.calibrate(r),this.ahead.calibrate(r),this.spineLength=this.tiltJoint.setFromMatrixPosition(e.bones.spine.matrixWorld).distanceTo(this.tiltChest.setFromMatrixPosition(e.bones.chest.matrixWorld));for(let[e,[t,r]]of n)e.quaternion.copy(t),e.position.copy(r);t.updateMatrixWorld(!0)}get active(){return this.ragdolling}get record(){return this.lastFall}sample(e){this.ragdolling||e<=0||(this.sampleBefore.set(this.sampleNow),this.read(this.sampleNow),this.sampleRoot.setFromMatrixPosition(this.root.matrixWorld),this.sampleSeconds=e,this.samples=Math.min(2,this.samples+1))}tick(e){this.clock+=e}takeBlow(e,t,n,r,i){let a={step:0,x:e.x,y:e.y,z:e.z,driveX:t.x,driveY:t.y,driveZ:t.z,target:n,twist:r,style:i};if(this.ragdolling){if(this.age>aC)return;if(this.replaying!==null){this.replaying.impulses.length===0&&this.replaying.impulses.push({...a,step:this.body.steps});return}this.lastFall?.impulses.push(this.body.impulse(a))}else this.pending={...a,at:this.clock}}dropBlow(){this.pending=null}twitch(e,t,n){this.ragdolling&&!this.following&&(this.body.twitch(e,t,n),this.replaying===null&&this.lastFall!==null&&(this.lastFall.rest.steps=-1))}prime(){this.primed=this.lastFall!==null}forget(){this.lastFall=null,this.primed=!1}start(e){let t=this.primed?this.lastFall:null;if(this.primed=!1,this.root.updateMatrixWorld(!0),this.captureLocals(this.fromLocal,this.fromHips),t!==null){this.replaying=t,this.body.start(t.positions,t.velocities,t.style),this.body.trackObstacle(t.obstacles,!0),this.replayLosses(this.body,t,0);for(let[e,n]of t.offsets.entries())this.offsets[e].copy(n);this.aheadOf=null,t.rest.steps<0&&this.runAhead(t,0)}else{this.replaying=null;let t=this.point.setFromMatrixPosition(this.root.matrixWorld).sub(this.sampleRoot),n=this.samples>0&&t.lengthSq()<=cC*cC;if(!n)this.read(this.sampleNow);else for(let e=0;e<26;e+=1)for(let n of[this.sampleNow,this.sampleBefore])n[e*3]=n[e*3]+t.x,n[e*3+1]=n[e*3+1]+t.y,n[e*3+2]=n[e*3+2]+t.z;let r=n&&this.samples>=2&&this.sampleSeconds>0?this.sampleSeconds:0;this.samples=0;for(let e=0;e<78;e+=1){let t=r>0?(this.sampleNow[e]-this.sampleBefore[e])/r:0;this.velocities[e]=Math.max(-3,Math.min(TS,t))}let i=this.rig.bones.neck,a=this.rig.bones.head;this.point.copy(this.rig.restLocalPosition(a)).applyMatrix4(i.matrixWorld).sub(this.other.setFromMatrixPosition(a.matrixWorld));for(let e of Wx)this.sampleNow[e*3]=this.sampleNow[e*3]+this.point.x,this.sampleNow[e*3+1]=this.sampleNow[e*3+1]+this.point.y,this.sampleNow[e*3+2]=this.sampleNow[e*3+2]+this.point.z;let o=this.pending!==null&&this.clock-this.pending.at<=oC?this.pending:null;this.body.start(this.sampleNow,this.velocities,o?.style??e),this.computeOffsets();let s=this.recordImpulses;s.length=0,o!==null&&s.push(this.body.impulse({step:0,x:o.x,y:o.y,z:o.z,driveX:o.driveX,driveY:o.driveY,driveZ:o.driveZ,target:o.target,twist:o.twist}));let c=this.recordObstacles;c.steps=0,this.body.trackObstacle(c,!1),this.recordPositions.set(this.sampleNow),this.recordVelocities.set(this.velocities);for(let e=0;e=.008333333333333333&&i=.008333333333333333&&n=0)this.body.restore(t);else{let t=this.body.steps+Math.ceil(pC/Zx);for(;!this.body.asleep&&this.body.steps=1)return;let t=Math.min(1,Math.max(0,e));this.bodyTurns(this.solvedTurns),this.rig.bones.hips.position.lerpVectors(this.riseHips,this.rig.bones.hips.position,t);for(let e=0;eQS(e,t,n),r=e=>this.point.setFromMatrixPosition(e.matrixWorld),i=(e,t,n)=>n.setFromMatrixColumn(e.matrixWorld,t).normalize();n(U.pelvis,r(t.hips)),n(U.hipL,r(t.hipL)),n(U.hipR,r(t.hipR)),n(U.belly,r(t.hips).addScaledVector(i(t.hips,2,this.axisZ),wx)),n(U.chest,r(t.chest)),n(U.upper,r(t.upperChest)),n(U.neck,r(t.neck)),n(U.shoulderL,r(t.shoulderL)),n(U.shoulderR,r(t.shoulderR)),n(U.head,r(t.head)),n(U.crown,r(t.head).addScaledVector(i(t.head,1,this.axisY),Tx)),n(U.face,r(t.head).addScaledVector(i(t.head,2,this.axisZ),Ex).addScaledVector(i(t.head,1,this.axisY),Dx)),n(U.elbowL,r(t.elbowL)),n(U.wristL,r(t.gloveL)),n(U.fistL,r(t.gloveL).addScaledVector(i(t.gloveL,1,this.axisY),Ox)),n(U.elbowR,r(t.elbowR)),n(U.wristR,r(t.gloveR)),n(U.fistR,r(t.gloveR).addScaledVector(i(t.gloveR,1,this.axisY),Ox)),n(U.kneeL,r(t.kneeL)),n(U.ankleL,r(t.ankleL)),n(U.toeL,r(t.toeL)),n(U.heelL,r(t.ankleL).addScaledVector(i(t.toeL,1,this.axisY),-.07).addScaledVector(i(t.toeL,2,this.axisZ),-.09)),n(U.kneeR,r(t.kneeR)),n(U.ankleR,r(t.ankleR)),n(U.toeR,r(t.toeR)),n(U.heelR,r(t.ankleR).addScaledVector(i(t.toeR,1,this.axisY),-.07).addScaledVector(i(t.toeR,2,this.axisZ),-.09))}computeOffsets(){this.prepareFrames(this.body.position);for(let e=0;e=0&&this.rig.setWorldPosition(i,XS(e,a,this.point)),tC[r]===`upperChest`&&(this.rig.bones.clavicleL.updateWorldMatrix(!1,!1),this.rig.bones.clavicleR.updateWorldMatrix(!1,!1))}this.root.updateMatrixWorld(!0)}tiltHips(e){let t=this.rig.bones.hips,n=this.point.setFromMatrixPosition(t.matrixWorld),r=this.tiltJoint.copy(this.rig.restLocalPosition(this.rig.bones.spine)).applyMatrix4(t.matrixWorld).sub(n),i=XS(e,U.chest,this.tiltChest).sub(n),a=this.pelvisX,o=a.dot(r),s=this.tiltAcross.copy(r).addScaledVector(a,-o),c=(r.lengthSq()+i.lengthSq()-this.spineLength*this.spineLength)/2-o*a.dot(i),l=s.dot(i),u=this.other.crossVectors(a,s).dot(i),d=Math.hypot(l,u);if(d<1e-9)return;let f=Math.atan2(u,l),p=Math.acos(Math.min(1,Math.max(-1,c/d))),m=ZS(f-p),h=ZS(f+p),g=Math.abs(m)<=Math.abs(h)?m:h;Math.abs(g)<1e-5||(t.getWorldQuaternion(this.world).premultiply(this.tiltTurn.setFromAxisAngle(a,g)),this.rig.setWorldRotation(t,this.world))}prepareFrames(e){this.segment(e,U.hipR,U.hipL,this.pelvisX),this.axisZ.set(e[U.belly*3]-(e[U.hipL*3]+e[U.hipR*3])/2,e[U.belly*3+1]-(e[U.hipL*3+1]+e[U.hipR*3+1])/2,e[U.belly*3+2]-(e[U.hipL*3+2]+e[U.hipR*3+2])/2),this.axisZ.addScaledVector(this.pelvisX,-this.axisZ.dot(this.pelvisX)).normalize(),this.pelvisY.crossVectors(this.axisZ,this.pelvisX).normalize(),this.segment(e,U.shoulderR,U.shoulderL,this.upperX),this.segment(e,U.head,U.crown,this.axisX),this.segment(e,U.head,U.face,this.other),this.headX.crossVectors(this.axisX,this.other).normalize()}segment(e,t,n,r){return r.set(e[n*3]-e[t*3],e[n*3+1]-e[t*3+1],e[n*3+2]-e[t*3+2]),r.lengthSq()>1e-12?r.normalize():r.set(0,1,0)}frameFor(e,t,n){let r=tC[e];switch(r){case`hips`:return Zb(this.pelvisY,this.pelvisX,`x`,n);case`spine`:{let r=this.bones[e];return r.updateWorldMatrix(!1,!1),this.axisY.setFromMatrixPosition(r.matrixWorld),this.axisY.set(t[U.chest*3]-this.axisY.x,t[U.chest*3+1]-this.axisY.y,t[U.chest*3+2]-this.axisY.z),this.axisY.lengthSq()>1e-12?this.axisY.normalize():this.segment(t,U.pelvis,U.chest,this.axisY),Zb(this.axisY,this.hint.copy(this.pelvisX).multiplyScalar(.75).addScaledVector(this.upperX,.25),`x`,n)}case`chest`:return this.segment(t,U.chest,U.upper,this.axisY),Zb(this.axisY,this.hint.copy(this.pelvisX).multiplyScalar(.4).addScaledVector(this.upperX,.6),`x`,n);case`upperChest`:return this.segment(t,U.upper,U.neck,this.axisY),Zb(this.axisY,this.upperX,`x`,n);case`neck`:return this.segment(t,U.neck,U.head,this.axisY),Zb(this.axisY,this.hint.copy(this.upperX).add(this.headX),`x`,n);case`head`:return this.segment(t,U.head,U.crown,this.axisY),Zb(this.axisY,this.segment(t,U.head,U.face,this.hint),`z`,n);case`shoulderL`:case`elbowL`:case`gloveL`:case`shoulderR`:case`elbowR`:case`gloveR`:{let i=+!r.endsWith(`L`),a=nC[e],o=this.body.elbowAxis(i,t,this.elbowAxes[i]);return this.segment(t,a[0],a[1],this.axisY),Zb(this.axisY,o,`x`,n)}case`hipL`:case`kneeL`:case`hipR`:case`kneeR`:{let i=+!r.endsWith(`L`),a=nC[e],o=this.body.kneeAxis(i,t,this.kneeAxes[i]);return this.segment(t,a[0],a[1],this.axisY),Zb(this.axisY,o,`x`,n)}default:{let e=r===`ankleL`,i=e?U.ankleL:U.ankleR,a=e?U.toeL:U.toeR,o=e?U.heelL:U.heelR;return this.segment(t,i,a,this.axisY),this.segment(t,o,a,this.hint),this.other.set(t[i*3]-t[o*3],t[i*3+1]-t[o*3+1],t[i*3+2]-t[o*3+2]),this.hint.cross(this.other),Zb(this.axisY,this.hint,`x`,n)}}}};function gC(e,t,n){let r=Math.min(1,Math.max(0,(n-e)/(t-e)));return r*r*(3-2*r)}var _C=3,vC=5;function yC(e){return 1-.74*gC(-.6,1.4,e)}var bC=.23,xC=.22,SC=.22,CC=1.15,wC=.5,TC=.9,EC=.045,DC=[.33,.66],OC=EC*2*.33*.67,kC=.04;function AC(e,t){return{pressX:Math.min(xC,Math.max(0,Math.abs(e)+bC-g_)),pressZ:Math.min(xC,Math.max(0,Math.abs(t)+bC-g_))}}function jC(e,t,n){return n.x=Math.sign(e)*Math.max(0,Math.abs(e)+bC-g_-xC),n.z=Math.sign(t)*Math.max(0,Math.abs(t)+bC-g_-xC),n}var MC=` float ropeGive(float along, float position, float height) { - float near = 1.0 - smoothstep(${UP.toFixed(2)}, ${WP.toFixed(2)}, abs(along)); - float tied = smoothstep(0.0, ${GP.toFixed(2)}, ${TE.toFixed(4)} - abs(position)); - return near * tied * (${KP.toFixed(2)} + ${.09999999999999998.toFixed(2)} * smoothstep(0.5, 0.88, height)); + float near = 1.0 - smoothstep(${SC.toFixed(2)}, ${CC.toFixed(2)}, abs(along)); + float tied = smoothstep(0.0, ${wC.toFixed(2)}, ${g_.toFixed(4)} - abs(position)); + return near * tied * (${TC.toFixed(2)} + ${.09999999999999998.toFixed(2)} * smoothstep(0.5, 0.88, height)); } -`,eF=` +`,NC=` vec3 ropeWorld = (modelMatrix * vec4(transformed, 1.0)).xyz; bool ropeSideX = abs(ropeWorld.x) > abs(ropeWorld.z); vec3 ropeOut = ropeSideX ? vec3(sign(ropeWorld.x), 0.0, 0.0) : vec3(0.0, 0.0, sign(ropeWorld.z)); @@ -5349,13 +5230,280 @@ for (int ropeIndex = 0; ropeIndex < 2; ropeIndex += 1) { ropeFlex = max(ropeFlex, press * sameSide * ropeGive(ropeAlong - along, ropeAlong, ropeWorld.y)); } transformed += ropeOut * ropeFlex; -`;function tF(e,t){let n=document.createElement(`canvas`);n.width=e,n.height=e;let r=n.getContext(`2d`);r!==null&&t(r,e);let i=new ky(n);return i.anisotropy=8,i.colorSpace=uh,i}function nF(){return tF(1024,(e,t)=>{e.fillStyle=`#9d968a`,e.fillRect(0,0,t,t);let n=e.createLinearGradient(0,0,t,t);n.addColorStop(0,`rgba(255,255,255,0.08)`),n.addColorStop(.5,`rgba(60,50,40,0.06)`),n.addColorStop(1,`rgba(255,255,255,0.04)`),e.fillStyle=n,e.fillRect(0,0,t,t);for(let n=0;n<2600;n+=1){let r=Math.sin(n*12.9898)*43758.5453%1,i=Math.sin(n*78.233)*12543.1234%1;e.fillStyle=`rgba(${n%3==0?`255,255,255`:`70,55,45`},${.02+n%5*.006})`,e.fillRect(Math.abs(r)*t,Math.abs(i)*t,2+n%4,1+n%3)}for(let n=0;n<40;n+=1){let r=Math.abs(Math.sin(n*91.7)*7919.3%1)*t,i=Math.abs(Math.sin(n*47.1)*4271.9%1)*t;e.fillStyle=`rgba(80,60,50,${.05+n%4*.02})`,e.beginPath(),e.ellipse(r,i,18+n%7*6,6+n%5*3,n*.7%Math.PI,0,Math.PI*2),e.fill()}e.strokeStyle=`rgba(30,60,140,0.85)`,e.lineWidth=12,e.beginPath(),e.arc(t/2,t/2,t*.2,0,Math.PI*2),e.stroke(),e.fillStyle=`rgba(30,60,140,0.9)`,e.font=`800 ${Math.round(t*.062)}px Inter, system-ui, sans-serif`,e.textAlign=`center`,e.textBaseline=`middle`,e.fillText(`H A N D S`,t/2,t/2-t*.012),e.font=`600 ${Math.round(t*.024)}px Inter, system-ui, sans-serif`,e.fillText(`CHAMPIONSHIP BOXING`,t/2,t/2+t*.052),e.strokeStyle=`rgba(30,60,140,0.6)`,e.lineWidth=6,e.strokeRect(t*.035,t*.035,t*.93,t*.93)})}function rF(){let e=[],t=[],n=[],r=new t_;r.name=`ring`;let i=nF();n.push(i);let a=new Ab({map:i,roughness:.88,metalness:0});t.push(a);let o=new hb(xE*2,xE*2);e.push(o);let s=new Y(o,a);s.rotation.x=-Math.PI/2,s.position.y=.002,s.receiveShadow=!0,r.add(s);let c=new Ab({color:`#1c2b52`,roughness:.85});t.push(c);let l=new gb(xE*.98,SE,4,1);e.push(l);let u=new Y(l,c);u.rotation.x=-Math.PI/2,u.rotation.z=Math.PI/4,u.position.y=.001,u.receiveShadow=!0,r.add(u);let d=new Ab({color:`#0c1424`,roughness:.9});t.push(d);let f=new Ny(CE*2,1,CE*2);e.push(f);let p=new Y(f,d);p.position.y=-.5,p.receiveShadow=!0,r.add(p);let m=new Ab({color:`#101b33`,roughness:.95});t.push(m);for(let t=0;t<4;t+=1){let n=new hb(CE*2,.95);e.push(n);let i=new Y(n,m),a=t*Math.PI/2;i.position.set(Math.sin(a)*(CE-.001),-.48,Math.cos(a)*(CE-.001)),i.rotation.y=a,r.add(i)}let h=new Ab({color:`#9aa7b5`,roughness:.35,metalness:.75});t.push(h);let g=[OE.neutral,OE.red,OE.neutral,OE.blue],_=new Iy(.055,.055,1.55,12);e.push(_);let v=new Ny(.34,.52,.13);e.push(v);let y=new Ny(.16,.07,.1);e.push(y);let b=[];for(let e=0;e<4;e+=1){let n=Math.PI/4+e*Math.PI/2,i=Math.sin(n)*wE*Math.SQRT2*.72,a=Math.cos(n)*wE*Math.SQRT2*.72;b.push(new q(i,0,a));let o=new Y(_,h);o.position.set(i,.78,a),o.castShadow=!0,r.add(o);let s=new Ab({color:g[e],roughness:.55});t.push(s);for(let e of[.62,1.12]){let t=new Y(v,s);t.position.set(i*.985,e,a*.985),t.lookAt(0,e,0),t.castShadow=!0,r.add(t)}}let x=[new Sg(0,0,0,0),new Sg(0,0,0,0)],S={uRopeContactA:{value:x[0]},uRopeContactB:{value:x[1]}},C=[12131356,15067115,1920728],w=e=>{e.uniforms.uRopeContactA=S.uRopeContactA,e.uniforms.uRopeContactB=S.uRopeContactB,e.vertexShader=e.vertexShader.replace(`#include `,`#include \nuniform vec4 uRopeContactA;\nuniform vec4 uRopeContactB;\n${$P}`).replace(`#include `,`#include ${eF}`)},T=e=>{let n=new Ab(e);return n.onBeforeCompile=w,t.push(n),n},E=new Mb;E.onBeforeCompile=w,E.customProgramCacheKey=()=>`hands-rope-depth`,t.push(E);let D=e=>T({color:e,roughness:.42,metalness:.05}),O=C.map(D),k=C.map(D),A=T({color:14212840,roughness:.6}),j=T({color:14212840,roughness:.6});k.push(j);let ee=EE[0]-YP-XP,M=EE[EE.length-1]-YP+XP,te=new Ny(.035,M-ee,.012,1,6,1);e.push(te);let ne=(e,t)=>{for(let[n,r]of[e,t].entries()){let e=x[n];if(r===null){e.set(0,0,0,0);continue}let t=ZP(r.x,r.z);e.set(r.x,r.z,t.pressX,t.pressZ)}};for(let t=0;t<4;t+=1){let n=b[t],i=b[(t+1)%4];for(let[a,o]of EE.entries()){let s=n.clone().add(i).multiplyScalar(.5);s.y=o-qP;let c=new yb(new ub(new q(n.x,o,n.z),s,new q(i.x,o,i.z)),72,.028,8,!1);e.push(c);let l=new Y(c,(t===RP?k:O)[a]);l.castShadow=!0,l.customDepthMaterial=E,t===RP&&(l.renderOrder=zP),r.add(l)}for(let e of JP){let a=n.x+(i.x-n.x)*e,o=n.z+(i.z-n.z)*e,s=new Y(te,t===RP?j:A);s.position.set(a,(ee+M)/2,o),s.lookAt(0,s.position.y,0),t===RP&&(s.renderOrder=zP),r.add(s)}}for(let e of k)e.transparent=!0;return{group:r,materials:t,geometries:e,textures:n,setRopeContacts:ne,ropeContacts:x,setNearRopeOpacity:e=>{for(let t of k)t.opacity=G.clamp(e,0,1),t.visible=t.opacity>.03,t.depthWrite=t.opacity>=1},nearRopeOpacity:()=>k[0].opacity}}function iF(e){for(let t of e.geometries)t.dispose();for(let t of e.materials)t.dispose();for(let t of e.textures)t.dispose()}var aF={MHeadMat0:`head`,GlovesMat0:`gloves`,MBodyMat0:`body`,ShoesMat0:`shoes`,PantsMat0:`pants`},oF=new Map,sF=new Map,cF=null,lF=null;function uF(e){return e.colorSpace=uh,e.flipY=!1,e}function dF(e){let t=oF.get(e);if(t!==void 0)return Promise.resolve(t);let n=sF.get(e);if(n!==void 0)return n;let r=new mx().loadAsync($k[e]).then(t=>(oF.set(e,uF(t)),t));return sF.set(e,r),r}function fF(){return Promise.all(Object.keys($k).map(dF))}async function pF(){let e=Uint8Array.from(atob(Zk),e=>e.charCodeAt(0)),t=new Response(e).body;if(t===null)throw Error(`fighter_glb_stream_unavailable`);return new Response(t.pipeThrough(new DecompressionStream(`gzip`))).arrayBuffer()}function mF(){if(cF===null){let e=pF().then(e=>new Promise((t,n)=>{new ZO().parse(e,``,t,e=>n(e instanceof Error?e:Error(String(e))))}));cF=Promise.all([e,fF()]).then(([e])=>(lF=e.scene,e))}return cF}function hF(){gF(lF,oF.values())}function gF(e,t){e?.traverse(e=>{e instanceof Y&&e.geometry.dispose()});for(let e of t)e.dispose()}function _F(e){e.traverse(e=>{e instanceof Hv&&e.skeleton.dispose()})}function vF(e){let t=oF.get(e);if(t!==void 0)return t;let n=uF(new mx().load($k[e]));return oF.set(e,n),n}var yF=`{ +`;function PC(e,t){let n=document.createElement(`canvas`);n.width=e,n.height=e;let r=n.getContext(`2d`);r!==null&&t(r,e);let i=new Wl(n);return i.anisotropy=8,i.colorSpace=wa,i}function FC(){return PC(1024,(e,t)=>{e.fillStyle=`#9d968a`,e.fillRect(0,0,t,t);let n=e.createLinearGradient(0,0,t,t);n.addColorStop(0,`rgba(255,255,255,0.08)`),n.addColorStop(.5,`rgba(60,50,40,0.06)`),n.addColorStop(1,`rgba(255,255,255,0.04)`),e.fillStyle=n,e.fillRect(0,0,t,t);for(let n=0;n<2600;n+=1){let r=Math.sin(n*12.9898)*43758.5453%1,i=Math.sin(n*78.233)*12543.1234%1;e.fillStyle=`rgba(${n%3==0?`255,255,255`:`70,55,45`},${.02+n%5*.006})`,e.fillRect(Math.abs(r)*t,Math.abs(i)*t,2+n%4,1+n%3)}for(let n=0;n<40;n+=1){let r=Math.abs(Math.sin(n*91.7)*7919.3%1)*t,i=Math.abs(Math.sin(n*47.1)*4271.9%1)*t;e.fillStyle=`rgba(80,60,50,${.05+n%4*.02})`,e.beginPath(),e.ellipse(r,i,18+n%7*6,6+n%5*3,n*.7%Math.PI,0,Math.PI*2),e.fill()}e.strokeStyle=`rgba(30,60,140,0.85)`,e.lineWidth=12,e.beginPath(),e.arc(t/2,t/2,t*.2,0,Math.PI*2),e.stroke(),e.fillStyle=`rgba(30,60,140,0.9)`,e.font=`800 ${Math.round(t*.062)}px Inter, system-ui, sans-serif`,e.textAlign=`center`,e.textBaseline=`middle`,e.fillText(`H A N D S`,t/2,t/2-t*.012),e.font=`600 ${Math.round(t*.024)}px Inter, system-ui, sans-serif`,e.fillText(`CHAMPIONSHIP BOXING`,t/2,t/2+t*.052),e.strokeStyle=`rgba(30,60,140,0.6)`,e.lineWidth=6,e.strokeRect(t*.035,t*.035,t*.93,t*.93)})}function IC(){let e=[],t=[],n=[],r=new gs;r.name=`ring`;let i=FC();n.push(i);let a=new Ku({map:i,color:`#c8c2b8`,roughness:.84,metalness:0});t.push(a);let o=new Au(f_*2,f_*2);e.push(o);let s=new V(o,a);s.rotation.x=-Math.PI/2,s.position.y=.002,s.receiveShadow=!0,r.add(s);let c=new Ku({color:`#1c2b52`,roughness:.85});t.push(c);let l=new ju(f_*.98,p_,4,1);e.push(l);let u=new V(l,c);u.rotation.x=-Math.PI/2,u.rotation.z=Math.PI/4,u.position.y=.001,u.receiveShadow=!0,r.add(u);let d=new Ku({color:`#0c1424`,roughness:.9});t.push(d);let f=new Jl(m_*2,1,m_*2);e.push(f);let p=new V(f,d);p.position.y=-.5,p.receiveShadow=!0,r.add(p);let m=new Ku({color:`#101b33`,roughness:.95});t.push(m);for(let t=0;t<4;t+=1){let n=new Au(m_*2,.95);e.push(n);let i=new V(n,m),a=t*Math.PI/2;i.position.set(Math.sin(a)*(m_-.001),-.48,Math.cos(a)*(m_-.001)),i.rotation.y=a,r.add(i)}let h=new Ku({color:`#9aa7b5`,roughness:.35,metalness:.75});t.push(h);let g=[y_.neutral,y_.red,y_.neutral,y_.blue],_=new Zl(.055,.055,1.55,12);e.push(_);let v=new Jl(.34,.52,.13);e.push(v);let y=new Jl(.16,.07,.1);e.push(y);let b=[];for(let e=0;e<4;e+=1){let n=Math.PI/4+e*Math.PI/2,i=Math.sin(n)*h_*Math.SQRT2*.72,a=Math.cos(n)*h_*Math.SQRT2*.72;b.push(new z(i,0,a));let o=new V(_,h);o.position.set(i,.78,a),o.castShadow=!0,r.add(o);let s=new Ku({color:g[e],roughness:.55});t.push(s);for(let e of[.62,1.12]){let t=new V(v,s);t.position.set(i*.985,e,a*.985),t.lookAt(0,e,0),t.castShadow=!0,r.add(t)}}let x=[new Lo(0,0,0,0),new Lo(0,0,0,0)],S={uRopeContactA:{value:x[0]},uRopeContactB:{value:x[1]}},C=[12131356,15067115,1920728],w=e=>{e.uniforms.uRopeContactA=S.uRopeContactA,e.uniforms.uRopeContactB=S.uRopeContactB,e.vertexShader=e.vertexShader.replace(`#include `,`#include \nuniform vec4 uRopeContactA;\nuniform vec4 uRopeContactB;\n${MC}`).replace(`#include `,`#include ${NC}`)},T=e=>{let n=new Ku(e);return n.onBeforeCompile=w,t.push(n),n},E=new Ju;E.onBeforeCompile=w,E.customProgramCacheKey=()=>`hands-rope-depth`,t.push(E);let D=e=>T({color:e,roughness:.42,metalness:.05}),O=C.map(D),k=C.map(D),A=T({color:14212840,roughness:.6}),j=T({color:14212840,roughness:.6});k.push(j);let ee=__[0]-OC-kC,M=__[__.length-1]-OC+kC,te=new Jl(.035,M-ee,.012,1,6,1);e.push(te);let ne=(e,t)=>{for(let[n,r]of[e,t].entries()){let e=x[n];if(r===null){e.set(0,0,0,0);continue}let t=AC(r.x,r.z);e.set(r.x,r.z,t.pressX,t.pressZ)}};for(let t=0;t<4;t+=1){let n=b[t],i=b[(t+1)%4];for(let[a,o]of __.entries()){let s=n.clone().add(i).multiplyScalar(.5);s.y=o-EC;let c=new Fu(new Tu(new z(n.x,o,n.z),s,new z(i.x,o,i.z)),72,.028,8,!1);e.push(c);let l=new V(c,(t===_C?k:O)[a]);l.castShadow=!0,l.customDepthMaterial=E,t===_C&&(l.renderOrder=vC),r.add(l)}for(let e of DC){let a=n.x+(i.x-n.x)*e,o=n.z+(i.z-n.z)*e,s=new V(te,t===_C?j:A);s.position.set(a,(ee+M)/2,o),s.lookAt(0,s.position.y,0),t===_C&&(s.renderOrder=vC),r.add(s)}}for(let e of k)e.transparent=!0;return{group:r,materials:t,geometries:e,textures:n,setRopeContacts:ne,ropeContacts:x,setNearRopeOpacity:e=>{for(let t of k)t.opacity=L.clamp(e,0,1),t.visible=t.opacity>.03,t.depthWrite=t.opacity>=1},nearRopeOpacity:()=>k[0].opacity}}function LC(e){for(let t of e.geometries)t.dispose();for(let t of e.materials)t.dispose();for(let t of e.textures)t.dispose()}var RC={MHeadMat0:`head`,GlovesMat0:`gloves`,MBodyMat0:`body`,ShoesMat0:`shoes`,PantsMat0:`pants`},zC={GlovesMat0:.33,PantsMat0:.44,ShoesMat0:.5},BC=new Map,VC=new Map,HC=null,UC=null,WC=new Map;function GC(e){return e.colorSpace=wa,e.flipY=!1,e}function KC(e){let t=BC.get(e);if(t!==void 0)return Promise.resolve(t);let n=VC.get(e);if(n!==void 0)return n;let r=new Ad().loadAsync(_y[e]).then(t=>(BC.set(e,GC(t)),t));return VC.set(e,r),r}function qC(){return Promise.all(Object.keys(_y).map(KC))}async function JC(){let e=Uint8Array.from(atob(hy),e=>e.charCodeAt(0)),t=new Response(e).body;if(t===null)throw Error(`fighter_glb_stream_unavailable`);return new Response(t.pipeThrough(new DecompressionStream(`gzip`))).arrayBuffer()}function YC(){if(HC===null){let e=JC().then(e=>new Promise((t,n)=>{new hv().parse(e,``,t,e=>n(e instanceof Error?e:Error(String(e))))}));HC=Promise.all([e,qC()]).then(([e])=>(UC=e.scene,e))}return HC}function XC(){ZC(UC,BC.values());for(let e of WC.values())e.dispose()}function ZC(e,t){e?.traverse(e=>{e instanceof V&&e.geometry.dispose()});for(let e of t)e.dispose()}function QC(e){e.traverse(e=>{e instanceof rl&&e.skeleton.dispose()})}function $C(e){let t=BC.get(e);if(t!==void 0)return t;let n=GC(new Ad().load(_y[e]));return BC.set(e,n),n}var ew=`{ vec4 pressedOntoCanvas = modelMatrix * vec4( transformed, 1.0 ); - if ( pressedOntoCanvas.y < ${0 .toFixed(4)} && max( abs( pressedOntoCanvas.x ), abs( pressedOntoCanvas.z ) ) < ${CE.toFixed(4)} ) { + if ( pressedOntoCanvas.y < ${0 .toFixed(4)} && max( abs( pressedOntoCanvas.x ), abs( pressedOntoCanvas.z ) ) < ${m_.toFixed(4)} ) { transformed += inverse( mat3( modelMatrix ) ) * vec3( 0.0, ${0 .toFixed(4)} - pressedOntoCanvas.y, 0.0 ); } -}`;function bF(e){let t=e.onBeforeCompile,n=Object.hasOwn(e,`customProgramCacheKey`)?e.customProgramCacheKey():`plain`;e.onBeforeCompile=(n,r)=>{t.call(e,n,r),n.vertexShader=n.vertexShader.replace(`#include `,`${yF}\n#include `)},e.customProgramCacheKey=()=>`${n}-on-canvas`,e.needsUpdate=!0}function xF(e,t){let n=t.outfit!==void 0,r=!n||t.wounds===!0,i=[],a=[],o=new Map,s=null,c={value:0},l=null,u=null;if(e.traverse(e=>{if(!(e instanceof Hv)||Array.isArray(e.material))return;let d=e.material.name,f=aF[d];if(f===void 0)throw Error(`fighter GLB has unsupported material ${d}`);let p=o.get(d);if(p===void 0){let e=d===`MHeadMat0`||d===`MBodyMat0`,m=t.outfit,h=d===`GlovesMat0`?t.gear:d===`PantsMat0`?m?.trousers??t.gear:d===`ShoesMat0`&&m!==void 0?m.shoes:16777215,g=vF(f);p=e&&!n?new jb({map:g,color:h,roughness:.58,metalness:.02,clearcoat:.25,clearcoatRoughness:.6}):new Ab({map:g,color:h,roughness:e?.58:.4,metalness:e?.02:.03}),p.name=d,o.set(d,p),a.push(p),e&&i.push(p),d===`MHeadMat0`&&(l=new nj(r?p:null,iA,{core:zA,lids:VA})),d===`MBodyMat0`&&(u=new nj(r?p:null,aA,{core:BA,wash:!0}));let _=SF[d];m!==void 0&&_!==void 0?Zj(p,_,m):d===`PantsMat0`?c=rA(p,!1,`trunks`):d===`GlovesMat0`&&(s=rA(p)),bF(p)}e.material=p,e.castShadow=!n,e.receiveShadow=!0,e.frustumCulled=!1}),i.length!==2||s===null||a.length!==5||l===null||u===null)throw Error(`fighter GLB material contract failed: ${i.length} skin, ${a.length} total`);return{skin:i,gloveBlood:s,trunksBlood:c,owned:a,headInjury:l,bodyInjury:u}}var SF={MHeadMat0:`head`,MBodyMat0:`body`,ShoesMat0:`shoes`,PantsMat0:`pants`},CF=new J().setRGB(.6,.32,.19,dh),wF=(e,t,n,r)=>e+(t-e)*(1-Math.exp(-n*r)),TF=(e,t,n,r)=>e+(((t-e+Math.PI)%(Math.PI*2)+Math.PI*2)%(Math.PI*2)-Math.PI)*(1-Math.exp(-n*r)),EF=G.clamp,DF=class{root=new t_;bones=new Map;rig;metrics;skinMaterials;ownedMaterials;gloveBlood;trunksBlood;headMeshes=[];handMeshes={left:[],right:[]};decapitated=!1;burst=!1;dismemberedHands={left:!1,right:!1};dressed;ownedGeometries=[];gearBaseColor;skinBaseColor;headInjury;bodyInjury;headLook;bareHand;constructor(e,t){let n=YO(e.scene);n.scale.setScalar(1),this.root.add(n);let r=xF(n,t);this.skinMaterials=r.skin,this.ownedMaterials=[...r.owned],this.gloveBlood=r.gloveBlood,this.trunksBlood=r.trunksBlood,this.headInjury=r.headInjury,this.bodyInjury=r.bodyInjury,this.gearBaseColor=new J(t.gear),this.skinBaseColor=new J(t.skin),this.dressed=t.outfit!==void 0,n.traverse(e=>{e instanceof Hv&&e.name===`BoxerHead`&&this.headMeshes.push(e),e instanceof Hv&&e.name===`BoxerGloveLeft`&&this.handMeshes.left.push(e),e instanceof Hv&&e.name===`BoxerGloveRight`&&this.handMeshes.right.push(e),e instanceof Uv&&this.bones.set(e.name,e)});let i=Object.values(Qk).filter(e=>!this.bones.has(e));if(i.length>0)throw Error(`fighter GLB missing required bones: ${i.join(`, `)}`);if(this.headMeshes.length!==1)throw Error(`fighter GLB requires one BoxerHead mesh, found ${this.headMeshes.length}`);let a=this.headInjury.shadowMaterial();this.headMeshes[0].customDepthMaterial=a;let o=this.headMeshes[0].material;o.side=0,o.shadowSide=1,this.ownedMaterials.push(a);for(let e of[`left`,`right`])if(this.handMeshes[e].length!==1)throw Error(`fighter GLB requires one ${e} glove mesh, found ${this.handMeshes[e].length}`);this.root.updateMatrixWorld(!0),this.rig=new SM(this.root),this.headLook=new Aj(this.headMeshes[0].material),this.bareHand=t.outfit===void 0?null:this.addHands(t.outfit),this.setLook(t.look??mj);let s=this.rig.metrics;this.metrics={armUpper:s.armL.upper,armFore:s.armL.lower,legThigh:s.legL.upper,legShin:s.legL.lower,headRestY:s.headHeight,chestRestY:s.chestHeight,ankleRestY:s.ankleHeight}}bone(e){return this.bones.get(Qk[e]??e)??null}setGloveBlood(e){this.gloveBlood.value=EF(e,0,1)}get gloveBloodLevel(){return this.gloveBlood.value}setTrunksBlood(e){this.trunksBlood.value=EF(e,0,1)}get trunksBloodLevel(){return this.trunksBlood.value}get headMesh(){return this.headMeshes[0]}gloveMesh(e){return this.handMeshes[e][0]}get skin(){return this.skinMaterials[0]}get isDecapitated(){return this.decapitated}setDecapitated(e){this.decapitated=e,this.burst=!1,this.headInjury.setSevered(e),this.bone(`head`).visible=!e}get isHeadBurst(){return this.burst}setHeadBurst(e){this.burst=e,this.decapitated=!1,this.headInjury.setBurst(e),this.bone(`head`).visible=!e}isHandDismembered(e){return this.dismemberedHands[e]}setHandDismembered(e,t){this.dismemberedHands[e]=t;for(let n of this.handMeshes[e])n.visible=!t&&!this.dressed}setLook(e){this.headLook.set(e);for(let t of this.skinMaterials)t.color.setHex(e.tint);this.bareHand?.color.copy(CF).multiply(this.skinMaterials[0].color)}get look(){return this.headLook.look}addHands(e){let t=e.gloves!==null,n=new Ab({color:t?e.gloves:CF,roughness:t?.38:.6,metalness:.02}),r=t?n:new Ab({color:new J(e.shirt).multiplyScalar(.9),roughness:.88,metalness:0});this.ownedMaterials.push(n),r!==n&&this.ownedMaterials.push(r);let i=tM();this.ownedGeometries.push(i);for(let e of[`left`,`right`]){for(let t of this.handMeshes[e])t.visible=!1;let t=eM(e);this.ownedGeometries.push(t);let a=e===`left`?`L`:`R`;for(let[o,s,c,l]of[[this.rig.bones[`glove${a}`],t,n,`hand-${e}`],[this.rig.bones[`elbow${a}`],i,r,`cuff-${e}`]]){let e=new Y(s,c);e.name=l,e.castShadow=!1,e.receiveShadow=!0,o.add(e)}}return t?null:n}setSkinClearcoat(e){for(let t of this.skinMaterials)t instanceof jb&&(t.clearcoat=e)}dispose(){for(let e of this.ownedMaterials)e.dispose();for(let e of this.ownedGeometries)e.dispose();_F(this.root)}},OF=(e,t,n,r,i)=>{let a=e.value,o=e.velocity;o.addScaledVector(a,-n*t).multiplyScalar(Math.exp(-r*t)),a.addScaledVector(o,t),a.length()>i&&a.setLength(i)},kF=.06,AF=150,jF=.58,MF=.25,NF=.32,PF=9,FF=1,IF=.08,LF=.3,RF=1,zF=1.6,BF=.25,VF=.12,HF=.3,UF=.3,WF=8;function GF(e,t,n,r){QP(e,t,n);let i=Math.hypot(n.x,n.z);if(i<=0)return r.x=0,r.z=0,0;let a=EM(0,BF,i),o=1+VF*a/i;return r.x=n.x*o,r.z=n.z*o,a}var KF=(e,t)=>e===0||Math.sign(t)===Math.sign(e)&&Math.abs(t)>Math.abs(e)?t:e,qF=.75,JF=.38,YF=.72,XF=.5,ZF=.2,QF=.55,$F=.7,eI=6,tI=.4,nI=.2,rI=.3,iI=.5,aI=class{mapping;boxer;solver;yaw=0;yawInitialized=!1;rootX=null;rootZ=0;punchActive=!1;punchAgeTicks=0;punchTotalTicks=1;punchClass=`jab`;punchHand=`left`;punchTarget=`head`;punchPower=`normal`;punchTiming=oe(`jab`,`head`,`normal`);actionId=null;completedActionId=null;ownActionId=null;ownPress=!1;ownLeadTicks=0;ownAuthoritativeAge=null;ownWaitedTicks=0;ownExpectedTicks=0;ownPulled=!1;ownSequence=null;ownStarted=!1;ownPressedAt=0;ownRefused=!1;ownCut=!1;recoveryCut=!1;ownQueued=null;contactId=null;contactParried=!1;shownFighter=null;shownOpponent=null;retiredOwnIds=[];pressesLanded=[];anticipatedId=null;hitstop=0;hitstopScale=1;hitstopLag=0;downState=`up`;fallAge=0;riseProgress=0;riseFrom=0;fallSide=0;fallProne=!1;fallKneel=!1;windedSide=-1;windedTime=0;winded=0;landProne=!1;landSide=0;landShift=new q;landSettled=!1;fallen=SL();fallenFromPhysics=!1;riseRoot=new q;riseRootFrom=new q;downPoles=[new q,new q,new q,new q];downPolesSet=!1;poleSettle=0;characterInverse=new Dg;place=new q;riseRootVelocity=new q;liveOpponentHead=new q;hasLiveHead=!1;guardOpponentHead=new q;opponentHeadOffset=new q;opponentSteadySeconds=0;followHead=0;aimActionId=null;refereeContactId=null;refereeHead=new q;hasRefereeHead=!1;followReferee=0;headKick={value:new q,velocity:new q};torsoKick={value:new q,velocity:new q};rootKick={value:new q,velocity:new q};coverKick={value:new q,velocity:new q};foldDelay=0;pendingFold=0;guardKick=0;guardHigh=0;guardLow=0;guardSpent=0;slip=0;weave=0;weaveTime=0;pull=0;crouchExtra=0;bouncePhase=0;weightPhase=0;stunPhase=0;feintTimer=2;feint=0;stunAmount=0;tired=0;clinchWeight=0;foulWeight=0;tauntWeight=0;crowding=0;punchCommit=0;headSpace=new K;ownHead=new q;ropeHold=new q;ropeExcess={x:0,z:0};ropeOwn={x:0,z:0};ropeTheirs={x:0,z:0};ropeLeanTarget=0;ropeLean=0;ropeOutward=new q(1,0,0);ropeLocal=new q;tauntEnd=null;lastSpeed=0;stool;stoolRoot=new q;stoolYaw=0;enswell;bottle;treatProp=`enswell`;treatTarget=new q;treatScratch=new q;treatFacing=new q(0,0,-1);treatFacingLocal=new q;treatSide=1;treating=!1;treatWeight=0;resting=!1;seated=0;stillTime=0;celebrateTime=0;celebration=0;waveTime=0;wave=0;breakTime=0;breakWeight=0;breakFighters=[new q,new q];breakAimed=!1;attending=!1;verdictSide=0;verdict=null;squareWeight=0;raisedWeight=0;bowedWeight=0;wrists=[null,null];wristTargets=[new q,new q];wristWeights=[0,0];attendWeight=0;countdownTicks=null;countdownEnd=null;touchWeight=0;touchOffset=new q;touchVelocity=new q;debugHoldImpact=!1;feet=[{planted:new q,from:new q,to:new q,progress:1,stepping:!1,duration:.2},{planted:new q,from:new q,to:new q,progress:1,stepping:!1,duration:.2}];feetInitialized=!1;dislocation=null;scratch=new q;scratchB=new q;scratchC=new q;scratchD=new q;scratchE=new q;clinchCentre=new q;clinchForward=new q;clinchTemp=new q;scratchQ=new rg;headWorld=new q;hand={L:this.makeHand(),R:this.makeHand()};punchGuard=this.makeHand();punchDir=new q;punchContact=new q;punchStart=new q;punchSweepFrom=new q;punchSweepTo=new q;punchMid=new q;foot={L:this.makeFoot(),R:this.makeFoot()};torso={hips:new q,hipsYaw:0,hipsPitch:0,hipsRoll:0,shouldersYaw:0,spinePitch:0,spineRoll:0,headYaw:0,headPitch:0,headRoll:0,headOffset:new q};pose;downStanding=SL();downFrom=SL();downTo=SL();downResult=SL();downStand=1;fallStart=SL();fallStartStand=1;fallFromGetUp=!1;referee;refereeCount=0;refereeCounting=!1;countChangedTick=null;ragdoll;forcedDown=!1;heldDown=!1;authoredNextFall=!1;obstacle=null;blows=0;riseBlendAge=0;posedInjuries=0;armCarry=[`whole`,`whole`];armLimp=[0,0];armSnap=[0,0];armDangle=[wI(),wI()];forearmDangle=[wI(),wI()];trunkLow=new q;trunkHigh=new q;lostLean=0;cover=0;kneeBlown=[!1,!1];kneeGive=[0,0];gutted=!1;hunch=0;liver=!1;curl=0;faintTarget=0;faint=0;retchTime=0;retching=0;dazed=!1;daze=0;dazeTime=0;stepPace=[1,1];stepLift=[1,1];stepSlack=1;hurt=!1;punchReach=0;dead=!1;deathFall=!1;deathStyle=`crumple`;deathAge=0;throe=DI.length;throeSide=0;laidOut=!1;constructor(e,t,n={}){this.mapping=t,this.boxer=e,this.referee=n.referee===!0,this.solver=new BM(e.rig),this.pose={torso:this.torso,handL:this.hand.L,handR:this.hand.R,footL:this.foot.L,footR:this.foot.R,shrugL:0,shrugR:0},this.stool=YL(),this.stool.group.position.set(0,0,.02),e.root.add(this.stool.group),this.enswell=qL(),e.rig.bones.gloveL.add(this.enswell.group),this.bottle=JL(),e.rig.bones.gloveL.add(this.bottle.group),this.ragdoll=this.referee&&n.knockout!==!0?null:new IP(e.rig,e.root)}primeReplayFall(){this.ragdoll?.prime()}useAuthoredFall(){this.authoredNextFall=!0}knockOut(){this.forcedDown=!0}stayDown(e){this.heldDown=e}setObstacle(e,t){this.obstacle??={x:e,z:t},this.obstacle.x=e,this.obstacle.z=t}get fallBody(){return this.ragdoll?.active===!0?this.ragdoll:null}setResting(e){this.resting=e}get stoolVisible(){return this.stool.group.visible}celebrate(e=4.4){this.celebrateTime=e}resetTransient(e=!1){this.forcedDown=!1;let t=this.ragdoll;t!==null&&(e?t.active?t.settle():t.restoreSettled():(t.stop(),t.clearRise())),this.downState=e?`down`:`up`,this.landSettled=!1,this.fallenFromPhysics=!1,this.riseRoot.set(0,0,0),this.riseRootFrom.set(0,0,0),this.riseRootVelocity.set(0,0,0),this.fallAge=e?qF:0,this.riseProgress=0,this.hitstop=0,this.hitstopScale=1,this.hitstopLag=0;for(let e of[this.headKick,this.torsoKick,this.rootKick,this.coverKick])e.value.set(0,0,0),e.velocity.set(0,0,0);this.foldDelay=0,this.pendingFold=0,this.guardKick=0,this.stunAmount=0,this.windedTime=0,this.winded=0,this.celebrateTime=0,this.celebration=0,this.waveTime=0,this.wave=0,this.verdictSide=0,this.verdict=null,this.squareWeight=0,this.raisedWeight=0,this.bowedWeight=0,this.wrists.fill(null),this.wristWeights.fill(0),this.seated=0,this.stillTime=0,this.rootX=null,this.yawInitialized=!1,this.feetInitialized=!1,this.retirePunch(),this.ownQueued=null,this.completedActionId=null,this.retiredOwnIds.length=0,this.anticipatedId=null,this.retchTime=0,this.retching=0,this.dazed=!1,this.daze=0,this.dazeTime=0;for(let e=0;e<2;e+=1)EI(this.armDangle[e]),EI(this.forearmDangle[e]);this.dead=!1,this.deathFall=!1,this.throe=DI.length,this.laidOut=e}waveOff(e=2.6){this.waveTime=e}setCountdown(e){this.countdownTicks=e}attend(e){this.attending=e}treat(e,t,n=1,r=`enswell`){this.treating=e!==null,e!==null&&(this.treatTarget.copy(e),t!==void 0&&this.treatFacing.copy(t),this.treatSide=n,this.treatProp=r)}awaitVerdict(e){this.verdictSide=e??0,e===null&&(this.verdict=null)}announce(e){this.verdict=e}raise(e,t){this.wrists[0]=e===null?null:this.wristTargets[0].copy(e),this.wrists[1]=t===null?null:this.wristTargets[1].copy(t)}breakClinch(e=1.3){this.breakTime=e}get breaking(){return this.breakTime>0}aimBreak(e,t){this.breakFighters[0].copy(e),this.breakFighters[1].copy(t),this.breakAimed=!0}makeHand(){return{position:new q,knuckles:new q(0,1,0),palm:new q(0,0,1),pole:new q(0,-1,0)}}makeFoot(){return{position:new q,toe:new q(0,0,1),heel:0,pole:new q(0,0,1)}}get currentRoot(){return{x:this.rootX??0,z:this.rootZ}}get isDown(){return this.downState!==`up`||this.dead}setRefereeCount(e,t){(e!==this.refereeCounting||t!==this.refereeCount)&&(this.countChangedTick=null),this.refereeCounting=e,this.refereeCount=t}predict(e,t,n,r=0,i,a=r){if(e.kind!==`punch`||e.id===void 0)return;let o={action:{...e,id:e.id},timing:i??oe(e.class,e.target,e.power),leadTicks:r,answerTicks:a,pressedAt:t,sequence:null,started:!1,waited:0};if(this.punchActive&&this.ownActionId!==null&&this.ownAuthoritativeAge===null&&!this.ownPulled&&!this.ownStarted&&(t-this.ownPressedAt)*n0||e.clinch_ticks>0||e.clinch_startup_ticks>0,a=this.ownQueued;if(a!==null&&(a.sequence??=r?.(a.action.id)??null,e.action_id===a.action.id?a.started=!0:!a.started&&(i||a.sequence!==null&&e.last_input_sequence>=a.sequence&&e.queued_actions===0)&&(this.ownQueued=null)),!this.punchActive||this.ownActionId===null||this.ownPulled||this.ownRefused)return;this.ownStarted||(this.ownSequence??=r?.(this.ownActionId)??null);let o=e.action_id===this.ownActionId;o&&(this.ownStarted=!0);let s=this.ownQueued;s!==null&&s.sequence!==null&&r!==null&&!this.ownStarted&&this.ownSequence===null&&this.ownAuthoritativeAge===null?(this.ownActionId=null,this.ownQueued=null,this.retirePunch(),this.startOwnPunch(s)):(o?i&&e.action_contact_tick===null:!this.ownStarted&&this.ownAuthoritativeAge===null&&(i||this.ownSequence!==null&&e.last_input_sequence>=this.ownSequence&&e.queued_actions===0))&&(this.ownRefused=!0,this.takeBack())}takeBack(){this.punchAgeTickse.action_startup_ticks*(1/sR-1)||this.punchActive&&this.punchAgeTicks/this.punchTotalTicks<=.55)return;this.anticipatedId=n;let r=e.action_target??`head`,i=e.action_power??`normal`,a={...oe(e.action,r,i),startup:e.action_startup_ticks,active:e.action_active_ticks,recovery:e.action_recovery_ticks},o=e.action_hand??(e.stance===`orthodox`?`left`:`right`);this.startEarly(n,e.action,o,r,i,a,t,t)}startOwnPunch(e){let{action:t,timing:n}=e;this.startEarly(t.id,t.class,t.hand,t.target,t.power,n,0,Math.max(0,e.answerTicks)),this.ownPress=!0,this.ownSequence=e.sequence,this.ownStarted=e.started,this.ownPressedAt=e.pressedAt}startEarly(e,t,n,r,i,a,o,s){this.retirePunch(),this.punchClass=t,this.punchHand=n,this.punchTarget=r,this.punchPower=i,this.punchTiming=a,this.punchTotalTicks=Math.max(1,de(a)),this.punchAgeTicks=0,this.punchActive=!0,this.ownActionId=e,this.ownLeadTicks=EF(o,0,ZL),this.ownExpectedTicks=s}followUpStartAge(e){let t=this.shownFighter,n=this.shownOpponent,r=this.actionId??this.ownActionId,i=r!==null&&r===this.contactId&&!this.contactParried;return t!==null&&n!==null&&D(this.punchClass,i,e.action,t.stamina,n.stunned_ticks>0,t.style)?E(this.punchTiming):this.punchTotalTicks}releaseQueuedPress(e){let t=this.ownQueued;t!==null&&(t.waited+=e*30,this.punchActive&&!this.ownPulled&&this.punchAgeTicks+this.serverLag(t.leadTicks)6&&this.retiredOwnIds.shift()),this.actionId=null,this.punchActive=!1,this.ownActionId=null,this.ownPress=!1,this.ownLeadTicks=0,this.ownAuthoritativeAge=null,this.ownWaitedTicks=0,this.ownExpectedTicks=0,this.ownPulled=!1,this.ownSequence=null,this.ownStarted=!1,this.ownRefused=!1,this.ownCut=!1,this.recoveryCut=!1,this.hitstopLag=0}setRefereeHead(e){this.hasRefereeHead=e!==null,e!==null&&this.refereeHead.copy(e)}landedHit(e,t,n=!1){this.punchActive&&e!==null&&e===(this.actionId??this.ownActionId)&&(this.punchAgeTicks>=this.punchTiming.startup+this.punchTiming.active+1||(this.hitstop=Math.max(this.hitstop,(t?o.block:n?o.power:o.hit)/1e3)))}powerHeat(e){if(!this.punchActive||this.punchPower!==`power`||this.punchHand!==e||this.ownPulled)return 0;let{startup:t,active:n,recovery:r}=this.punchTiming,i=this.punchAgeTicks;return i=0?-1:1;if(t===`body`){switch(r){case`hook`:this.torsoKick.velocity.x+=3*s,this.torsoKick.velocity.z+=4.6*s*c,this.rootKick.velocity.x+=.5*s*c,this.coverKick.velocity.x+=2.2*s*c;break;case`uppercut`:this.rootKick.velocity.y+=.9*s,this.torsoKick.velocity.x-=1.6*s,this.foldDelay=.1,this.pendingFold=5.2*s;break;default:this.torsoKick.velocity.x+=4.6*s}this.rootKick.velocity.z-=.45*s,this.headKick.velocity.z-=.6*s,this.headKick.velocity.y-=.7*s,this.guardKick=Math.max(this.guardKick,.6*s)}else{switch(e===`hit`&&(this.guardKick=Math.max(this.guardKick,.4*s)),r){case`hook`:this.headKick.velocity.x+=2.6*s*c,this.headKick.velocity.z-=.7*s,this.torsoKick.velocity.z+=.9*s*c;break;case`uppercut`:this.headKick.velocity.y+=2.2*s,this.headKick.velocity.z-=1.2*s,this.torsoKick.velocity.x-=1.2*s;break;case`straight`:this.headKick.velocity.z-=2.4*s,this.torsoKick.velocity.x-=.6*s;break;default:this.headKick.velocity.z-=1.5*s,this.torsoKick.velocity.x-=.35*s}this.rootKick.velocity.z-=.45*s,e===`block`&&(this.guardKick=Math.max(this.guardKick,.9*s))}if(e===`hit`&&(this.dentSurface(t,c,r,o),this.fallSide=r===`hook`?c:c*.5,this.fallProne=r===`hook`||t===`body`),e===`hit`&&a>=10&&this.ragdoll!==null){let e=FP({target:t,punchClass:r,hand:i,lateral:c,amount:a}),n=this.scratchE.set(e.x,e.y,e.z).applyAxisAngle(XL,this.yaw),o=this.scratchD.set(e.driveX,e.driveY,e.driveZ).applyAxisAngle(XL,this.yaw);this.blows+=1,this.ragdoll.takeBlow(n,o,t,e.twist,gP(r,t,a,this.blows+Math.round(a)))}}stagger(){this.torsoKick.velocity.x-=2.6,this.headKick.velocity.z-=1.4,this.headKick.velocity.y+=.5,this.rootKick.velocity.z-=1.1,this.guardKick=Math.max(this.guardKick,1.1)}windedFor(e,t){this.windedTime=Math.max(this.windedTime,e),this.windedSide=t>=0?1:-1}fallToKnee(e){this.dead||(this.fallKneel=e,e&&(this.authoredNextFall=!0))}dentSurface(e,t,n,r){let i=1.1+r*2.1;if(e===`body`){let e=n===`hook`?t>0?`rightRibs`:`leftRibs`:`solarPlexus`;this.boxer.bodyInjury.impact(e,[n===`hook`?t*i*.8:0,0,-i],9)}else n===`hook`?this.boxer.headInjury.impact(t>0?`rightCheek`:`leftCheek`,[t*i,0,-i*.35],5.5):n===`uppercut`?this.boxer.headInjury.impact(`chin`,[0,i*.7,-i*.6],5):this.boxer.headInjury.impact(n===`jab`?`nose`:`mouth`,[0,0,-i],4.5)}stepFeet(e,t,n,r,i,a){let o=this.scratch,s=this.scratchQ.setFromAxisAngle(XL,a);for(let c=0;c<2;c+=1){let l=this.feet[c],u=c===0==t>0?VM.leadFoot:VM.rearFoot;if(this.referee||this.squareWeight>.5?o.set(c===0?.16:-.16,0,c===0?.02:-.02).applyQuaternion(s).add(i):o.set(u.x*t,0,u.z).applyQuaternion(s).add(i),o.y=0,this.daze>.001&&this.stumble(c,o,a),!this.feetInitialized){l.planted.copy(o),l.progress=1,l.stepping=!1;continue}if(l.stepping){l.progress=Math.min(1,l.progress+e/l.duration),l.progress>=1&&(l.stepping=!1,l.planted.copy(l.to));continue}let d=this.feet[1-c];l.planted.distanceTo(o)>(n>.05?.09:.14)*this.stepSlack&&!d.stepping&&(l.stepping=!0,l.progress=0,l.duration=EF(.24-n*.07,.15,.24)*this.stepPace[c],l.from.copy(l.planted),l.to.copy(o).addScaledVector(r,l.duration*.6),l.to.y=0)}this.feetInitialized=!0}footWorld(e,t){let n=this.feet[e];if(!n.stepping)return t.copy(n.planted),0;let r=OM(n.progress,1.6);return t.copy(n.from).lerp(n.to,r),Math.sin(n.progress*Math.PI)*.055*this.stepLift[e]}update(e,t,n,r,i,a,o,s){let c=this.boxer,l=e.stance===`orthodox`?1:-1,u=i?.35:1,d=this.touchWalk(e,t,n,o);this.walkBackFromTheFall(n);let f=this.holdOnTheRopes(t,this.mapping.x(e.x)+d.x+this.riseRoot.x,this.mapping.z(e.y)+d.z+this.riseRoot.z),p=this.mapping.x(e.x)+d.x+this.riseRoot.x-f.x,h=this.mapping.z(e.y)+d.z+this.riseRoot.z-f.z;this.place.set(p,0,h),this.rootX===null&&(this.rootX=p,this.rootZ=h);let g=_R*Math.max(n,1/60);this.rootX+=EF(p-this.rootX,-g,g),this.rootZ+=EF(h-this.rootZ,-g,g);let _=Math.atan2(e.facing_x,-e.facing_y);this.yawInitialized||=(this.yaw=_,!0);let v=this.punchActive&&this.punchAgeTicks0?.12:1;let y=n*this.hitstopScale;this.punchActive&&this.hitstop>0&&(this.hitstopLag+=(n-y)*30),this.syncAction(e,t,o,y),this.debugHoldImpact||(this.boxer.headInjury.update(y),this.boxer.bodyInjury.update(y)),s!==void 0&&this.trackOpponentHead(t,s,n);let b=this.scratchB.set(this.mapping.x(e.velocity_x)*30,0,this.mapping.z(e.velocity_y)*30).add(this.touchVelocity).add(this.riseRootVelocity),x=b.length(),S=Math.hypot(b.x-this.riseRootVelocity.x,b.z-this.riseRootVelocity.z);this.lastSpeed=x,this.stillTime=x<.03?this.stillTime+n:0;let C=this.resting&&this.stillTime>.2&&this.downState===`up`;this.seated=wF(this.seated,+!!C,C?2.2:4,n);let w=this.resting&&this.stillTime>.05&&this.downState===`up`;w&&(this.stoolRoot.set(this.rootX,0,this.rootZ),this.stoolYaw=this.yaw),this.stool.group.visible=w||this.seated>sI&&this.downState===`up`,this.stool.group.position.set(this.stoolRoot.x-this.rootX,0,this.stoolRoot.z-this.rootZ).add(this.scratch.set(0,0,.02).applyAxisAngle(XL,this.stoolYaw)).applyAxisAngle(XL,-this.yaw),this.stool.group.rotation.y=this.stoolYaw-this.yaw,this.celebrateTime=Math.max(0,this.celebrateTime-n),this.celebration=wF(this.celebration,+(this.celebrateTime>0&&this.downState===`up`),3.5,n),this.waveTime=Math.max(0,this.waveTime-n),this.wave=wF(this.wave,+(this.waveTime>0&&this.downState===`up`),4,n),this.breakTime=Math.max(0,this.breakTime-n),this.breakWeight=wF(this.breakWeight,+(this.breakTime>0&&this.downState===`up`),6,n),this.attendWeight=wF(this.attendWeight,+!!this.attending,2.5,n),this.squareWeight=wF(this.squareWeight,this.verdictSide===0?0:1,3,n),this.raisedWeight=wF(this.raisedWeight,+(this.verdictSide!==0&&(this.verdict===`winner`||this.verdict===`level`)),3.2,n),this.bowedWeight=wF(this.bowedWeight,+(this.verdictSide!==0&&this.verdict===`loser`),2.2,n);for(let e of[0,1])this.wristWeights[e]=wF(this.wristWeights[e],this.wrists[e]===null?0:1,3.2,n);this.treatWeight=wF(this.treatWeight,+!!this.treating,3,n),this.windedTime=Math.max(0,this.windedTime-n);let T=this.fallKneel&&this.downState===`falling`;this.winded=wF(this.winded,this.windedTime>0&&this.downState===`up`||T?1:0,this.windedTime>0||T?12:4,n),this.enswell.group.visible=this.treatWeight>.4&&this.treatProp===`enswell`,this.bottle.group.visible=this.treatWeight>.4&&this.treatProp===`bottle`;let E=this.countdownTicks!==null&&this.countdownTicks<=dI&&this.countdownTicks>=fI;this.touchWeight=wF(this.touchWeight,+!!E,6,n);let D=e.stamina/Math.max(1,e.maximum_stamina);this.tired=wF(this.tired,EF((.55-D)/.5,0,1),2,n),this.stunAmount=wF(this.stunAmount,Math.min(1,e.stunned_ticks/24),8,n);let O=e.defense;this.guardHigh=wF(this.guardHigh,+(O===`guard_high`),dR,n),this.guardLow=wF(this.guardLow,+(O===`guard_low`),dR,n),this.guardSpent=wF(this.guardSpent,+(e.guard0||e.clinch_startup_ticks>0),10,n),this.foulWeight=wF(this.foulWeight,+!!e.is_foul_recovery_target,8,n),this.tauntWeight=wF(this.tauntWeight,+(e.taunt_ticks>0),10,n);let j=Math.hypot(this.mapping.x(t.x)-this.mapping.x(e.x),this.mapping.z(t.y)-this.mapping.z(e.y)),ee=this.referee||e.is_downed||t.is_downed?0:1-EM(jF,FF,j);this.crowding=wF(this.crowding,ee,9,n);let M=1/0;if(this.hasLiveHead&&!this.referee&&this.downState===`up`){let e=this.boxer.rig.bones.head.getWorldPosition(this.ownHead),t=e.x-this.liveOpponentHead.x,r=e.z-this.liveOpponentHead.z,i=Math.hypot(t,r);if(M=Math.hypot(t,e.y-this.liveOpponentHead.y,r),M1e-4){let e=(MF-M)/MF*PF*n,a=Math.cos(-this.yaw),o=Math.sin(-this.yaw);this.headSpace.x+=(t*a+r*o)/i*e,this.headSpace.y+=(-t*o+r*a)/i*e,this.headSpace.lengthSq()>1&&this.headSpace.normalize()}}M>NF&&this.headSpace.multiplyScalar(Math.exp(-3*n)),this.tauntEnd=GL(this.tauntEnd,o,e.taunt_ticks>0?e.taunt_ticks:null),OF(this.headKick,n,190,7.5,.24),OF(this.torsoKick,n,150,7,.7),OF(this.rootKick,n,120,8,.12),OF(this.coverKick,n,110,15,.3),this.foldDelay>0&&(this.foldDelay-=n,this.foldDelay<=0&&(this.torsoKick.velocity.x+=this.pendingFold,this.pendingFold=0)),this.guardKick=Math.max(0,this.guardKick-n*2.4),this.ragdoll?.tick(n),this.updateDownState(e,n,i,S),this.stepDeath(n),this.stepInjuries(n);let te=(1.9-this.tired*.7)*(1-this.stunAmount*.6);this.bouncePhase+=n*te*Math.PI*2*u,this.weightPhase+=n*.55*Math.PI*2*u,this.stunPhase+=n*5.5,this.feintTimer-=n,this.feintTimer<=0&&!this.punchActive&&x<.05&&this.downState===`up`&&(this.feintTimer=2.5+this.bouncePhase%1.7,this.feint=1),this.feint=Math.max(0,this.feint-n*3.5);let ne=this.scratchC.set(this.rootX,0,this.rootZ);(this.downState===`up`||this.downState===`rising`)&&this.stepFeet(n,l,x,b,ne,this.yaw);let re=this.scratchQ.setFromAxisAngle(XL,-this.yaw),ie=l>0?this.foot.L:this.foot.R,N=l>0?this.foot.R:this.foot.L,ae=l>0?0:1,oe=+(l>0),se=this.footWorld(ae,ie.position),ce=this.footWorld(oe,N.position);ie.position.sub(ne).applyQuaternion(re),N.position.sub(ne).applyQuaternion(re);let le=this.boxer.rig.metrics.ankleHeight;ie.position.y=le+se,N.position.y=le+ce,HM(VM.leadToe,l,ie.toe),HM(VM.rearToe,l,N.toe),ie.heel=0,N.heel=0,ie.pole.copy(ie.toe).setY(.35).normalize(),N.pole.copy(N.toe).setY(.35).normalize();let P=this.torso,ue=VM.bladeYaw*l,de=Math.sin(this.bouncePhase)*.012*(1-this.stunAmount)*(x>.6?.6:1),fe=Math.sin(this.weightPhase)*.02,pe=.012+this.tired*.03+this.stunAmount*.05;P.hips.set(fe*l+Math.sin(this.stunPhase*.9)*.05*this.stunAmount,VM.hipsHeight-pe+de,0),P.hipsYaw=ue,P.hipsPitch=.02+this.tired*.08,P.hipsRoll=Math.sin(this.stunPhase)*.09*this.stunAmount,P.shouldersYaw=ue*.88,P.spinePitch=.16+this.tired*.16+Math.sin(r*(2.1+this.tired*1.8))*.012,P.spineRoll=Math.sin(this.stunPhase*1.3)*.06*this.stunAmount,P.headYaw=-.12*l+Math.sin(r*.9)*.05+Math.sin(this.stunPhase*.7)*.25*this.stunAmount,P.headPitch=.12+Math.sin(r*1.7)*.02+this.stunAmount*.18,P.headRoll=Math.sin(this.stunPhase*1.1)*.14*this.stunAmount,P.headOffset.set(0,0,0);let me=l>0?this.hand.L:this.hand.R,he=l>0?this.hand.R:this.hand.L,ge=this.headRestChar(l),_e=EF(this.guardHigh+this.guardLow,0,1),ve=this.scratch.copy(VM.relaxedLead).lerp(VM.guardHighLead,this.guardHigh).lerp(VM.guardLowLead,this.guardLow),ye=this.scratchB.copy(VM.relaxedRear).lerp(VM.guardHighRear,this.guardHigh).lerp(VM.guardLowRear,this.guardLow);ve.y-=this.tired*.12+this.stunAmount*.22,ye.y-=this.tired*.1+this.stunAmount*.2,ve.y-=this.guardSpent*xI,ye.y-=this.guardSpent*xI,ve.z-=this.guardSpent*.04,ye.z-=this.guardSpent*.03,ve.z+=this.feint*.1+Math.sin(r*2.3)*.012*u,ve.x+=Math.sin(r*1.9)*.01*u,ye.y+=Math.cos(r*2.7)*.01*u,ve.z-=this.guardKick*.07,ye.z-=this.guardKick*.05,ve.y-=this.guardKick*.02,ve.add(ge),ye.add(ge),me.position.set(ve.x*l,ve.y,ve.z),he.position.set(ye.x*l,ye.y,ye.z),HM(VM.leadKnuckles,l,me.knuckles),HM(VM.leadPalm,l,me.palm),HM(VM.rearKnuckles,l,he.knuckles),HM(VM.rearPalm,l,he.palm),HM(VM.leadPole,l,me.pole),HM(VM.rearPole,l,he.pole);let be=.15*_e,xe=.25*_e;if(this.hurt&&this.applyHurtStance(r,l,me,he,ge),Math.abs(this.slip)>.001){let e=this.slip;P.headOffset.x+=e*.13,P.spineRoll+=-e*.28,P.hips.x+=e*.03,P.hips.y-=Math.abs(e)*.05,P.spinePitch+=Math.abs(e)*.12,P.headRoll+=-e*.2}if(this.weave>.001){let e=this.weave,t=EF(this.weaveTime/fR,0,1),n=Math.sin(t*Math.PI);P.hips.y-=e*.2,P.spinePitch+=e*.42,P.headOffset.x+=e*(1-2*t)*.16*l,P.headOffset.y-=e*n*.08,P.spineRoll+=e*(1-2*t)*.18*l,me.position.y-=e*.1,he.position.y-=e*.1}if(this.pull>.001){let e=this.pull;P.spinePitch-=e*.34,P.hips.z-=e*.11,P.hips.x-=e*.05*l,P.headOffset.z-=e*.06,P.headPitch-=e*.1}this.punchCommit=wF(this.punchCommit,+!!this.punchActive,10,n);let Se=this.crowding*(1-this.clinchWeight)*(1-this.punchCommit);if(Se>.001&&(P.headOffset.x-=Se*.075,P.headOffset.z-=Se*.05,P.headYaw-=Se*.2,P.spinePitch-=Se*.07,P.hips.z-=Se*.05,me.position.z-=Se*.14,me.position.x-=Se*.035*l,he.position.z-=Se*.07),Math.abs(this.headSpace.x)+Math.abs(this.headSpace.y)>.001){let e=this.headSpace.x,t=this.headSpace.y,n=1-this.clinchWeight;P.spinePitch+=t*.7*n,P.spineRoll-=e*.7*n,P.hips.z+=t*.1*n,P.hips.x+=e*.05*n,P.headOffset.x+=e*.05,P.headOffset.z+=t*.05,P.headPitch+=t*.2,P.headRoll-=e*.3}if(this.ropeLean=wF(this.ropeLean,this.referee||this.downState!==`up`?0:this.ropeLeanTarget,WF,n),this.ropeLean>.001){let e=this.ropeLocal.copy(this.ropeOutward).applyAxisAngle(XL,-this.yaw);P.hipsPitch+=e.z*HF*this.ropeLean,P.hipsRoll-=e.x*UF*this.ropeLean}if(this.referee||this.applyReactions(me,he,ie,N),this.punchActive){be=0,xe=0;let e=this.applyPunch(l,me,he,ie,N,ge);this.punchReach=e,this.punchHand===`left`==l>0?be=e:xe=e}if(this.referee&&(this.applyRefereePose(l,me,he,ie,N,ge,r,o,e.stunned_ticks),this.applyReactions(me,he,ie,N)),this.clinchWeight>.001&&this.applyClinchPose(this.clinchWeight,r,l,e,t,me,he,ge),this.foulWeight>.001){let e=this.foulWeight;P.hips.y-=e*.16,P.spinePitch+=e*.55,P.headPitch+=e*.2,me.position.lerp(this.scratch.set(.06*l,.72,.16),e),he.position.lerp(this.scratch.set(-.05*l,.7,.14),e),me.pole.set(.6*l,-.6,.5),he.pole.set(-.6*l,-.6,.5)}if(this.tauntWeight>.001){let e=this.tauntEnd===null?0:EF(this.tauntEnd-o,0,yI);this.applyTauntPose(this.tauntWeight,(yI-e)/yI*bI,l,me,he,ge)}if(this.dislocation===`shoulder_left`||this.dislocation===`shoulder_right`){let e=this.dislocation===`shoulder_left`?this.hand.L:this.hand.R,t=this.dislocation===`shoulder_left`?1:-1;e.position.set(.24*t,.55,.05),e.pole.set(.9*t,-.3,.2),e.knuckles.set(0,-1,.1),e.palm.set(-t,0,.2)}this.winded>.001&&(this.downState===`up`||T)&&this.applyWindedPose(this.winded,r,l,me,he),this.hurt&&this.downState===`up`&&this.applyHurtActs(r,l,ie,N),this.touchWeight>.001&&this.downState===`up`&&this.applyTouchGlovesPose(this.touchWeight,l,me,he),this.celebration>.001&&this.downState===`up`&&this.applyCelebratePose(this.celebration,r,l,me,he,ie,N),this.wave>.001&&this.downState===`up`&&this.applyWaveOffPose(this.wave,r,l,me,he),this.squareWeight>.001&&this.downState===`up`&&this.applyVerdictPose(this.squareWeight,r,l,me,he,ie,N,ge),(this.wristWeights[0]>.001||this.wristWeights[1]>.001)&&this.downState===`up`&&this.applyRaisePose(l,me,he),this.breakWeight>.001&&this.downState===`up`&&this.applyBreakPose(this.breakWeight,l,me,he),this.attendWeight>.001&&this.downState===`up`&&this.applyAttendPose(this.attendWeight,r,l,me,he),this.treatWeight>.001&&this.downState===`up`&&this.applyTreatPose(this.treatWeight,r,l,me,he,ie,N),this.seated>.001&&this.downState===`up`&&this.applySeatedPose(this.seated,r,l,me,he,ie,N),this.downState!==`up`&&this.applyDownPose(l,me,he,ie,N),this.steadyJointPoles(l,me,he,ie,N,n),pe=0;let F=this.pose;F.shrugL=l>0?be:xe,F.shrugR=l>0?xe:be;let Ce=this.ragdoll;if(Ce?.active===!0&&i&&(Ce.stop(),Ce.clearRise()),Ce?.active===!0&&!Ce.handingOver)Ce.setLost(c.isDecapitated,c.isHandDismembered(`left`),c.isHandDismembered(`right`)),Ce.update(n,this.obstacle),this.hurt&&this.dropDangles();else{if(this.solver.apply(c.root,this.pose),Ce?.handingOver===!0)Ce.followPose(n,this.obstacle),this.riseProgress>=JF&&Ce.handOverSeconds>=rI&&(Ce.letGo(),this.riseBlendAge=0);else if(Ce!==null&&Ce.hasRisePose){let e=EM(0,nI,this.riseBlendAge);e<1&&this.downState!==`up`?Ce.blendRise(e):Ce.clearRise()}this.hurt&&this.dangleArms(n),Ce?.sample(n)}this.applyDislocation();let we=Math.min(1,(t.trauma.bleeding+t.trauma.left_cut+t.trauma.right_cut+t.trauma.head/4)/300*(a===`off`?0:a===`reduced`?.15:1.5));c.setGloveBlood(we),c.setTrunksBlood(fj(e.trauma,a)),dj(c.headInjury,e.trauma,a),pj(c.bodyInjury,e.trauma,a),c.setSkinClearcoat(.25+(1-D)*.4),this.laidOut=!1}applyTauntPose(e,t,n,r,i,a){let o=this.torso,s=.5-.5*Math.cos(t*Math.PI*2);i.position.lerp(this.scratch.set(-.3*n,a.y-.62,.02),e),i.pole.lerp(this.scratch.set(-.5*n,-.4,-.75),e).normalize(),i.knuckles.lerp(this.scratch.set(-.1*n,-.95,.3),e).normalize(),i.palm.lerp(this.scratch.set(0,.3,.95),e).normalize(),r.position.lerp(this.scratch.set(.26*n,a.y-.36+s*.1,.52-s*.24),e),r.pole.lerp(this.scratch.set(.7*n,-.7,.1),e).normalize(),r.knuckles.lerp(this.scratch.set(.1*n,.25+s*.6,.95-s*.7),e).normalize(),r.palm.lerp(this.scratch.set(-.2*n,.95,-.2-s*.5),e).normalize(),o.spinePitch-=e*.12,o.headPitch-=e*.22,o.headYaw+=Math.sin(t*Math.PI)*.15*e,o.shouldersYaw+=Math.sin(t*Math.PI*3)*.1*e,o.hips.x+=Math.sin(t*Math.PI)*.03*e*n,o.headOffset.z+=e*.03}applyClinchPose(e,t,n,r,i,a,o,s){let c=this.torso,l=r.player_idy&&(h.x*=y/v,h.z*=y/v),h.x+=o,h.z+=u,t.position.lerp(h,e),t.pole.lerp(this.clinchTemp.set(r*.85,l?.35:-.6,.25),e).normalize(),t.knuckles.lerp(this.clinchTemp.set(-p*r*.9+f.x*.3,l?-.25:.1,-m*r*.9+f.z*.3),e).normalize(),t.palm.lerp(this.clinchTemp.set(-f.x,l?.1:.35,-f.z),e).normalize()}}holdOnTheRopes(e,t,n){if(this.referee)return this.ropeLeanTarget=0,this.ropeHold.set(0,0,0);this.ropeLeanTarget=GF(t,n,this.ropeExcess,this.ropeOwn);let r=Math.hypot(this.ropeExcess.x,this.ropeExcess.z);r>0&&this.ropeOutward.set(this.ropeExcess.x/r,0,this.ropeExcess.z/r);let i=this.mapping.x(e.x),a=this.mapping.z(e.y);GF(i,a,this.ropeTheirs,this.ropeTheirs);let o=1-EM(RF,zF,Math.hypot(i-t,a-n));return this.ropeHold.set(KF(this.ropeOwn.x,this.ropeTheirs.x*o),0,KF(this.ropeOwn.z,this.ropeTheirs.z*o))}headRestChar(e){let t=this.boxer.rig.metrics;return this.headWorld.set(-.08,t.headHeight-t.hipsHeight+this.torso.hips.y,.02)}syncAction(e,t,n,r){this.shownFighter=e,this.shownOpponent=t;let i=this.ownQueued;if(i!==null&&e.action_id===i.action.id&&(this.ownQueued=null,this.retirePunch(),this.startOwnPunch(i),this.ownPress=!1),e.action_id!==null&&e.action_id!==this.actionId&&e.action_id!==this.completedActionId&&!this.retiredOwnIds.includes(e.action_id)){let t=e.action;if(t!==null){let r=e.action_hand??(e.stance===`orthodox`?`left`:`right`),i=this.ownActionId===e.action_id&&this.punchActive,a=this.punchTiming;this.actionId=e.action_id,this.punchClass=t,this.punchHand=r,this.punchTarget=e.action_target??`head`,this.punchPower=e.action_power??`normal`,this.punchTiming={...oe(this.punchClass,this.punchTarget,this.punchPower),startup:e.action_startup_ticks,active:e.action_active_ticks,recovery:e.action_recovery_ticks},this.punchTotalTicks=Math.max(1,e.action_startup_ticks+e.action_active_ticks+e.action_recovery_ticks);let o=Math.max(0,n-e.action_start_tick);i?(this.punchAgeTicks=gR(this.punchAgeTicks,a,this.punchTiming),this.ownAuthoritativeAge=o,this.ownRefused||(this.ownPulled=!1,this.ownCut=!1,o-this.punchAgeTicks>1&&(this.punchAgeTicks=o))):(this.punchAgeTicks=o,this.ownActionId=null,this.ownPress=!1,this.ownLeadTicks=0,this.ownAuthoritativeAge=null),this.ownWaitedTicks=0,this.punchActive=!0}}if(e.action_id===null)this.actionId=null,this.completedActionId=null;else if(e.action_id===this.actionId&&this.punchActive){let t=Math.max(0,n-e.action_start_tick);this.ownActionId===this.actionId?(this.ownAuthoritativeAge=t,!this.ownPulled&&t-this.punchAgeTicks-this.hitstopLag>1.5&&(this.punchAgeTicks=t)):Math.abs(this.punchAgeTicks+this.hitstopLag-t)>1.5&&(this.punchAgeTicks=t,this.hitstopLag=0)}if(this.punchActive&&this.ownActionId!==null&&this.ownAuthoritativeAge===null&&!this.ownPulled&&!this.ownCut&&(this.ownWaitedTicks+=r*30,this.ownWaitedTicks>this.ownExpectedTicks*1.5+QL&&(this.ownPress?!this.ownStarted:this.punchAgeTicks=e,n=this.hitstop>0?0:Math.min(this.hitstopLag,r*30*tR);this.hitstopLag-=n,this.punchAgeTicks+=r*30*(t?eR:this.ownPunchRate())+n,this.ownPress&&this.ownActionId!==null&&!this.ownCut&&this.punchAgeTicks>=this.punchTiming.startup&&this.pressesLanded.at(-1)!==this.ownActionId&&(this.pressesLanded.push(this.ownActionId),this.pressesLanded.length>6&&this.pressesLanded.shift()),this.punchAgeTicks>=this.punchTotalTicks&&this.retirePunch()}e.is_downed&&(this.punchActive&&this.retirePunch(),this.ownQueued=null),this.releaseQueuedPress(r);let a=this.actionId??this.ownActionId;a!==this.aimActionId&&(this.aimActionId=a,this.followHead=0),this.followHead=wF(this.followHead,+(a!==null&&a===this.contactId),mR,r),this.followReferee=wF(this.followReferee,+(a!==null&&a===this.refereeContactId),mR,r)}trackOpponentHead(e,t,n){let r=this.guardOpponentHead.set(this.mapping.x(e.x),0,this.mapping.z(e.y));this.opponentSteadySeconds=uR.has(e.defense)?0:this.opponentSteadySeconds+n,(!this.hasLiveHead||this.opponentSteadySeconds>=pR)&&this.opponentHeadOffset.copy(t).sub(r),r.add(this.opponentHeadOffset),this.liveOpponentHead.copy(t),this.hasLiveHead=!0}ownPunchRate(){if(this.ownActionId===null||this.ownPress)return 1;let e=this.punchTiming.startup,t=this.ownAuthoritativeAge;return t===null?this.punchAgeTicks0,h=m?t:n,g=m?n:t,_=m?1:-1,v=+(this.punchPower===`power`),y=+(this.punchTarget===`body`),b,x,S,C=1,w=1,T=0;if(u0){let t=this.scratchQ.setFromAxisAngle(XL,-ae*e*E);r.toe.applyQuaternion(t),r.pole.applyQuaternion(t)}if(ie>.3){let t=this.scratchQ.setFromAxisAngle(XL,.45*e*E);i.toe.applyQuaternion(t),i.pole.applyQuaternion(t)}let _e=this.scratchE;switch(this.punchClass){case`hook`:_e.set(.22*_*e,-.06,-.12);break;case`uppercut`:_e.set(.05*_*e,-.42,-.02);break;case`straight`:_e.set(.02*_*e,-.03,-.09-.05*v);break;default:_e.set(0,-.01,-.05-.04*v)}_e.x+=(this.punchClass===`hook`?.08:0)*_*e*v,_e.y-=.05*v,_e.z-=.12*v;let ve=this.punchStart.copy(k).addScaledVector(_e,Math.max(x,this.punchClass===`hook`||this.punchClass===`uppercut`?(1-D)*.6*C:0));if(this.punchClass===`hook`){let t=Math.hypot(ve.x-de.x,ve.z-de.z),n=Math.hypot(ge.x-de.x,ge.z-de.z),r=this.punchSweepFrom.copy(ve).sub(de).setY(0).normalize(),i=this.punchSweepTo.copy(ge).sub(de).setY(0).normalize(),a=Math.acos(EF(r.dot(i),-1,1)),o=r.z*i.x-r.x*i.z>=0?1:-1,s=EM(0,1,D),c=r.applyAxisAngle(XL,a*s*o).normalize();h.position.copy(de).addScaledVector(c,G.lerp(t,n,s)),h.position.y=G.lerp(ve.y,ge.y,s),h.pole.set(.95*_*e,.08,.3).normalize(),h.knuckles.copy(c).applyAxisAngle(XL,o*Math.PI/2).setY(.05).normalize(),h.palm.set(0,-1,0)}else if(this.punchClass===`uppercut`){let t=EM(0,1,D),n=ve,r=this.punchMid.copy(ge).lerp(n,.5);r.y=Math.min(n.y,ge.y)-.04,r.z+=.08,h.position.copy(n).lerp(r,t*2>1?1:t*2),t>.5&&h.position.copy(r).lerp(ge,(t-.5)*2),h.pole.set(.3*_*e,-.2,1),h.knuckles.set(.05*_*e,.9,.35).normalize(),h.palm.set(-.2*_*e,.3,-.95).normalize()}else{h.position.copy(ve).lerp(ge,Math.min(1,D)),h.position.y+=Math.sin(EF(D,0,1)*Math.PI)*.025,h.pole.set(.55*_*e,-.9,.35);let t=EM(.55,1,D);h.knuckles.copy(fe).lerp(this.scratchC.set(.1*_*e,.55,.8),1-t).normalize(),h.palm.set(-.9*_*e,.2,-.3).lerp(this.scratchC.set(0,-1,.1),t).normalize()}if(O>0&&(h.position.lerp(k,O),h.knuckles.lerp(A,O).normalize(),h.palm.lerp(j,O).normalize(),h.pole.lerp(ee,O).normalize()),w<1){let t=(1-h.pole.dot(ee)/Math.max(1e-6,h.pole.length()*ee.length()))/2;h.knuckles.lerp(A,1-w).normalize(),h.palm.lerp(j,1-w).normalize(),h.pole.lerp(ee,1-w).addScaledVector(this.scratchC.set(_*e,0,0),hR*t*Math.sin(Math.PI*w)).normalize()}let ye=this.scratchE.set(-.1*_*e,a.y-.04,.12+a.z);return g.position.lerp(ye,E*.7),E}applyReactions(e,t,n,r){let i=this.torso;i.headOffset.add(this.headKick.value),i.headPitch+=-this.headKick.value.z*2.4+this.headKick.value.y*1.6,i.headYaw+=this.headKick.value.x*2.2,i.headRoll+=-this.headKick.value.x*.9,i.spinePitch+=this.torsoKick.value.x,i.spineRoll+=this.torsoKick.value.z*.5,i.hips.x+=this.rootKick.value.x,i.hips.z+=this.rootKick.value.z,i.hips.y-=Math.max(0,this.torsoKick.value.x)*.08,this.torsoKick.value.x>.05&&(e.position.y-=this.torsoKick.value.x*.25,t.position.y-=this.torsoKick.value.x*.2,e.position.z-=this.torsoKick.value.x*.1);let a=Math.max(0,this.rootKick.value.y);i.hips.y+=a,n.heel+=a*6,r.heel+=a*6;let o=this.coverKick.value.x;if(Math.abs(o)>.002){let e=o>0?this.hand.R:this.hand.L;e.position.y-=Math.abs(o)*.9,e.position.x+=o*.2,e.position.z-=Math.abs(o)*.25,e.pole.y-=Math.abs(o)*3}}applyRefereePose(e,t,n,r,i,a,o,s,c=0){let l=this.torso;l.hipsYaw=0,l.shouldersYaw=0,l.hipsPitch=0,l.spinePitch=.06,l.headYaw=Math.sin(o*.7)*.08,l.headPitch=.08,l.hips.y=VM.hipsHeight+.03,l.hips.x=0,l.hips.z=0,r.toe.set(.12*e,0,1).normalize(),i.toe.set(-.12*e,0,1).normalize(),r.pole.copy(r.toe).setY(.3).normalize(),i.pole.copy(i.toe).setY(.3).normalize();let u=Math.sin(o*1.3)*.01;if(t.position.set(.27*e,.86+u,.12),n.position.set(-.27*e,.86-u,.12),t.pole.set(.5*e,-.4,-.8).normalize(),n.pole.set(-.5*e,-.4,-.8).normalize(),t.knuckles.set(.15*e,-.9,.35).normalize(),n.knuckles.set(-.15*e,-.9,.35).normalize(),t.palm.set(-.9*e,.1,.35).normalize(),n.palm.set(.9*e,.1,.35).normalize(),this.refereeCounting){this.countChangedTick??=s;let r=EF((s-this.countChangedTick)/ee,0,1),i=r0){let r=Math.min(1,c/12),i=Math.sin(o*9.5);l.hips.y-=.09*r,l.hips.x+=i*.05*r,l.spineRoll+=i*.18*r,l.headRoll-=i*.35*r,l.headPitch+=.25*r,t.position.x+=.18*e*r,n.position.x-=.18*e*r,t.position.y-=.1*r,n.position.y-=.1*r}}updateDownState(e,t,n,r){if(this.riseBlendAge+=t,e.is_downed||this.forcedDown||this.dead){if(this.downState===`up`||this.downState===`rising`||this.deathFall)this.deathFall=!1,this.fallFromGetUp=this.downState!==`up`,this.fallFromGetUp&&(HL(this.fallStart,this.downResult),this.fallStartStand=this.downStand),this.downState=`falling`,this.fallAge=0,this.riseProgress=0,this.riseRootFrom.copy(this.riseRoot),this.landSettled=!1,this.fallenFromPhysics=!1,this.downPolesSet=!1,this.ragdoll?.clearRise(),this.authoredNextFall?this.ragdoll?.forget():n||this.startFall(e),this.authoredNextFall=!1;else if(this.downState===`falling`)this.fallAge+=t,this.fallAge>=qF&&(this.downState=`down`);else if(this.fallKneel)this.riseProgress=YF;else{let n=(!this.forcedDown&&!this.heldDown&&!this.dead&&e.get_up_required>0?EF(e.get_up_meter/e.get_up_required,0,1):0)*YF;if(this.ragdoll?.active===!0&&!this.ragdoll.handingOver){if(n<=0)return;this.handOverFall(e)}this.riseProgress+=EF(n-this.riseProgress,-.4*t,QF*t)}return}if((this.downState===`down`||this.downState===`falling`)&&(this.downState=`rising`,this.ragdoll?.active===!0&&!this.ragdoll.handingOver&&this.handOverFall(e),this.fallKneel&&(this.riseProgress=Math.max(this.riseProgress,YF)),this.riseFrom=this.riseProgress,this.feetInitialized=!1),this.downState!==`rising`)return;let i=r>.3||this.punchActive,a=(1-this.riseFrom)/(i?ZF:XF);this.riseProgress=Math.min(1,this.riseProgress+(this.riseProgress=1&&(this.downState=`up`,this.fallKneel=!1)}startFall(e){let t=this.ragdoll;t!==null&&(this.rootX!==null&&Math.hypot(this.place.x-this.rootX,this.place.z-this.rootZ)>iI&&(this.rootX=this.place.x,this.rootZ=this.place.z,this.boxer.root.position.set(this.rootX,0,this.rootZ)),t.start(this.dead?this.deathStyle:`crumple`),e.get_up_count>0&&!this.dead&&(t.settle(),this.fallAge=qF))}handOverFall(e){let t=this.ragdoll;if(t===null||!t.active||t.handingOver)return;let n=e.stance===`orthodox`?1:-1,r=this.boxer.rig.bones;this.boxer.root.updateMatrixWorld(!0);let i=this.scratchC.set(this.rootX??0,0,this.rootZ),a=this.scratchQ.setFromAxisAngle(XL,-this.yaw),o=this.fallen,s=(e,t)=>t.setFromMatrixPosition(e.matrixWorld).sub(i).applyQuaternion(a),c=(e,t,n,r)=>NL(vL.setFromQuaternion(e.getWorldQuaternion(_L).premultiply(a),`YXZ`),t,n,r);s(r.hips,o.hips),this.landProne=t.faceDown();let l=Math.abs(o.hips.x)>.12?Math.sign(o.hips.x):0,u=this.landProne?kL(this.downTo,TL,EL,n,l,this.boxer.rig.metrics.ankleHeight):kL(this.downTo,CL,wL,n,l,this.boxer.rig.metrics.ankleHeight);this.landSide=l,this.landShift.set(o.hips.x-u.hips.x,0,o.hips.z-u.hips.z);let d=c(r.hips,u.hipsPitch,u.hipsYaw,u.hipsRoll);o.hipsPitch=d.x,o.hipsYaw=d.y,o.hipsRoll=d.z;let f=c(r.upperChest,o.hipsPitch,o.hipsYaw,o.hipsRoll);o.shouldersYaw=f.y,o.spinePitch=f.x-o.hipsPitch,o.spineRoll=f.z-o.hipsRoll;let p=c(r.head,f.x,f.y,f.z);o.headPitch=p.x,o.turn=p.y,o.headRoll=p.z,s(n>0?r.gloveL:r.gloveR,o.leadHand),s(n>0?r.gloveR:r.gloveL,o.rearHand),s(n>0?r.ankleL:r.ankleR,o.leadFoot),s(n>0?r.ankleR:r.ankleL,o.rearFoot);let m=this.boxer.rig.metrics.ankleHeight;o.leadFoot.y=Math.max(o.leadFoot.y,m),o.rearFoot.y=Math.max(o.rearFoot.y,m);let h=(e,t,n,r,i)=>{let o=s(e,this.scratchB),c=s(n,this.scratchD).sub(o).normalize();s(t,r).sub(o),r.addScaledVector(uL.copy(i).applyQuaternion(e.getWorldQuaternion(_L)).applyQuaternion(a),gL),r.addScaledVector(c,-r.dot(c)),r.lengthSq()>1e-6?r.normalize():r.copy(i===pL?dL:fL)},g=n>0;h(g?r.hipL:r.hipR,g?r.kneeL:r.kneeR,g?r.ankleL:r.ankleR,o.leadKnee,pL),h(g?r.hipR:r.hipL,g?r.kneeR:r.kneeL,g?r.ankleR:r.ankleL,o.rearKnee,pL),h(g?r.shoulderL:r.shoulderR,g?r.elbowL:r.elbowR,g?r.gloveL:r.gloveR,o.leadElbow,g?mL:hL),h(g?r.shoulderR:r.shoulderL,g?r.elbowR:r.elbowL,g?r.gloveR:r.gloveL,o.rearElbow,g?hL:mL);let _=(e,t,n)=>{let r=e.getWorldQuaternion(_L).premultiply(a);t.set(0,1,0).applyQuaternion(r),n.set(0,0,1).applyQuaternion(r)};_(g?r.gloveL:r.gloveR,o.leadKnuckles,o.leadPalm),_(g?r.gloveR:r.gloveL,o.rearKnuckles,o.rearPalm),o.ownJoints=1,o.leadHeel=0,o.rearHeel=0,o.palmsDown=+!!this.landProne,this.fallenFromPhysics=!0,this.landSettled=!0,this.downPolesSet=!1,t.handOver(),this.riseBlendAge=0;let v=this.scratchE.set(t.pelvis(this.scratchD).x-(this.rootX??0),0,this.scratchD.z-this.rootZ),y=this.scratchB.copy(v).applyQuaternion(a);for(let e of[o.hips,o.leadHand,o.rearHand,o.leadFoot,o.rearFoot])e.x-=y.x,e.z-=y.z;t.shiftRise(this.scratchC.copy(v).negate()),this.rootX=(this.rootX??0)+v.x,this.rootZ+=v.z,this.boxer.root.position.set(this.rootX,0,this.rootZ),this.riseRoot.set(this.rootX-this.mapping.x(e.x)-this.touchOffset.x,0,this.rootZ-this.mapping.z(e.y)-this.touchOffset.z),this.riseRootFrom.copy(this.riseRoot)}walkBackFromTheFall(e){let t=this.downState===`rising`?1-EM(YF,1,this.riseProgress):this.downState===`up`?0:1,n=this.riseRootFrom.x*t,r=this.riseRootFrom.z*t;e>0?this.riseRootVelocity.set((n-this.riseRoot.x)/e,0,(r-this.riseRoot.z)/e):this.riseRootVelocity.set(0,0,0),this.riseRoot.set(n,0,r),t===0&&this.riseRootFrom.set(0,0,0)}steadyJointPoles(e,t,n,r,i,a){if(this.poleSettle=this.downState===`up`?Math.max(0,this.poleSettle-a):tI,this.poleSettle<=0||this.ragdoll?.active===!0&&!this.ragdoll.handingOver){this.downPolesSet=!1;return}let o=this.boxer.rig.bones,s=e>0;this.characterInverse.copy(this.boxer.root.matrixWorld).invert();for(let e=0;e<4;e+=1){let c=e<2,l=e%2==0,u=l===s,d=c?u?o.hipL:o.hipR:u?o.shoulderL:o.shoulderR,f=c?l?r:i:l?t:n,p=f.position,m=f.pole,h=this.downPoles[e];if(!this.downPolesSet){h.copy(m);continue}let g=this.scratchB.setFromMatrixPosition(d.matrixWorld).applyMatrix4(this.characterInverse).sub(p).negate();if(g.lengthSq()<1e-6){h.copy(m);continue}g.normalize();let _=this.scratchD.copy(h).addScaledVector(g,-h.dot(g)),v=this.scratchE.copy(m).addScaledVector(g,-m.dot(g));if(_.lengthSq()<1e-4||v.lengthSq()<1e-4){h.copy(m);continue}let y=Math.atan2(this.scratch.crossVectors(_,v).dot(g),_.dot(v)),b=eI*Math.max(a,1/120);Math.abs(y)<=b||m.copy(_.normalize().applyAxisAngle(g,Math.sign(y)*b)),h.copy(m)}this.downPolesSet=!0}applyWindedPose(e,t,n,r,i){let a=this.torso,o=G.lerp,s=this.windedSide,c=Math.sin(t*23)*.006;a.hips.y=o(a.hips.y,VM.hipsHeight-.1,e),a.hips.z=o(a.hips.z,-.04,e),a.hipsPitch=o(a.hipsPitch,.2,e),a.spinePitch=o(a.spinePitch,.62+c,e),a.spineRoll=o(a.spineRoll,s*.16,e),a.headPitch=o(a.headPitch,.38,e);let l=s>0?this.hand.L:this.hand.R,u=l===r?i:r;l.position.lerp(Q.set(s*.13,.98,.17),e),l.palm.lerp(Q.set(-s*.6,0,-.8),e).normalize(),l.knuckles.lerp(Q.set(-s*.5,.5,.2),e).normalize(),l.pole.lerp(Q.set(s*.9,-.3,-.3),e).normalize(),u.position.lerp(Q.set(-s*.2,.86,.3),e),u.pole.lerp(Q.set(-s*.8,-.6,0),e).normalize()}applyTouchGlovesPose(e,t,n,r){let i=this.torso,a=G.lerp;i.hips.z=a(i.hips.z,.06,e),i.hipsYaw=a(i.hipsYaw,i.hipsYaw*.4,e),i.shouldersYaw=a(i.shouldersYaw,0,e),i.spinePitch=a(i.spinePitch,.12,e),i.headPitch=a(i.headPitch,.1,e),n.position.lerp(Q.set(.11*t,1.24,.5),e),r.position.lerp(Q.set(-.11*t,1.22,.47),e),n.palm.lerp(Q.set(-t,0,0),e).normalize(),r.palm.lerp(Q.set(t,0,0),e).normalize(),n.knuckles.lerp(Q.set(0,.15,1),e).normalize(),r.knuckles.lerp(Q.set(0,.15,1),e).normalize(),n.pole.lerp(Q.set(.7*t,-.7,0),e).normalize(),r.pole.lerp(Q.set(-.7*t,-.7,0),e).normalize()}touchWalk(e,t,n,r){this.countdownEnd=GL(this.countdownEnd,r,this.countdownTicks);let i=this.countdownEnd===null?0:KL(this.countdownEnd-r),a=this.mapping.x(t.x)-this.mapping.x(e.x),o=this.mapping.z(t.y)-this.mapping.z(e.y),s=Math.hypot(a,o),c=s>pI?(s-pI)/2/s*i:0;return this.touchVelocity.set(a*c-this.touchOffset.x,0,o*c-this.touchOffset.z).divideScalar(Math.max(n,.001)).clampLength(0,vI),this.touchOffset.set(a*c,0,o*c)}applyCelebratePose(e,t,n,r,i,a,o){let s=this.torso,c=G.lerp,l=Math.sin(t*6)*.04;s.hips.y=c(s.hips.y,VM.hipsHeight+.035+l*.5,e),s.hipsYaw=c(s.hipsYaw,0,e),s.hipsPitch=c(s.hipsPitch,-.12,e),s.hipsRoll=c(s.hipsRoll,0,e),s.shouldersYaw=c(s.shouldersYaw,0,e),s.spinePitch=c(s.spinePitch,-.1,e),s.headPitch=c(s.headPitch,-.25,e),r.position.lerp(Q.set(.3*n,1.86+l,.08),e),i.position.lerp(Q.set(-.3*n,1.84+l,.06),e),r.palm.lerp(Q.set(0,0,1),e).normalize(),i.palm.lerp(Q.set(0,0,1),e).normalize(),r.knuckles.lerp(Q.set(.15*n,1,0),e).normalize(),i.knuckles.lerp(Q.set(-.15*n,1,0),e).normalize(),r.pole.lerp(Q.set(n,.1,-.3),e).normalize(),i.pole.lerp(Q.set(-n,.1,-.3),e).normalize(),a.heel=c(a.heel,.45,e),o.heel=c(o.heel,.45,e)}applyAttendPose(e,t,n,r,i){let a=this.torso,o=G.lerp,s=Math.sin(t*3.1)*.03;a.hips.z=o(a.hips.z,.12,e),a.hips.y=o(a.hips.y,VM.hipsHeight-.04,e),a.hipsPitch=o(a.hipsPitch,.3,e),a.spinePitch=o(a.spinePitch,.42,e),a.headPitch=o(a.headPitch,.4,e),r.position.lerp(Q.set(.2*n,1.3+s,.62),e),i.position.lerp(Q.set(-.18*n,1.24-s,.58),e),r.palm.lerp(Q.set(0,-.6,.8),e).normalize(),i.palm.lerp(Q.set(0,-.6,.8),e).normalize(),r.knuckles.lerp(Q.set(.1*n,.5,1),e).normalize(),i.knuckles.lerp(Q.set(-.1*n,.5,1),e).normalize(),r.pole.lerp(Q.set(.8*n,-.5,-.1),e).normalize(),i.pole.lerp(Q.set(-.8*n,-.5,-.1),e).normalize()}applyTreatPose(e,t,n,r,i,a,o){let s=this.torso,c=G.lerp,l=this.treatScratch.set(this.rootX??0,0,this.rootZ),u=this.scratchQ.setFromAxisAngle(XL,-this.yaw),d=Q.copy(this.treatTarget).sub(l).applyQuaternion(u),f=this.treatFacingLocal.copy(this.treatFacing).applyQuaternion(u),p=f.z,m=-f.x,h=Math.sin(t*2.6)*.006;s.hips.lerp(this.treatScratch.set(0,.62,.04),e),s.hipsYaw=c(s.hipsYaw,0,e),s.hipsPitch=c(s.hipsPitch,.22,e),s.hipsRoll=c(s.hipsRoll,0,e),s.shouldersYaw=c(s.shouldersYaw,0,e),s.spinePitch=c(s.spinePitch,.3,e),s.headPitch=c(s.headPitch,.2,e),a.position.x=c(a.position.x,.24*n,e),a.position.z=c(a.position.z,.14,e),o.position.x=c(o.position.x,-.2*n,e),o.position.z=c(o.position.z,-.2,e),o.heel=c(o.heel,.55,e),a.toe.lerp(this.treatScratch.set(.2*n,0,1),e).normalize(),o.toe.lerp(this.treatScratch.set(-.1*n,0,1),e).normalize(),a.pole.lerp(this.treatScratch.set(.25*n,.4,1),e).normalize(),o.pole.lerp(this.treatScratch.set(-.2*n,.4,1),e).normalize();let g=this.treatProp===`bottle`,_=g?.3:.08-h;r.position.lerp(this.treatScratch.set(d.x+f.x*_,d.y+(g?.02:-.07),d.z+f.z*_),e),g?r.knuckles.lerp(this.treatScratch.set(-f.x,-.25,-f.z),e).normalize():r.knuckles.lerp(this.treatScratch.set(0,1,.05),e).normalize(),r.palm.lerp(g?this.treatScratch.set(0,-1,0):this.treatScratch.set(-f.x,0,-f.z),e).normalize(),r.pole.lerp(this.treatScratch.set(.85*n,-.35,.1),e).normalize();let v=this.treatSide*.135;i.position.lerp(this.treatScratch.set(d.x-p*v+f.x*.05,d.y-.2,d.z-m*v+f.z*.05),e),i.knuckles.lerp(this.treatScratch.set(0,.9,.4),e).normalize(),i.palm.lerp(this.treatScratch.set(p*this.treatSide*.8-f.x*.6,.1,m*this.treatSide*.8-f.z*.6),e).normalize(),i.pole.lerp(this.treatScratch.set(-.85*n,-.4,.1),e).normalize()}applyBreakPose(e,t,n,r){let i=this.torso,a=G.lerp;i.hipsPitch=a(i.hipsPitch,.14,e),i.spinePitch=a(i.spinePitch,.08,e);let o=this.scratchC.set(.48*t,1.22,.52),s=this.scratchD.set(-.48*t,1.22,.52);if(this.breakAimed){let[e,n]=this.breakFighters,r=this.scratch.subVectors(n,e).setY(0).normalize(),i=this.scratchQ.setFromAxisAngle(XL,-this.yaw),a=this.scratchB.set(this.rootX??0,0,this.rootZ);o.copy(e).addScaledVector(r,lI).sub(a).applyQuaternion(i),s.copy(n).addScaledVector(r,-lI).sub(a).applyQuaternion(i),o.x*tqF*.15;let s=this.downResult;if(this.downState!==`falling`){let a=this.riseProgress,c=0;if(this.fallKneel)c=EM(YF,1,a),UL(s,this.placeKneel(this.downFrom,e),o,c);else if(a0==t>0;return e.hips.set(.02*t,.53,-.06),e.hipsYaw=VM.bladeYaw*t*.3,e.hipsPitch=.24,e.hipsRoll=0,e.shouldersYaw=VM.bladeYaw*t*.2,e.spinePitch=.62,e.headPitch=.48,(r?e.leadHand:e.rearHand).set(n*.13,.66,.2),(r?e.rearHand:e.leadHand).set(.13*t,.66,.37),e.leadFoot.set(.16*t,.125,.32),e.rearFoot.set(-.12*t,.12,-.5),e.leadHeel=0,e.rearHeel=0,e.palmsDown=1,e}placeLying(e){let t=this.boxer.rig.metrics.ankleHeight;return PL(this.landProne?kL(this.downFrom,TL,EL,e,this.landSide,t):kL(this.downFrom,CL,wL,e,this.landSide,t),this.landShift)}placeDown(e,t,n){return kL(e,t,null,n,0,this.boxer.rig.metrics.ankleHeight)}chooseLanding(e){let t=this.boxer.rig.metrics.ankleHeight,n=1/0;for(let r=0;r=n||(n=u.length()+o,this.landProne=s,this.landSide=c,this.landShift.copy(u))}}ropeShift(e,t){let n=this.scratchQ.setFromAxisAngle(XL,this.yaw);vL.set(e.hipsPitch+e.spinePitch*.7,e.hipsYaw,e.hipsRoll,`YXZ`),RL[0].set(0,IL,0).applyEuler(vL).add(e.hips),RL[1].set(.2,LL,0).applyEuler(vL).add(e.hips),RL[2].set(-.2,LL,0).applyEuler(vL).add(e.hips),RL[3].copy(e.leadHand),RL[4].copy(e.rearHand),RL[5].copy(e.leadFoot).z+=e.leadHeel>0?.25:.19,RL[6].copy(e.rearFoot).z+=e.rearHeel>0?.25:.19,RL[7].copy(e.hips);let r=1/0,i=-1/0,a=1/0,o=-1/0;for(let e=0;e0==t>0,c=s?n:r,l=s?r:n;i.pole.lerp(Q.set(.15*t,.35,1),e).normalize(),a.pole.lerp(Q.set(-.1*t,-1,.3),e).normalize(),i.toe.lerp(Q.set(.15*t,0,1),e).normalize(),a.toe.lerp(Q.set(0,-.35,-1),e).normalize(),c.palm.lerp(Q.set(-o*.75,0,-.65),e).normalize(),c.knuckles.lerp(Q.set(-o*.35,.25,.9),e).normalize(),c.pole.lerp(Q.set(o*.9,-.35,-.25),e).normalize(),l.palm.lerp(Q.set(0,-1,.1),e).normalize(),l.knuckles.lerp(Q.set(.2*t,-.2,1),e).normalize(),l.pole.lerp(Q.set(t*.7,.1,-.7),e).normalize()}writeDown(e,t,n,r,i,a,o,s){let c=this.torso,l=1-s;this.downStand=s,c.hips.copy(e.hips),c.hipsYaw=e.hipsYaw,c.hipsPitch=e.hipsPitch,c.hipsRoll=e.hipsRoll,c.shouldersYaw=e.shouldersYaw,c.spinePitch=e.spinePitch,c.spineRoll=c.spineRoll*s+e.spineRoll,c.headPitch=e.headPitch,c.headYaw=c.headYaw*s+e.turn,c.headRoll=c.headRoll*s+e.headRoll,c.headOffset.multiplyScalar(s),c.headOffset.z-=o,n.position.copy(e.leadHand),r.position.copy(e.rearHand),xL(n,t,e.palmsDown,l),xL(r,-t,e.palmsDown,l),i.position.copy(e.leadFoot),a.position.copy(e.rearFoot),i.toe.lerp(uL.set(.2*t,0,1).normalize(),l).normalize(),a.toe.lerp(uL.set(-.2*t,0,1).normalize(),l).normalize(),i.heel=e.leadHeel,a.heel=e.rearHeel;let u=uL.set(0,0,1).applyEuler(vL.set(e.hipsPitch,e.hipsYaw,e.hipsRoll,`YXZ`));if(i.pole.lerp(u,l),a.pole.lerp(u,l),e.ownJoints>0){let t=e.ownJoints*l;ML(i.pole,e.leadKnee,t),ML(a.pole,e.rearKnee,t),ML(n.pole,e.leadElbow,t),ML(r.pole,e.rearElbow,t),ML(n.knuckles,e.leadKnuckles,t),ML(n.palm,e.leadPalm,t),ML(r.knuckles,e.rearKnuckles,t),ML(r.palm,e.rearPalm,t)}}calmInjuries(){this.armLimp.fill(0),this.armSnap.fill(0),this.kneeGive.fill(0),this.lostLean=0,this.cover=0,this.hunch=0,this.curl=0,this.faint=0,this.retching=0,this.daze=0,this.stepPace.fill(1),this.stepLift.fill(1),this.stepSlack=1,this.hurt=!1,this.dropDangles()}dropDangles(){for(let e=0;e<2;e+=1)this.armDangle[e].live=!1,this.forearmDangle[e].live=!1}stepInjuries(e){this.retchTime=Math.max(0,this.retchTime-e);let t=this.posedInjuries>1||this.faintTarget>0||this.retchTime>0||this.dazed;if(!t&&!this.hurt)return;let n=this.downState===`up`,r=0;for(let t=0;t<2;t+=1){let n=this.armCarry[t];this.armLimp[t]=wF(this.armLimp[t],+(n===`dead`||n===`gone`),OI,e),this.armSnap[t]=wF(this.armSnap[t],+(n===`snapped`),OI,e),this.kneeGive[t]=wF(this.kneeGive[t],+!!this.kneeBlown[t],8,e),r=Math.max(r,this.armLimp[t],this.armSnap[t],this.kneeGive[t])}let i=this.armCarry[0],a=this.armCarry[1],o=i===`whole`||i===`stump`,s=a===`whole`||a===`stump`;this.cover=wF(this.cover,o===s?0:o?1:-1,6,e),this.lostLean=wF(this.lostLean,(i===`gone`)-+(a===`gone`),4,e),this.hunch=wF(this.hunch,+!!this.gutted,5,e),this.curl=wF(this.curl,+!!this.liver,4,e),this.faint=wF(this.faint,this.faintTarget,2.5,e);let c=this.retchTime>0&&n;this.retching=wF(this.retching,+!!c,c?12:5,e);let l=this.dazed&&n;if(this.daze=wF(this.daze,+!!l,l?8:5,e),this.dazeTime=this.daze>.001?this.dazeTime+e:0,r=Math.max(r,Math.abs(this.cover),Math.abs(this.lostLean),this.hunch,this.curl,this.faint,this.retching,this.daze),!t&&r<.001){this.calmInjuries();return}this.hurt=!0;let u=this.hunch,d=this.faint,f=this.daze;this.stepSlack=(1-.3*u)*(1-.55*f);for(let e=0;e<2;e+=1){let t=this.kneeGive[e],n=this.kneeGive[1-e];this.stepPace[e]=(1-.4*n)*(1+.25*t)*(1-.25*u)*(1+.15*d)*(1+.2*f),this.stepLift[e]=(1-.5*t)*(1-.6*u)*(1-.75*d)*(1-.4*f)}}stepDeath(e){if(!(!this.dead||this.throe>=DI.length))for(this.deathAge+=e;this.throe=DI[this.throe].at;){let e=DI[this.throe];this.ragdoll?.twitch(e.part,(this.throe+this.throeSide)%2,e.speed),this.throe+=1}}stumble(e,t,n){let r=this.dazeTime;t.add(this.scratchD.set(Math.sin(r*1.7+e*2.1)*.07,0,Math.sin(r*1.25+e*1.3)*.06).multiplyScalar(this.daze).applyAxisAngle(XL,n))}applyHurtStance(e,t,n,r,i){let a=this.torso,o=0,s=0,c=0,l=this.hunch;l>.001&&(s+=.3*l,o+=.045*l,a.hipsPitch+=.06*l,a.headPitch+=.12*l);let u=this.curl;u>.001&&(s+=.1*u,a.spineRoll+=.21*u,a.headRoll+=.08*u,c+=.02*u,this.hand.R.position.y-=.08*u);let d=this.lostLean;Math.abs(d)>.001&&(a.spineRoll+=.15*d,c+=.025*d,a.headRoll-=.05*d);let f=this.faint;if(f>.001){let t=Math.sin(e*1.15),i=Math.sin(e*.83+1.3);a.hips.x+=t*.09*f,a.hips.z+=i*.06*f,a.hipsRoll+=t*.05*f,a.spineRoll+=Math.sin(e*1.15-.7)*.2*f,s+=(.17+i*.06)*f,o+=.03*f+(.06+.04*(.5+.5*Math.sin(e*2.6)))*f*f,a.headPitch+=(.4+Math.sin(e*.9+.4)*.14)*f,a.headRoll+=Math.sin(e*.7)*.36*f,a.headYaw+=Math.sin(e*.53+2)*.18*f,n.position.y-=.32*f,r.position.y-=.27*f,n.position.z-=.07*f}for(let e=0;e<2;e+=1){let t=this.kneeGive[e];if(t<=.001)continue;let n=e===0?1:-1,r=e===0?this.foot.L:this.foot.R,i=e===0?this.foot.R:this.foot.L,s=this.feet[1-e],c=s.stepping?Math.sin(s.progress*Math.PI)*t:0,l=t-c;a.hips.x+=(i.position.x-a.hips.x)*.25*l,a.hips.z+=(i.position.z-a.hips.z)*.18*l,o+=.085*c+.01*l,a.hipsRoll-=n*.16*c,a.spineRoll+=n*.13*c,r.heel+=.3*l,r.pole.x-=n*(.35*t+.9*c),r.pole.normalize()}if(a.hips.x+=Math.cos(a.hipsYaw)*c,a.hips.z-=Math.sin(a.hipsYaw)*c,o!==0||s!==0){a.hips.y-=o,a.spinePitch+=s;let e=o+s*XI,t=s*YI;i.y-=e,i.z+=t,n.position.y-=e,n.position.z+=t,r.position.y-=e,r.position.z+=t}let p=this.cover;if(Math.abs(p)>.001){let e=p>0?this.hand.L:this.hand.R,n=Math.abs(p);e.position.x+=(ZI*t-e.position.x)*.7*n,e.position.y+=.03*n,e.position.z+=.03*n}}applyHurtActs(e,t,n,r){let i=this.torso,a=G.lerp,o=+(t>0),s=this.armCarry[o]===`whole`?o:this.armCarry[1-o]===`whole`?1-o:-1,c=this.retching*(1-.7*this.punchCommit);if(c>.001){let t=Math.max(0,Math.sin(e*10.5))**2;i.hips.y=a(i.hips.y,VM.hipsHeight-.13-t*.02,c),i.hips.z=a(i.hips.z,-.08,c),i.hipsPitch=a(i.hipsPitch,.36,c),i.spinePitch=a(i.spinePitch,.78+t*.12,c),i.spineRoll=a(i.spineRoll,0,c),i.headPitch=a(i.headPitch,1.3+t*.15,c),i.headYaw=a(i.headYaw,0,c),i.headRoll=a(i.headRoll,0,c),i.headOffset.multiplyScalar(1-c);let n=s<0?o:1-s;if(this.armCarry[n]===`whole`){let e=n===0?1:-1,t=n===0?this.hand.L:this.hand.R;t.position.lerp(Q.set(e*.19,.62,n===o?-.02:.15),c),t.pole.lerp(Q.set(e*.9,.1,-.4),c).normalize(),t.knuckles.lerp(Q.set(-e*.2,-.7,.6),c).normalize(),t.palm.lerp(Q.set(0,-.6,-.8),c).normalize()}}let l=Math.max(Math.abs(this.slip),this.weave,this.pull),u=EF(1-this.guardHigh-this.guardLow,0,1)*(1-this.punchCommit)*(1-l)*(1-this.clinchWeight),d=this.punchActive&&s===(this.punchHand===`left`?0:1)?EF(this.punchReach*4,0,1):0,f=Math.max(c,this.hunch*u)*(1-d);f>.001&&s>=0&&this.clutchBelly(s,f);let p=this.daze;if(p>.001){let e=this.dazeTime,o=EM(.7,1.6,e),s=Math.sin(e*2.2),c=Math.sin(e*1.45+.9),l=VM.bladeYaw*t;i.hips.x=a(i.hips.x,s*.06,p),i.hips.z=a(i.hips.z,c*.045,p),i.hips.y=a(i.hips.y,VM.hipsHeight-.08-Math.sin(e*4.4+1)*.02,p),i.hipsYaw=a(i.hipsYaw,l*.8,p),i.hipsPitch=a(i.hipsPitch,.04,p),i.hipsRoll=a(i.hipsRoll,s*.05,p),i.shouldersYaw=a(i.shouldersYaw,l*.65,p),i.spinePitch=a(i.spinePitch,.24+c*.07,p),i.spineRoll=a(i.spineRoll,Math.sin(e*2.2-.9)*.13,p),i.headYaw=a(i.headYaw,o*Math.sin(e*1.1+2)*.3,p),i.headPitch=a(i.headPitch,.95-o*(.28+Math.sin(e*1.3)*.25),p),i.headRoll=a(i.headRoll,o*Math.sin(e*1.9)*.42,p),i.headOffset.multiplyScalar(1-p),n.heel=a(n.heel,0,p),r.heel=a(r.heel,0,p)}}clutchBelly(e,t){let n=this.torso,r=e===0?this.hand.L:this.hand.R,i=e===0?1:-1,a=n.hipsYaw+(n.shouldersYaw-n.hipsYaw)*.25,o=n.hipsPitch+n.spinePitch*.2;r.position.lerp(Q.set(i*.05,.17,.19+o*.08).applyAxisAngle(XL,a).add(n.hips),t),r.knuckles.lerp(Q.set(-i*.9,-.3,.2).applyAxisAngle(XL,a),t).normalize(),r.palm.lerp(Q.set(-i*.1,.15,-1).applyAxisAngle(XL,a),t).normalize(),r.pole.lerp(Q.set(i*.85,-.35,-.4).applyAxisAngle(XL,a),t).normalize()}dangleArms(e){let t=this.daze,n=this.boxer.rig,r=n.bones;yM(r.hips,this.trunkLow),yM(r.upperChest,this.trunkHigh),this.trunkLow.addScaledVector(QI.subVectors(this.trunkLow,this.trunkHigh).normalize(),KI);let i=this.ragdoll?.handingOver===!0;for(let a=0;a<2;a+=1){let o=Math.max(this.armLimp[a],t),s=this.armSnap[a],c=this.armDangle[a],l=this.forearmDangle[a];if(o<=.001&&(c.live=!1),s<=.001&&(l.live=!1),o<=.001&&s<=.001)continue;let u=a===0,d=u?1:-1,f=u?r.shoulderL:r.shoulderR,p=u?r.elbowL:r.elbowR,m=u?r.gloveL:r.gloveR,h=u?n.metrics.armL:n.metrics.armR;if(o>.001){let t=yM(m,$I);if(bM(m,cL),this.armCarry[a]===`dead`){let e=yM(f,eL);e.y-=kI*this.armLimp[a],n.aimAt(u?r.clavicleL:r.clavicleR,e,`z`),f.updateWorldMatrix(!1,!1)}let s=yM(f,eL),l=(h.upper+h.lower)*AI;if(!c.live){let e=o>WI&&!i;TI(c,e?QI.set(s.x,s.y-l,s.z):t,s),e&&this.holdDangle(c.at,s,l,!1,null)}let g=this.punchActive&&this.punchHand===`left`===u?this.punchReach:0;this.swing(c,s,l,!1,e,jI,MI,t,g*PI);let _=tL.set(d*.3,.15+3*EF(1-s.y/JI,0,1),-1).lerp(u?this.hand.L.pole:this.hand.R.pole,1-o).applyAxisAngle(XL,this.yaw);n.solveLimb(f,p,h,t.lerp(c.at,o),_,`z`,u?1:-1,.012),m.updateWorldMatrix(!1,!1),xM(nL.subVectors(yM(m,$I),yM(p,QI)).normalize(),tL.set(-d,0,.2).applyAxisAngle(XL,this.yaw),`z`,lL),n.setWorldRotation(m,cL.slerp(lL,o))}if(s>.001){let t=yM(p,eL),r=yM(m,$I);bM(m,cL);let a=Math.max(0,-(t.y-yM(f,QI).y)/h.upper),o=sL.set(d*(FI+II*a*a),-1,0).applyAxisAngle(XL,this.yaw).normalize();l.live||(TI(l,s>WI&&!i?QI.set(t.x,t.y-h.lower,t.z):r,t),this.holdDangle(l.at,t,h.lower,!0,o)),this.swing(l,t,h.lower,!0,e,jI,NI,null,0,o);let c=nL.subVectors(r,t).lerp(QI.subVectors(l.at,t),s).normalize(),u=tL.setFromMatrixColumn(p.matrixWorld,2).lerp(QI.setFromMatrixColumn(p.matrixWorld,0).multiplyScalar(d),s);n.setWorldFrame(p,c,u,`z`),m.updateWorldMatrix(!1,!1),xM(QI.copy(c).addScaledVector(fL,.9).normalize(),tL.set(-d,.2,-.4).applyAxisAngle(XL,this.yaw),`z`,lL),n.setWorldRotation(m,cL.slerp(lL,s))}}}swing(e,t,n,r,i,a,o,s,c,l=null){let u=e.at,d=e.velocity;(e.carried||t.distanceToSquared(e.pivot)>UI*UI)&&(u.add(t).sub(e.pivot),d.set(0,0,0),e.pivot.copy(t),e.carried=!1);let f=i>0?Math.min(VI,Math.ceil(i/BI)):0,p=f>0?i/f:0;for(let i=1;i<=f;i+=1)rL.copy(u),d.addScaledVector(a,p),s!==null&&c>0&&d.addScaledVector(iL.subVectors(s,u),c*p),d.multiplyScalar(Math.exp(-o*p)),u.addScaledVector(d,p),this.holdDangle(u,iL.lerpVectors(e.pivot,t,i/f),n,r,l),d.subVectors(u,rL).divideScalar(p).clampLength(0,HI);f===0&&this.holdDangle(u,t,n,r,l),e.pivot.copy(t)}holdDangle(e,t,n,r,i){let a=this.trunkLow,o=aL.subVectors(this.trunkHigh,a);for(let s=0;s<2;s+=1){let s=EF(oL.subVectors(e,a).dot(o)/Math.max(1e-6,o.lengthSq()),0,1),c=oL.addScaledVector(o,-s).length();c1e-4&&e.addScaledVector(oL,(GI-c)/c),e.y=Math.max(e.y,qI);let l=oL.subVectors(e,t),u=l.length();if(u<1e-6?e.set(t.x,t.y-n,t.z):(r||u>n)&&e.copy(t).addScaledVector(l,n/u),i===null)continue;l.subVectors(e,t);let d=l.dot(i);if(d>=n*RI)continue;let f=l.addScaledVector(i,-d).length();e.copy(t).addScaledVector(i,n*(f>1e-6?RI:1)),f>1e-6&&e.addScaledVector(l,n*zI/f)}}applyDislocation(){if(this.dislocation!==`jaw`)return;let e=this.boxer.bone(`head`);e!==null&&(e.quaternion.multiply(SI),e.updateWorldMatrix(!1,!0))}dispose(){this.stool.dispose(),this.enswell.dispose(),this.bottle.dispose(),this.boxer.dispose()}},oI=.44,sI=.2,cI=.75,lI=.26,uI=1.2,dI=48,fI=14,pI=1.34,mI=80,hI=56,gI=24,_I=4,vI=1.5,yI=60,bI=4,xI=.15,Q=new q,SI=new rg().setFromEuler(new Lg(.08,.2,-.22)),CI=[`shoulder_left_dislocated`,`shoulder_right_dislocated`,`arm_left_broken`,`arm_right_broken`,`forearm_left_severed`,`forearm_right_severed`,`arm_left_torn`,`arm_right_torn`,`knee_left_blown`,`knee_right_blown`,`disemboweled`,`liver_ruptured`];function wI(){return{at:new q,velocity:new q,pivot:new q,live:!1,carried:!1}}function TI(e,t,n){e.at.copy(t),e.velocity.set(0,0,0),e.pivot.copy(n),e.live=!0,e.carried=!1}function EI(e){e.velocity.set(0,0,0),e.carried=!0}var DI=[{at:1.5,part:`leg`,speed:2.8},{at:2.1,part:`back`,speed:2.4},{at:2.6,part:`arm`,speed:2.6},{at:3.3,part:`leg`,speed:1.9},{at:4,part:`back`,speed:1.4},{at:4.7,part:`arm`,speed:1.2}],OI=12,kI=.05,AI=.985,jI=new q(0,-9.81,0),MI=2.4,NI=3,PI=22,FI=.7,II=1.8,LI=.4,RI=Math.cos(LI),zI=Math.sin(LI),BI=1/90,VI=4,HI=8,UI=.35,WI=.5,GI=.25,KI=.3,qI=.07,JI=.6,YI=.36,XI=.05,ZI=-.06,QI=new q,$I=new q,eL=new q,tL=new q,nL=new q,rL=new q,iL=new q,aL=new q,oL=new q,sL=new q,cL=new rg,lL=new rg,uL=new q,dL=new q(0,0,1),fL=new q(0,-1,0),pL=new q(0,0,1),mL=new q(1,0,0),hL=new q(-1,0,0),gL=.04,_L=new rg,vL=new Lg,yL={pole:TM(.4,.9,.2),knuckles:TM(.6,.2,-.75).normalize(),palm:TM(0,1,.2).normalize()},bL={pole:TM(.6,.2,-.7),knuckles:TM(.25,-.1,1).normalize(),palm:TM(0,-1,.1).normalize()};function xL(e,t,n,r){uL.lerpVectors(yL.pole,bL.pole,n),uL.x*=t,e.pole.lerp(uL,r),uL.lerpVectors(yL.knuckles,bL.knuckles,n),uL.x*=t,e.knuckles.lerp(uL.normalize(),r).normalize(),uL.lerpVectors(yL.palm,bL.palm,n),uL.x*=t,e.palm.lerp(uL.normalize(),r).normalize()}function SL(e={}){return{hips:new q,hipsYaw:0,hipsPitch:0,hipsRoll:0,shouldersYaw:0,spinePitch:0,spineRoll:0,headPitch:0,headRoll:0,leadHand:new q,rearHand:new q,leadFoot:new q,rearFoot:new q,leadHeel:0,rearHeel:0,palmsDown:0,turn:0,leadKnee:new q(0,0,1),rearKnee:new q(0,0,1),leadElbow:new q(0,-1,0),rearElbow:new q(0,-1,0),leadKnuckles:new q(0,0,1),leadPalm:new q(0,-1,0),rearKnuckles:new q(0,0,1),rearPalm:new q(0,-1,0),ownJoints:0,...e}}var CL=SL({hips:TM(0,.14,-.4),hipsPitch:-1.42,spinePitch:.1,headPitch:-.5,leadHand:TM(.52,.1,-.62),rearHand:TM(-.5,.1,-.7),leadFoot:TM(.17,0,.16),rearFoot:TM(-.16,0,-.02)}),wL=SL({hips:TM(.22,0,0),hipsYaw:-.35,hipsRoll:-.25,shouldersYaw:-.2,leadFoot:TM(.05,0,0),rearFoot:TM(.05,0,0)}),TL=SL({hips:TM(0,.25,.32),hipsPitch:1.5,spinePitch:.05,headPitch:.2,palmsDown:1,leadHand:TM(.34,.12,.78),rearHand:TM(-.3,.12,.62),leadFoot:TM(.16,0,-.82),rearFoot:TM(-.15,0,-.86),leadHeel:1.3,rearHeel:1.3}),EL=SL({hips:TM(.12,0,0),hipsYaw:.3,hipsRoll:.15,shouldersYaw:.15,leadFoot:TM(.04,0,0),rearFoot:TM(.04,0,0)}),DL=SL({hips:TM(.05,.52,-.2),hipsYaw:VM.bladeYaw*.15,hipsPitch:1.38,shouldersYaw:VM.bladeYaw*.15,spinePitch:.35,headPitch:1,palmsDown:1,leadHand:TM(.2,.115,.36),rearHand:TM(-.2,.115,.32),leadFoot:TM(.15,0,-.74),rearFoot:TM(-.14,0,-.78),leadHeel:1.25,rearHeel:1.25}),OL=SL({hips:TM(0,.47,-.05),hipsYaw:VM.bladeYaw*.12,hipsPitch:.2,shouldersYaw:VM.bladeYaw*.4,spinePitch:.3,headPitch:.2,palmsDown:1,leadHand:TM(.15,.68,.32),rearHand:TM(-.26,.42,.02),leadFoot:TM(.15,0,.36),rearFoot:TM(-.13,0,-.7),rearHeel:1.2});function kL(e,t,n,r,i,a){return e.hips.set(t.hips.x*r,t.hips.y,t.hips.z),e.hipsYaw=t.hipsYaw*r,e.hipsPitch=t.hipsPitch,e.hipsRoll=t.hipsRoll*r,e.shouldersYaw=t.shouldersYaw*r,e.spinePitch=t.spinePitch,e.spineRoll=0,e.headPitch=t.headPitch,e.headRoll=0,HM(t.leadHand,r,e.leadHand),HM(t.rearHand,r,e.rearHand),HM(t.leadFoot,r,e.leadFoot).y+=a,HM(t.rearFoot,r,e.rearFoot).y+=a,e.leadHeel=t.leadHeel,e.rearHeel=t.rearHeel,e.palmsDown=t.palmsDown,e.turn=0,e.ownJoints=0,n===null||i===0||(e.hips.addScaledVector(n.hips,i),e.hipsYaw+=n.hipsYaw*i,e.hipsPitch+=n.hipsPitch*i,e.hipsRoll+=n.hipsRoll*i,e.shouldersYaw+=n.shouldersYaw*i,e.spinePitch+=n.spinePitch*i,e.headPitch+=n.headPitch*i,e.leadHand.addScaledVector(n.leadHand,i),e.rearHand.addScaledVector(n.rearHand,i),e.leadFoot.addScaledVector(n.leadFoot,i),e.rearFoot.addScaledVector(n.rearFoot,i)),e}var AL=e=>Math.atan2(Math.sin(e),Math.cos(e)),jL=new q;function ML(e,t,n){if(n<=0)return e;e.normalize();let r=e.angleTo(t);return r<1e-4?e:(jL.crossVectors(e,t),jL.lengthSq()<1e-8&&jL.crossVectors(e,Math.abs(e.y)<.9?XL:dL),e.applyAxisAngle(jL.normalize(),r*Math.min(1,n)))}function NL(e,t,n,r){let i=t+AL(e.x-t),a=n+AL(e.y-n),o=r+AL(e.z-r),s=t+AL(Math.PI-e.x-t),c=n+AL(e.y+Math.PI-n),l=r+AL(e.z+Math.PI-r);return Math.abs(i-t)+Math.abs(a-n)+Math.abs(o-r)<=Math.abs(s-t)+Math.abs(c-n)+Math.abs(l-r)?e.set(i,a,o,`YXZ`):e.set(s,c,l,`YXZ`)}function PL(e,t){return e.hips.add(t),e.leadHand.add(t),e.rearHand.add(t),e.leadFoot.add(t),e.rearFoot.add(t),e}var FL=wE*.72-.05,IL=.78,LL=.5,RL=Array.from({length:8},()=>new q),zL=[.17,.22,.22,.13,.13,.12,.12,.2],BL=[[!1,1,0],[!1,0,.15],[!1,-1,.3],[!0,1,.4],[!0,0,.5],[!0,-1,.6]];function VL(e,t){return e<-FL&&t>FL?-(e+t)/2:e<-FL?-FL-e:t>FL?FL-t:0}function HL(e,t){return UL(e,t,t,0)}function UL(e,t,n,r){let i=G.lerp;return e.hips.copy(t.hips).lerp(n.hips,r),e.hipsYaw=i(t.hipsYaw,n.hipsYaw,r),e.hipsPitch=i(t.hipsPitch,n.hipsPitch,r),e.hipsRoll=i(t.hipsRoll,n.hipsRoll,r),e.shouldersYaw=i(t.shouldersYaw,n.shouldersYaw,r),e.spinePitch=i(t.spinePitch,n.spinePitch,r),e.spineRoll=i(t.spineRoll,n.spineRoll,r),e.headPitch=i(t.headPitch,n.headPitch,r),e.headRoll=i(t.headRoll,n.headRoll,r),e.leadHand.copy(t.leadHand).lerp(n.leadHand,r),e.rearHand.copy(t.rearHand).lerp(n.rearHand,r),e.leadFoot.copy(t.leadFoot).lerp(n.leadFoot,r),e.rearFoot.copy(t.rearFoot).lerp(n.rearFoot,r),e.leadHeel=i(t.leadHeel,n.leadHeel,r),e.rearHeel=i(t.rearHeel,n.rearHeel,r),e.palmsDown=i(t.palmsDown,n.palmsDown,r),e.turn=i(t.turn,n.turn,r),ML(e.leadKnee.copy(t.leadKnee),n.leadKnee,r),ML(e.rearKnee.copy(t.rearKnee),n.rearKnee,r),ML(e.leadElbow.copy(t.leadElbow),n.leadElbow,r),ML(e.rearElbow.copy(t.rearElbow),n.rearElbow,r),ML(e.leadKnuckles.copy(t.leadKnuckles),n.leadKnuckles,r),ML(e.leadPalm.copy(t.leadPalm),n.leadPalm,r),ML(e.rearKnuckles.copy(t.rearKnuckles),n.rearKnuckles,r),ML(e.rearPalm.copy(t.rearPalm),n.rearPalm,r),e.ownJoints=i(t.ownJoints,n.ownJoints,r),e}var WL=3;function GL(e,t,n){if(n===null)return null;let r=t+n;return e===null||Math.abs(r-e)>WL?r:e}function KL(e){return(1-EM(hI,mI,e))*EM(_I,gI,e)}function qL(){let e=new t_;e.name=`enswell`,e.visible=!1;let t=new Iy(3.2,3.2,.9,20),n=new Iy(.8,.8,6,10),r=new Ab({color:13159634,roughness:.3,metalness:.9}),i=new Y(t,r);i.rotation.x=Math.PI/2,i.position.set(0,9.5,3.4),e.add(i);let a=new Y(n,r);return a.position.set(0,5.5,2.4),e.add(a),{group:e,dispose:()=>{t.dispose(),n.dispose(),r.dispose()}}}function JL(){let e=new t_;e.name=`bottle`,e.visible=!1;let t=new Iy(3.3,3.3,15,18),n=new Iy(1.3,3.3,3,18),r=new Iy(.7,1.1,3.2,10),i=new Ab({color:14280430,roughness:.32,metalness:0}),a=new Ab({color:1920728,roughness:.5,metalness:0}),o=new Y(t,i);o.position.set(0,9,2.6);let s=new Y(n,i);s.position.set(0,18,2.6);let c=new Y(r,a);return c.position.set(0,21,2.6),e.add(o,s,c),{group:e,dispose:()=>{t.dispose(),n.dispose(),r.dispose(),i.dispose(),a.dispose()}}}function YL(){let e=new t_;e.name=`stool`,e.visible=!1;let t=new Iy(.17,.17,.035,18),n=new Iy(.012,.014,.42,8),r=new Ab({color:13222581,roughness:.85}),i=new Ab({color:2764083,roughness:.45,metalness:.6}),a=new Y(t,r);a.position.y=.4225,a.castShadow=!0,e.add(a);for(let t=0;t<4;t+=1){let r=Math.PI/4+t*Math.PI/2,a=new Y(n,i);a.position.set(Math.cos(r)*.13,.42/2,Math.sin(r)*.13),a.rotation.set(-Math.sin(r)*.12,0,Math.cos(r)*.12),a.castShadow=!0,e.add(a)}return{group:e,dispose:()=>{t.dispose(),n.dispose(),r.dispose(),i.dispose()}}}var XL=new q(0,1,0),ZL=6,QL=3,$L=1.5,eR=2.5,tR=1.5,nR=.55,rR=2.1,iR=.42,aR=.22,oR=.08,sR=.5,cR=.5,lR=new Set([`hit`,`counter_hit`,`block`,`perfect_block`,`referee_hit`]),uR=new Set([`slip_left`,`slip_right`,`weave`,`pull`]),dR=40,fR=y/a,pR=.12,mR=30,hR=2;function gR(e,t,n){if(e0;case`forearm_left`:return t===`glove_left`||o&&yA(r,i,a,1)>0;case`forearm_right`:return t===`glove_right`||o&&yA(r,i,a,-1)>0;case`arm_left`:return t===`glove_left`||o&&bA(r,i,a,1)>0;case`arm_right`:return t===`glove_right`||o&&bA(r,i,a,-1)>0;case`leg_left`:return r>=0&&(t===`shoes`||o&&i<60);case`leg_right`:return r<0&&(t===`shoes`||o&&i<60);case`upper_body`:return t===`head`||t===`glove_left`||t===`glove_right`||o&&xA(r,i,a)>0;case`torso`:return t===`pants`||o&&i>=60&&bA(r,i,a,1)<=0&&bA(r,i,a,-1)<=0}}var yR={head:`BoxerHead`,body:`BoxerBody`,glove_left:`BoxerGloveLeft`,glove_right:`BoxerGloveRight`,pants:`BoxerPants`,shoes:`BoxerShoes`},bR=new WeakMap;function xR(e,t){let n=bR.get(e);if(n===void 0){n={};let t=new Map(Object.entries(yR).map(([e,t])=>[t,e]));e.root.traverse(e=>{let r=e instanceof Hv?t.get(e.name):void 0;r!==void 0&&(n[r]=e)}),bR.set(e,n)}return n[t]??null}var SR=[`left`,`right`],CR=new q(0,1,0),wR=new q(0,-1,0),TR=15129792,ER=6032400,DR=9313310,OR=4982537,kR=14200392,AR=2228997,jR=14263970,MR=8270912,NR=11618383,PR=15524550,FR=12866653,IR=13602176,LR=9384504,RR=new J,zR=new J,BR=new q,VR=G.smoothstep;function HR(e,t){e.deleteAttribute(`uv`);let n=e.getAttribute(`position`),r=new Float32Array(n.count*3);for(let e=0;eo/2-.001){let t=Math.atan2(BR.z,BR.x);BR.y+=i<1e-4?-n*.8:n*(.5*Math.sin(t*3+e[1])+.35*Math.sin(t*5+e[2]))}c.setXYZ(t,BR.x,BR.y+o/2,BR.z*r)}return s.computeVertexNormals(),HR(s,(t,r)=>{let i=1-VR(t.y/o,.15,.42)*(.85+.15*Math.sin(Math.atan2(t.z,t.x)*4+e[0]));r.setHex(TR).lerp(zR.setHex(OR),i),Math.hypot(t.x,t.z)o*.5&&r.setHex(ER)}),s.applyQuaternion(new rg().setFromUnitVectors(CR,a.normalize())),s.translate(i.x,i.y,i.z),s}function GR(e,t,n,r=!1){return HR(new yb(new Jy(e.map(e=>new q(...e)),r),e.length*5,t,7,r),n)}var KR=[0,123.6,-3.2],qR=[4.5,4,5];function JR(){let e=new _b(1,40,24,0,Math.PI*2,0,Math.PI*.6),t=e.getAttribute(`position`),n=new Float32Array(t.count);for(let e=0;e{let i=n[r];r+=1,t.setHex(MR).lerp(zR.setHex(jR),VR(i,-.5,.45)),(i<-1||Math.sin(e.x*.9+e.z*1.3)>.72)&&t.lerp(zR.setHex(DR),.7)})}function YR(){let e=[[1,.2,TR],[.9,0,TR],[.82,0,ER],[.74,0,TR],[.66,-.9,OR]],t=[],n=[],r=[];for(let[i,[a,o,s]]of e.entries())for(let e=0;e<32;e+=1){let c=e/32*Math.PI*2;if(t.push(Math.cos(c)*5.6*a,124+o,-3.3+Math.sin(c)*6.4*a),RR.setHex(s).multiplyScalar(.85+.15*Math.sin(c*11+i)),n.push(RR.r,RR.g,RR.b),i===0)continue;let l=(e+1)%32;r.push((i-1)*32+e,i*32+e,(i-1)*32+l,(i-1)*32+l,i*32+e,i*32+l)}let i=new iv;return i.setAttribute(`position`,new K_(t,3)),i.setAttribute(`color`,new K_(n,3)),i.setIndex(r),i.computeVertexNormals(),i}var XR=[0,112.9,-.4],ZR=9,QR=new q(0,-.93,.37).normalize(),$R=.95;function ez(){let e=new Py(1.5,6,6,16,8),t=e.getAttribute(`position`);for(let e=0;e0?.5*(1-VR(r,0,.45)):0,a=.5*Math.sin(n*5)*(1-n);t.setXYZ(e,BR.x*G.lerp(.9,1.1,Math.sin(n*Math.PI))+a*.4,BR.y-ZR/2,(BR.z-i)*.3+.35*r*r+1.3*n*n)}return e.computeVertexNormals(),HR(e,(e,t)=>{let n=-e.y/ZR,r=Math.sin(e.y*2.6+e.x*2.1)*Math.sin(e.x*3.3-e.y*1.2);t.setHex(FR).multiplyScalar(.8+.2*r).lerp(zR.setHex(OR),.8*(1-VR(n,0,.35))),(r>.45||n>.88)&&t.lerp(zR.setHex(DR),.65)})}function tz(){let e=[],t=new _b(1,18,12,Math.PI,Math.PI);t.scale(3.3,2.5,3.2),t.translate(0,113.3,-.5),e.push(HR(t,(e,t)=>{t.setHex(AR).lerp(zR.setHex(DR),VR(Math.hypot(e.x,e.y-112.6,(e.z+3)*.7),.7,2.6))}));let n=new Fy(1,20);n.rotateX(Math.PI/2),n.scale(3.3,1,3.9),n.translate(0,115.25,.5),e.push(HR(n,(e,t)=>{t.setHex(LR).multiplyScalar(.75+.25*Math.sin(e.z*5)).lerp(zR.setHex(AR),1-VR(e.z,-3,.5))}));let r=[];for(let t=0;t<14;t+=1){let n=-1.75+t/13*3.5,i=1-Math.abs(n)/1.75,a=t===4||t===9?1.35:G.lerp(.85,1.2,i),o=new Iy(.3,t===4||t===9?.16:.37,a,6);o.scale(1,1,G.lerp(1.15,.55,i)),o.rotateY(n);let s=Math.sin(n)*2.75,c=.9+Math.cos(n)*3.1;o.translate(s,114.9-a/2,c),e.push(HR(o,(e,t)=>{t.setHex(PR).lerp(zR.setHex(DR),.8*VR(e.y,114.3,114.9))})),r.push([s,114.95,c])}return e.push(GR(r,.45,NR)),UR(e)}function nz(e){return UR([WR([e*29.4,103.8,-4.2],[e*32.9,104.1,-4],.85),WR([e*29.4,102,-6.2],[e*32.3,101.8,-6.5],.7)])}function rz(e){let t=new _b(1,12,9);return t.scale(.9,1.7,1.5),t.translate(e*13.3,103.4,-5.5),HR(t,(e,t)=>{t.setHex(15327954).lerp(zR.setHex(DR),Math.sin(e.y*3.1+e.z*2.3)>.4?.75:.1)})}function iz(){return UR([HR(new Iy(2,2.1,1.8,10).translate(0,80.4,-5.4),TR),HR(new Iy(1.8,1.8,.6,10).translate(0,81.6,-5.4),12563866),WR([0,81.9,-5.4],[.4,85.4,-5.8],1.9),GR([[.2,84.6,-5.6],[.3,86.6,-5.8],[.9,87.8,-5.2]],.55,15255984),GR([[-6.5,81.6,.5],[-3,82.6,3.6],[1.5,81.8,4.4],[6,82.8,2],[7,81.6,-2],[3.5,82.9,-1],[-1,81.7,.6],[-5,82.9,-2.6],[-7.2,81.5,-4]],1.25,IR,!0),GR([[4.5,83.6,1.6],[1,84.4,2.4],[-3,83.5,.6],[-2,84.2,-2.6],[2.5,83.6,-2.2]],1.05,12548720,!0),HR(new _b(1,10,7).scale(3.2,1.6,2.6).translate(-6,82.2,1.5),4854808)])}function az(e){return UR(NA.map((t,n)=>{let r=new q(-t[0],0,-2-t[2]).normalize();return WR([e*(t[0]+r.x*3),t[1]-.3,t[2]+r.z*3],[e*(t[0]-r.x*1.3),t[1]+.7-.3*n,t[2]-r.z*1.3+.7],.75,.5)}))}function oz(){let e=[];for(let t=0;t<5;t+=1){let n=.5+t*1.26,r=Math.cos(n),i=Math.sin(n);e.push(WR([r*5.8,99.5+i*5.8,3.9],[r*2.9,99.5+i*2.9,2.4],.7,.5)),e.push(WR([i*5.6,99.5-r*5.6,-9.6],[i*4.3,99.5-r*4.3,-12.8],.7,.5))}return UR(e)}var sz=new q,cz=new q,lz=new q,uz=new q,dz=new WeakMap;function fz(e,t,n){let r=e.getAttribute(`position`),i=e.getAttribute(`skinIndex`),a=e.getAttribute(`skinWeight`),o=new Map,s=new q;for(let e of t)o.has(e)||(o.set(e,o.size),s.add(BR.fromBufferAttribute(r,e)));s.multiplyScalar(1/o.size);let c=n.layers.length,l=[],u=[],d=[],f=[],p=new Map;for(let e of o.keys()){for(let[t,[o,c]]of n.layers.entries()){n.place(BR.fromBufferAttribute(r,e),s,o,sz),l.push(sz.x,sz.y,sz.z),RR.setHex(c).multiplyScalar(.8+.4*Math.abs(Math.sin(e*12.9898+t*4.1))),u.push(RR.r,RR.g,RR.b);for(let t=0;t<4;t+=1)d.push(i.getComponent(e,t)),f.push(a.getComponent(e,t))}for(let t=0;t<4;t+=1)p.set(i.getComponent(e,t),(p.get(i.getComponent(e,t))??0)+a.getComponent(e,t))}let m=o.size*c;if(n.middle!==null){n.place(s,s,1,sz),l.push(sz.x,sz.y,sz.z),RR.setHex(n.middle),u.push(RR.r,RR.g,RR.b);let e=[...p].sort((e,t)=>t[1]-e[1]).slice(0,4),t=e.reduce((e,[,t])=>e+t,0);for(let n=0;n<4;n+=1)d.push(e[n]?.[0]??0),f.push((e[n]?.[1]??0)/t)}let h=[],g=(e,t,r)=>{sz.fromArray(l,e*3),cz.fromArray(l,t*3),lz.fromArray(l,r*3),n.facing(BR.copy(sz).add(cz).add(lz).multiplyScalar(1/3),s,uz);let i=cz.sub(sz).cross(lz.sub(sz)).dot(uz)>=0;h.push(e,i?t:r,i?r:t)};for(let e=0;evoid a.copy(n).lerp(r,i).addScaledVector(e,-t*i),facing:(t,n,r)=>void r.copy(e),middle:AR}}var mz={layers:[[0,OR],[.4,OR],[1,AR]],place:(e,t,n,r)=>void r.set(G.lerp(e.x,t.x,.22*n),G.lerp(e.y,t.y,.22*n),G.lerp(e.z,t.z-Math.sign(e.z-t.z)*.6,n)),facing:(e,t,n)=>void n.set(t.x-e.x,t.y-e.y,0),middle:null},hz={nose:{bone:`head`,mesh:`head`,at:[0,117,5.3],axis:[0,-.3,1]},mouth:{bone:`head`,mesh:`head`,at:[0,114.3,4.6],axis:[0,-.35,1]},eye_left:{bone:`head`,mesh:`head`,at:VA[0],axis:[.2,0,1]},eye_right:{bone:`head`,mesh:`head`,at:VA[1],axis:[-.2,0,1]},ear_left:{bone:`head`,mesh:`head`,at:MA,axis:[1,-.2,0]},ear_right:{bone:`head`,mesh:`head`,at:[-MA[0],MA[1],MA[2]],axis:[-1,-.2,0]},skull:{bone:`head`,mesh:`head`,at:[0,127.5,-3],axis:[0,1,0]},neck:{bone:`neck`,mesh:`body`,at:[0,109,-2],axis:[0,1,0]},shoulder_left:{bone:`clavicleL`,mesh:`body`,at:[15,103.5,-5.5],axis:[1,0,0]},shoulder_right:{bone:`clavicleR`,mesh:`body`,at:[-15,103.5,-5.5],axis:[-1,0,0]},elbow_left:{bone:`shoulderL`,mesh:`body`,at:[31,102.8,-5.2],axis:[1,0,0]},elbow_right:{bone:`shoulderR`,mesh:`body`,at:[-31,102.8,-5.2],axis:[-1,0,0]},chest:{bone:`chest`,mesh:`body`,at:[0,99.5,5.6],axis:[0,0,1]},ribs_left:{bone:`chest`,mesh:`body`,at:NA[1],axis:[1,0,.3]},ribs_right:{bone:`chest`,mesh:`body`,at:[-NA[1][0],NA[1][1],NA[1][2]],axis:[-1,0,.3]},liver:{bone:`chest`,mesh:`body`,at:[-8.5,89.5,4.4],axis:[-.5,0,1]},belly:{bone:`spine`,mesh:`body`,at:IA,axis:[0,-.2,1]},waist:{bone:`spine`,mesh:`body`,at:[0,81.5,-1],axis:[0,1,0]},crotch:{bone:`hips`,mesh:`body`,at:[0,72,2],axis:[0,-1,.15]},knee_left:{bone:`kneeL`,mesh:`body`,at:FA,axis:[1,0,.2]},knee_right:{bone:`kneeR`,mesh:`body`,at:[-FA[0],FA[1],FA[2]],axis:[-1,0,.2]}},gz=[`skull`,`maw`,`chest`,`waist`,...SR.flatMap(e=>[`fracture`,`ribs`,`knee`,`elbow`,`shoulder`].map(t=>`${t}_${e}`))],_z={left:{sign:1,bone:`L`,ear:`leftEar`,face:`leftFace`,cheek:`leftCheek`,eye:`leftEye`,arm:`leftArm`,shoulder:`leftShoulder`,elbow:`leftElbow`,ribs:`leftRibs`,knee:`leftKnee`,smear:`leftShoulderSmear`},right:{sign:-1,bone:`R`,ear:`rightEar`,face:`rightFace`,cheek:`rightCheek`,eye:`rightEye`,arm:`rightArm`,shoulder:`rightShoulder`,elbow:`rightElbow`,ribs:`rightRibs`,knee:`rightKnee`,smear:`rightShoulderSmear`}},vz=class{boxer;headRaises=[];bodyRaises=[];gloveGone={left:!1,right:!1};eyeOut={left:!1,right:!1};eyeShut={left:!1,right:!1};gloved;flesh;owned=[];tongueTip=new q;tongueVelocity=new q;root=new q;rest=new q;reach=new q;matrix=new Dg;fit=new Dg;upperGone=!1;headHidden=!1;injuries=0;blood=`full`;hole=!1;jawHung=!1;pieces=new Map;geometries=[];skull=null;skullMount=new Dg;brain=null;tongue=null;bodyShadow=null;standIns=null;tongueHung=!1;constructor(e){this.boxer=e,this.gloved={left:e.gloveMesh(`left`).visible,right:e.gloveMesh(`right`).visible},this.flesh=new Ab({vertexColors:!0,roughness:.3,metalness:0,side:2}),bF(this.flesh)}apply(e,t){let n=0;for(let t=0;tc*3)&&(this.tongueHung=!0,l.copy(o).addScaledVector(s,c),u.set(0,0,0));let d=this.reach.copy(l);e>1e-4&&(u.y-=9.8*e,u.addScaledVector(BR.copy(o).addScaledVector(s,c).sub(l),60*e).multiplyScalar(Math.exp(-5*e)),d.addScaledVector(u,e)),d.sub(o).setLength(c),d.angleTo(s)>$R&&(BR.copy(d).addScaledVector(s,-d.dot(s)).setLength(Math.sin($R)*c),d.copy(s).multiplyScalar(Math.cos($R)*c).add(BR)),d.add(o),e>1e-4&&u.copy(d).sub(l).multiplyScalar(1/e),l.copy(d),r.quaternion.setFromUnitVectors(wR,BR.copy(l).sub(o).transformDirection(a.invert()))}compileStandIns(){if(this.standIns!==null)return this.standIns;let e=this.boxer;for(let e of gz)this.built(e);let t=[],n=[[e.headMesh,e.headInjury],[xR(e,`body`),e.bodyInjury]];for(let[e,r]of n)for(let n of[!1,!0]){let i=e===null?null:r.variant(n);if(e===null||i===null)continue;this.owned.push(i);let a=new Hv(e.geometry,i);if(a.bind(e.skeleton,e.bindMatrix),a.frustumCulled=!1,a.castShadow=e.castShadow,n){let e=r.shadowVariant();this.owned.push(e),a.customDepthMaterial=e}t.push(a)}this.brain!==null&&t.push(new Y(this.brain.geometry,this.flesh));let r=this.built(`waist`).find(e=>e instanceof Hv);if(r!==void 0){let e=new Hv(r.geometry,this.flesh);e.bind(r.skeleton,r.bindMatrix),e.frustumCulled=!1,t.push(e)}return this.standIns=t,t}clear(){this.upperGone=!1,this.hole=!1,this.injuries=0,this.show(),this.setPallor(0)}dispose(){this.clear();for(let e of this.standIns??[])e.removeFromParent();this.standIns=null;for(let e of this.pieces.values())for(let t of e)t.removeFromParent();for(let e of this.geometries)e.dispose();this.pieces.clear(),this.geometries.length=0,this.skull=this.brain=this.tongue=null,this.bodyShadow?.dispose(),this.bodyShadow=null;for(let e of this.owned)e.dispose();this.owned.length=0,this.flesh.dispose()}has(e){return!!(this.injuries&1<this.blood!==`off`&&this.has(e),o=r&&this.upperGone,s=this.isPartGone(`jaw`),c=r&&this.has(`skull_fractured`);t.setExplicit(r),n.setExplicit(r);let l=this.headRaises,u=this.bodyRaises;l.length=0,u.length=0;let d=(e,t,n,r=0,a=0)=>void e.push({site:t,bruise:n,blood:r*i,cut:a});if(t.setWound(`nose`,+!!a(`broken_nose`)),a(`broken_nose`)&&d(l,`nose`,1.1,1.4),a(`broken_jaw`)||a(`jaw_torn`)){let e=a(`jaw_torn`);d(l,`chin`,1.2),d(l,`leftJaw`,e?1.2:1),d(l,`rightJaw`,e?1.2:1),d(l,`mouth`,.7,e?1.4:.9,.7),d(u,`neckSmear`,0,e?1.4:.6)}a(`skull_fractured`)&&(d(l,`forehead`,1.1,1.4,+!r),d(u,`neckSmear`,0,1.1)),t.setGone(`jaw`,+!!s),t.setGone(`skull`,+!!c);let f=!1;for(let i of SR){let s=_z[i];t.setWound(s.ear,+!!a(`ear_${i}_torn`));let c=a(`face_${i}_flayed`);t.setWound(s.face,+!!c),c&&(d(l,s.cheek,.8,1.2),d(u,`neckSmear`,0,.9));let p=a(`eye_${i}_out`);p&&d(l,s.eye,1.1,+!r),this.eyeOut[i]&&!(p&&r)&&(f=!0),this.eyeOut[i]=p&&r,this.eyeShut[i]=p&&!r;let m=o?0:this.isPartGone(`arm_${i}`)?2:+!!this.isPartGone(`forearm_${i}`),h=!r&&a(`arm_${i}_torn`),g=!r&&a(`forearm_${i}_severed`);n.setGone(s.arm,m),n.setWound(s.shoulder,a(`shoulder_${i}_dislocated`)||h?1:0),n.setWound(s.elbow,a(`arm_${i}_broken`)||g?1:0),n.setWound(s.ribs,+!!a(`ribs_${i}_broken`)),n.setWound(s.knee,+!!a(`knee_${i}_blown`)),(m===2||h)&&d(u,s.smear,0,1.2),a(`ribs_${i}_broken`)&&d(u,s.ribs,1.2);let _=m>0||o;_?e.gloveMesh(i).visible=!1:this.gloveGone[i]&&(e.gloveMesh(i).visible=this.gloved[i]&&!e.isHandDismembered(i)),this.gloveGone[i]=_,this.piece(`fracture_${i}`,r&&!o&&m===0&&this.has(`arm_${i}_broken`)),this.piece(`ribs_${i}`,r&&!o&&this.has(`ribs_${i}_broken`)),this.piece(`knee_${i}`,r&&this.has(`knee_${i}_blown`)),this.piece(`elbow_${i}`,m===1),this.piece(`shoulder_${i}`,m===2)}f&&t.setEyeOut(this.eyeOut.left&&this.eyeOut.right?`both`:this.eyeOut.left?`left`:this.eyeOut.right?`right`:null),n.setWound(`liver`,+!!a(`liver_ruptured`)),n.setWound(`belly`,+!!a(`disemboweled`)),n.setGone(`waist`,+!!o),n.setGone(`chestHole`,r&&this.hole&&!o?1:0);let p=r&&this.has(`broken_jaw`)&&!s;this.jawHung&&!p&&t.setJaw(0),this.jawHung=p,o?e.headMesh.visible=!1:this.headHidden&&(e.headMesh.visible=!0),this.headHidden=o,this.piece(`skull`,c&&!o),this.piece(`maw`,s&&!o),this.piece(`chest`,r&&this.hole&&!o),this.piece(`waist`,o),c&&!o&&this.fitSkull();let m=xR(e,`body`);m!==null&&n.material!==null&&(n.open?m.customDepthMaterial=this.bodyShadow??=n.shadowMaterial():m.customDepthMaterial===this.bodyShadow&&(m.customDepthMaterial=void 0))}assert(){let e=this.boxer,t=e.headInjury,n=this.headRaises,r=this.bodyRaises;for(let e=0;e0,o=this.eyeOut.right||i.y>0;(this.eyeOut.left&&i.x===0||this.eyeOut.right&&i.y===0)&&t.setEyeOut(a&&o?`both`:a?`left`:`right`);let s=t.uniforms.uInjuryLid.value;(this.eyeShut.left||this.eyeShut.right)&&t.setEyesShut(this.eyeShut.left?1:s[0].w,this.eyeShut.right?1:s[1].w),this.gloveGone.left&&(e.gloveMesh(`left`).visible=!1),this.gloveGone.right&&(e.gloveMesh(`right`).visible=!1)}piece(e,t){if(t||this.pieces.has(e))for(let n of this.built(e))n.visible=t}built(e){let t=this.pieces.get(e);return t===void 0&&(t=this.make(e),this.pieces.set(e,t)),t}bindToWorld(e,t,n){let r=this.boxer.rig.bones[t],i=e.skeleton.bones.indexOf(r);return i<0?!1:(n.multiplyMatrices(r.matrixWorld,e.skeleton.boneInverses[i]).multiply(e.bindMatrix),!0)}fitSkull(){let e=this.skull;if(e===null)return;let t=this.boxer.look,n=Dj(BR.set(5.9,124.6,-3.3),t,this.root).x,r=Dj(BR.set(-5.9,124.6,-3.3),t,this.root).x,i=Dj(BR.set(0,124.6,3.3),t,this.root).z,a=Dj(BR.set(0,124.6,-9.9),t,this.root).z,o=(i-a)/13.2;this.fit.makeScale((n-r)/11.8,1,o).setPosition((n+r)/2,0,(i+a)/2+3.3*o),e.matrix.multiplyMatrices(this.skullMount,this.fit)}solid(e){this.geometries.push(e);let t=new Y(e,this.flesh);return t.receiveShadow=!0,t}mount(e,t,n=xR(this.boxer,`body`)){let r=this.boxer.rig.bones[e],i=n===null?-1:n.skeleton.bones.indexOf(r);return n!==null&&i>=0&&t.matrix.multiplyMatrices(n.skeleton.boneInverses[i],n.bindMatrix),t.matrixAutoUpdate=!1,t.visible=!1,r.add(t),t}closing(e,t,n){let r=xR(this.boxer,`body`);if(r===null)return[];let i=dz.get(r.geometry);i===void 0&&dz.set(r.geometry,i=new Map);let a=i.get(e);if(a===void 0&&i.set(e,a=AO(r.geometry,t)),a.length===0)return[];let o=new Hv(fz(r.geometry,a,n),this.flesh);return this.geometries.push(o.geometry),o.bind(r.skeleton,r.bindMatrix),o.frustumCulled=!1,o.receiveShadow=!0,o.visible=!1,(r.parent??this.boxer.root).add(o),[o]}make(e){let t=this.boxer.headMesh;if(e===`skull`){let e=new t_,n=this.solid(JR());return n.position.set(...KR),e.add(n,this.solid(YR())),this.mount(`head`,e,t),this.skullMount.copy(e.matrix),this.skull=e,this.brain=n,[e]}if(e===`maw`){let e=new t_,n=this.solid(ez());return n.position.set(...XR),e.add(this.solid(tz()),n),this.tongue=n,[this.mount(`head`,e,t)]}if(e===`chest`)return[...this.closing(e,e=>SA(e.x,e.y,e.z)<=0,mz),this.mount(`chest`,this.solid(oz()))];if(e===`waist`)return[...this.closing(e,e=>!vR(`upper_body`,`body`,e),pz(CR,.8)),this.mount(`spine`,this.solid(iz()))];let n=e.endsWith(`_left`)?`left`:`right`,{sign:r,bone:i}=_z[n];switch(e.slice(0,e.indexOf(`_`))){case`fracture`:return[this.mount(`shoulder${i}`,this.solid(WR([r*27.6,103.3,-5],[r*(PA[0]+2.4),PA[1]+2.6,PA[2]+1.4],1.05))),this.mount(`elbow${i}`,this.solid(UR([WR([r*34.6,102.3,-4.8],[r*30,98.6,-.8],.8),WR([r*34,103.2,-5.6],[r*30.6,100.6,-9.8],.6)])))];case`ribs`:return[this.mount(`chest`,this.solid(az(r)))];case`knee`:return[this.mount(`knee${i}`,this.solid(WR([r*8.8,37.8,-4.6],[r*(FA[0]+3.8),FA[1]-1.2,FA[2]-.2],1.2)))];case`elbow`:return[...this.closing(e,e=>!vR(`forearm_${n}`,`body`,e),pz(new q(r,0,0),0)),this.mount(`shoulder${i}`,this.solid(nz(r)))];case`shoulder`:return[...this.closing(e,e=>!vR(`arm_${n}`,`body`,e),pz(new q(r,0,0),1.6)),this.mount(`clavicle${i}`,this.solid(rz(r)))]}}},yz={broken_nose:[`nose`,.3],broken_jaw:[`mouth`,.25],jaw_torn:[`mouth`,.75],eye_left_out:[`eye_left`,.3],eye_right_out:[`eye_right`,.3],ear_left_torn:[`ear_left`,.3],ear_right_torn:[`ear_right`,.3],skull_fractured:[`skull`,.4],arm_left_broken:[`elbow_left`,.3],arm_right_broken:[`elbow_right`,.3],forearm_left_severed:[`elbow_left`,1],forearm_right_severed:[`elbow_right`,1],arm_left_torn:[`shoulder_left`,1],arm_right_torn:[`shoulder_right`,1],ribs_left_broken:[`ribs_left`,.15],ribs_right_broken:[`ribs_right`,.15],disemboweled:[`belly`,.6],knee_left_blown:[`knee_left`,.2],knee_right_blown:[`knee_right`,.2]},bz=new Map(he.map(e=>[e,[]]));for(let[e,[t,n]]of Object.entries(yz))bz.get(t).push([e,n]);var xz=new Set([`nose`,`mouth`,`eye_left`,`eye_right`,`ear_left`,`ear_right`,`skull`]),Sz=new Set([`waist`,`crotch`,`knee_left`,`knee_right`]),Cz=1.5,wz=8,Tz=.9,Ez=18,Dz=36,Oz=.45,kz=.25,Az=.3,jz=.08,Mz=.012,Nz=[`ankleL`,`ankleR`],Pz=.35,Fz=.05,Iz=.5,Lz=.3,Rz=.4,zz=[`left`,`right`],Bz={left:`eye_left_out`,right:`eye_right_out`},Vz={left:`eye_left`,right:`eye_right`},Hz={left:[`forearm_left_severed`,`arm_left_torn`],right:[`forearm_right_severed`,`arm_right_torn`]},Uz=[`head`,`arm_left`,`arm_right`,`leg_left`,`leg_right`,`torso`],Wz={head:[`neck`,`neck`],jaw:[`mouth`,`head`],forearm_left:[`elbow_left`,`elbowL`],forearm_right:[`elbow_right`,`elbowR`],arm_left:[`shoulder_left`,`shoulderL`],arm_right:[`shoulder_right`,`shoulderR`],leg_left:[`knee_left`,`kneeL`],leg_right:[`knee_right`,`kneeR`],upper_body:[`waist`,`hips`],torso:[`chest`,`upperChest`]},Gz=Object.keys(Wz),Kz={head:[`head`],jaw:[`head`],forearm_left:[`body`,`glove_left`],forearm_right:[`body`,`glove_right`],arm_left:[`body`,`glove_left`],arm_right:[`body`,`glove_right`],leg_left:[`body`,`shoes`],leg_right:[`body`,`shoes`],upper_body:[`head`,`body`,`glove_left`,`glove_right`],torso:[`body`,`pants`]},qz=new q(0,1,0),Jz=new q(0,.12,.02),Yz=class{effects;bake;bodies=[null,null];position=new q;axis=new q;scratch=new q;turn=new rg;skullOffset=new q;injuries=new Set;time=0;settings={blood:`full`,reducedMotion:!1};constructor(e,t){this.effects=e,this.bake=t}attach(e,t){this.bodies[e]?.mutilation.dispose();let n={graph:t,mutilation:new vz(t.boxer),shown:new Set,early:new Map,awaited:new Map,inflicted:new Set,fatalWounds:new Map,forced:new Set,fatalParts:[],burst:new Set,fatality:null,dead:null,gutsDropAt:null,gibbed:!1,vomitUntil:0,printed:[new q,new q],dragged:new q,sliding:!1};return this.bodies[e]=n,n.mutilation}get graphic(){return this.settings.blood===`full`&&!this.settings.reducedMotion}expect(e,t){let n=this.bodies[e];n!=null&&!n.inflicted.has(t)&&n.awaited.set(t,this.time+wz)}sync(e,t,n,r,i,a=!1){this.time=i,this.settings=n;let o=this.bodies[e];if(o==null)return;let s=this.graphic;!s&&(o.gibbed||o.fatalParts.length>0||o.fatalWounds.size>0||o.forced.size>0)&&this.unmaim(o,e);let c=this.injuries;c.clear();let l=!1;for(let e of t.injuries){let t=o.awaited.get(e);if(t!==void 0){if(i<=t){l=!0;continue}o.awaited.delete(e)}c.add(e),o.early.delete(e),o.inflicted.add(e)}for(let[e,t]of o.early)i>t?o.early.delete(e):c.add(e);for(let e of o.forced)c.add(e);if(l)for(let e of o.shown)c.add(e);o.shown.clear();for(let e of c)o.shown.add(e);for(let e of o.inflicted)o.shown.has(e)||o.inflicted.delete(e);let u=o.graph.boxer,d=G.clamp(1-t.blood_volume/ve,0,1);if(o.mutilation.apply(o.shown,s?`full`:n.blood===`off`?`off`:`reduced`),o.mutilation.setPallor(n.blood===`off`?0:d),o.graph.setInjuries(o.shown,s),o.graph.setFaint(o.dead===null?G.clamp((.6-t.blood_volume/ve)/.6,0,1):0),o.dead!==null&&!o.graph.isDead&&o.graph.die(o.dead),o.mutilation.update(r,i),u.root.visible=!o.gibbed,o.gibbed)return;let f=o.mutilation.isPartGone(`upper_body`),p=f||u.isDecapitated,m=p||u.isHeadBurst,h=1-.65*d,g=0;for(let t of he){let n=o.fatalWounds.get(t)??0,r=`blood`,i=bz.get(t);for(let e=0;e0&&o.mutilation.anchor(t,this.position,this.axis)&&this.effects.anchorWound(e,t,this.position,this.axis)}for(let t=0;t=o.gutsDropAt&&(o.gutsDropAt=null,this.effects.dropGuts(e)),this.effects.anchorGuts(e,this.position,this.axis)):this.effects.gutsOut(e)&&this.effects.clearGuts(e),i=kz&&this.track(o,Math.min(1,g)),o.dead===null||!o.mutilation.anchor(`waist`,this.position,this.axis))return;this.effects.setCorpse(e,s?this.position:null);let v=s&&this.position.yIz?o.dragged.copy(this.position):y>Fz&&(this.effects.smear(o.dragged.x,o.dragged.z,this.position.x,this.position.z,Lz),o.dragged.copy(this.position)),o.sliding=v}gibbed(e){return this.bodies[e]?.gibbed===!0}hasGlove(e,t){let n=this.bodies[e]?.shown;return n===void 0||!this.graphic||!(n.has(Hz[t][0])||n.has(Hz[t][1]))}vomiting(e){return this.time<(this.bodies[e]?.vomitUntil??0)}punched(e,t,n){let r=this.bodies[e];r!=null&&this.graphic&&r.shown.has(Bz[t])&&this.effects.burstEye(e,t,n)&&r.burst.add(t)}eyeBurst(e,t){return this.bodies[e]?.burst.has(t)===!0}inflict(e,t,n,r){let i=this.bodies[e];if(i==null||(i.awaited.delete(t),i.inflicted.has(t)||i.gibbed))return!1;if(i.inflicted.add(t),i.early.set(t,this.time+Cz),i.shown.add(t),!this.graphic)return!0;let a=this.effects,o=this.position,s=this.axis,c=t.includes(`_right_`)?`right`:`left`,l=e=>i.mutilation.anchor(e,o,s);switch(t){case`broken_nose`:l(`nose`)&&a.sprayFluid(`blood`,o,r,140,n,1.1);break;case`broken_jaw`:l(`mouth`)&&(a.spawnTeeth(o,r,5,n),a.sprayFluid(`blood`,o,r,180,n));break;case`jaw_torn`:l(`mouth`)&&(this.fling(i,e,`jaw`,n,r,{radius:.05,speed:1.2,lift:.8}),a.spawnDebris(`jawbone`,o,r,1,n,1.2),a.spawnTeeth(o,r,9,n),a.sprayFluid(`blood`,o,r,420,n,1.2));break;case`eye_left_out`:case`eye_right_out`:l(`eye_${c}`)&&(a.gougeEye(e,o,s,r,n,c),a.sprayFluid(`blood`,o,r,120,n));break;case`ear_left_torn`:case`ear_right_torn`:l(`ear_${c}`)&&(a.spawnDebris(`ear`,o,r,1,n),a.sprayFluid(`blood`,o,r,130,n));break;case`face_left_flayed`:case`face_right_flayed`:l(`eye_${c}`)&&(a.spawnDebris(`skin`,o,r,3,n),a.sprayFluid(`blood`,o,r,260,n));break;case`skull_fractured`:l(`skull`)&&(a.spawnDebris(`shard`,o,r,7,n,1.2),a.spawnDebris(`brain`,o,r,8,n),a.sprayFluid(`blood`,o,r,300,n,1.3),a.sprayFluid(`brain`,o,r,90,n));break;case`shoulder_left_dislocated`:case`shoulder_right_dislocated`:break;case`arm_left_broken`:case`arm_right_broken`:l(`elbow_${c}`)&&(a.spawnDebris(`bone`,o,r,3,n),a.sprayFluid(`blood`,o,r,200,n));break;case`forearm_left_severed`:case`forearm_right_severed`:this.fling(i,e,`forearm_${c}`,n,r,{radius:.07,speed:1.1}),l(`elbow_${c}`)&&(a.spawnDebris(`bone`,o,r,2,n),a.spawnDebris(`flesh`,o,r,8,n),a.sprayFluid(`blood`,o,r,600,n,1.3));break;case`arm_left_torn`:case`arm_right_torn`:this.fling(i,e,`arm_${c}`,n,r,{radius:.08,speed:1,spin:.7}),l(`shoulder_${c}`)&&(a.spawnDebris(`flesh`,o,r,14,n),a.spawnDebris(`bone`,o,r,2,n),a.sprayFluid(`blood`,o,r,800,n,1.4));break;case`ribs_left_broken`:case`ribs_right_broken`:l(`ribs_${c}`)&&(a.spawnDebris(`bone`,o,r,2,n,.8),a.sprayFluid(`blood`,o,r,140,n));break;case`liver_ruptured`:this.vomit(e,n,1.6);break;case`disemboweled`:l(`belly`)&&(a.spillGuts(e,o,n,Ez),a.spawnDebris(`organ`,o,r,3,n),a.spawnDebris(`gut`,o,r,4,n),a.spawnDebris(`fat`,o,r,4,n),a.sprayFluid(`blood`,o,r,650,n,1.2),a.sprayFluid(`bile`,o,r,110,n));break;case`knee_left_blown`:case`knee_right_blown`:l(`knee_${c}`)&&(a.spawnDebris(`bone`,o,r,2,n,.7),a.sprayFluid(`blood`,o,r,110,n))}return!0}vomit(e,t,n=1.3){let r=this.bodies[e];r==null||r.gibbed||this.settings.reducedMotion||(r.graph.retch(n),this.settings.blood===`full`&&r.mutilation.anchor(`mouth`,this.position,this.axis)&&(r.vomitUntil=this.time+n,this.effects.gush(e,this.position,this.axis.addScaledVector(qz,-.4).normalize(),n,520,t,`bile`),this.effects.sprayFluid(`blood`,this.position,0,90,t,.6),this.effects.puddle(this.position.x+this.axis.x*Rz,this.position.z+this.axis.z*Rz,.22,`bile`,t)))}fatality(e,t,n,r){let i=this.bodies[e];if(i==null||i.fatality!==null||!this.graphic)return!1;i.fatality=t;let a=this.effects,o=this.position,s=this.axis,c=(t,i,s=1)=>a.spawnDebris(t,o,r,i,n,s,e),l=(e,t,i=1)=>a.sprayFluid(e,o,r,t,n,i);if(t===`eyes_out`){for(let t=0;tr||Math.hypot(this.position.x-o.x,this.position.z-o.z)t!==n&&e.mutilation.isPartGone(t)),d=[],f=new q;for(let e of Kz[n]){let t=xR(c,e);if(t===null||!t.visible)continue;let r=t=>vR(n,e,t)&&!u.some(n=>vR(n,e,t)),i=t.geometry.getAttribute(`position`),a=t.geometry.getIndex(),o=0,s=0,p=new Uint8Array(i.count);if(a===null)p.fill(1);else for(let e=0;e0&&d.push(this.bake(c,e,t,l,this.turn,o===s?void 0:r))}return d.length>0&&this.effects.flingPart(Xz(t,n),d,l,this.turn,i,r,{...a,part:n})}};function Xz(e,t){return`${e}:${t}`}var Zz=96,Qz=4,$z=2.5,eB=.45,tB=.032,nB=e=>()=>(e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296);function rB(e){let t=document.createElement(`canvas`);t.width=Zz,t.height=Zz;let n=t.getContext(`2d`);if(n===null)return t;let r=nB(e),i=Zz/2,a=4+Math.floor(r()*3);for(let e=0;e.05)||!Number.isFinite(e)||!Number.isFinite(t))return;let i=nB((Number.isSafeInteger(r)?r:0)*40503+11),a=Math.min(24,Math.max(1,Math.round(n*12))),o=.7+.3*Math.min(3,n);for(let r=0;r=1.5?1.8:1),l=$z+i()*2.5;this.drops.push({x:Math.min(1,Math.max(0,a?i():e+(i()+i()-1)*s*1.6)),y:Math.min(1,Math.max(0,a?i():t+(i()+i()-1)*s)),radius:c,alpha:.6+i()*.35,life:l,maxLife:l,run:c>=tB?.02+i()*.04:0,ran:0,sprite:Math.floor(i()*Qz),turn:i()*Math.PI*2})}this.drops.length>96&&this.drops.splice(0,this.drops.length-96)}update(e){let t=Number.isFinite(e)?Math.max(0,e):0;for(let e=this.drops.length-1;e>=0;--e){let n=this.drops[e];n.life-=t,n.life<=0?this.drops.splice(e,1):n.ran+=n.run*t*(n.life/n.maxLife)}}draw(e,t,n){if(this.drops.length!==0){this.sprites??=Array.from({length:Qz},(e,t)=>rB(1374496523+t*7919)),e.save();for(let r of this.drops){let i=Math.min(1,r.life/(r.maxLife*eB)),a=r.radius*n,o=r.x*t,s=(r.y+r.ran)*n;if(e.globalAlpha=r.alpha*i,r.ran>0){let t=r.y*n,i=e.createLinearGradient(0,t,0,s);i.addColorStop(0,`rgba(88,0,6,0)`),i.addColorStop(1,`rgba(88,0,6,0.6)`),e.fillStyle=i,e.beginPath(),e.moveTo(o-a*.06,t),e.lineTo(o+a*.06,t),e.lineTo(o+a*.28,s),e.lineTo(o-a*.28,s),e.closePath(),e.fill()}e.save(),e.translate(o,s),e.rotate(r.turn),e.drawImage(this.sprites[r.sprite],-a,-a,a*2,a*2),e.restore()}e.restore()}}clear(){this.drops.length=0}},aB=.026,oB=.038,sB=22,cB=[[.55,.85],[.55,.1],[.4,-.12],[-.4,-.12],[-.55,.05],[-.55,.6],[-.32,.62],[-.3,.16],[.3,.16],[.32,.85]],lB=.03;function uB(){let e=[],t=[],n=cB.length,r=new q,i=new q,a=new q;for(let t=0;t<=sB;t+=1){let n=t/sB*2-1;r.set(n*aB,0,oB*(1-n*n)-oB*.5),i.set(aB,0,-2*oB*n).normalize(),a.set(i.z,0,-i.x),a.dot(r.clone().setY(0).add(new q(0,0,oB*.5)))<0&&a.negate();for(let[t,n]of cB)e.push(r.x+a.x*t*.01,n*.01,r.z+a.z*t*.01)}for(let e=0;e=50:e===`hit`&&t>=65:!1}var fB=9.81,pB=.32,mB=4.5,hB=.04,gB=3;function _B(){return{out:!1,moving:!1,sliding:!1,x:0,y:-50,z:0,vx:0,vy:0,vz:0,wx:0,wy:0,wz:0,bounces:0,age:0,restYaw:0}}function vB(e,t,n,r){if(!e.out||!e.moving)return!1;e.age+=n;let i=r+.006;if(!e.sliding)e.vy-=fB*n,e.x+=e.vx*n,e.y+=e.vy*n,e.z+=e.vz*n,CB(t,e.wx*n,e.wy*n,e.wz*n),e.y<=i&&(e.y=i,e.bounces.6?(e.bounces+=1,e.vy=-e.vy*pB,e.vx*=.72,e.vz*=.72,e.wx*=.55,e.wy*=.7,e.wz*=.55):(e.vy=0,e.sliding=!0));else{let r=Math.hypot(e.vx,e.vz),a=Math.max(0,r-mB*n);a<=hB?(e.vx=0,e.vz=0):(e.vx*=a/r,e.vz*=a/r),e.x+=e.vx*n,e.z+=e.vz*n,e.y=i,e.wy*=Math.exp(-4*n),e.restYaw+=e.wy*n,bB.setFromAxisAngle(yB,e.restYaw),t.slerp(bB,1-Math.exp(-12*n)),e.vx===0&&e.vz===0&&t.angleTo(bB)<.02&&(t.copy(bB),e.moving=!1)}return e.moving}var yB=new q(0,1,0),bB=new rg,xB=new rg,SB=new Lg;function CB(e,t,n,r){xB.setFromEuler(SB.set(t,n,r)),e.multiply(xB).normalize()}var wB=[.84,.78,.62],TB=[.4,.04,.04],EB=[.3,.012,.018],DB=[.5,.045,.05],OB=[.86,.64,.16],kB=[.42,.19,.09],AB=[.92,.88,.74],jB=[.72,.36,.34],MB=[.82,.52,.46],NB=(e,t,n)=>{let r=Math.min(1,Math.max(0,n));return[e[0]+(t[0]-e[0])*r,e[1]+(t[1]-e[1])*r,e[2]+(t[2]-e[2])*r]},PB=e=>{let t=Math.min(1,Math.max(0,e));return t*t*(3-2*t)},FB=(e,t,n=0)=>.5+.25*Math.sin(e.x*t*1.31+n)*Math.sin(e.y*t*1.93+n*1.7)+.25*Math.sin(e.z*t*1.57+n*.6)*Math.sin(e.x*t*.83-n),IB=e=>()=>(e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296),LB=new q;function RB(e,t){e.deleteAttribute(`normal`),e.deleteAttribute(`uv`);let n=yE(e,1e-5);e.dispose();let r=n.getAttribute(`position`);for(let e=0;enew Dg().compose(new q(e,t,n),new rg().setFromEuler(new Lg(r,i,a)),new q(o,s,c));function HB(e,t,n){return zB(new yb(new Jy(e.map(e=>new q(...e))),Math.max(4,e.length*3),t,7,!1),n)}var UB=new Map;function WB(e){let t=UB.get(e);return t===void 0&&(t=e(),UB.set(e,t)),t.clone()}function GB(){return BB([zB(RB(new fb(1,3),e=>{e.normalize();let t=.45+.55*PB((e.x+1)/2),n=1-.34*Math.exp(-(((e.x+.2)/.14)**2))*PB(e.z+.6),r=1+.07*Math.sin(e.x*5.1+.7)*Math.sin(e.z*4.3+1.9);e.set(e.x*.1*r,(e.y>0?e.y:e.y*.4)*.04*t*r,e.z*.062*n*(.7+.3*t))}),e=>NB(NB([.2,.035,.022],[.34,.07,.04],FB(e,70)),EB,e.y<-.006?.5:0)),zB(RB(new fb(1,2),e=>e.set(e.x*.03,e.y*.012,e.z*.014)),[.16,.24,.04],VB(.03,-.012,.03,0,.5,0)),HB([[.01,.004,-.03],[0,.012,-.055],[-.012,.014,-.075]],.007,e=>NB([.16,.05,.2],EB,PB((-e.z-.06)*60)))])}function KB(){return BB([zB(RB(new fb(1,3),e=>{e.normalize();let t=1-.42*Math.exp(-((e.x/.4)**2))*PB(e.z);e.set(e.x*.058,e.y*.024,e.z*.033*t-e.x*e.x*.012)}),e=>NB([.3,.05,.075],[.19,.025,.05],FB(e,120,1.3))),HB([[0,0,.014],[.004,.002,.034],[.018,0,.058],[.02,-.002,.082]],.0048,e=>NB([.86,.72,.56],EB,PB((e.z-.066)*70))),HB([[-.006,.002,.014],[-.012,.004,.034],[-.03,.002,.046]],.0042,EB),zB(RB(new fb(1,1),e=>e.set(e.x*.014,e.y*.009,e.z*.01)),OB,VB(0,.002,.02))])}function qB(){return BB([zB(RB(new fb(1,3),e=>{e.normalize();let t=.55+.45*PB((1-e.z)/2+.1),n=1-.3*Math.exp(-(((e.z-.1-e.x*.3)/.1)**2)),r=1+.035*Math.sin(e.x*23)*Math.sin(e.y*19)*Math.sin(e.z*21);e.set(e.x*.062*t*n*r,(e.y>0?e.y:e.y*.55)*.036*t*n*r,e.z*.09*r)}),e=>NB(NB([.66,.34,.34],[.34,.16,.2],PB(FB(e,160,.4)*1.7-.5)),EB,PB((e.z-.05)*22)*.7)),zB(new Iy(.011,.012,.045,9,5,!0),e=>Math.abs((e.y+.5)*110%2)<1?[.84,.74,.62]:[.6,.26,.24],VB(0,.006,.105,Math.PI/2-.2,0,0))])}function JB(){let e=new Jy([[-.085,0,.012],[-.045,.004,-.02],[0,0,.018],[.04,.003,-.016],[.082,0,.014]].map(e=>new q(...e))),t=[],n=[],r=[],i=e.computeFrenetFrames(30,!1);for(let r=0;r<=30;r+=1){let a=r/30,o=e.getPointAt(a),s=Math.min(1,Math.sin(a*Math.PI)*5),c=.0175*(.82+.18*Math.abs(Math.sin(a*Math.PI*5.5)))*(.25+.75*s);for(let e=0;e<9;e+=1){let l=e/9*Math.PI*2,u=LB.copy(i.normals[r]).multiplyScalar(Math.cos(l)).addScaledVector(i.binormals[r],Math.sin(l));t.push(o.x+u.x*c,o.y+u.y*c,o.z+u.z*c);let d=1-.3*(1-Math.abs(Math.sin(a*Math.PI*5.5))),f=e===0?EB:NB(NB(jB,MB,.5+.5*Math.sin(a*23+e)),EB,s<1?.8:0);n.push(f[0]*d,f[1]*d,f[2]*d)}}for(let e=0;e<30;e+=1)for(let t=0;t<9;t+=1){let n=e*9+t,i=e*9+(t+1)%9;r.push(n,i,n+9,i,i+9,n+9)}let a=new iv;a.setAttribute(`position`,new K_(t,3)),a.setAttribute(`color`,new K_(n,3)),a.setIndex(r),a.computeVertexNormals();let o=a.toNonIndexed();return a.dispose(),BB([o,...[[-.03,-.004,-.03],[.012,-.004,.03],[.05,-.004,-.028]].map(([e,t,n])=>zB(RB(new fb(1,1),e=>e.set(e.x*.016,e.y*.007,e.z*.011)),OB,VB(e,t,n,0,e*20,0)))])}function YB(){let e=[[.012,.008],[.004,.0105],[-.01,.0075],[-.013,-.004],[-.002,-.0095],[.01,-.0065]],t=[-1,-.72,-.3,.2,.62,1],n=[.02,.62,1,.9,.5,.02],r=[.004,-.002,0,.001,-.003,.005],i=[],a=[],o=(i,a)=>{let[o,s]=e[a%e.length];return[t[i]*.062,s*n[i],o*n[i]+r[i]]},s=(n,r)=>{let i=Math.abs(t[n]);return NB(r%e.length===3||r%e.length===4?NB(wB,TB,.75):wB,EB,PB((i-.6)*3.2))};for(let n=0;nNB(kB,DB,PB((-e.x-.006)*90));return BB([zB(RB(new fb(1,3),e=>{e.normalize();let t=e.y>0?1-.75*Math.exp(-(((e.x-.1)/.5)**2+((e.z+.1)/.55)**2)):1;e.set(e.x*.019,e.y*.0055*t,e.z*.031*(1-.18*e.x))}),t=>NB(e(t),[.24,.08,.05],t.y<.003&&t.y>-.001?.5:0)),zB(new vb(.024,.0048,7,18,Math.PI*1.25),kB,VB(-.001,.004,.004,-Math.PI/2,0,-Math.PI*.72,.78,1.18,1)),zB(RB(new fb(1,2),e=>e.set(e.x*.0095,e.y*.0055,e.z*.0105)),e,VB(.002,.002,.031)),zB(RB(new fb(1,1),e=>e.set(e.x*.005,e.y*.005,e.z*.007)),e,VB(-.011,.004,.006)),zB(RB(new fb(1,1),e=>e.set(e.x*.006,e.y*.005,e.z*.022)),DB,VB(-.017,0,.002))])}var ZB=12;function QB(){let e=e=>[Math.sin(e)*.046,Math.cos(e)*.056-.02],t=[],n=e=>NB(NB(wB,[.7,.6,.44],FB(e,200)),EB,PB((e.y-.003)*220)*.75),r=Math.PI*.62,i=[];for(let t=0;t<=22;t+=1){let[n,a]=e(-r+t/22*r*2);i.push(new q(n,0,a))}let a=new yb(new Jy(i),44,.0085,8,!1);t.push(zB(RB(a,e=>e.setY(e.y*1.35)),n)),t.push(zB(RB(new fb(1,2),e=>e.set(e.x*.016,e.y*.013,e.z*.011)),n,VB(0,-.003,.038)));for(let n=0;nNB(AB,[.7,.2,.14],PB((-e.y-5e-4)*400)),VB(a,.0125+(s?.0045:.003),o,0,-i,0))),t.push(zB(RB(new fb(1,1),e=>e.set(e.x*.0058,e.y*.0045,e.z*.0058)),c?[.05,.004,.006]:[.5,.07,.08],VB(a,.0105,o)))}for(let n of[-1,1]){let[i,a]=e(n*r),o=RB(new Ny(.008,.05,.026,1,4,2),e=>{let t=e.y/.05+.5;e.z+=-.012*t+(t>.9?Math.sign(e.z)*.004:0),e.x*=1-.3*t});t.push(zB(o,e=>NB(wB,EB,PB((e.y-.012)*60)),VB(i,.02,a-.006,0,n*.25,n*-.12))),t.push(zB(RB(new fb(1,1),e=>e.set(e.x*.009,e.y*.006,e.z*.014)),DB,VB(i,.047,a-.016)))}let o=BB(t);return o.translate(0,-.016,0),o.computeBoundingBox(),o.computeBoundingSphere(),o}function $B(){let e=(e,t,n)=>{let r=t/13*Math.PI*2,i=.55+.45*Math.abs(Math.sin(t*2.7+.9))+.12*Math.sin(t*5.3),a=e/3*i,o=Math.cos(r)*a*.062,s=Math.sin(r)*a*.044;return[o,.009*Math.sin(o*60+.4)*Math.cos(s*48)+.3*(o*o+s*s)/.062+n*.0028*(1-e/3*.7),s]},t=[],n=[],r=(e,r,i,a)=>{for(let o of[e,r,i])t.push(...o),n.push(...a(o))},i=()=>kB,a=e=>Math.sin(e[0]*310+1)*Math.sin(e[2]*270)>.45?OB:NB(DB,EB,.5+.5*Math.sin(e[0]*140+e[2]*90));for(let t=0;t<3;t+=1)for(let n=0;n<13;n+=1){let o=(n+1)%13;r(e(t,n,1),e(t+1,o,1),e(t+1,n,1),i),r(e(t,n,0),e(t+1,n,0),e(t+1,o,0),a),t>0&&(r(e(t,n,1),e(t,o,1),e(t+1,o,1),i),r(e(t,n,0),e(t+1,o,0),e(t,o,0),a))}for(let t=0;t<13;t+=1){let n=(t+1)%13;r(e(3,t,1),e(3,n,1),e(3,t,0),()=>DB),r(e(3,n,1),e(3,n,0),e(3,t,0),()=>DB)}let o=new iv;return o.setAttribute(`position`,new K_(t,3)),o.setAttribute(`color`,new K_(n,3)),o.computeVertexNormals(),BB([o])}function eV(){let e=IB(795558343),t=[];for(let n=0;n<9;n+=1){let r=e()*Math.PI*2,i=n===0?0:.012+e()*.02,a=n===0?.021:.009+e()*.009,o=e();t.push(zB(RB(new fb(1,2),e=>e.set(e.x*a,e.y*a*.7,e.z*a)),NB(OB,[.92,.8,.36],o),VB(Math.cos(r)*i,(e()-.3)*.008,Math.sin(r)*i*.8)))}return t.push(zB(RB(new fb(1,1),e=>e.set(e.x*.02,e.y*.005,e.z*.009)),DB,VB(.018,-.006,.01,0,.6,0))),BB(t)}function tV(){let e=e=>NB(NB(wB,[.68,.58,.42],FB(e,260)),EB,PB(FB(e,90,2.2)*2.4-1.3)),t=zB(RB(new Iy(.02,.02,.022,14,2),e=>{let t=1-.14*(1-(e.y/.011)**2);e.x*=t,e.z*=t*(e.z<0?.8:1)}),e,VB(0,0,.008)),n=zB(new Iy(.0175,.0175,.005,12),e=>NB([.78,.5,.46],DB,FB(e,400)),VB(0,.0125,.008)),r=zB(new vb(.0115,.0042,6,12),e,VB(0,0,-.016,Math.PI/2,0,0)),i=zB(RB(new Ny(.007,.011,.03,1,1,3),e=>{let t=.5-e.z/.03;e.x*=1-.55*t,e.y=e.y*(1-.4*t)-.008*t}),e,VB(0,0,-.04)),a=[-1,1].map(t=>zB(RB(new Ny(.024,.008,.008,3,1,1),e=>{let n=.5+t*e.x/.024;e.y*=1-.5*n,e.z=e.z*(1-.4*n)-.006*n}),e,VB(t*.027,0,-.012))),o=zB(new Iy(.0048,.0048,.03,7),e=>NB([.88,.8,.6],EB,PB((Math.abs(e.y)-.009)*200)),VB(0,0,-.016));return BB([t,n,r,i,...a,o])}function nV(){return BB([zB(RB(new Ny(.075,.004,.022,9,1,3),e=>{let t=e.x/.075+.5;e.x+=.0375,e.z=e.z*(1-.75*t)*(1+.5*Math.sin(t*17))+.006*Math.sin(t*9),e.y+=.004*Math.sin(t*13)}),e=>NB(NB(DB,EB,FB(e,240)),OB,Math.sin(e.x*260)>.93?.8:0))])}var rV={position:new q(.012,.089,.004),direction:new q(.47,.88,-.12).normalize()};function iV(){let e=zB(RB(new fb(1,4),e=>{e.normalize();let t=PB((1-e.y)/2),n=1-.62*t**2.4,r=1-.1*Math.exp(-(((e.x+.12)/.14)**2))*(e.z>-.2?1:.4);e.set(e.x*.05*n*r+.012*t,e.y>0?e.y*.038:e.y*.07,e.z*.04*n*r)}),e=>{let t=Math.exp(-(((e.x+.008+e.y*.3)/.006)**2)),n=Math.exp(-(((e.y-.032)/.006)**2));return NB(NB(NB([.42,.03,.035],[.26,.015,.025],FB(e,130)),OB,Math.max(t*.85,n*.7)*PB(FB(e,420,.7)*2)),[.12,.02,.1],t>.6&&Math.sin(e.y*300)>.2?.7:0)}),t=(e,t,n)=>zB(RB(new fb(1,2),e=>{let t=1+.12*Math.sin(e.x*9)*Math.sin(e.z*8);e.set(e.x*n*t,e.y*n*.72,e.z*n*.9*t)}),e=>NB([.3,.02,.05],[.18,.012,.045],FB(e,200)),VB(e,.04,t)),n=(e,t)=>n=>NB(e,EB,PB((n.y-t)*120)),r=HB([[-.006,.03,.006],[-.004,.058,.008],[.004,.08,.006],[.012,.095,.004]],.0125,n([.82,.56,.44],.082)),i=[-1,0,1].map(e=>HB([[-.003+e*.004,.066,.008],[-.012+e*.012,.086,.012-e*.004],[-.016+e*.018,.1,.014-e*.006]],.0048,n([.78,.5,.4],.09))),a=HB([[.016,.03,.022],[.012,.052,.026],[-.006,.066,.03],[-.026,.07,.03]],.0105,e=>NB([.3,.3,.52],EB,PB((-e.x-.014)*110))),o=HB([[.03,.036,-.016],[.034,.058,-.018],[.036,.08,-.02]],.0095,n([.16,.14,.34],.068)),s=BB([e,t(.027,-.006,.024),t(-.024,-.004,.022),r,...i,a,o]);return s.translate(0,-.006,0),s.computeBoundingBox(),s.computeBoundingSphere(),s}var aV=2;function oV(e){let t=Math.min(14,Math.max(0,e));return aV*t-1.55*t*t/28}function sV(e){return Math.max(0,1-Math.max(0,e)/14)**.8}function cV(e){let t=e-Math.floor(e);return t<.16?PB(t/.16):1-PB((t-.16)/.3)}var lV=9.81,uV=.97,dV=.6,fV=10,pV=1.02,mV=.5,hV=.5,gV=2e-4,_V=.45,vV=.03,yV=.15,bV=class{capacity;radius;selfAvoiding;positions;previous;nodes=0;segment=0;pinned=!1;resting=!0;paidOut=0;payRate=0;still=0;constructor(e,t,n){this.capacity=e,this.radius=t,this.selfAvoiding=n,this.positions=new Float32Array(e*3),this.previous=new Float32Array(e*3)}get held(){return this.pinned?Math.max(0,this.nodes-1-Math.floor(this.paidOut)):-1}spill(e,t,n,r,i){this.nodes=Math.min(this.capacity,Math.max(2,Math.round(e)+1)),this.segment=t,this.pinned=!0,this.resting=!1,this.paidOut=1,this.payRate=r,this.still=0;for(let e=0;e.4)for(let e=0;ethis.segment?this.segment:s=a-1?this.still+e:0,this.still>=hV&&(this.resting=!0,s.set(o)),!0}drape(e,t,n,r=!1){let i=Math.hypot(n.x,n.z);if(i<.3)return;let a=this.positions;for(let o=e;o_V||s<-.05)continue;let c=vV+yV*Math.min(1,Math.max(0,s)/.25),l=((a[e]-t.x)*n.x+(a[e+2]-t.z)*n.z)/i;if(l>=c+(r?1e-4:0))continue;let u=Math.max(0,c-l);if(a[e]=a[e]+n.x/i*u,a[e+2]=a[e+2]+n.z/i*u,!r)continue;let d=((a[e]-this.previous[e])*n.x+(a[e+2]-this.previous[e+2])*n.z)/i;this.previous[e]=this.previous[e]+n.x/i*d,this.previous[e+2]=this.previous[e+2]+n.z/i*d}}keepApart(e){let t=this.positions,n=this.radius*1.7;for(let r=e;r=n*n)continue;let c=Math.sqrt(s),l=Math.hypot(i,o)1e-10&&TV.copy(OV).normalize(),EV.addScaledVector(TV,-EV.dot(TV)),EV.lengthSq()<1e-8&&(EV.set(+(Math.abs(TV.x)<.9),0,Math.abs(TV.x)<.9?0:1),EV.addScaledVector(TV,-EV.dot(TV))),EV.normalize(),DV.crossVectors(TV,EV);let a=Math.min(e,n-1-e),c=this.radii[e]*(a===0?.08:a===1?.62:a===2?.9:1);for(let t=0;t0?t.fromBufferAttribute(n,0):t.set(0,1,0).applyQuaternion(e.mesh.quaternion),t.lengthSq()>1e-8?t.normalize():t.set(0,1,0)}var WH=e=>()=>(e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296),$=(e,t=0)=>Number.isFinite(e)?e:t,GH=()=>({alive:!1,x:0,y:-50,z:0,vx:0,vy:0,vz:0,rx:0,ry:0,rz:0,vrx:0,vry:0,vrz:0,scale:0,stretch:1,bounces:0,stained:!1,kind:`flesh`,resting:!1,born:0,owner:-1,fading:-1}),KH=e=>{for(let t of e)if(!t.alive)return!0;return!1},qH=new J(16054267),JH=.012,YH=.055,XH=90,ZH=10,QH=.985,$H=new K(.097,.132),eU=.012,tU={r:.82,g:.86,b:.9},nU=4,rU=(e,t)=>Math.trunc(e)*2+(t===`left`?0:1),iU=new q(1,0,0),aU=[`blood`,`bile`,`brain`,`urine`],oU=2400,sU={liver:{build:GB,share:.06,size:[.8,.5],stretch:[.9,.3],stain:.5},kidney:{build:KB,share:.06,size:[.9,.5],stretch:[.9,.25],stain:.3},lung:{build:qB,share:.06,size:[.75,.45],stretch:[.9,.3],stain:.45},gut:{build:JB,share:.18,size:[.8,.5],stretch:[.8,.5],stain:.4},bone:{build:YB,share:.24,size:[.7,.8],stretch:[.8,.6],stain:.14},vertebra:{build:tV,share:.1,size:[.9,.3],stretch:[1,0],stain:.2},skin:{build:$B,share:.1,size:[.8,.8],stretch:[.7,.7],stain:.3},fat:{build:eV,share:.12,size:[.6,.7],stretch:[.8,.5],stain:.2},ear:{build:XB,share:.03,size:[1.3,.3],stretch:[1,0],stain:.14},jawbone:{build:QB,share:.016,size:[1.1,.15],stretch:[1,0],stain:.34}},cU=Object.keys(sU),lU=[`liver`,`kidney`,`lung`],uU=Object.fromEntries(he.map((e,t)=>[e,t])),dU=14,fU=3.5,pU=1100,mU=.12,hU=.45,gU=TH*Math.sqrt(Math.PI),_U=e=>G.clamp((e-.3)/.6,0,1),vU=e=>dU+326*e**2.2,yU=e=>vU(e)*(1-_U(e)*.88*(1-gU)),bU=16,xU=8,SU=.4,CU=24,wU=11,TU=.046,EU=[0,0,1,3,6],DU=50,OU=48,kU=.6,AU=1,jU=.06,MU=.075,NU=4,PU=24,FU=1.3,IU=new rg().setFromEuler(new Lg(.95,0,0)),LU=60,RU=4,zU=5,BU=1.2,VU=1.5,HU=.5;function UU(e){if(typeof e==`number`)return{x:e<0?-1:1,z:0};let t=Math.hypot(e.x,e.z);return Number.isFinite(t)&&t>1e-6?{x:e.x/t,z:e.z/t}:{x:1,z:0}}var WU=new q(0,1,0),GU=new q(0,0,1),KU=e=>Number.isFinite(e)?G.clamp(e,0,hH):0,qU=new Set([`hit`,`counter_hit`,`block`,`perfect_block`,`guard_break`,`knockdown`,`bleed`]);function JU(e,t,n,r){let i=Math.abs(e)-r;if(i<=0)return{position:e,velocity:t};let a=Math.sign(e);return Math.abs(n)<=r?{position:a*r,velocity:t*-.42}:{position:e,velocity:-a*Math.max(-a*t,i*ZV)}}function YU(e){if(e.kind===`bleed`)return`ooze`;if(e.kind===`knockdown`)return`impact`;let t=e.detail.split(`:`);if(t.at(-1)===`body`)return`body_burst`;let n=t.find(e=>[`jab`,`straight`,`hook`,`uppercut`].includes(e));return n===`hook`?`fan`:n===`uppercut`?`plume`:`jet`}function XU(e,t){e.set($(t.x),$(t.y),$(t.z),$(t.w,1)),e.lengthSq()<1e-6?e.identity():e.normalize()}function ZU(){return new jb({color:9063730,roughness:.58,metalness:.02,clearcoat:.25,clearcoatRoughness:.6})}function QU(e,t){let n=ZU();n.map=t;let r=e?new nj(n,aA,{core:BA,wash:!0,baked:!0}):new nj(n,iA,{core:zA,lids:VA,baked:!0});if(!e)return{material:n,injury:r,look:new Aj(n,!0)};let i=n.onBeforeCompile;return n.onBeforeCompile=(e,t)=>{i.call(n,e,t),e.vertexShader=e.vertexShader.replace(`#include `,`#include -attribute vec3 bindPosition;`)},{material:n,injury:r,look:null}}var $U=0,eW=1,tW=2,nW=3;function rW(e,t,n){return e===void 0||e===`forearm_left`||e===`forearm_right`?$U:e===`head`?tW:e===`upper_body`?t?nW:eW:e===`torso`&&n?tW:eW}function iW(e,t,n,r=0){let i=new Ab({map:e,color:t,roughness:n===void 0?.6:.38,metalness:.02,side:2});return n!==void 0&&(rA(i,!0,n).value=r),i}function aW(e,t,n){n.identity();let r=e.getAttribute(`position`),i=e.getAttribute(`bindPosition`),a=e.getIndex();if(i===void 0||i.count!==r.count)return n;let o=new Uint8Array(r.count);if(a===null)o.fill(1);else for(let e=0;e({active:!1,eventId:null,fluid:`blood`,life:0,seconds:1,rate:0,accumulator:0,position:new q,axis:new q(0,1,0)}));simulationRemainder=0;ambientSeed=1597463007;shake=0;lowTier=!1;bloodLevel=`full`;lens=new iB;camera=null;lensPoint=new q;debrisCursor=new Map;visceraMaterial;viscera=[];visceraByShape={};wounds=[];woundsOpen=0;woundShare=1;woundClock=0;parts=[];partsThrown=0;partBox=new T_;partMiddle=new q;partVertex=new q;limbMap;limbMaterial;trunkMap;trunkMaterial;fleshSections;spines=[];spineMesh;spineStretch;shredGeometry;shredMesh;spineNeck=new q;guts=[];heartGeometry;heartMesh;heartRest;heartRadius;heart={active:!1,moving:!1,owner:-1,age:0,beats:0,vx:0,vy:0,vz:0,vrx:0,vry:0,vrz:0,bounces:0,settle:-1,settleFrom:new rg,settleTo:new rg,settleFromY:0,pool:0,trail:0};corpses=[];flyGeometry;flyMaterial;flyMesh;flies;constructor(e,t=1024,n=NV){this.scene=e,this.budget=n,this.dropletPositions=new Float32Array(n.droplets*3),this.dropletColors=new Float32Array(n.droplets*3),this.dropletBuffers={position:new U_(this.dropletPositions,3),color:new U_(this.dropletColors,3)},this.dropletGeometry=CO(),this.dropletMaterial=new Ab({color:16777215,roughness:.3,metalness:.02}),this.dropletMesh=new ny(this.dropletGeometry,this.dropletMaterial,n.droplets),this.dropletMesh.instanceMatrix.setUsage(gh),this.dropletMesh.frustumCulled=!1,this.dropletMesh.castShadow=!1,e.add(this.dropletMesh);for(let e=0;eObject.assign(new Y(e.geometry,e.material),{castShadow:e.castShadow}));if(e.push(Object.assign(new Y(this.stumpGeometry,this.jawMaterial),{castShadow:this.stumps[0].mesh.castShadow})),this.bakedStandIns===null){let e=new xg,t=[QU(!1,e),QU(!0,e)].flatMap(e=>[e.material,e.injury.variant(!1),e.injury.variant(!0)]),n=new Ab({color:1920728,roughness:.38,metalness:.03,map:e});rA(n,!0);let r=[iW(e,16777215),iW(null,16777215),iW(e,1920728,`gloves`),iW(e,1920728,`trunks`)],i=new ny(this.heartGeometry,this.visceraMaterial,1);i.setColorAt(0,this.gibColor.setHex(16777215)),i.castShadow=!0,this.bakedStandIns={map:e,materials:[...t,n,...r],instanced:[i,new ny(this.flyGeometry,this.flyMaterial,1)]}}for(let t of this.bakedStandIns.materials)e.push(Object.assign(new Y(this.headGeometry,t),{castShadow:!0}));return e.push(Object.assign(new Y(this.heartGeometry,this.visceraMaterial),{castShadow:!0}),...this.bakedStandIns.instanced),e}setCamera(e){this.camera=e}drawLens(e,t,n){this.lens.draw(e,t,n)}get lensDrops(){return this.lens.count}setBloodLevel(e){if(e===this.bloodLevel)return;let t=this.bloodLevel;this.bloodLevel=e,(e===`off`||t===`full`&&e===`reduced`)&&this.clearArcadeGore()}get shakeAmount(){return this.shake}get liveParticles(){return this.droplets.filter(e=>e.alive).length}get liveBloodParticles(){return this.droplets.filter(e=>e.alive&&e.blood).length}get liveMist(){return this.mists.filter(e=>e.alive).length}get canvasStains(){return this.canvasBlood.stains}useUploader(e){this.canvasBlood.useUploader(e)}setLowTier(e){this.canvasBlood.setLowTier(e),this.lowTier=e}get liveGibs(){return this.gibs.filter(e=>e.alive).length}get liveShards(){return this.shards.filter(e=>e.alive).length}debrisCount(e){let t=0;for(let n of this.gibs)n.alive&&n.kind===e&&(t+=1);for(let n of this.shards)n.alive&&n.kind===e&&(t+=1);for(let n of this.eyeballs)n.alive&&n.kind===e&&(t+=1);for(let n of this.viscera)for(let r of n.pieces)r.alive&&r.kind===e&&(t+=1);return t}get activeHeads(){return this.heads.filter(e=>e.active).length}headBurst(e){let t=this.stumps[Math.trunc(e)];return t!==void 0&&t.active&&t.mesh.material===this.jawMaterial}severedHeadPosition(e,t){let n=this.heads[Math.trunc(e)];return n===void 0||!n.active?!1:(t.copy(n.mesh.position),!0)}severedHeadFacing(e,t){let n=this.heads[Math.trunc(e)];return n===void 0||!n.active?!1:(t.set(0,0,1).applyQuaternion(n.mesh.quaternion),!0)}mouthpieceOut(e){return this.shields[Math.trunc(e)]?.out===!0}mouthpiecePosition(e,t){let n=this.shields[Math.trunc(e)];return n===void 0||!n.out?!1:(t.set(n.x,n.y,n.z),!0)}ejectMouthpiece(e,t,n,r,i,a,o=!1){if(e<0||e>=BV)return!1;let s=Math.trunc(e),c=this.shields[s],l=Number.isSafeInteger(i)?i:0;if(c.out&&!o||this.lastShieldEvent[s]===l)return!1;this.lastShieldEvent[s]=l;let u=WH(l*48271+s*7907+5),d=UU(r),f=.9+u()*.9,p=.9+u()*.9,m=(u()-.5)*1.1;Object.assign(c,_B(),{out:!0,moving:!0,x:$(t.x),y:$(t.y,1.45),z:$(t.z),vx:f*d.x-m*d.z,vy:p,vz:f*d.z+m*d.x,wx:(u()-.5)*26,wy:(u()-.5)*18,wz:(u()-.5)*26,restYaw:u()*Math.PI*2});let h=this.shieldMeshes[s];h.position.set(c.x,c.y,c.z),XU(h.quaternion,n),h.visible=!0,this.shieldMaterials[s].color.setHex(a).lerp(qH,.55);let g=this.bloodLevel===`full`;for(let e=0;e<(g?22:12);e+=1){let t=u()*Math.PI*2,n=g?e%3!=0:this.bloodLevel===`reduced`&&e%3==0;this.spawnDroplet(c.x+(u()-.5)*.03,c.y+(u()-.5)*.03,c.z+(u()-.5)*.03,c.vx*(.5+u()*.6)+Math.sin(t)*.4,c.vy*(.4+u()*.6),c.vz*.5+Math.cos(t)*.4,n?EO(u()):tU,.5+u()*.5,n)}return!0}gougeEye(e,t,n,r,i,a,o=!1){if(this.bloodLevel!==`full`||e<0||e>=BV)return;let s=Math.trunc(e),c=rU(s,a),l=this.eyes[c],u=Number.isSafeInteger(i)?i:0;if(l.active&&(o||l.eventId===u))return;l.active&&this.burstEye(s,a,u),l.active=!0,l.eventId=u,l.socket.set($(t.x),$(t.y,1.6),$(t.z)),l.facing.copy(n),l.hasSkull=!1,l.position.copy(l.socket).addScaledVector(n,JH*1.5),this.eyeDirection.copy(n).multiplyScalar(1.3);let d=UU(r);if(this.eyeDirection.x+=d.x*.5,this.eyeDirection.z+=d.z*.5,l.previous.copy(l.position),o||l.previous.addScaledVector(this.eyeDirection,-.016666666666666666),l.bleeding=o?0:ZH,l.accumulator=0,this.eyeMeshes[c].visible=!0,this.nerveMeshes[c].visible=!0,this.writeEye(c),o)return;let f=WH(u*52711+s*3571+(a===`right`?977:0)+13);for(let e=0;e1e-8&&o.facing.copy(n).normalize(),r!==void 0&&i!==void 0&&(o.skull.set($(r.x),$(r.y,1.6),$(r.z)),XU(o.skullTurn,i),o.hasSkull=!0))}eyeOut(e,t){return t===void 0?this.eyes[rU(e,`left`)]?.active===!0||this.eyes[rU(e,`right`)]?.active===!0:this.eyes[rU(e,t)]?.active===!0}eyePosition(e,t,n){let r=this.eyes[rU(e,`left`)],i=this.eyes[rU(e,`right`)],a=n===`left`||n===void 0&&r?.active===!0?r:i;return a===void 0||!a.active?!1:(t.copy(a.position),!0)}updateEyes(e){for(let[t,n]of this.eyes.entries()){if(!n.active)continue;this.eyeDirection.copy(n.position).sub(n.previous).multiplyScalar(QH),n.previous.copy(n.position),n.position.add(this.eyeDirection),n.position.y-=QV*e*e,this.eyeDirection.copy(n.position).sub(n.socket);let r=this.eyeDirection.length();if(r>.055&&n.position.copy(n.socket).addScaledVector(this.eyeDirection,YH/r),n.hasSkull&&this.restOnFace(n)){n.previous.lerp(n.position,.6),this.eyeDirection.copy(n.position).sub(n.socket);let e=this.eyeDirection.length();e>.055&&n.position.copy(n.socket).addScaledVector(this.eyeDirection,YH/e)}if(n.position.y<0+JH&&(n.position.y=0+JH),this.bloodLevel===`full`&&n.bleeding>0)for(n.bleeding=Math.max(0,n.bleeding-e),n.accumulator+=e*this.forDevice(XH);n.accumulator>=1;){--n.accumulator;let e=.15+this.ambientRandom()*.5;this.spawnDroplet(n.socket.x,n.socket.y-.005,n.socket.z,n.facing.x*e+(this.ambientRandom()-.5)*.2,-.15-this.ambientRandom()*.4,n.facing.z*e+(this.ambientRandom()-.5)*.2,EO(this.ambientRandom()),.9,!0)}this.writeEye(t)}}restOnFace(e){this.eyeTurn.copy(e.skullTurn).invert();let t=this.eyeDirection.copy(e.position).sub(e.skull).applyQuaternion(this.eyeTurn),n=this.eyeSocketLocal.copy(e.socket).sub(e.skull).applyQuaternion(this.eyeTurn).z+JH+eU;if(t.z>=n)return!1;let r=Math.hypot(t.x/$H.x,t.y/$H.y);return r>=1?!1:(n-t.z<=(1-r)*Math.min($H.x,$H.y)||r<1e-6?t.z=n:(t.x/=r,t.y/=r),e.position.copy(e.skull).add(t.applyQuaternion(e.skullTurn)),!0)}writeEye(e){let t=this.eyes[e],n=this.eyeMeshes[e],r=this.nerveMeshes[e];n.position.copy(t.position),this.eyeDirection.copy(t.position).sub(t.socket);let i=this.eyeDirection.length();i>1e-5&&(this.eyeDirection.multiplyScalar(1/i),r.quaternion.setFromUnitVectors(WU,this.eyeDirection),this.eyeDirection.addScaledVector(t.facing,.9).normalize(),n.quaternion.setFromUnitVectors(GU,this.eyeDirection)),r.position.copy(t.socket),r.scale.set(1,Math.max(.001,i-JH*.8),1)}returnMouthpiece(e){let t=Math.trunc(e),n=this.shields[t];n!==void 0&&(Object.assign(n,_B()),this.shieldMeshes[t].visible=!1,this.lastShieldEvent[t]=null)}clearMouthpieces(){for(let[e,t]of this.shields.entries())Object.assign(t,_B()),this.shieldMeshes[e].visible=!1,this.lastShieldEvent[e]=null}updateShields(e){for(let[t,n]of this.shields.entries()){if(!n.out||!n.moving)continue;let r=this.shieldMeshes[t],i=n.age<.3&&!n.sliding,a=n.x,o=n.z;vB(n,r.quaternion,e,0);let s=TE-lB-XV,c=JU(n.x,n.vx,a,s),l=JU(n.z,n.vz,o,s);if(n.x=c.position,n.vx=c.velocity,n.z=l.position,n.vz=l.velocity,r.position.set(n.x,n.y,n.z),i&&this.ambientRandom()e.active).length}get activeStumps(){return[...this.stumps,...this.handStumps].filter(e=>e.active).length}spawnDroplet(e,t,n,r,i,a,o,s,c,l=c?.0035+this.ambientRandom()**3*.0125:.0025+this.ambientRandom()**2*.004,u=`blood`){let d=this.liveDropletsthis.droplets[e].maxLife-this.droplets[e].life;for(let n=0;n0&&t(e[i-1])_H&&e.pop()}}forDevice(e){return Math.round(e*this.budget.droplets*(this.lowTier?.5:1)/NV.droplets)}uploadDroplets(e,t,n){if(this.dropletMesh.count=this.liveDroplets,t<=e)return;this.dropletMesh.instanceMatrix.addUpdateRange(e*16,(t-e)*16),this.dropletMesh.instanceMatrix.needsUpdate=!0;let r=this.dropletMesh.instanceColor;n&&r!==null&&(r.addUpdateRange(e*3,(t-e)*3),r.needsUpdate=!0)}retireDroplet(e){this.oldest.length=0;let t=this.liveDroplets-1,n=this.droplets[e];if(n.alive=!1,this.liveDroplets=t,e!==t){let r=this.droplets[t];this.droplets[e]=r,this.droplets[t]=n,this.dropletPositions.copyWithin(e*3,t*3,t*3+3),this.dropletColors.copyWithin(e*3,t*3,t*3+3),this.dropletMesh.setColorAt(e,this.dropletColor.setRGB(r.r,r.g,r.b)),this.writeDropletMatrix(e,r)}this.dropletPositions[t*3+1]=-50,this.writeDropletMatrix(t,n)}sprayDroplet(e,t,n,r,i,a,o,s,c,l,u,d){this.spawnDroplet(t,n,r,i*e.x-o*e.z,a,i*e.z+o*e.x,s,c,l,u,d)}writeDropletMatrix(e,t){if(!t.alive){this.dropletScale.setScalar(0),this.dropletQuaternion.identity(),this.dropletMatrix.compose(this.dropletVelocity.set(0,-50,0),this.dropletQuaternion,this.dropletScale),this.dropletMesh.setMatrixAt(e,this.dropletMatrix);return}let n=Math.hypot(t.vx,t.vy,t.vz);n>1e-4?(this.dropletVelocity.set(t.vx/n,t.vy/n,t.vz/n),this.dropletQuaternion.setFromUnitVectors(WU,this.dropletVelocity)):this.dropletQuaternion.identity();let r=Math.min(1,t.life/(t.maxLife*.3))*this.dropletCloseness*(t.blood&&this.bloodLevel===`full`?dH:1),i=wO(t.radius*r,n,this.dropletShape);this.dropletScale.set(i.width,i.length,i.width),this.dropletMatrix.compose(this.dropletVelocity.set(t.x,t.y,t.z),this.dropletQuaternion,this.dropletScale),this.dropletMesh.setMatrixAt(e,this.dropletMatrix)}spawnMist(e,t,n,r,i){let a=this.mistIndex%this.budget.mist;this.mistIndex+=1;let o=this.mists[a];o.alive=!0,o.x=$(e),o.y=$(t,1),o.z=$(n),o.maxLife=Math.max(.05,$(i,.5)),o.life=o.maxLife,o.scale=Math.max(.1,$(r,1)),this.mistPositions[a*3]=o.x,this.mistPositions[a*3+1]=o.y,this.mistPositions[a*3+2]=o.z,this.mistColors[a*4+3]=Math.min(1,o.scale),this.mistGeometry.attributes.position.needsUpdate=!0,this.mistGeometry.attributes.color.needsUpdate=!0}placeDecal(e,t,n,r,i,a,o){this.canvasBlood.stain($(e),$(t),Math.max(.01,$(n,.2))*.28,Math.max(.01,$(r,.15))*.28,$(i),G.clamp($(a,.4),0,.95),o)}splashLens(e,t,n,r,i){let a=this.camera;if(a===null||this.bloodLevel===`off`||!(r>0))return;let o=this.lensPoint.set($(e),$(t,1.5),$(n)),s=o.distanceTo(a.position);if(o.project(a),!(o.z<1)||Math.abs(o.x)>1.15||Math.abs(o.y)>1.15)return;let c=G.clamp((vH-s)/8.5,0,1);this.lens.splash((o.x+1)/2,(1-o.y)/2,c*r*(this.bloodLevel===`reduced`?.25:1),i)}ambientRandom(){return this.ambientSeed=Math.imul(this.ambientSeed^this.ambientSeed>>>15,1|this.ambientSeed),this.ambientSeed^=this.ambientSeed+Math.imul(this.ambientSeed^this.ambientSeed>>>7,61|this.ambientSeed),((this.ambientSeed^this.ambientSeed>>>14)>>>0)/4294967296}splatter(e,t,n,r=()=>this.ambientRandom(),i=12,a=oH){if(this.bloodLevel===`off`)return;let o=this.bloodLevel===`reduced`,s=o?Math.ceil(i/4):i,c=o?.35:sH;for(let i=0;i0?$(t.y):e.detail.endsWith(`:body`)?1.05:1.58,z:$(t.z)},f=e.kind===`bleed`,p=n||f?0:Math.round(s?(a?4:6)+Math.min(6,Math.max(0,e.amount)/40):(a?6:16)+Math.min(20,Math.max(0,e.amount)/20)),m={x:0,y:0,z:0,vx:0,vy:0,vz:0,life:0,radius:0,color:EO(0)},h=e.kind===`hit`||e.kind===`counter_hit`,g=h?Math.max(0,e.blood-Math.floor(Math.max(0,e.amount)/3)):0,_=n||e.blood<=0||this.bloodLevel===`off`?0:f?this.bloodLevel===`reduced`?1:Math.min(12,3+Math.floor(Math.max(0,e.amount)/8)):this.bloodLevel===`reduced`?Math.min(24,Math.round(e.blood*(a?.12:.24))):this.forDevice(a?Math.round(vO(e.blood,0)/2):o?vO(e.blood,0)+fH:vO(e.blood,h?e.amount:0));f||(this.shake=Math.min(.14,this.shake+(a?.008:Math.max(.012,e.amount/1500)))),o&&(this.shake=Math.min(.2,this.shake+.09));let v=o?1.2:h?G.clamp((e.amount-40)/60,0,1)*(.6+Math.min(100,e.blood)/150):0;!n&&!f&&e.blood>0&&this.splashLens(d.x,d.y,d.z,v,e.event_id);for(let e=0;e0&&t<=eH){let e=1-tH*t;this.spawnDroplet(m.x,m.y,m.z,m.vx*e,m.vy*e,m.vz*e,m.color,m.life,!0,m.radius*(1-nH*t));continue}let n=t===0,r=(i()-.5)*Math.PI,a=n?2.2+i()*1.8:.9+i()*1.5,o=a,s=.5+i()*1.25,u=(i()-.5)*.5;if(c===`fan`)o=a*(.45+Math.cos(r)*.35),s=.55+i()*1.15,u=Math.sin(r)*a*.9;else if(c===`plume`)o=a*(.25+i()*.25),s=1.8+i()*2.2,u=(i()-.5)*a*.65;else if(c===`body_burst`)o=a*(.55+i()*.45),s=-.15+i()*1.05,u=Math.sin(r)*a*.75;else if(c===`ooze`)o=.08+i()*.22,s=-.3-i()*.55,u=(i()-.5)*.22;else if(c===`impact`)o=a*(.45+i()*.65),s=.9+i()*2.1,u=Math.sin(r)*a;else{let e=n?.12:.34;o=a*(.8+i()*.35),s=n?1.3+i()*1.6:.5+i()*1.25,u=(i()-.5)*a*e}let f=o*l.x-u*l.z,p=o*l.z+u*l.x,h=EO(i()),g=d.x+(i()-.5)*.12,_=d.y+(i()-.5)*.14,v=d.z+(i()-.5)*.12,y=.65+i()*.85;n?(m.x=g,m.y=_,m.z=v,m.vx=f,m.vy=s,m.vz=p,m.color=h,m.life=y,m.radius=.008+i()*.008,this.spawnDroplet(g,_,v,f,s,p,h,y,!0,m.radius)):this.spawnDroplet(g,_,v,f,s,p,h,y,!0)}let y=s?o||e.kind===`counter_hit`||h&&(e.amount>=35||g>=cH):e.kind===`hit`&&e.amount>=70||o||e.kind===`counter_hit`||g>=16;if(!n&&e.blood>0&&this.bloodLevel!==`off`&&y){let t=s?this.forDevice(o?36:12+Math.min(24,Math.floor(g/2)+Math.floor(Math.max(0,e.amount-35)/6))):o?3:2,n=s?1:.35;for(let e=0;e0&&this.bloodLevel!==`off`){let t=o?1+Math.min(2,e.blood/55):.8+Math.min(1.2,g/30);this.splatter(d.x+(i()-.5)*.6,d.z+(i()-.5)*.6,s?t*1.3:t,i,x,o?aH:iH)}let S=e.amount>=70||e.kind===`counter_hit`&&e.amount>=gO,C=h&&(e.amount>=60||S&&g>=cH/4);if(s&&!n&&C&&!e.detail.endsWith(`:body`)){let t=Math.min(20,Math.max(3,Math.round((e.amount-10)/6)));for(let e=0;e0){e.sideLow=1/0,e.sideHigh=-1/0;for(let t=0;t=BV)return;let s=Math.trunc(e),c=Number.isSafeInteger(i)?i:0,l=this.heads[s];if(l.active||this.lastDecapitationEvent[s]===c)return;this.stopGush(s),this.applyBakedPart(l,o,a);let u=WH(c*104729+s*8191+23),d=UU(r);this.lastDecapitationEvent[s]=c,l.active=!0,l.moving=!0,l.eventId=c;let f=1.8+u()*1.1;l.vy=2.3+u()*1.1;let p=(u()-.5)*2.2;l.vx=f*d.x-p*d.z,l.vz=f*d.z+p*d.x,l.vrx=(u()-.5)*12,l.vry=(u()-.5)*12,l.vrz=(u()-.5)*12,l.bounces=0,l.trail=0,l.stained=!1,l.settle=-1,l.mesh.position.set($(t.x),$(t.y,1.55),$(t.z)),XU(l.mesh.quaternion,n),l.mesh.visible=!0;let m=this.stumps[s];m.mesh.material=this.stumpMaterial,m.active=!0,m.fountainLife=14,m.accumulator=0,m.seed=c|1,m.direction=d,m.mesh.position.copy(l.mesh.position),m.mesh.quaternion.copy(l.mesh.quaternion),m.mesh.visible=!0;for(let e=0;e=BV)return;let i=Math.trunc(e),a=Number.isSafeInteger(r)?r:0,o=this.stumps[i];if(o.active||this.lastBurstEvent[i]===a)return;this.lastBurstEvent[i]=a,this.stopGush(i);let s=WH(a*91813+i*6151+41),c=UU(n),l=$(t.x),u=$(t.y,1.6),d=$(t.z),f=(e,t,n,r,a)=>{for(let o=0;o=BV)return;let c=Math.trunc(e)*2+(t===`left`?0:1),l=Number.isSafeInteger(a)?a:0,u=this.hands[c];if(u.active||this.lastDismembermentEvent[c]===l)return;this.applyBakedPart(u,s,o);let d=WH(l*130363+c*12289+37),f=UU(i);this.lastDismembermentEvent[c]=l,u.active=!0,u.moving=!0,u.eventId=l;let p=1.3+d()*1.1;u.vy=1.5+d()*1.2;let m=(d()-.5)*1.8;u.vx=p*f.x-m*f.z,u.vz=p*f.z+m*f.x,u.vrx=(d()-.5)*16,u.vry=(d()-.5)*16,u.vrz=(d()-.5)*16,u.bounces=0,u.trail=0,u.stained=!1,u.mesh.position.set($(n.x),$(n.y,1.25),$(n.z)),XU(u.mesh.quaternion,r),u.mesh.visible=!0;let h=this.handStumps[c];h.active=!0,h.fountainLife=SH,h.accumulator=0,h.seed=l|1,h.direction=f,h.mesh.position.copy(u.mesh.position),h.mesh.quaternion.copy(u.mesh.quaternion),h.mesh.visible=!0;for(let t=0;t=BV)return;let o=Math.trunc(e),s=Number.isSafeInteger(i)?i:0,c=WH(s*69061+o*2741+29),l=UU(r),u=this.tornAxis.copy(n);u.lengthSq()>1e-8&&Number.isFinite(u.lengthSq())||u.set(0,1,0),u.normalize();let d=$(t.x),f=$(t.y,1.2),p=$(t.z);for(let e=0;e{for(let n=0;n=BV)return;let i=Math.trunc(e)*2+(t===`left`?0:1),a=this.handStumps[i];a.active&&(a.mesh.position.set($(n.x),$(n.y,1.2),$(n.z)),XU(a.mesh.quaternion,r))}anchorStump(e,t,n,r,i){if(this.bloodLevel!==`full`||e<0||e>=BV)return;let a=this.stumps[Math.trunc(e)];a.active&&(a.mesh.position.set($(t.x),$(t.y,1.5),$(t.z)),r===void 0||r.length<18?(a.mesh.geometry=this.stumpGeometry,XU(a.mesh.quaternion,n)):(RO(a.flesh,r,a.mesh.position,this.stumpOutward.set(0,1,0).applyQuaternion(n),.01,i),a.mesh.geometry=a.flesh,a.mesh.quaternion.identity()))}restoreFighter(e){if(e<0||e>=BV)return;let t=Math.trunc(e),n=this.heads[t];n.active=!1,n.moving=!1,n.mesh.visible=!1,n.mesh.position.y=-50,this.applyBakedPart(n,void 0,9063730);let r=this.stumps[t];r.active=!1,r.fountainLife=0,r.accumulator=0,r.mesh.visible=!1,r.mesh.position.y=-50,r.mesh.material=this.stumpMaterial,this.clearGibs(t),this.stopGush(t);for(let e of[t*2,t*2+1]){let t=this.eyes[e];t.active=!1,t.bleeding=0,this.eyeMeshes[e].visible=!1,this.nerveMeshes[e].visible=!1}this.clearWounds(t),this.clearGuts(t),this.clearSpine(t),this.clearCorpse(t),this.heart.owner===t&&(this.heart.active=!1,this.heartMesh.visible=!1);for(let e of[t*2,t*2+1]){let t=this.hands[e];t.active=!1,t.moving=!1,t.mesh.visible=!1,t.mesh.position.y=-50,this.applyBakedPart(t,void 0,1920728);let n=this.handStumps[e];n.active=!1,n.fountainLife=0,n.accumulator=0,n.mesh.visible=!1,n.mesh.position.y=-50}}drip(e,t,n,r=0){let i=+(r===1);if(this.bloodLevel===`off`||n||t<=.05){this.stopDrip(i);return}let a=this.dripEmitters[i];a.position.set($(e.x),$(e.y,1.5),$(e.z)),a.rate=this.bloodLevel===`reduced`?Math.min(3,t*3):Math.min(60,t*40),a.active=!0}stopDrip(e){let t=this.dripEmitters[+(e===1)];t.active=!1,t.rate=0,t.accumulator=0}gush(e,t,n,r,i,a,o=`blood`){if(this.bloodLevel!==`full`||e<0||e>=this.gushes.length)return;let s=this.gushes[Math.trunc(e)],c=Number.isSafeInteger(a)?a:0;s.active&&s.eventId===c||(s.active=!0,s.eventId=c,s.fluid=o,s.seconds=Math.max(.1,$(r,1)),s.life=s.seconds,s.rate=Math.max(0,$(i)),s.accumulator=0,this.anchorGush(e,t,n))}anchorGush(e,t,n){let r=this.gushes[Math.trunc(e)];r!==void 0&&r.active&&(r.position.set($(t.x),$(t.y,1.4),$(t.z)),n.lengthSq()>1e-8&&Number.isFinite(n.lengthSq())&&r.axis.copy(n).normalize())}gushing(e){return this.gushes[Math.trunc(e)]?.active===!0}stopGush(e){let t=this.gushes[e];t!==void 0&&(t.active=!1,t.eventId=null)}updateGushes(e){for(let t of this.gushes){if(!t.active)continue;if(t.life-=e,t.life<=0||this.bloodLevel!==`full`){t.active=!1;continue}let n=t.life/t.seconds,r=(t.seconds-t.life)*wH%1,i=Math.exp(-(((r-.5)/FH)**2));if(t.accumulator+=e*this.forDevice(t.rate)*n*(IH+.7*i),!(t.accumulator<1))for(BH.set(Math.abs(t.axis.y)<.9?0:1,+(Math.abs(t.axis.y)<.9),0).cross(t.axis).normalize(),VH.crossVectors(t.axis,BH);t.accumulator>=1;){--t.accumulator;let e=Math.sqrt(this.ambientRandom())*RH,r=this.ambientRandom()*Math.PI*2,a=(LH+this.ambientRandom()*2)*(.5+.5*n)*(.7+.3*i);HH.copy(t.axis).multiplyScalar(Math.cos(e)).addScaledVector(BH,Math.sin(e)*Math.cos(r)).addScaledVector(VH,Math.sin(e)*Math.sin(r)).multiplyScalar(a),this.spawnDroplet(t.position.x+(this.ambientRandom()-.5)*.03,t.position.y+(this.ambientRandom()-.5)*.02,t.position.z+(this.ambientRandom()-.5)*.03,HH.x,HH.y,HH.z,OO(t.fluid,this.ambientRandom()),1.2,!0,(.004+this.ambientRandom()**2*.01)*DO[t.fluid].drop,t.fluid)}}}updateDripEmitters(e){for(let t of this.dripEmitters)if(t.active)for(t.accumulator+=e*t.rate;t.accumulator>=1;)--t.accumulator,this.spawnDroplet(t.position.x+(this.ambientRandom()-.5)*.14,t.position.y-.04,t.position.z+(this.ambientRandom()-.5)*.1,(this.ambientRandom()-.5)*.08,-.25-this.ambientRandom()*.4,(this.ambientRandom()-.5)*.08,EO(this.ambientRandom()),1.1,!0)}spawnTeeth(e,t,n,r){if(this.bloodLevel===`off`)return;let i=this.bloodLevel===`reduced`?+(n>=3):Math.min(12,Math.max(1,Math.round(n)));if(i<=0)return;let a=WH((Number.isSafeInteger(r)?r:0)*7331+91),o=UU(t);for(let t=0;t>3):f.length>>2)}debrisSlot(e){let t=this.debrisCursor.get(e)??0,n=t%e.length;for(let r=0;r=0?n.scale*Math.max(0,n.fading)/bH:n.scale;this.gibScale.set(e*n.stretch,e,e/Math.sqrt(n.stretch))}this.gibMatrix.compose(this.gibPosition,this.gibQuaternion,this.gibScale),e.setMatrixAt(t,this.gibMatrix)}updateDebris(e,t,n,r){let i=!1;for(let[a,o]of e.entries()){if(!o.alive||o.resting&&o.fading<0)continue;if(i=!0,o.fading>=0){o.fading-=n,o.fading<=0&&(o.alive=!1),this.writeDebrisMatrix(t,a,o);continue}o.vy-=6.4*n,o.x+=o.vx*n,o.y+=o.vy*n,o.z+=o.vz*n,o.rx+=o.vrx*n,o.ry+=o.vry*n,o.rz+=o.vrz*n,this.confineGib(o);let e=0+(r===void 0?o.kind===`eye`?JH*RV:.015:r.low*o.scale);if(o.y<=e){if(o.y=e,!o.stained&&this.bloodLevel===`full`&&o.kind!==`tooth`&&o.kind!==`eye`&&(o.stained=!0,r===void 0?this.placeDecal(o.x,o.z,.24+o.scale*.16,.14+o.scale*.1,o.rz,.55,6425104):this.canvasBlood.stain(o.x,o.z,sU[r.shape].stain*o.scale,sU[r.shape].stain*o.scale*.7,o.ry,.6,6425104)),o.bounces.35)o.bounces+=1,o.vy=Math.abs(o.vy)*.3,o.vx*=.68,o.vz*=.68,o.vrx*=.7,o.vry*=.7,o.vrz*=.7;else{if(o.vx=0,o.vy=0,o.vz=0,o.vrx=o.vry=o.vrz=0,o.kind===`shard`&&(o.rx=Math.round(o.rx/Math.PI)*Math.PI),r!==void 0){let e=Math.round(o.rx/Math.PI),t=Math.round(o.rz/Math.PI);o.rx=e*Math.PI,o.rz=t*Math.PI,o.y=0+((e+t)%2==0?r.low:r.high)*o.scale}o.resting=!0}}this.writeDebrisMatrix(t,a,o)}i?t.instanceMatrix.needsUpdate=!0:r!==void 0&&(r.moving=!1)}confineGib(e){Math.abs(e.x)>3.05&&(e.x=Math.sign(e.x)*xE,e.vx*=-.45),Math.abs(e.z)>3.05&&(e.z=Math.sign(e.z)*xE,e.vz*=-.45)}updateDetachedParts(e,t){for(let n of e){if(n.active&&n.settle>=0&&n.settle<1){n.settle=Math.min(1,n.settle+t/YV);let e=n.settle*n.settle*(3-2*n.settle);n.mesh.quaternion.slerpQuaternions(n.settleFrom,n.settleTo,e),n.mesh.position.y=n.settleFromY+(n.settleToY-n.settleFromY)*e}if(!n.active||!n.moving)continue;let e=n.mesh.position.x,r=n.mesh.position.z;if(n.vy-=5.8*t,n.mesh.position.x+=n.vx*t,n.mesh.position.y+=n.vy*t,n.mesh.position.z+=n.vz*t,n.mesh.rotation.x+=n.vrx*t,n.mesh.rotation.y+=n.vry*t,n.mesh.rotation.z+=n.vrz*t,this.bloodLevel===`full`)for(n.trail+=t*this.forDevice(zV),n.trail>=1&&this.trailPoint.copy(n.cap.position).multiply(n.mesh.scale).applyQuaternion(n.mesh.quaternion).add(n.mesh.position);n.trail>=1;)--n.trail,this.spawnDroplet(this.trailPoint.x+(this.ambientRandom()-.5)*.03,this.trailPoint.y+(this.ambientRandom()-.5)*.03,this.trailPoint.z+(this.ambientRandom()-.5)*.03,n.vx*.35+(this.ambientRandom()-.5)*.9,n.vy*.35+(this.ambientRandom()-.5)*.9,n.vz*.35+(this.ambientRandom()-.5)*.9,EO(this.ambientRandom()),.9,!0);let i=TE-n.radius-XV,a=JU(n.mesh.position.x,n.vx,e,i),o=JU(n.mesh.position.z,n.vz,r,i);if(n.mesh.position.x=a.position,n.mesh.position.z=o.position,n.vx=a.velocity,n.vz=o.velocity,n.mesh.position.y<=0+n.radius){if(n.mesh.position.y=0+n.radius,!n.stained&&this.bloodLevel===`full`){n.stained=!0;let e=n.radius===JV?1:.55;this.placeDecal(n.mesh.position.x,n.mesh.position.z,1.3*e,.9*e,n.mesh.rotation.z,.85,4392199)}n.bounces<2&&Math.abs(n.vy)>.42?(n.bounces+=1,n.vy=Math.abs(n.vy)*.32,n.vx*=.62,n.vz*=.62,n.vrx*=.65,n.vry*=.65,n.vrz*=.65):(n.moving=!1,n.vx=0,n.vy=0,n.vz=0,n.vrx=0,n.vry=0,n.vrz=0,n.look!==null&&this.rollOntoEar(n))}Number.isFinite(n.mesh.position.x)&&Number.isFinite(n.mesh.position.y)&&Number.isFinite(n.mesh.position.z)&&Number.isFinite(n.mesh.quaternion.x)&&Number.isFinite(n.mesh.quaternion.y)&&Number.isFinite(n.mesh.quaternion.z)&&Number.isFinite(n.mesh.quaternion.w)||(n.mesh.position.set(0,0+n.radius,0),n.mesh.quaternion.identity(),n.moving=!1,n.vx=0,n.vy=0,n.vz=0)}}rollOntoEar(e){let t=this.settleAxis.set(1,0,0).applyQuaternion(e.mesh.quaternion),n=t.y>=0?1:-1;e.settleFrom.copy(e.mesh.quaternion),e.settleTo.setFromUnitVectors(t,this.settleUp.set(0,n,0)).multiply(e.mesh.quaternion),e.settleFromY=e.mesh.position.y,e.settleToY=0+(n>0?-e.sideLow:e.sideHigh),e.settle=0}stumpRandom(e){let t=e.seed|0;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),e.seed=t|0,((t^t>>>14)>>>0)/4294967296}updateStumpFountains(e){if(this.bloodLevel===`full`)for(let t of[...this.stumps,...this.handStumps]){if(!t.active||t.fountainLife<=0)continue;t.fountainLife=Math.max(0,t.fountainLife-e);let n=Math.min(1,t.fountainLife/CH),r=t.fountainLife*wH%1,i=Math.exp(-(((r-.5)/TH)**2));if(t.accumulator+=e*this.forDevice(EH)*n*(DH+.88*i),t.accumulator<1)continue;let a=UH(t,zH);for(BH.set(Math.abs(a.y)<.9?0:1,+(Math.abs(a.y)<.9),0).cross(a).normalize(),VH.crossVectors(a,BH);t.accumulator>=1;){--t.accumulator;let e=this.stumpRandom(t),r=this.stumpRandom(t),o=this.stumpRandom(t),s=Math.sqrt(e)*AH,c=r*Math.PI*2;HH.copy(a).multiplyScalar(Math.cos(s)).addScaledVector(BH,Math.sin(s)*Math.cos(c)).addScaledVector(VH,Math.sin(s)*Math.sin(c)).multiplyScalar(G.lerp(OH,kH,o)*(.7+.3*i)*(.55+.45*n)),this.spawnDroplet(t.mesh.position.x+a.x*.015+(e-.5)*.03,t.mesh.position.y+a.y*.015,t.mesh.position.z+a.z*.015+(r-.5)*.03,HH.x,HH.y,HH.z,EO(e),1.2+o*.6,!0,.004+o*o*.01)}}}update(e){for(this.canvasBlood.update(KU(e)),this.lens.update(KU(e)),this.simulationRemainder+=KU(e);this.simulationRemainder+1e-9>=gH;)this.simulationRemainder=Math.max(0,this.simulationRemainder-gH),this.simulate(gH);for(let e of this.guts)e.active&&e.sinceDrop<0&&e.rope.hold(e.anchor)&&(e.moved=!0),e.moved&&=(e.tube.write(e.rope),!1)}simulate(e){this.shake*=.02**e,this.updateDripEmitters(e),this.updateGushes(e),this.updateStumpFountains(e),this.updateDetachedParts(this.heads,e),this.updateDetachedParts(this.hands,e),this.updateShields(e),this.updateEyes(e),this.updateDebris(this.gibs,this.gibMesh,e),this.updateDebris(this.shards,this.shardMesh,e),this.updateDebris(this.eyeballs,this.eyeballMesh,e);for(let t of this.viscera)t.moving&&this.updateDebris(t.pieces,t.mesh,e,t);this.updateWounds(e),this.updateParts(e),this.updateSpines(e),this.updateGuts(e),this.updateHeart(e),this.updateCorpses(e);let t=this.liveDroplets,n=!1;for(let t=0;t0&&(this.dropletBuffers.position.needsUpdate=!0,this.dropletBuffers.color.needsUpdate=!0,this.uploadDroplets(0,this.liveDroplets,n));let r=!1;for(let[t,n]of this.mists.entries()){if(!n.alive)continue;if(r=!0,n.life-=e,n.life<=0){n.alive=!1,this.mistPositions[t*3+1]=-50;continue}let i=1-n.life/n.maxLife;this.mistPositions[t*3]=n.x,this.mistPositions[t*3+1]=n.y+i*.14,this.mistPositions[t*3+2]=n.z,this.mistColors[t*4+3]=Math.max(0,1-i)*Math.min(1,n.scale)}r&&(this.mistGeometry.attributes.position.needsUpdate=!0,this.mistGeometry.attributes.color.needsUpdate=!0)}clearDroplets(e){let t=this.liveDroplets;for(let t=0;t0))return;let s=WH((Number.isSafeInteger(i)?i:0)*15485863+e.charCodeAt(0)*131+e.length*977+7),c=UU(n),l=Math.max(.2,$(a,1)),u=$(t.x),d=$(t.y,1.2),f=$(t.z),p=Math.min(Math.round(r),this.debrisPlaces(e));for(let t=0;t0))return;let o=Number.isSafeInteger(i)?i:0,s=WH(o*86243+aU.indexOf(e)*3331+59),c=UU(n),l=DO[e],u=Math.max(.2,$(a,1)),d=$(t.x),f=$(t.y,1.2),p=$(t.z),m=Math.min(oU,r);for(let t=this.forDevice(m);t>0;--t){let t=s()*Math.PI*2,n=(.5+s()*1.9)*u;this.sprayDroplet(c,d+(s()-.5)*.08,f+(s()-.5)*.08,p+(s()-.5)*.08,(.4+s()*1.9)*u+Math.sin(t)*n*.35,(.3+s()*2.3)*Math.sqrt(u),Math.cos(t)*n*.8,OO(e,s()),.7+s(),!0,(.004+s()**2*.013)*l.drop,e)}if(e===`blood`){for(let e=Math.min(48,Math.round(m/25));e>0;--e)this.spawnMist(d+(s()-.5)*.4,f+(s()-.5)*.3,p+(s()-.5)*.4,.9+s()*1.5,.6+s()*.7);this.splatter(d+c.x*.3,p+c.z*.3,1+Math.min(2.4,m/500),s,Math.min(50,Math.round(m/20))),this.splashLens(d,f,p,Math.min(3,m/350),o)}else for(let e=Math.min(10,Math.round(m/30));e>0;--e){let t=.2+s()*.9*u;this.placeDecal(d+c.x*t+(s()-.5)*.5,p+c.z*t+(s()-.5)*.5,.5+s()*.9,.3+s()*.7,s()*Math.PI,.7*l.soak,e%2==0?l.splash:l.stain)}this.shake=Math.min(.22,this.shake+Math.min(.06,m/2e4))}puddle(e,t,n,r,i){if(this.bloodLevel!==`full`)return;let a=DO[r];this.canvasBlood.pool($(e),$(t),Math.max(.02,$(n,.1)),.95*a.soak,i,a.pool)}smear(e,t,n,r,i){this.bloodLevel===`full`&&this.canvasBlood.smear(e,t,n,r,Math.max(.005,$(i,.05)),.75,DO.blood.splash)}footprint(e,t,n,r,i){this.bloodLevel===`full`&&i>0&&this.canvasBlood.print(e,t,n,r,Math.min(1,i)*.85,DO.blood.splash)}setWound(e,t,n,r=`blood`){let i=this.woundAt(e,t);if(i===null)return;let a=this.bloodLevel===`full`?G.clamp($(n),0,1):0;a>0&&i.strength<=0&&(i.anchored=!1,i.accumulator=0,i.run=0,i.pool=0),i.strength=a,i.fluid=r,this.shareWounds()}anchorWound(e,t,n,r){let i=this.woundAt(e,t);i===null||i.strength<=0||(i.position.set($(n.x),$(n.y,1.2),$(n.z)),r.lengthSq()>1e-8&&Number.isFinite(r.lengthSq())&&i.axis.copy(r).normalize(),i.anchored=!0)}woundStrength(e,t){return this.woundAt(e,t)?.strength??0}clearWounds(e){for(let[t,n]of this.wounds.entries())(e===void 0||Math.floor(t/he.length)===Math.trunc(e))&&(n.strength=0);this.shareWounds()}get openWounds(){return this.woundsOpen}woundAt(e,t){let n=Math.trunc(e);return n>=0&&npU?pU/e:1}updateWounds(e){if(this.woundsOpen!==0&&this.bloodLevel===`full`){this.woundClock+=e;for(let t=0;t=mU){n.run-=mU;let e=.12+fU*r*r,i=l.y*e,a=(i+Math.sqrt(i*i+2*QV*Math.max(0,u.y-0)))/QV,o=u.x+l.x*e*a,s=u.z+l.z*e*a;n.pool<=0||Math.hypot(o-n.poolX,s-n.poolZ)>Math.max(.12,n.pool*1.2)?(n.poolX=o,n.poolZ=s,n.pool=.03):n.pool=Math.min(hU*(.25+.75*r),n.pool+.012);let c=DO[n.fluid];this.canvasBlood.pool(n.poolX,n.poolZ,n.pool,.95*c.soak,t*7+Math.round(n.pool*80),c.pool)}if(n.accumulator<1)continue;BH.set(Math.abs(l.y)<.9?0:1,+(Math.abs(l.y)<.9),0).cross(l).normalize(),VH.crossVectors(l,BH);let d=G.lerp(.8,AH*.8,r),f=DO[n.fluid].drop;for(;n.accumulator>=1;){--n.accumulator;let e=Math.sqrt(this.ambientRandom())*d,t=this.ambientRandom()*Math.PI*2;HH.copy(l).multiplyScalar(Math.cos(e)).addScaledVector(BH,Math.sin(e)*Math.cos(t)).addScaledVector(VH,Math.sin(e)*Math.sin(t)).multiplyScalar(c*(.75+this.ambientRandom()*.4)),this.spawnDroplet(u.x+l.x*.012+(this.ambientRandom()-.5)*.02,u.y+l.y*.012,u.z+l.z*.012+(this.ambientRandom()-.5)*.02,HH.x,HH.y,HH.z,OO(n.fluid,this.ambientRandom()),1.3+r*.5,!0,(.004+this.ambientRandom()**2*.01)*f,n.fluid)}}}}burstEye(e,t,n){let r=Math.trunc(e),i=rU(r,t),a=this.eyes[i];if(r<0||r>=BV||a===void 0||!a.active)return!1;if(a.active=!1,a.bleeding=0,this.eyeMeshes[i].visible=!1,this.nerveMeshes[i].visible=!1,this.bloodLevel!==`full`)return!0;let o=Number.isSafeInteger(n)?n:0,s=WH(o*39916801+i*211+3),{x:c,y:l,z:u}=a.position;for(let e=this.forDevice(160);e>0;--e){let t=s()*Math.PI*2,n=s()*1.6-.6,r=Math.sqrt(Math.max(0,1-Math.min(1,n*n))),i=.6+s()*2.2,a=e%3!=0;this.spawnDroplet(c,l,u,Math.cos(t)*r*i,n*i+.5,Math.sin(t)*r*i,a?EO(s()):tU,.5+s()*.7,a,.003+s()**2*.008)}for(let e=0;e<4;e+=1)this.spawnGib(c,l,u,(s()-.5)*1.6,.4+s()*1.2,(s()-.5)*1.6,s,`flesh`,r);for(let e=0;e<8;e+=1)this.spawnMist(c+(s()-.5)*.12,l+(s()-.5)*.1,u+(s()-.5)*.12,.5+s()*.6,.4+s()*.4);return this.splashLens(c,l,u,.8,o),!0}skinOf(e,t){let n=QU(t.sites===aA,e.map),r=e.look??mj;return n.look?.set(r),n.material.color.setHex(e.color),n.injury.copyFrom(t),n.injury.setBindToPart(aW(e.geometry,r,this.bindToPartMatrix)),t.material instanceof jb&&(n.material.clearcoat=t.material.clearcoat),n.material}flingPart(e,t,n,r,i,a,o={}){this.removePart(e);let s=this.partBox.makeEmpty();for(let e of t){let t=e.geometry.getAttribute(`position`),n=e.geometry.getIndex(),r=n===null?t.count:n.count;for(let e=0;ep.reach)&&(p=e),(m===null||e.height>m.height)&&(m=e);for(let{fan:e,opening:t}of f)e.materialIndex=rW(o.part,t===p,t===m);c.cut.set(0,0,0),p!==null&&c.cut.copy(p.centre).sub(l),XU(c.group.quaternion,r),c.group.position.copy(l).applyQuaternion(c.group.quaternion),c.group.position.set(c.group.position.x+$(n.x),c.group.position.y+$(n.y,1.2),c.group.position.z+$(n.z)),c.group.visible=!0,c.key=e,c.born=this.partsThrown++;let h=0;for(let t=0;tt.key===e)}partPosition(e,t){let n=this.parts.find(t=>t.key===e);return n!==void 0&&(t.copy(n.group.position),!0)}removePart(e){for(let t of this.parts)if(t.key===e){t.key=null,t.moving=!1,t.settle=-1,t.group.visible=!1,t.group.clear();for(let e of t.geometries)e.dispose();for(let e of t.materials)e.dispose();t.geometries.length=0,t.materials.length=0}}get activeParts(){let e=0;for(let t of this.parts)t.key!==null&&(e+=1);return e}partResting(e){return this.parts.some(t=>t.key===e&&!t.moving&&(t.settle<0||t.settle>=1))}updateParts(e){let t=this.bloodLevel===`full`;for(let n=0;n=0&&r.settle<1){r.settle=Math.min(1,r.settle+e/YV);let t=r.settle*r.settle*(3-2*r.settle);i.quaternion.slerpQuaternions(r.settleFrom,r.settleTo,t),i.position.y=r.settleFromY+(r.settleToY-r.settleFromY)*t}if(!r.moving){if(!t||r.lain>=xU)continue;let a=Math.floor(r.lain/SU);for(r.lain+=e,this.trailPoint.copy(r.cut).applyQuaternion(i.quaternion).add(i.position),r.trail+=e*this.forDevice(CU);r.trail>=1;)--r.trail,this.spawnDroplet(this.trailPoint.x,Math.max(.02,this.trailPoint.y),this.trailPoint.z,(this.ambientRandom()-.5)*.5,.2+this.ambientRandom()*.5,(this.ambientRandom()-.5)*.5,EO(this.ambientRandom()),.6,!0);if(Math.floor(r.lain/SU)===a)continue;let o=.1+r.radius*1.8;r.pool=Math.min(o,r.pool+o*SU*1.5/xU),this.canvasBlood.pool(this.trailPoint.x,this.trailPoint.z,r.pool,.95,n*13+a);continue}let a=i.position.x,o=i.position.z;if(r.vy-=5.8*e,i.position.x+=r.vx*e,i.position.y+=r.vy*e,i.position.z+=r.vz*e,i.rotation.x+=r.vrx*e,i.rotation.y+=r.vry*e,i.rotation.z+=r.vrz*e,t)for(r.trail+=e*this.forDevice(zV),r.trail>=1&&this.trailPoint.copy(r.cut).applyQuaternion(i.quaternion).add(i.position);r.trail>=1;)--r.trail,this.spawnDroplet(this.trailPoint.x+(this.ambientRandom()-.5)*.03,this.trailPoint.y+(this.ambientRandom()-.5)*.03,this.trailPoint.z+(this.ambientRandom()-.5)*.03,r.vx*.35+(this.ambientRandom()-.5)*.9,r.vy*.35+(this.ambientRandom()-.5)*.9,r.vz*.35+(this.ambientRandom()-.5)*.9,EO(this.ambientRandom()),.9,!0);let s=Math.max(.5,TE-r.reach-XV),c=JU(i.position.x,r.vx,a,s),l=JU(i.position.z,r.vz,o,s);if(i.position.x=c.position,i.position.z=l.position,r.vx=c.velocity,r.vz=l.velocity,i.position.y<=0+r.radius){if(i.position.y=0+r.radius,!r.stained&&t){r.stained=!0;let e=Math.min(2.4,r.radius/JV+.3);this.placeDecal(i.position.x,i.position.z,1.3*e,.9*e,i.rotation.z,.85,4392199)}if(r.bounces<2&&Math.abs(r.vy)>.42)r.bounces+=1,r.vy=Math.abs(r.vy)*.32,r.vx*=.62,r.vz*=.62,r.vrx*=.65,r.vry*=.65,r.vrz*=.65;else{r.moving=!1,r.trail=0;let e=this.settleAxis.copy(r.thin).applyQuaternion(i.quaternion);r.settleFrom.copy(i.quaternion),r.settleTo.setFromUnitVectors(e,this.settleUp.set(0,e.y>=0?1:-1,0)).multiply(i.quaternion),r.settleFromY=i.position.y,r.settleToY=0+r.thickness,r.settle=0}}Number.isFinite(i.position.x+i.position.y+i.position.z+i.quaternion.x+i.quaternion.y+i.quaternion.z+i.quaternion.w)||(i.position.set(0,0+r.thickness,0),i.quaternion.identity(),r.moving=!1,r.settle=-1)}}attachSpine(e){let t=this.spines[Math.trunc(e)];t!==void 0&&this.bloodLevel===`full`&&(t.wanted=!0)}spineOut(e){return this.spines[Math.trunc(e)]?.out===!0}spineTail(e,t){let n=this.spines[Math.trunc(e)];return n===void 0||!n.out?!1:(n.rope.node(wU,t),!0)}updateSpines(e){for(let t=0;t=1;){--n.trail;let e=a.node(Math.floor(this.ambientRandom()*12),this.gibPosition);this.spawnDroplet(e.x,e.y,e.z,(this.ambientRandom()-.5)*.8,(this.ambientRandom()-.5)*.8,(this.ambientRandom()-.5)*.8,EO(this.ambientRandom()),.8,!0)}}}}writeSpine(e){let t=this.spines[e].rope;for(let n=0;n1e-6?i.multiplyScalar(1/a):i.set(0,1,0)),r.add(this.partVertex).multiplyScalar(.5);let o=(.9+.5*Math.min(1,n/6))*(n>=9?.55+.25*(10-n):1);this.gibMatrix.compose(r,this.gibQuaternion,this.gibScale.set(o,this.spineStretch,o)),this.spineMesh.setMatrixAt(e*wU+n,this.gibMatrix)}this.spineMesh.instanceMatrix.needsUpdate=!0;for(let n=0;ne.out);this.spineMesh.visible=n,this.shredMesh.visible=n}spillGuts(e,t,n,r=18){let i=this.guts[Math.trunc(e)];if(i===void 0||e<0||this.bloodLevel!==`full`)return;let a=Number.isSafeInteger(n)?n:0;if(i.active&&i.eventId===a)return;let o=G.clamp(Math.round($(r,18)),2,OU),s=Math.max(2,Math.min(o,this.lowTier?Math.ceil(this.budget.gutLinks/2):this.budget.gutLinks));i.active=!0,i.eventId=a,i.sinceDrop=-1,i.drip=0,i.smeared.fill(NaN),i.anchor.set($(t.x),$(t.y,.9),$(t.z)),i.rope.spill(s,o*SV/s,i.anchor,s/kU,WH(a*28657+Math.trunc(e)*5+1)),i.tube.write(i.rope),i.mesh.visible=!0,i.moved=!1}anchorGuts(e,t,n){let r=this.guts[Math.trunc(e)];r===void 0||!r.active||r.sinceDrop>=0||(r.anchor.set($(t.x),$(t.y,.9),$(t.z)),n.lengthSq()>1e-8&&Number.isFinite(n.lengthSq())&&r.away.copy(n).normalize())}gutsOut(e){return this.guts[Math.trunc(e)]?.active===!0}dropGuts(e){let t=this.guts[Math.trunc(e)];t===void 0||!t.active||t.sinceDrop>=0||(t.sinceDrop=0,t.rope.release())}clearGuts(e){for(let[t,n]of this.guts.entries())(e===void 0||t===Math.trunc(e))&&(n.active=!1,n.eventId=null,n.moved=!1,n.rope.clear(),n.mesh.visible=!1)}gutsLength(e){let t=this.guts[Math.trunc(e)];return t===void 0||!t.active?0:t.rope.length}gutsPoint(e,t,n){let r=this.guts[Math.trunc(e)];return r===void 0||!r.active?!1:(r.rope.node(Math.round(G.clamp(t,0,1)*(r.rope.nodes-1)),n),!0)}updateGuts(e){for(let t=0;t=0&&n.sinceDrop=AU&&i)){let e=r.node(r.nodes>>1,this.gibPosition);this.canvasBlood.pool(e.x,e.z,.26,.95,t+3),this.puddle(e.x+.12,e.z+.05,.11,`bile`,t+5)}if(r.step(e,n.anchor,0,Math.max(2.4383999999999997,Math.abs(n.anchor.x),Math.abs(n.anchor.z)),n.away)&&(n.moved=!0,i)){for(let e=0;e0+.024*1.5){n.smeared[e*2]=NaN;continue}let i=n.smeared[e*2],a=n.smeared[e*2+1],o=Math.hypot(t.x-i,t.z-a);o=0))for(n.drip+=e*this.forDevice(PU);n.drip>=1;){--n.drip;let e=r.node(Math.floor(this.ambientRandom()*r.nodes),this.gibPosition),t=this.ambientRandom()<.8?`blood`:`bile`;this.spawnDroplet(e.x,e.y-xV,e.z,(this.ambientRandom()-.5)*.3,-.1,(this.ambientRandom()-.5)*.3,OO(t,this.ambientRandom()),.9,!0,.004+this.ambientRandom()*.005,t)}}}}ejectHeart(e,t,n,r=-1){if(this.bloodLevel!==`full`)return;let i=this.heart,a=WH((Number.isSafeInteger(n)?n:0)*611953+19),o=UU(t),s=2+a()*1.2,c=(a()-.5)*1.2;i.active=!0,i.moving=!0,i.owner=Math.trunc(r),i.age=0,i.beats=0,i.bounces=0,i.settle=-1,i.pool=0,i.trail=0,i.vx=s*o.x-c*o.z,i.vy=1.8+a()*1.2,i.vz=s*o.z+c*o.x,i.vrx=(a()-.5)*14,i.vry=(a()-.5)*14,i.vrz=(a()-.5)*14,i.settleTo.setFromAxisAngle(WU,a()*Math.PI*2).multiply(IU),this.heartMesh.position.set($(e.x),$(e.y,1.2),$(e.z)),this.heartMesh.quaternion.identity(),this.heartMesh.scale.setScalar(FU),this.heartMesh.visible=!0}get heartOut(){return this.heart.active}get heartBeating(){return this.heart.active&&this.heart.age<14}heartPosition(e){return this.heart.active?(e.copy(this.heartMesh.position),!0):!1}updateHeart(e){let t=this.heart;if(!t.active)return;let n=this.heartMesh,r=this.bloodLevel===`full`;if(t.moving){let i=n.position.x,a=n.position.z;t.vy-=6.4*e,n.position.x+=t.vx*e,n.position.y+=t.vy*e,n.position.z+=t.vz*e,n.rotation.x+=t.vrx*e,n.rotation.y+=t.vry*e,n.rotation.z+=t.vrz*e;let o=TE-this.heartRadius-XV,s=JU(n.position.x,t.vx,i,o),c=JU(n.position.z,t.vz,a,o);if(n.position.x=s.position,n.position.z=c.position,t.vx=s.velocity,t.vz=c.velocity,r)for(t.trail+=e*this.forDevice(zV/2);t.trail>=1;)--t.trail,this.spawnDroplet(n.position.x,n.position.y,n.position.z,t.vx*.3+(this.ambientRandom()-.5)*.8,t.vy*.3+(this.ambientRandom()-.5)*.8,t.vz*.3+(this.ambientRandom()-.5)*.8,EO(this.ambientRandom()),.8,!0);n.position.y<=0+this.heartRadius&&(n.position.y=0+this.heartRadius,t.bounces===0&&r&&this.placeDecal(n.position.x,n.position.z,.9,.7,n.rotation.z,.8,4392199),t.bounces<2&&Math.abs(t.vy)>.4?(t.bounces+=1,t.vy=Math.abs(t.vy)*.3,t.vx*=.6,t.vz*=.6,t.vrx*=.6,t.vry*=.6,t.vrz*=.6):(t.moving=!1,t.settle=0,t.settleFrom.copy(n.quaternion),t.settleFromY=n.position.y)),Number.isFinite(n.position.x+n.position.y+n.position.z)||(n.position.set(0,0+this.heartRest,0),n.quaternion.copy(t.settleTo),t.moving=!1,t.settle=1)}else if(t.settle<1){t.settle=Math.min(1,t.settle+e/YV);let r=t.settle*t.settle*(3-2*t.settle);n.quaternion.slerpQuaternions(t.settleFrom,t.settleTo,r),n.position.y=t.settleFromY+(0+this.heartRest-t.settleFromY)*r}if(t.age>=14)return;t.age+=e;let i=sV(t.age),a=oV(t.age),o=cV(a)*(.35+.65*i);if(n.scale.set(FU*(1-.17*o),FU*(1+.08*o),FU*(1-.17*o)),Math.floor(a)<=t.beats||(t.beats=Math.floor(a),!r))return;let s=this.trailPoint.copy(rV.position).multiply(n.scale).applyQuaternion(n.quaternion).add(n.position),c=zH.copy(rV.direction).applyQuaternion(n.quaternion);BH.set(Math.abs(c.y)<.9?0:1,+(Math.abs(c.y)<.9),0).cross(c).normalize(),VH.crossVectors(c,BH);for(let e=this.forDevice(Math.round(8+LU*i));e>0;--e){let e=Math.sqrt(this.ambientRandom())*.2,t=this.ambientRandom()*Math.PI*2;HH.copy(c).multiplyScalar(Math.cos(e)).addScaledVector(BH,Math.sin(e)*Math.cos(t)).addScaledVector(VH,Math.sin(e)*Math.sin(t)).multiplyScalar((.7+2.9*i)*(.5+.55*this.ambientRandom())),this.spawnDroplet(s.x,s.y,s.z,HH.x,HH.y,HH.z,EO(this.ambientRandom()),1.1,!0,.004+this.ambientRandom()**2*.011)}t.moving||(t.pool=Math.min(.3,t.pool+.022),this.canvasBlood.pool(n.position.x,n.position.z,t.pool,.95,t.beats))}setCorpse(e,t){let n=Math.trunc(e),r=this.corpses[n];r!==void 0&&(t===null||this.bloodLevel!==`full`?this.clearCorpse(n):(r.active||(r.active=!0,r.age=0,r.puddle=0),r.position.set($(t.x),Math.max(0,$(t.y,0)),$(t.z))))}fliesOver(e){let t=this.corpses[Math.trunc(e)];return t===void 0||!t.active?0:this.fliesArrived(t.age)}fliesArrived(e){let t=this.lowTier?this.budget.flies>>1:this.budget.flies;return Math.floor(G.clamp((e-RU)/zU,0,1)*t)}updateCorpses(e){for(let t=0;t=n.puddle+.04&&(n.puddle=r,this.puddle(n.position.x,n.position.z,r,`urine`,t*11+Math.round(r*25)));let i=this.fliesArrived(n.age);if(i===0)continue;let a=this.budget.flies,o=zU/(this.lowTier?a>>1:a);for(let e=0;e=i)this.gibMatrix.makeScale(0,0,0).setPosition(0,-50,0);else{let t=Math.min(1,(n.age-RU-e*o)/BU),i=MV(this.flies,r,n.age,this.gibPosition),a=1+(1-t)*2.5;this.gibMatrix.makeTranslation(n.position.x+i.x*a,Math.max(.03,n.position.y+i.y+(1-t)*(1-t)*1.6),n.position.z+i.z*a)}this.flyMesh.setMatrixAt(r,this.gibMatrix)}this.flyMesh.visible=!0,this.flyMesh.instanceMatrix.needsUpdate=!0}}clearCorpse(e){let t=this.corpses[e];if(t.active){t.active=!1,this.gibMatrix.makeScale(0,0,0).setPosition(0,-50,0);for(let t=0;te.active)}}dispose(){this.scene.remove(this.dropletMesh),this.scene.remove(this.mistPoints),this.scene.remove(this.gibMesh),this.scene.remove(this.shardMesh),this.scene.remove(this.eyeballMesh);for(let e of this.viscera)this.scene.remove(e.mesh),e.mesh.dispose(),e.geometry.dispose();this.visceraMaterial.dispose();for(let e of this.parts)e.key!==null&&this.removePart(e.key),this.scene.remove(e.group);this.limbMaterial.dispose(),this.limbMap.dispose(),this.trunkMaterial.dispose(),this.trunkMap.dispose(),this.scene.remove(this.spineMesh,this.shredMesh,this.heartMesh,this.flyMesh),this.spineMesh.dispose(),this.shredMesh.dispose(),this.shredGeometry.dispose();for(let e of this.guts)this.scene.remove(e.mesh),e.tube.dispose();this.heartGeometry.dispose(),this.flyMesh.dispose(),this.flyGeometry.dispose(),this.flyMaterial.dispose(),this.dropletMesh.dispose(),this.dropletGeometry.dispose(),this.dropletMaterial.dispose(),this.canvasBlood.dispose();for(let e of[...this.heads,...this.hands])e.baked?.dispose(),e.bakedFlesh?.dispose();for(let e of[...this.stumps,...this.handStumps])e.flesh.dispose();this.mistGeometry.dispose(),this.mistMaterial.dispose(),this.mistMap.dispose(),this.gibMesh.dispose(),this.gibGeometry.dispose(),this.gibMaterial.dispose(),this.shardMesh.dispose(),this.eyeballMesh.dispose(),this.shardGeometry.dispose(),this.shardMaterial.dispose(),this.jawMaterial.dispose(),this.jawMap.dispose(),this.headGeometry.dispose();for(let e of this.headMaterials)e.dispose();this.handGeometry.dispose();for(let e of this.handMaterials)e.dispose();this.stumpGeometry.dispose(),this.wristStumpGeometry.dispose(),this.shieldGeometry.dispose();for(let e of this.shieldMaterials)e.dispose();for(let e of this.shieldMeshes)this.scene.remove(e);this.eyeGeometry.dispose(),this.eyeMap.dispose(),this.eyeMaterial.dispose(),this.nerveGeometry.dispose(),this.nerveMaterial.dispose();for(let e of[...this.eyeMeshes,...this.nerveMeshes])this.scene.remove(e);if(this.stumpMaterial.dispose(),this.stumpMap.dispose(),this.wristMaterial.dispose(),this.wristMap.dispose(),this.bakedStandIns!==null){this.bakedStandIns.map.dispose();for(let e of this.bakedStandIns.materials)e.dispose();for(let e of this.bakedStandIns.instanced)e.dispose();this.bakedStandIns=null}for(let e of this.heads)this.scene.remove(e.mesh);for(let e of this.hands)this.scene.remove(e.mesh);for(let e of[...this.stumps,...this.handStumps])this.scene.remove(e.mesh)}},cW={maximum:1,minimum:.55,slowMs:24,fastMs:17.5,windowMs:1e3,step:.15},lW=10,uW=10,dW=160,fW=3,pW=3,mW=class{options;scale;elapsed=0;frames=0;fastWindows=0;holdWindows=0;fruitlessAttempts=0;pending=null;raised=null;raiseHoldWindows=0;failedRaises=0;constructor(e=cW){this.options=e,this.scale=e.maximum}record(e){if(!(e>0)||e>1e3||(this.elapsed+=e,this.frames+=1,this.elapsede.before*.9)return this.scale=e.previous,this.holdWindows=Math.min(dW,lW*2**this.fruitlessAttempts),this.fruitlessAttempts+=1,!0;this.fruitlessAttempts=0}if(this.raised!==null){let e=this.raised;if(t>this.options.slowMs)return this.raised=null,this.scale=e.previous,this.fastWindows=0,this.raiseHoldWindows=Math.min(dW,uW*2**this.failedRaises),this.failedRaises+=1,!0;e.windows+=1,e.windows>=pW&&(this.raised=null,this.failedRaises=0)}if(t>this.options.slowMs){if(this.fastWindows=0,this.holdWindows>0)return--this.holdWindows,!1;if(this.scale<=this.options.minimum)return!1;let e=this.scale;return this.scale=Math.max(this.options.minimum,this.scale-this.options.step),this.pending={before:t,previous:e},!0}return t0?(--this.raiseHoldWindows,!1):this.fastWindows>=fW&&this.scale0&&e.poise===0)return 1;if(e.is_downed)return gW;let n=e.stunned_ticksthis.value?7:.9;return this.value+=(e-this.value)*(1-Math.exp(-n*Math.max(0,t))),e===0&&this.value<.003&&(this.value=0),this.value}},yW=.4,bW=.5,xW={before:24,after:24,speed:.5};function SW(e,t,n=30,r=yW,i=42,a=33){let o=t.tick-i,s=t.tick+a,c=e.filter(e=>e.tick>=o-1&&e.tick<=s+1),l=c.at(-1),u=l!==void 0&&l.result!==null&&l.tick({...l,tick:l.tick+t+1,events:[]}))]:c,d=u[0],f=u.at(-1);if(d===void 0||f===void 0||u.length<8||d.tick>t.tick-12||f.tick=1&&this.lastHeat<1&&!r&&(this.flare=1),this.lastHeat=t,this.flare=Math.max(0,this.flare-n/DW);let a=this.mesh.material;if(a.opacity=Math.min(1,t*.8+this.flare*.6),this.mesh.visible=a.opacity>.01,!this.mesh.visible)return;this.mesh.position.copy(e),this.mesh.quaternion.copy(i.quaternion);let o=TW*(.55+.45*t)*(1+this.flare*EW);this.mesh.scale.set(o,o,1)}get active(){return this.mesh.visible}standIn(){return new Y(this.mesh.geometry,this.mesh.material)}reset(){this.flare=0,this.lastHeat=0,this.mesh.material.opacity=0,this.mesh.visible=!1}dispose(){this.mesh.geometry.dispose(),this.mesh.material.dispose()}},FW=class{group=new t_;flash;ring;age=1/0;constructor(e){this.flash=NW(e,new J(1,.86,.62)),this.flash.material.depthTest=!1,this.ring=new Y(new gb(.42,.5,40),new yv({color:wW,blending:2,depthWrite:!1,transparent:!0,side:2})),this.flash.renderOrder=6,this.ring.renderOrder=6,this.group.add(this.flash,this.ring),this.group.visible=!1}fire(e){this.age=0,this.group.position.copy(e)}update(e,t){this.age+=e;let n=this.age/OW,r=this.age/AW;if(this.group.visible=r<1,!this.group.visible)return;this.group.quaternion.copy(t.quaternion),this.flash.visible=n<1;let i=kW*(.35+.65*Math.sqrt(Math.min(1,n)));this.flash.scale.set(i,i,1),this.flash.material.opacity=(1-Math.min(1,n))**2;let a=jW*(.15+.85*(1-(1-r)**3));this.ring.scale.set(a,a,a),this.ring.material.opacity=.9*(1-r)}get active(){return this.group.visible}standIns(){return[new Y(this.flash.geometry,this.flash.material),new Y(this.ring.geometry,this.ring.material)]}reset(){this.age=1/0,this.group.visible=!1}dispose(){this.flash.geometry.dispose(),this.flash.material.dispose(),this.ring.geometry.dispose(),this.ring.material.dispose()}},IW=10,LW=.055,RW=3.2,zW=1.4,BW=class{color;mesh;geometry;positions=new Float32Array(60);colors=new Float32Array(80);history=[];last=new q;hasLast=!1;tangent=new q;side=new q;toCamera=new q;shade=new J;strength=0;heat=0;constructor(e){this.color=e,this.geometry=new iv,this.geometry.setAttribute(`position`,new U_(this.positions,3).setUsage(gh)),this.geometry.setAttribute(`color`,new U_(this.colors,4).setUsage(gh));let t=[];for(let e=0;e<9;e+=1){let n=e*2;t.push(n,n+1,n+2,n+1,n+3,n+2)}this.geometry.setIndex(t);let n=new yv({vertexColors:!0,transparent:!0,blending:2,depthWrite:!1,side:2});this.mesh=new Y(this.geometry,n),this.mesh.frustumCulled=!1,this.mesh.visible=!1,this.mesh.renderOrder=4}update(e,t,n,r,i=0){if(t<=0)return;let a=this.hasLast?e.distanceTo(this.last)/t:0;this.last.copy(e),this.hasLast=!0,this.heat=i>this.heat?i:this.heat+(i-this.heat)*Math.min(1,t*6);let o=RW*(1-.55*this.heat),s=r&&a>o?Math.min(1,(a-o)/4+this.heat*.4):0;this.strength+=(s-this.strength)*Math.min(1,t*18);let c=this.history.length>=IW?this.history.shift():new q;if(c.copy(e),this.history.push(c),this.strength<.02||this.history.length<3){this.mesh.visible=!1;return}let l=this.history.length,u=this.shade.copy(this.color).lerp(wW,this.heat),d=LW*(1+zW*this.heat);for(let e=0;e3*t}function WW(e,t,n){let r=e.detail.endsWith(`:head`)||e.detail.endsWith(`:body`);return t===void 0||![`hit`,`counter_hit`].includes(e.kind)||!r||n===null||n.winner_id===null||n.winner_id!==e.actor_id?!1:n.finish_method===`flash_ko`||(n.finish_method===`ko`||n.finish_method===`tko`)&&t.is_downed}function GW(e){for(let t of e.passes)t.dispose?.();e.dispose()}function KW(e,t,n,r,i){e.setRenderTarget(t.readBuffer);let a=e.compileAsync(n,r,i);return e.setRenderTarget(null),a}var qW=-4e-4,JW=10,YW=16;function XW(e,t,n){let r=t?YW:n;e.autoUpdate=!t,e.intensity=+!t,e.bias=t?JW:qW,e.mapSize.x!==r&&(e.mapSize.set(r,r),e.map?.dispose(),e.map=null,e.needsUpdate=!0)}function ZW(e,t){let n=t.fighters.findIndex(t=>t.player_id===e.target_id),r=t.fighters.findIndex(t=>t.player_id===e.actor_id),i=e.kind===`block`||e.kind===`perfect_block`;return{recipientIndex:i?r:n,puncherIndex:i?n:r}}function QW(e,t,n){if(e===void 0||t===void 0)return;let r=n.x(t.x)-n.x(e.x),i=n.z(t.y)-n.z(e.y),a=Math.hypot(r,i);return Number.isFinite(a)&&a>.001?{x:r/a,z:i/a}:void 0}var $W=e=>e.kind===`hit`||e.kind===`counter_hit`,eG=e=>e.kind===`block`||e.kind===`perfect_block`,tG=480,nG=.56,rG=1.8,iG=1.7,aG=1.2,oG=1.6,sG=30,cG=6.5,lG=.4,uG=600,dG=2.8,fG=.6,pG=[[1,0],[-1,0],[.75,-.66],[-.75,-.66],[.75,.66],[-.75,.66]],mG=.15,hG=.6,gG=2.3,_G=.5,vG=3.42,yG=2.2,bG=.9,xG=`body`,SG=`collapse`,CG=.55,wG=.5,TG=.5,EG=.28,DG=104,OG=260,kG=.05,AG=2.95,jG=2.4,MG=1.6,NG=.98,PG={uniforms:{tDiffuse:{value:null},uTime:{value:0},uVignette:{value:.32},uGrain:{value:.035},uRocked:{value:0}},vertexShader:` +}`;function tw(e){let t=e.onBeforeCompile,n=Object.hasOwn(e,`customProgramCacheKey`)?e.customProgramCacheKey():`plain`;e.onBeforeCompile=(n,r)=>{t.call(e,n,r),n.vertexShader=n.vertexShader.replace(`#include `,`${ew}\n#include `)},e.customProgramCacheKey=()=>`${n}-on-canvas`,e.needsUpdate=!0}function nw(e,t){let n=t.outfit!==void 0,r=!n||t.wounds===!0,i=[],a=[],o=new Map,s=null,c={value:0},l=null,u=null;if(e.traverse(e=>{if(!(e instanceof rl)||Array.isArray(e.material))return;let d=e.material.name,f=RC[d];if(f===void 0)throw Error(`fighter GLB has unsupported material ${d}`);let p=o.get(d);if(p===void 0){let e=d===`MHeadMat0`||d===`MBodyMat0`,m=t.outfit,h=d===`GlovesMat0`?t.gear:d===`PantsMat0`?m?.trousers??t.gear:d===`ShoesMat0`&&m!==void 0?m.shoes:16777215,g=$C(f);p=e&&!n?new qu({map:g,color:h,roughness:.58,metalness:.02,clearcoat:.25,clearcoatRoughness:.6}):new Ku({map:g,color:h,roughness:e?.58:zC[d]??.4,metalness:e?.02:.03}),p.name=d,o.set(d,p),a.push(p),e&&i.push(p),d===`MHeadMat0`&&(l=new e_(r?p:null,Qh,{core:Ng,lids:Fg})),d===`MBodyMat0`&&(u=new e_(r?p:null,$h,{core:Pg,wash:!0}));let _=rw[d];m!==void 0&&_!==void 0?cb(p,_,m):d===`PantsMat0`?c=xy(p,!1,`trunks`):d===`GlovesMat0`&&(s=xy(p)),e&&!n&&hb(p),tw(p)}if(e.material=p,!n&&e.name===`BoxerPants`){let t=WC.get(e.geometry);t===void 0&&WC.set(e.geometry,t=Eb(e.geometry,e.skeleton.bones.map(e=>e.name))),e.geometry=t}e.castShadow=!n,e.receiveShadow=!0,e.frustumCulled=!1}),i.length!==2||s===null||a.length!==5||l===null||u===null)throw Error(`fighter GLB material contract failed: ${i.length} skin, ${a.length} total`);return{skin:i,gloveBlood:s,trunksBlood:c,owned:a,headInjury:l,bodyInjury:u}}var rw={MHeadMat0:`head`,MBodyMat0:`body`,ShoesMat0:`shoes`,PantsMat0:`pants`},iw=new B().setRGB(.6,.32,.19,Ta),aw=(e,t,n,r)=>e+(t-e)*(1-Math.exp(-n*r)),ow=(e,t,n,r)=>e+(((t-e+Math.PI)%(Math.PI*2)+Math.PI*2)%(Math.PI*2)-Math.PI)*(1-Math.exp(-n*r)),sw=L.clamp,cw=class{root=new gs;bones=new Map;rig;metrics;skinMaterials;ownedMaterials;gloveBlood;trunksBlood;headMeshes=[];handMeshes={left:[],right:[]};decapitated=!1;burst=!1;dismemberedHands={left:!1,right:!1};dressed;ownedGeometries=[];gearBaseColor;skinBaseColor;headInjury;bodyInjury;headLook;face;bareHand;constructor(e,t){let n=pv(e.scene);n.scale.setScalar(1),this.root.add(n);let r=nw(n,t);this.skinMaterials=r.skin,this.ownedMaterials=[...r.owned],this.gloveBlood=r.gloveBlood,this.trunksBlood=r.trunksBlood,this.headInjury=r.headInjury,this.bodyInjury=r.bodyInjury,this.gearBaseColor=new B(t.gear),this.skinBaseColor=new B(t.skin),this.dressed=t.outfit!==void 0,n.traverse(e=>{e instanceof rl&&e.name===`BoxerHead`&&this.headMeshes.push(e),e instanceof rl&&e.name===`BoxerGloveLeft`&&this.handMeshes.left.push(e),e instanceof rl&&e.name===`BoxerGloveRight`&&this.handMeshes.right.push(e),e instanceof il&&this.bones.set(e.name,e)});let i=Object.values(gy).filter(e=>!this.bones.has(e));if(i.length>0)throw Error(`fighter GLB missing required bones: ${i.join(`, `)}`);if(this.headMeshes.length!==1)throw Error(`fighter GLB requires one BoxerHead mesh, found ${this.headMeshes.length}`);let a=this.headInjury.shadowMaterial();this.headMeshes[0].customDepthMaterial=a;let o=this.headMeshes[0].material;o.side=0,o.shadowSide=1,this.ownedMaterials.push(a);for(let e of[`left`,`right`])if(this.handMeshes[e].length!==1)throw Error(`fighter GLB requires one ${e} glove mesh, found ${this.handMeshes[e].length}`);this.root.updateMatrixWorld(!0),this.rig=new Qb(this.root),this.headLook=new Vy(this.headMeshes[0].material),this.face=new jb(t.gear^t.skin),this.bareHand=t.outfit===void 0?null:this.addHands(t.outfit),this.setLook(t.look??Sy);let s=this.rig.metrics;this.metrics={armUpper:s.armL.upper,armFore:s.armL.lower,legThigh:s.legL.upper,legShin:s.legL.lower,headRestY:s.headHeight,chestRestY:s.chestHeight,ankleRestY:s.ankleHeight}}bone(e){return this.bones.get(gy[e]??e)??null}setGloveBlood(e){this.gloveBlood.value=sw(e,0,1)}get gloveBloodLevel(){return this.gloveBlood.value}setTrunksBlood(e){this.trunksBlood.value=sw(e,0,1)}get trunksBloodLevel(){return this.trunksBlood.value}get headMesh(){return this.headMeshes[0]}gloveMesh(e){return this.handMeshes[e][0]}get skin(){return this.skinMaterials[0]}get isDecapitated(){return this.decapitated}setDecapitated(e){this.decapitated=e,this.burst=!1,this.headInjury.setSevered(e),this.bone(`head`).visible=!e}get isHeadBurst(){return this.burst}setHeadBurst(e){this.burst=e,this.decapitated=!1,this.headInjury.setBurst(e),this.bone(`head`).visible=!e}isHandDismembered(e){return this.dismemberedHands[e]}setHandDismembered(e,t){this.dismemberedHands[e]=t;for(let n of this.handMeshes[e])n.visible=!t&&!this.dressed}setLook(e){this.headLook.set(e);for(let t of this.skinMaterials)t.color.setHex(e.tint);this.bareHand?.color.copy(iw).multiply(this.skinMaterials[0].color)}get look(){return this.headLook.look}addHands(e){let t=e.gloves!==null,n=new Ku({color:t?e.gloves:iw,roughness:t?.38:.6,metalness:.02}),r=t?n:new Ku({color:new B(e.shirt).multiplyScalar(.9),roughness:.88,metalness:0});this.ownedMaterials.push(n),r!==n&&this.ownedMaterials.push(r);let i=fb();this.ownedGeometries.push(i);for(let e of[`left`,`right`]){for(let t of this.handMeshes[e])t.visible=!1;let t=db(e);this.ownedGeometries.push(t);let a=e===`left`?`L`:`R`;for(let[o,s,c,l]of[[this.rig.bones[`glove${a}`],t,n,`hand-${e}`],[this.rig.bones[`elbow${a}`],i,r,`cuff-${e}`]]){let e=new V(s,c);e.name=l,e.castShadow=!1,e.receiveShadow=!0,o.add(e)}}return t?null:n}setSkinClearcoat(e){for(let t of this.skinMaterials)t instanceof qu&&(t.clearcoat=e)}flinch(e,t){this.face.flinch(e,t)}updateFace(e,t,n,r,i,a){this.face.update(e,t,n,r,i,a),this.headLook.setExpression(this.face.lids,this.face.mouth,this.face.brow)}dispose(){for(let e of this.ownedMaterials)e.dispose();for(let e of this.ownedGeometries)e.dispose();QC(this.root)}},lw=(e,t,n,r,i)=>{let a=e.value,o=e.velocity;o.addScaledVector(a,-n*t).multiplyScalar(Math.exp(-r*t)),a.addScaledVector(o,t),a.length()>i&&a.setLength(i)},uw=.06,dw=150,fw=.58,pw=.25,mw=.32,hw=9,gw=1,_w=.08,vw=.3,yw=1,bw=1.6,xw=.25,Sw=.12,Cw=.33,ww=.3,Tw=8;function Ew(e,t,n,r){jC(e,t,n);let i=Math.hypot(n.x,n.z);if(i<=0)return r.x=0,r.z=0,0;let a=rx(0,xw,i),o=1+Sw*a/i;return r.x=n.x*o,r.z=n.z*o,a}var Dw=(e,t)=>e===0||Math.sign(t)===Math.sign(e)&&Math.abs(t)>Math.abs(e)?t:e,Ow=.75,kw=.38,Aw=.72,jw=.5,Mw=.2,Nw=.55,Pw=.7,Fw=6,Iw=.4,Lw=.2,Rw=.3,zw=.5,Bw=class{mapping;boxer;solver;yaw=0;yawInitialized=!1;rootX=null;rootZ=0;punchActive=!1;punchAgeTicks=0;punchTotalTicks=1;punchClass=`jab`;punchHand=`left`;punchTarget=`head`;punchPower=`normal`;punchTiming=se(`jab`,`head`,`normal`);actionId=null;completedActionId=null;ownActionId=null;ownPress=!1;ownLeadTicks=0;ownAuthoritativeAge=null;ownWaitedTicks=0;ownExpectedTicks=0;ownPulled=!1;ownSequence=null;ownStarted=!1;ownPressedAt=0;ownRefused=!1;ownCut=!1;recoveryCut=!1;ownQueued=null;contactId=null;contactParried=!1;shownFighter=null;shownOpponent=null;retiredOwnIds=[];pressesLanded=[];anticipatedId=null;hitstop=0;hitstopScale=1;hitstopLag=0;downState=`up`;fallAge=0;riseProgress=0;riseFrom=0;fallSide=0;fallProne=!1;fallKneel=!1;windedSide=-1;windedTime=0;winded=0;landProne=!1;landSide=0;landShift=new z;landSettled=!1;fallen=SE();fallenFromPhysics=!1;riseRoot=new z;riseRootFrom=new z;downPoles=[new z,new z,new z,new z];downPolesSet=!1;poleSettle=0;characterInverse=new Ho;place=new z;riseRootVelocity=new z;liveOpponentHead=new z;hasLiveHead=!1;guardOpponentHead=new z;opponentHeadOffset=new z;opponentSteadySeconds=0;followHead=0;aimActionId=null;refereeContactId=null;refereeHead=new z;hasRefereeHead=!1;followReferee=0;headKick={value:new z,velocity:new z};torsoKick={value:new z,velocity:new z};rootKick={value:new z,velocity:new z};coverKick={value:new z,velocity:new z};foldDelay=0;pendingFold=0;coverDelay=0;pendingCover=0;liverDelay=0;pendingLiver=0;armKick={value:new z,velocity:new z};handsDrop=0;guardWasBroken=!1;hurtSeed=1;rockedTime=0;rockedPhase=0;nextLurch=0;guardKick=0;guardHigh=0;guardLow=0;guardSpent=0;slip=0;weave=0;weaveTime=0;pull=0;crouchExtra=0;bouncePhase=0;weightPhase=0;breathPhase=0;stunPhase=0;feintTimer=2;pawAge=bT;pawCount=0;idleSeed=-1;manner={...bx.balanced,lead:new z,rear:new z};mannerStyle=null;mannerSeed=0;breath=0;battered=0;walkLean=new R;leadingFoot=-1;nextFoot=-1;steppedYaw=0;stunAmount=0;tired=0;clinchWeight=0;foulWeight=0;tauntWeight=0;crowding=0;tight=0;punchCommit=0;punchMiss=0;headSpace=new R;ownHead=new z;ropeHold=new z;ropeExcess={x:0,z:0};ropeOwn={x:0,z:0};ropeTheirs={x:0,z:0};ropeLeanTarget=0;ropeLean=0;ropeOutward=new z(1,0,0);ropeLocal=new z;tauntEnd=null;lastSpeed=0;stool;stoolRoot=new z;stoolYaw=0;enswell;bottle;treatProp=`enswell`;treatTarget=new z;treatScratch=new z;treatFacing=new z(0,0,-1);treatFacingLocal=new z;treatSide=1;treating=!1;treatWeight=0;resting=!1;seated=0;stillTime=0;celebrateTime=0;celebration=0;waveTime=0;wave=0;breakTime=0;breakWeight=0;breakFighters=[new z,new z];breakAimed=!1;attending=!1;verdictSide=0;verdict=null;squareWeight=0;raisedWeight=0;bowedWeight=0;wrists=[null,null];wristTargets=[new z,new z];wristWeights=[0,0];attendWeight=0;countdownTicks=null;countdownEnd=null;touchWeight=0;touchOffset=new z;touchVelocity=new z;debugHoldImpact=!1;feet=[{planted:new z,from:new z,to:new z,progress:1,stepping:!1,duration:.2},{planted:new z,from:new z,to:new z,progress:1,stepping:!1,duration:.2}];feetInitialized=!1;dislocation=null;scratch=new z;scratchB=new z;scratchC=new z;scratchD=new z;scratchE=new z;clinchCentre=new z;clinchForward=new z;clinchTemp=new z;scratchQ=new vo;headWorld=new z;hand={L:this.makeHand(),R:this.makeHand()};punchGuard=this.makeHand();punchDir=new z;punchContact=new z;punchStart=new z;punchSweepFrom=new z;punchSweepTo=new z;punchMid=new z;foot={L:this.makeFoot(),R:this.makeFoot()};torso={hips:new z,hipsYaw:0,hipsPitch:0,hipsRoll:0,shouldersYaw:0,spinePitch:0,spineRoll:0,headYaw:0,headPitch:0,headRoll:0,headOffset:new z};pose;downStanding=SE();downFrom=SE();downTo=SE();downResult=SE();downStand=1;fallStart=SE();fallStartStand=1;fallFromGetUp=!1;referee;refereeCount=0;refereeCounting=!1;countChangedTick=null;countWeight=0;countPump=0;watchPoint=new z;watching=!1;duty=`watch`;backWeight=0;waveSlow=!1;mood=`work`;mournWeight=0;cheerWeight=0;treatUrgency=0;gazeYaw=0;gazePitch=0;travel=new z;strideYaw=0;backing=!1;footYaw=[0,0];ragdoll;forcedDown=!1;heldDown=!1;authoredNextFall=!1;obstacle=null;blows=0;riseBlendAge=0;posedInjuries=0;armCarry=[`whole`,`whole`];armLimp=[0,0];armSnap=[0,0];armDangle=[wT(),wT()];forearmDangle=[wT(),wT()];trunkLow=new z;trunkHigh=new z;lostLean=0;cover=0;kneeBlown=[!1,!1];kneeGive=[0,0];gutted=!1;hunch=0;liver=!1;curl=0;faintTarget=0;faint=0;retchTime=0;retching=0;dazed=!1;daze=0;dazeTime=0;stepPace=[1,1];stepLift=[1,1];stepSlack=1;hurt=!1;punchReach=0;dead=!1;deathFall=!1;deathStyle=`crumple`;deathAge=0;throe=DT.length;throeSide=0;laidOut=!1;constructor(e,t,n={}){this.mapping=t,this.boxer=e,this.referee=n.referee===!0,this.solver=new _x(e.rig),this.pose={torso:this.torso,handL:this.hand.L,handR:this.hand.R,footL:this.foot.L,footR:this.foot.R,shrugL:0,shrugR:0},this.stool=YE(),this.stool.group.position.set(0,0,.02),e.root.add(this.stool.group),this.enswell=qE(),e.rig.bones.gloveL.add(this.enswell.group),this.bottle=JE(),e.rig.bones.gloveL.add(this.bottle.group),this.ragdoll=this.referee&&n.knockout!==!0?null:new hC(e.rig,e.root)}primeReplayFall(){this.ragdoll?.prime()}useAuthoredFall(){this.authoredNextFall=!0}knockOut(){this.forcedDown=!0}stayDown(e){this.heldDown=e}setObstacle(e,t){this.obstacle??={x:e,z:t},this.obstacle.x=e,this.obstacle.z=t}get fallBody(){return this.ragdoll?.active===!0?this.ragdoll:null}setResting(e){this.resting=e}get stoolVisible(){return this.stool.group.visible}celebrate(e=4.4){this.celebrateTime=e}resetTransient(e=!1){this.forcedDown=!1;let t=this.ragdoll;t!==null&&(e?t.active?t.settle():t.restoreSettled():(t.stop(),t.clearRise())),this.downState=e?`down`:`up`,this.landSettled=!1,this.fallenFromPhysics=!1,this.riseRoot.set(0,0,0),this.riseRootFrom.set(0,0,0),this.riseRootVelocity.set(0,0,0),this.fallAge=e?Ow:0,this.riseProgress=0,this.hitstop=0,this.hitstopScale=1,this.hitstopLag=0;for(let e of[this.headKick,this.torsoKick,this.rootKick,this.coverKick,this.armKick])e.value.set(0,0,0),e.velocity.set(0,0,0);this.foldDelay=0,this.pendingFold=0,this.coverDelay=0,this.pendingCover=0,this.liverDelay=0,this.pendingLiver=0,this.handsDrop=0,this.rockedTime=0,this.guardKick=0,this.stunAmount=0,this.windedTime=0,this.winded=0,this.celebrateTime=0,this.celebration=0,this.waveTime=0,this.wave=0,this.verdictSide=0,this.verdict=null,this.squareWeight=0,this.raisedWeight=0,this.bowedWeight=0,this.wrists.fill(null),this.wristWeights.fill(0),this.seated=0,this.stillTime=0,this.rootX=null,this.yawInitialized=!1,this.feetInitialized=!1,this.retirePunch(),this.ownQueued=null,this.completedActionId=null,this.retiredOwnIds.length=0,this.anticipatedId=null,this.retchTime=0,this.retching=0,this.dazed=!1,this.daze=0,this.dazeTime=0;for(let e=0;e<2;e+=1)ET(this.armDangle[e]),ET(this.forearmDangle[e]);this.dead=!1,this.deathFall=!1,this.throe=DT.length,this.laidOut=e}waveOff(e=2.6,t=!1){this.waveTime=e,this.waveSlow=t}setCountdown(e){this.countdownTicks=e}attend(e,t=`work`){this.attending=e,this.mood=t}treat(e,t,n=1,r=`enswell`,i=0){this.treating=e!==null,e!==null&&(this.treatTarget.copy(e),t!==void 0&&this.treatFacing.copy(t),this.treatSide=n,this.treatProp=r,this.treatUrgency=i)}awaitVerdict(e){this.verdictSide=e??0,e===null&&(this.verdict=null)}announce(e){this.verdict=e}raise(e,t){this.wrists[0]=e===null?null:this.wristTargets[0].copy(e),this.wrists[1]=t===null?null:this.wristTargets[1].copy(t)}breakClinch(e=1.3){this.breakTime=e}get breaking(){return this.breakTime>0}aimBreak(e,t,n=null,r=`watch`){this.breakFighters[0].copy(e),this.breakFighters[1].copy(t),this.breakAimed=!0,this.watching=n!==null,n!==null&&this.watchPoint.copy(n),this.duty=r}makeHand(){return{position:new z,knuckles:new z(0,1,0),palm:new z(0,0,1),pole:new z(0,-1,0)}}makeFoot(){return{position:new z,toe:new z(0,0,1),heel:0,pole:new z(0,0,1)}}get currentRoot(){return{x:this.rootX??0,z:this.rootZ}}get isDown(){return this.downState!==`up`||this.dead}setRefereeCount(e,t){(e!==this.refereeCounting||t!==this.refereeCount)&&(this.countChangedTick=null),this.refereeCounting=e,this.refereeCount=t}predict(e,t,n,r=0,i,a=r){if(e.kind!==`punch`||e.id===void 0)return;let o={action:{...e,id:e.id},timing:i??se(e.class,e.target,e.power),leadTicks:r,answerTicks:a,pressedAt:t,sequence:null,started:!1,waited:0};if(this.punchActive&&this.ownActionId!==null&&this.ownAuthoritativeAge===null&&!this.ownPulled&&!this.ownStarted&&(t-this.ownPressedAt)*n0||e.clinch_ticks>0||e.clinch_startup_ticks>0,a=this.ownQueued;if(a!==null&&(a.sequence??=r?.(a.action.id)??null,e.action_id===a.action.id?a.started=!0:!a.started&&(i||a.sequence!==null&&e.last_input_sequence>=a.sequence&&e.queued_actions===0)&&(this.ownQueued=null)),!this.punchActive||this.ownActionId===null||this.ownPulled||this.ownRefused)return;this.ownStarted||(this.ownSequence??=r?.(this.ownActionId)??null);let o=e.action_id===this.ownActionId;o&&(this.ownStarted=!0);let s=this.ownQueued;s!==null&&s.sequence!==null&&r!==null&&!this.ownStarted&&this.ownSequence===null&&this.ownAuthoritativeAge===null?(this.ownActionId=null,this.ownQueued=null,this.retirePunch(),this.startOwnPunch(s)):(o?i&&e.action_contact_tick===null:!this.ownStarted&&this.ownAuthoritativeAge===null&&(i||this.ownSequence!==null&&e.last_input_sequence>=this.ownSequence&&e.queued_actions===0))&&(this.ownRefused=!0,this.takeBack())}takeBack(){this.punchAgeTickse.action_startup_ticks*(1/uD-1)||this.punchActive&&this.punchAgeTicks/this.punchTotalTicks<=.55)return;this.anticipatedId=n;let r=e.action_target??`head`,i=e.action_power??`normal`,a={...se(e.action,r,i),startup:e.action_startup_ticks,active:e.action_active_ticks,recovery:e.action_recovery_ticks},o=e.action_hand??(e.stance===`orthodox`?`left`:`right`);this.startEarly(n,e.action,o,r,i,a,t,t)}startOwnPunch(e){let{action:t,timing:n}=e;this.startEarly(t.id,t.class,t.hand,t.target,t.power,n,0,Math.max(0,e.answerTicks)),this.ownPress=!0,this.ownSequence=e.sequence,this.ownStarted=e.started,this.ownPressedAt=e.pressedAt}startEarly(e,t,n,r,i,a,o,s){this.retirePunch(),this.punchClass=t,this.punchHand=n,this.punchTarget=r,this.punchPower=i,this.punchTiming=a,this.punchTotalTicks=Math.max(1,pe(a)),this.punchAgeTicks=0,this.punchActive=!0,this.ownActionId=e,this.ownLeadTicks=sw(o,0,ZE),this.ownExpectedTicks=s}followUpStartAge(e){let t=this.shownFighter,n=this.shownOpponent,r=this.actionId??this.ownActionId,i=r!==null&&r===this.contactId&&!this.contactParried;return t!==null&&n!==null&&D(this.punchClass,i,e.action,t.stamina,n.stunned_ticks>0,t.style)?E(this.punchTiming):this.punchTotalTicks}releaseQueuedPress(e){let t=this.ownQueued;t!==null&&(t.waited+=e*30,this.punchActive&&!this.ownPulled&&this.punchAgeTicks+this.serverLag(t.leadTicks)6&&this.retiredOwnIds.shift()),this.actionId=null,this.punchActive=!1,this.ownActionId=null,this.ownPress=!1,this.ownLeadTicks=0,this.ownAuthoritativeAge=null,this.ownWaitedTicks=0,this.ownExpectedTicks=0,this.ownPulled=!1,this.ownSequence=null,this.ownStarted=!1,this.ownRefused=!1,this.ownCut=!1,this.recoveryCut=!1,this.hitstopLag=0}setRefereeHead(e){this.hasRefereeHead=e!==null,e!==null&&this.refereeHead.copy(e)}landedHit(e,t,n=!1){this.punchActive&&e!==null&&e===(this.actionId??this.ownActionId)&&(this.punchAgeTicks>=this.punchTiming.startup+this.punchTiming.active+1||(this.hitstop=Math.max(this.hitstop,(t?o.block:n?o.power:o.hit)/1e3)))}powerHeat(e){if(!this.punchActive||this.punchPower!==`power`||this.punchHand!==e||this.ownPulled)return 0;let{startup:t,active:n,recovery:r}=this.punchTiming,i=this.punchAgeTicks;return i>>0;let u=i===`left`?1:i===`right`||n>=0?-1:1;if(t===`body`){switch(r){case`hook`:this.torsoKick.velocity.x+=3*l,this.torsoKick.velocity.z+=4.6*l*u,this.rootKick.velocity.x+=.5*l*u,this.coverDelay=.09,this.pendingCover=2.4*l*u,u>0&&e===`hit`&&o>.25&&(this.liverDelay=.28,this.pendingLiver=l*(.4+o));break;case`uppercut`:this.rootKick.velocity.y+=.9*l,this.torsoKick.velocity.x-=1.6*l,this.foldDelay=.1,this.pendingFold=5.2*l;break;default:this.torsoKick.velocity.x+=4.6*l}this.rootKick.velocity.z-=.45*l,this.headKick.velocity.z-=.6*l,this.headKick.velocity.y-=.7*l,this.guardKick=Math.max(this.guardKick,.6*l)}else{switch(e===`hit`&&(this.guardKick=Math.max(this.guardKick,.4*l)),r){case`hook`:this.headKick.velocity.x+=2.6*l*u,this.headKick.velocity.z-=.7*l,this.torsoKick.velocity.y+=3.4*l*u,this.torsoKick.velocity.z-=1.2*l*u;break;case`uppercut`:this.headKick.velocity.y+=2.2*l,this.headKick.velocity.z-=1.2*l,this.torsoKick.velocity.x-=1.6*l;break;case`straight`:this.headKick.velocity.z-=2.4*l,this.headKick.velocity.x+=.5*l*u,this.torsoKick.velocity.x-=1*l,this.torsoKick.velocity.y+=1.4*l*u;break;default:this.headKick.velocity.z-=1.5*l,this.torsoKick.velocity.x-=.5*l,this.torsoKick.velocity.y+=.5*l*u}if(this.rootKick.velocity.z-=.45*l,e===`block`)this.guardKick=Math.max(this.guardKick,Math.min(1.2,2.4*l)),this.rootKick.velocity.z-=1.1*l,this.torsoKick.velocity.x-=1.2*l;else{this.rootKick.velocity.y-=1.1*l*o;let e=1.7*l*o;r===`hook`?this.armKick.velocity.add(this.scratchE.set(u,.3,-.2).multiplyScalar(e)):r===`uppercut`?this.armKick.velocity.add(this.scratchE.set(0,1,-.4).multiplyScalar(e)):this.armKick.velocity.add(this.scratchE.set(.3*u,.7,-.4).multiplyScalar(e)),this.handsDrop=Math.max(this.handsDrop,sw((o-.35)*2,0,1)*(.5+.5*c))}}if(e===`hit`&&(this.dentSurface(t,u,r,o),this.fallSide=r===`hook`?u:u*.5,this.fallProne=r===`hook`||t===`body`),e===`hit`&&a>=10&&this.ragdoll!==null){let e=mC({target:t,punchClass:r,hand:i,lateral:u,amount:a}),n=this.scratchE.set(e.x,e.y,e.z).applyAxisAngle(XE,this.yaw),o=this.scratchD.set(e.driveX,e.driveY,e.driveZ).applyAxisAngle(XE,this.yaw);this.blows+=1,this.ragdoll.takeBlow(n,o,t,e.twist,YS(r,t,a,this.blows+Math.round(a)))}}stagger(){this.torsoKick.velocity.x-=2.6,this.headKick.velocity.z-=1.4,this.headKick.velocity.y+=.5,this.rootKick.velocity.z-=1.1,this.guardKick=Math.max(this.guardKick,1.1)}windedFor(e,t){this.windedTime=Math.max(this.windedTime,e),this.windedSide=t>=0?1:-1}fallToKnee(e){this.dead||(this.fallKneel=e,e&&(this.authoredNextFall=!0))}dentSurface(e,t,n,r){let i=1.1+r*2.1;if(e===`body`){let e=n===`hook`?t>0?`rightRibs`:`leftRibs`:`solarPlexus`;this.boxer.bodyInjury.impact(e,[n===`hook`?t*i*.8:0,0,-i],9)}else n===`hook`?this.boxer.headInjury.impact(t>0?`rightCheek`:`leftCheek`,[t*i,0,-i*.35],5.5):n===`uppercut`?this.boxer.headInjury.impact(`chin`,[0,i*.7,-i*.6],5):this.boxer.headInjury.impact(n===`jab`?`nose`:`mouth`,[0,0,-i],4.5)}footPlace(e,t,n){if(this.squareWeight>.5)return n.set(e===0?.16:-.16,0,e===0?.02:-.02);let r=e===0==t>0?vx.leadFoot:vx.rearFoot;return n.set(r.x*t*this.manner.width*(1+pT*this.battered),0,r.z*this.manner.length*(1-lT*this.crowding))}standLike(e){this.mannerSeed=xT(e)+1,this.mannerStyle=null}keyManner(e){let t=bx[e],n=this.manner;if(this.mannerStyle=e,Object.assign(n,t,{lead:n.lead.copy(t.lead),rear:n.rear.copy(t.rear)}),this.mannerSeed===0)return;let r=e=>Math.abs(Math.sin(this.mannerSeed*(e*7.31+3.17))*43758.5453)%1*2-1;n.rise+=r(1)*.012,n.length*=1+r(2)*.05,n.width*=1+r(3)*.06,n.lead.y+=r(4)*.025,n.lead.z+=r(5)*.03,n.flare+=r(6)*.12,n.spring*=1+r(7)*.2,n.bob*=1+r(1)*r(4)*.4,n.rock*=1+r(2)*r(6)*.3}stepOfficialFeet(e,t,n,r,i){let a=t>Kw,o=n.x*Math.sin(i)+n.z*Math.cos(i),s=n.x*Math.cos(i)-n.z*Math.sin(i),c=0;a&&(o<-.35*t?this.backing=!0:o>-.05*t&&(this.backing=!1),c=this.backing?Math.atan2(-s,-o):Math.atan2(s,o)),this.strideYaw=aw(this.strideYaw,c,6,e);let l=1-Math.exp(-8*e);this.travel.x+=(s-this.travel.x)*l,this.travel.z+=(o-this.travel.z)*l;let u=this.scratch,d=this.scratchQ.setFromAxisAngle(XE,i+this.strideYaw),f=a?0:Math.sin(this.weightPhase*.17)>=0?.045:-.045,p=sw(.42/Math.max(t,.01),.22,.34),m=t*p*.4;for(let o=0;o<2;o+=1){let s=this.feet[o],c=o===0?1:-1;u.set(c*.15,0,c*f).applyQuaternion(d).add(r),u.y=0;let l=i+this.strideYaw*.85+c*.2;if(!this.feetInitialized){s.planted.copy(u),s.progress=1,s.stepping=!1,this.footYaw[o]=l;continue}let h=Math.atan2(Math.sin(this.footYaw[o]-l),Math.cos(this.footYaw[o]-l));if(!a&&Math.abs(h)>.8&&(this.footYaw[o]=l+Math.sign(h)*.8),s.stepping){s.progress=Math.min(1,s.progress+e/s.duration),this.footYaw[o]=ow(this.footYaw[o],l,14,e),s.progress>=1&&(s.stepping=!1,s.planted.copy(s.to));continue}let g=this.feet[1-o];if(g.stepping)continue;let _=u.x-s.planted.x,v=u.z-s.planted.z,y=Math.hypot(_,v),b=a?(_*n.x+v*n.z)/t:0;W.set(-c*.15,0,-c*f).applyQuaternion(d).add(r).sub(g.planted);let x=a?(W.x*n.x+W.z*n.z)/t:0;(a?b>(x>0?.05:Math.max(.05,m*.8))||y>m+.2:y>.085)&&(s.stepping=!0,s.progress=0,s.duration=a?sw((.22-x)/t,.16,p):y>.12?.2:.32,s.from.copy(s.planted),s.to.copy(u).addScaledVector(n,s.duration*1.6),s.to.y=0)}this.feetInitialized=!0}stepFeet(e,t,n,r,i,a){if(this.referee||this.squareWeight>.5){this.stepOfficialFeet(e,n,r,i,a);return}let o=this.scratch,s=this.scratchQ.setFromAxisAngle(XE,a),c=+(t>0),l=-1;n>mT&&(l=this.footPlace(0,t,o).applyQuaternion(s).dot(r)>=this.footPlace(1,t,o).applyQuaternion(s).dot(r)?0:1),l!==this.leadingFoot&&(this.leadingFoot=l,this.nextFoot=l);let u=l<0?c:l,d=Math.abs(a-this.steppedYaw)>vT*e;this.steppedYaw=a;for(let f=0;f<2;f+=1){let p=f===0?u:1-u,m=this.feet[p];if(this.footPlace(p,t,o).applyQuaternion(s).add(i),o.y=0,this.daze>.001&&this.stumble(p,o,a),!this.feetInitialized){m.planted.copy(o),m.progress=1,m.stepping=!1;continue}if(m.stepping){m.progress=Math.min(1,m.progress+e/m.duration),m.progress>=1&&(m.stepping=!1,m.planted.copy(m.to));continue}let h=this.feet[1-p],g=m.planted.distanceTo(o),_;if(l<0)_=g>(p===c||!d?hT:gT)*this.stepSlack&&!h.stepping;else{let e=!h.stepping||h.progress>=1-.6*sw((n-.4)/1,0,1),t=this.scratchD.subVectors(o,m.planted).dot(r)>0;_=this.nextFoot===p&&t&&g>_T*this.stepSlack&&e}_&&(m.stepping=!0,m.progress=0,m.duration=sw(.2-n*.05,.11,.2)*this.stepPace[p],m.from.copy(m.planted),m.to.copy(o).addScaledVector(r,m.duration*(p===l?1.3:1)),m.to.y=0,l>=0&&(this.nextFoot=1-p))}this.feetInitialized=!0}footWorld(e,t){let n=this.feet[e];if(!n.stepping)return t.copy(n.planted),0;let r=ax(n.progress,1.6);return t.copy(n.from).lerp(n.to,r),Math.sin(n.progress*Math.PI)*yT*this.stepLift[e]}update(e,t,n,r,i,a,o,s){let c=this.boxer,l=e.stance===`orthodox`?1:-1,u=i?.35:1,d=this.touchWalk(e,t,n,o);this.walkBackFromTheFall(n);let f=this.holdOnTheRopes(t,this.mapping.x(e.x)+d.x+this.riseRoot.x,this.mapping.z(e.y)+d.z+this.riseRoot.z),p=this.mapping.x(e.x)+d.x+this.riseRoot.x-f.x,h=this.mapping.z(e.y)+d.z+this.riseRoot.z-f.z;this.place.set(p,0,h),this.rootX===null&&(this.rootX=p,this.rootZ=h);let g=bD*Math.max(n,1/60);this.rootX+=sw(p-this.rootX,-g,g),this.rootZ+=sw(h-this.rootZ,-g,g);let _=Math.atan2(e.facing_x,-e.facing_y);this.yawInitialized||=(this.yaw=_,!0);let v=this.punchActive&&this.punchAgeTicks0?.12:1;let y=n*this.hitstopScale;this.punchActive&&this.hitstop>0&&(this.hitstopLag+=(n-y)*30),this.syncAction(e,t,o,y),this.debugHoldImpact||(this.boxer.headInjury.update(y),this.boxer.bodyInjury.update(y)),s!==void 0&&this.trackOpponentHead(t,s,n);let b=this.scratchB.set(this.mapping.x(e.velocity_x)*30,0,this.mapping.z(e.velocity_y)*30).add(this.touchVelocity).add(this.riseRootVelocity),x=b.length(),S=Math.hypot(b.x-this.riseRootVelocity.x,b.z-this.riseRootVelocity.z);this.lastSpeed=x,this.stillTime=x<.03?this.stillTime+n:0;let C=this.resting&&this.stillTime>.2&&this.downState===`up`;this.seated=aw(this.seated,+!!C,C?2.2:4,n);let w=this.resting&&this.stillTime>.05&&this.downState===`up`;w&&(this.stoolRoot.set(this.rootX,0,this.rootZ),this.stoolYaw=this.yaw),this.stool.group.visible=w||this.seated>Hw&&this.downState===`up`,this.stool.group.position.set(this.stoolRoot.x-this.rootX,0,this.stoolRoot.z-this.rootZ).add(this.scratch.set(0,0,.02).applyAxisAngle(XE,this.stoolYaw)).applyAxisAngle(XE,-this.yaw),this.stool.group.rotation.y=this.stoolYaw-this.yaw,this.celebrateTime=Math.max(0,this.celebrateTime-n),this.celebration=aw(this.celebration,+(this.celebrateTime>0&&this.downState===`up`),3.5,n),this.waveTime=Math.max(0,this.waveTime-n),this.wave=aw(this.wave,+(this.waveTime>0&&this.downState===`up`),4,n),this.breakTime=Math.max(0,this.breakTime-n),this.breakWeight=aw(this.breakWeight,+(this.breakTime>0&&this.downState===`up`),6,n),this.attendWeight=aw(this.attendWeight,+!!this.attending,2.5,n),this.mournWeight=aw(this.mournWeight,+(this.mood===`mourn`),2.5,n),this.cheerWeight=aw(this.cheerWeight,+(this.mood===`cheer`),2.5,n);let T=!this.referee&&(this.verdictSide!==0||this.resting||this.countdownTicks!==null&&this.countdownTicks>$w);this.squareWeight=aw(this.squareWeight,+!!T,3,n),this.raisedWeight=aw(this.raisedWeight,+(this.verdictSide!==0&&(this.verdict===`winner`||this.verdict===`level`)),3.2,n),this.bowedWeight=aw(this.bowedWeight,+(this.verdictSide!==0&&this.verdict===`loser`),2.2,n);for(let e of[0,1])this.wristWeights[e]=aw(this.wristWeights[e],this.wrists[e]===null?0:1,3.2,n);this.treatWeight=aw(this.treatWeight,+!!this.treating,3,n),this.windedTime=Math.max(0,this.windedTime-n);let E=this.fallKneel&&this.downState===`falling`;this.winded=aw(this.winded,this.windedTime>0&&this.downState===`up`||E?1:0,this.windedTime>0||E?12:4,n),this.enswell.group.visible=this.treatWeight>.4&&this.treatProp===`enswell`,this.bottle.group.visible=this.treatWeight>.4&&this.treatProp===`bottle`;let D=this.countdownTicks!==null&&this.countdownTicks<=Xw&&this.countdownTicks>=Zw;this.touchWeight=aw(this.touchWeight,+!!D,6,n);let O=e.stamina/Math.max(1,e.maximum_stamina);this.tired=aw(this.tired,sw((.55-O)/.5,0,1),2,n),this.stunAmount=aw(this.stunAmount,Math.min(1,e.stunned_ticks/24),8,n),c.updateFace(n,i,this.punchActive&&this.punchPower===`power`,this.tired,this.stunAmount,this.isDown);let k=e.defense;this.guardHigh=aw(this.guardHigh,+(k===`guard_high`),mD,n),this.guardLow=aw(this.guardLow,+(k===`guard_low`),mD,n),this.guardSpent=aw(this.guardSpent,+(e.guard0||e.clinch_startup_ticks>0),10,n),this.foulWeight=aw(this.foulWeight,+!!e.is_foul_recovery_target,8,n),this.tauntWeight=aw(this.tauntWeight,+(e.taunt_ticks>0),10,n);let ee=Math.hypot(this.mapping.x(t.x)-this.mapping.x(e.x),this.mapping.z(t.y)-this.mapping.z(e.y)),M=this.referee||e.is_downed||t.is_downed?0:1-rx(fw,gw,ee);this.crowding=aw(this.crowding,M,9,n);let te=this.referee||e.is_downed||t.is_downed?0:1-rx(sT,cT,ee);this.tight=aw(this.tight,te,9,n);let ne=1/0;if(this.hasLiveHead&&!this.referee&&this.downState===`up`){let e=this.boxer.rig.bones.head.getWorldPosition(this.ownHead),t=e.x-this.liveOpponentHead.x,r=e.z-this.liveOpponentHead.z,i=Math.hypot(t,r);if(ne=Math.hypot(t,e.y-this.liveOpponentHead.y,r),ne1e-4){let e=(pw-ne)/pw*hw*n,a=Math.cos(-this.yaw),o=Math.sin(-this.yaw);this.headSpace.x+=(t*a+r*o)/i*e,this.headSpace.y+=(-t*o+r*a)/i*e,this.headSpace.lengthSq()>1&&this.headSpace.normalize()}}if(ne>mw&&this.headSpace.multiplyScalar(Math.exp(-3*n)),this.tauntEnd=GE(this.tauntEnd,o,e.taunt_ticks>0?e.taunt_ticks:null),lw(this.headKick,n,190,7.5,.24),lw(this.torsoKick,n,150,7,.7),lw(this.rootKick,n,120,8,.12),lw(this.coverKick,n,110,15,.3),lw(this.armKick,n,55,6,.3),this.foldDelay>0&&(this.foldDelay-=n,this.foldDelay<=0&&(this.torsoKick.velocity.x+=this.pendingFold,this.pendingFold=0)),this.coverDelay>0&&(this.coverDelay-=n,this.coverDelay<=0&&(this.coverKick.velocity.x+=this.pendingCover,this.pendingCover=0)),this.liverDelay>0&&(this.liverDelay-=n,this.liverDelay<=0&&(this.rootKick.velocity.y-=1.4*this.pendingLiver,this.torsoKick.velocity.x+=2.6*this.pendingLiver,this.torsoKick.velocity.z+=1.6*this.pendingLiver,this.pendingLiver=0)),this.handsDrop=Math.max(0,this.handsDrop-n*1.5),e.guard_broken&&!this.guardWasBroken&&(this.handsDrop=1,this.guardKick=1.2),this.guardWasBroken=e.guard_broken,this.stunAmount>.25&&this.downState===`up`&&!this.referee){if(this.rockedTime===0&&(this.rockedPhase=this.hurtRandom()*Math.PI*2,this.nextLurch=.1+this.hurtRandom()*.2),this.rockedTime+=n,this.rockedTime>=this.nextLurch){let e=this.stunAmount;this.rootKick.velocity.x+=(this.hurtRandom()-.5)*1.4*e,this.rootKick.velocity.z+=(this.hurtRandom()-.6)*1.2*e,this.rootKick.velocity.y-=this.hurtRandom()*.9*e,this.torsoKick.velocity.z+=(this.hurtRandom()-.5)*1.5*e,this.nextLurch=this.rockedTime+.3+this.hurtRandom()*.5}}else this.stunAmount<.02&&(this.rockedTime=0);this.guardKick=Math.max(0,this.guardKick-n*2.4),this.ragdoll?.tick(n),this.updateDownState(e,n,i,S),this.stepDeath(n),this.stepInjuries(n),this.idleSeed<0&&(this.idleSeed=xT(e.player_id),this.bouncePhase=this.idleSeed*19,this.weightPhase=this.idleSeed*43,this.breathPhase=this.idleSeed*71);let re=this.idleSeed;e.style!==this.mannerStyle&&this.keyManner(e.style);let ie=this.manner;this.battered=aw(this.battered,sw((e.trauma.head+e.trauma.body-dT)/fT,0,1),1.5,n);let ae=this.battered,oe=r*(.93+re*.14)+re*37,se=(2.1-this.tired*.8)*(1-this.stunAmount*.6)*(.94+re*.12)*ie.tempo;if(this.bouncePhase+=n*se*Math.PI*2*u,this.weightPhase+=n*(.42+re*.1)*Math.PI*2*u,this.breathPhase+=n*(.3+this.tired*.75)*Math.PI*2,this.stunPhase+=n*5.5,this.feintTimer-=n,this.pawAge+=n,this.feintTimer<=0&&!this.punchActive&&x<1&&this.downState===`up`){this.pawCount+=1;let e=Math.abs(Math.sin(this.pawCount*12.9898+re*78.233)*43758.5453)%1;this.feintTimer=e<.3?bT*1.2:1.4+e*2.6,this.pawAge=0}let ce=this.pawAge/bT,le=ce<1?Math.sin(Math.PI*.5*(rx(0,.4,ce)+rx(.4,1,ce))):0,ue=this.referee?0:le*ie.paw*(1-.7*this.tight)*(1-.6*this.tired)*(1-this.stunAmount)*(1-ae)*sw(1-this.guardHigh-this.guardLow,0,1)*u,de=this.referee?0:(1-this.stunAmount)*(1-.6*this.tired)*(1-.7*ae)*(x>.6?.5:1)*ie.spring,fe=Math.sin(this.bouncePhase)*(.7+.3*Math.sin(oe*.83+1.7))*de,pe=Math.sin(this.bouncePhase*.5+.6)*de*ie.rock,me=Math.sin(this.breathPhase)*(1+2*this.tired);this.breath=me;let he=this.scratchC.set(this.rootX,0,this.rootZ);(this.downState===`up`||this.downState===`rising`)&&this.stepFeet(n,l,x,b,he,this.yaw);let ge=Math.cos(this.yaw),_e=Math.sin(this.yaw);this.walkLean.x=aw(this.walkLean.x,sw((b.x*ge-b.z*_e)*.03,-.04,.04),8,n),this.walkLean.y=aw(this.walkLean.y,sw((b.x*_e+b.z*ge)*.03,-.04,.04),8,n);let ve=this.scratchQ.setFromAxisAngle(XE,-this.yaw),ye=l>0?this.foot.L:this.foot.R,be=l>0?this.foot.R:this.foot.L,xe=l>0?0:1,Se=+(l>0),Ce=this.footWorld(xe,ye.position),we=this.footWorld(Se,be.position);ye.position.sub(he).applyQuaternion(ve),be.position.sub(he).applyQuaternion(ve);let N=this.boxer.rig.metrics.ankleHeight;ye.position.y=N+Ce,be.position.y=N+we,xx(vx.leadToe,l,ye.toe),xx(vx.rearToe,l,be.toe);let Te=sw(this.tired*.6+this.stunAmount+ae*.6,0,1),Ee=(Ce+we)*3;ye.heel=Math.max(0,vx.leadHeel+(ie.heel-1)*.12)+(.5+.5*fe)*.09*de+Math.max(0,-pe)*.06+Ee,be.heel=vx.rearHeel*ie.heel*(1-.7*Te)+(.5+.5*fe)*.07*de+Math.max(0,pe)*.07+Ee,this.referee&&(ye.heel=be.heel=Ee),ye.pole.copy(ye.toe).setY(.35).normalize(),be.pole.copy(be.toe).setY(.35).normalize();let P=this.torso,F=vx.bladeYaw*l,De=fe*.013,Oe=(Math.sin(this.weightPhase)*.018+Math.sin(oe*.31+2.2)*.008)*u*(.5+.5*ie.bob),ke=.012+this.tired*.03+this.stunAmount*.05+ae*.025;P.hips.set(Oe*l+Math.sin(this.stunPhase*.9)*.05*this.stunAmount+this.walkLean.x,vx.hipsHeight+ie.rise-ke+De+me*.002,pe*.018+this.walkLean.y+ie.weight),P.hipsYaw=F,P.hipsPitch=.02+this.tired*.08,P.hipsRoll=Math.sin(this.stunPhase)*.09*this.stunAmount,P.shouldersYaw=F*vx.shoulderBlade;let Ae=(vx.lean+ie.lean)*(1-.5*this.tight);P.spinePitch=vx.hunch+Ae*Math.cos(F)+this.tired*.16+ae*.06-me*.012+this.walkLean.y,P.spineRoll=Ae*Math.sin(F)+Math.sin(this.stunPhase*1.3)*.06*this.stunAmount-this.walkLean.x+(Math.sin(oe*.61+2)*.018+Math.sin(oe*1.43)*.008)*u*ie.bob,P.headYaw=-.12*l+Math.sin(oe*.9)*.05+Math.sin(this.stunPhase*.7)*.25*this.stunAmount,P.headPitch=vx.chinTuck+Math.sin(oe*1.7)*.02+this.stunAmount*.18+ae*.2*(1-this.punchCommit),P.headRoll=Math.sin(this.stunPhase*1.1)*.14*this.stunAmount,P.headOffset.set(0,0,0);let je=l>0?this.hand.L:this.hand.R,Me=l>0?this.hand.R:this.hand.L,Ne=this.headRestChar(l),Pe=sw(this.guardHigh+this.guardLow,0,1),Fe=1-this.crowding,Ie=this.scratch.copy(vx.relaxedLead).lerp(vx.tightLead,this.tight);Ie.x+=ie.lead.x*Fe,Ie.y+=ie.lead.y*Fe,Ie.z+=ie.lead.z*Fe*(1-this.tight*(1-ie.shell)),Ie.lerp(vx.guardHighLead,this.guardHigh).lerp(vx.guardLowLead,this.guardLow);let Le=this.scratchB.copy(vx.relaxedRear).lerp(vx.tightRear,this.tight).addScaledVector(ie.rear,Fe).lerp(vx.guardHighRear,this.guardHigh).lerp(vx.guardLowRear,this.guardLow);Ie.y-=this.tired*.12+this.stunAmount*.22+ae*.06,Le.y-=this.tired*.1+this.stunAmount*.2+ae*.05,Ie.y-=this.guardSpent*oT,Le.y-=this.guardSpent*oT,Ie.z-=this.guardSpent*.04,Le.z-=this.guardSpent*.03,Ie.z+=ue*.11+Math.sin(oe*2.3)*.012*u,Ie.x+=Math.sin(oe*1.9)*.01*u,Ie.y+=ue*.02+Math.sin(oe*1.27+1)*.008*u+me*.004,Le.y+=Math.cos(oe*2.7)*.006*u+me*.004,Le.x+=Math.sin(oe*1.13+2)*.004*u,Ie.z-=this.guardKick*.07,Le.z-=this.guardKick*.05,Ie.y-=this.guardKick*.02,Ie.add(Ne),Le.add(Ne),je.position.set(Ie.x*l,Ie.y,Ie.z),Me.position.set(Le.x*l,Le.y,Le.z),xx(vx.leadKnuckles,l,je.knuckles),xx(vx.leadPalm,l,je.palm),xx(vx.rearKnuckles,l,Me.knuckles),xx(vx.rearPalm,l,Me.palm),xx(vx.leadPole,l,je.pole),xx(vx.rearPole,l,Me.pole),je.pole.x*=1-.6*this.tight;let Re=Fe*(1-Pe);if(je.pole.x+=ie.flare*l*Re,Me.pole.x-=ie.flare*l*Re,ie.shell>0){let e=ie.shell*Re;je.knuckles.lerp(this.scratchD.set(-.8*l,.1,.6),e).normalize(),je.palm.lerp(this.scratchD.set(-.3*l,.35,-.9),e).normalize(),je.pole.lerp(this.scratchD.set(.5*l,-.8,-.35),e).normalize()}P.shouldersYaw+=F*.07*ue;let ze=vx.leadShrug+(.6-vx.leadShrug)*Pe+me*.12+ue*.2+ie.shrug*Re,Be=vx.rearShrug+(.5-vx.rearShrug)*Pe+me*.12+Math.min(0,ie.shrug)*Re;if(Pe>.001&&(je.pole.lerp(xx(vx.guardHighLeadPole,l,this.scratch),this.guardHigh).lerp(xx(vx.guardLowLeadPole,l,this.scratch),this.guardLow).normalize(),Me.pole.lerp(xx(vx.guardHighRearPole,l,this.scratch),this.guardHigh).lerp(xx(vx.guardLowRearPole,l,this.scratch),this.guardLow).normalize(),je.knuckles.lerp(xx(vx.guardKnuckles,l,this.scratch),Pe).normalize(),Me.knuckles.lerp(xx(vx.guardKnuckles,-l,this.scratch),Pe).normalize(),je.palm.lerp(xx(vx.guardPalm,l,this.scratch),Pe).normalize(),Me.palm.lerp(xx(vx.guardPalm,-l,this.scratch),Pe).normalize(),P.hips.y-=.03*this.guardHigh+.08*this.guardLow,P.spinePitch+=.05*this.guardHigh+.2*this.guardLow,P.headPitch+=.08*Pe),this.hurt&&this.applyHurtStance(r,l,je,Me,Ne),Math.abs(this.slip)>.001||this.weave>.001||this.pull>.001){let e=P.hips.x,t=P.hips.y,n=P.hips.z,r=P.spinePitch,i=P.spineRoll,a=P.shouldersYaw,o=this.slip;P.shouldersYaw+=o*.22,P.hipsYaw+=o*.1,this.leanHead(o*.18,0),P.hips.x+=o*.05,P.hips.y-=Math.abs(o)*.04;let s=this.weave,c=sw(this.weaveTime/hD,0,1),u=Math.sin(c*Math.PI),d=s*(1-2*c)*l;P.hips.y-=s*(.08+.14*u),P.hips.x+=d*.04,this.leanHead(d*.14,s*(.04+.06*u));let f=this.pull;P.hips.z-=f*.1,P.hips.y-=f*.03,this.leanHead(0,-f*.2),P.headPitch-=f*.06;let p=this.headTravel(this.scratch,e,t,n,r,i,a);je.position.add(p),Me.position.add(p)}this.punchCommit=aw(this.punchCommit,+!!this.punchActive,10,n);let Ve=this.crowding*(1-this.clinchWeight)*(1-this.punchCommit);if(Ve>.001&&(P.headOffset.x-=Ve*.075,P.headOffset.z-=Ve*.04,P.headYaw-=Ve*.2,P.spinePitch-=Ve*.07,P.hips.z-=Ve*.05,je.position.z-=Ve*.14,je.position.x-=Ve*.035*l,Me.position.z-=Ve*.07),Math.abs(this.headSpace.x)+Math.abs(this.headSpace.y)>.001){let e=this.headSpace.x,t=this.headSpace.y,n=1-this.clinchWeight;P.spinePitch+=t*.7*n,P.spineRoll-=e*.7*n,P.hips.z+=t*.1*n,P.hips.x+=e*.05*n,P.headOffset.x+=e*.05,P.headOffset.z+=t*.05,P.headPitch+=t*.2,P.headRoll-=e*.3}if(this.ropeLean=aw(this.ropeLean,this.referee||this.downState!==`up`?0:this.ropeLeanTarget,Tw,n),this.ropeLean>.001){let e=this.ropeLocal.copy(this.ropeOutward).applyAxisAngle(XE,-this.yaw);P.hipsPitch+=e.z*Cw*this.ropeLean,P.hipsRoll-=e.x*ww*this.ropeLean}if(this.referee||this.applyReactions(je,Me,ye,be),this.punchActive){let e=this.applyPunch(l,je,Me,ye,be,Ne);this.punchReach=e,this.punchHand===`left`==l>0?ze=Math.max(ze,e):Be=Math.max(Be,e)}if(this.referee&&(ze=Be=this.applyRefereePose(l,je,Me,ye,be,r,o,n,e.stunned_ticks),this.applyReactions(je,Me,ye,be)),this.clinchWeight>.001&&this.applyClinchPose(this.clinchWeight,r,l,e,t,je,Me,Ne),this.foulWeight>.001){let e=this.foulWeight;P.hips.y-=e*.16,P.spinePitch+=e*.55,P.headPitch+=e*.2,je.position.lerp(this.scratch.set(.06*l,.72,.16),e),Me.position.lerp(this.scratch.set(-.05*l,.7,.14),e),je.pole.set(.6*l,-.6,.5),Me.pole.set(-.6*l,-.6,.5)}if(this.tauntWeight>.001){let e=this.tauntEnd===null?0:sw(this.tauntEnd-o,0,iT);this.applyTauntPose(this.tauntWeight,(iT-e)/iT*aT,l,je,Me,Ne)}if(this.dislocation===`shoulder_left`||this.dislocation===`shoulder_right`){let e=this.dislocation===`shoulder_left`?this.hand.L:this.hand.R,t=this.dislocation===`shoulder_left`?1:-1;e.position.set(.24*t,.55,.05),e.pole.set(.9*t,-.3,.2),e.knuckles.set(0,-1,.1),e.palm.set(-t,0,.2)}this.winded>.001&&(this.downState===`up`||E)&&this.applyWindedPose(this.winded,r,l,je,Me),this.hurt&&this.downState===`up`&&this.applyHurtActs(r,l,ye,be),this.touchWeight>.001&&this.downState===`up`&&this.applyTouchGlovesPose(this.touchWeight,l,je,Me),this.celebration>.001&&this.downState===`up`&&this.applyCelebratePose(this.celebration,r,l,je,Me,ye,be),this.wave>.001&&this.downState===`up`&&this.applyWaveOffPose(this.wave,r,l,je,Me),this.squareWeight>.001&&this.downState===`up`&&(this.applyVerdictPose(this.squareWeight,r,l,je,Me,ye,be,Ne),ye.heel*=1-this.squareWeight,be.heel*=1-this.squareWeight,ze=L.lerp(ze,this.breath*.15,this.squareWeight),Be=L.lerp(Be,this.breath*.15,this.squareWeight)),(this.wristWeights[0]>.001||this.wristWeights[1]>.001)&&this.downState===`up`&&this.applyRaisePose(l,je,Me),this.breakWeight>.001&&this.downState===`up`&&this.applyBreakPose(this.breakWeight,l,je,Me),this.attendWeight>.001&&this.downState===`up`&&this.applyAttendPose(this.attendWeight,r,l,je,Me),this.treatWeight>.001&&this.downState===`up`&&this.applyTreatPose(this.treatWeight,r,l,je,Me,ye,be),this.seated>.001&&this.downState===`up`&&this.applySeatedPose(this.seated,r,l,je,Me,ye,be),this.downState!==`up`&&this.applyDownPose(l,je,Me,ye,be),this.steadyJointPoles(l,je,Me,ye,be,n),ke=0;let He=this.pose;He.shrugL=l>0?ze:Be,He.shrugR=l>0?Be:ze;let Ue=this.ragdoll;if(Ue?.active===!0&&i&&(Ue.stop(),Ue.clearRise()),Ue?.active===!0&&!Ue.handingOver)Ue.setLost(c.isDecapitated,c.isHandDismembered(`left`),c.isHandDismembered(`right`)),Ue.update(n,this.obstacle),this.hurt&&this.dropDangles();else{if(this.solver.apply(c.root,this.pose),Ue?.handingOver===!0)Ue.followPose(n,this.obstacle),this.riseProgress>=kw&&Ue.handOverSeconds>=Rw&&(Ue.letGo(),this.riseBlendAge=0);else if(Ue!==null&&Ue.hasRisePose){let e=rx(0,Lw,this.riseBlendAge);e<1&&this.downState!==`up`?Ue.blendRise(e):Ue.clearRise()}this.hurt&&this.dangleArms(n),Ue?.sample(n)}this.applyDislocation();let We=Math.min(1,(t.trauma.bleeding+t.trauma.left_cut+t.trauma.right_cut+t.trauma.head/4)/300*(a===`off`?0:a===`reduced`?.15:1.5));c.setGloveBlood(We),c.setTrunksBlood(u_(e.trauma,a)),l_(c.headInjury,e.trauma,a),d_(c.bodyInjury,e.trauma,a),c.setSkinClearcoat(.25+(1-O)*.4),this.laidOut=!1}applyTauntPose(e,t,n,r,i,a){let o=this.torso,s=.5-.5*Math.cos(t*Math.PI*2);i.position.lerp(this.scratch.set(-.3*n,a.y-.62,.02),e),i.pole.lerp(this.scratch.set(-.5*n,-.4,-.75),e).normalize(),i.knuckles.lerp(this.scratch.set(-.1*n,-.95,.3),e).normalize(),i.palm.lerp(this.scratch.set(0,.3,.95),e).normalize(),r.position.lerp(this.scratch.set(.26*n,a.y-.36+s*.1,.52-s*.24),e),r.pole.lerp(this.scratch.set(.7*n,-.7,.1),e).normalize(),r.knuckles.lerp(this.scratch.set(.1*n,.25+s*.6,.95-s*.7),e).normalize(),r.palm.lerp(this.scratch.set(-.2*n,.95,-.2-s*.5),e).normalize(),o.spinePitch-=e*.12,o.headPitch-=e*.22,o.headYaw+=Math.sin(t*Math.PI)*.15*e,o.shouldersYaw+=Math.sin(t*Math.PI*3)*.1*e,o.hips.x+=Math.sin(t*Math.PI)*.03*e*n,o.headOffset.z+=e*.03}applyClinchPose(e,t,n,r,i,a,o,s){let c=this.torso,l=r.player_idy&&(h.x*=y/v,h.z*=y/v),h.x+=o,h.z+=u,t.position.lerp(h,e),t.pole.lerp(this.clinchTemp.set(r*.85,l?.35:-.6,.25),e).normalize(),t.knuckles.lerp(this.clinchTemp.set(-p*r*.9+f.x*.3,l?-.25:.1,-m*r*.9+f.z*.3),e).normalize(),t.palm.lerp(this.clinchTemp.set(-f.x,l?.1:.35,-f.z),e).normalize()}}holdOnTheRopes(e,t,n){if(this.referee)return this.ropeLeanTarget=0,this.ropeHold.set(0,0,0);this.ropeLeanTarget=Ew(t,n,this.ropeExcess,this.ropeOwn);let r=Math.hypot(this.ropeExcess.x,this.ropeExcess.z);r>0&&this.ropeOutward.set(this.ropeExcess.x/r,0,this.ropeExcess.z/r);let i=this.mapping.x(e.x),a=this.mapping.z(e.y);Ew(i,a,this.ropeTheirs,this.ropeTheirs);let o=1-rx(yw,bw,Math.hypot(i-t,a-n));return this.ropeHold.set(Dw(this.ropeOwn.x,this.ropeTheirs.x*o),0,Dw(this.ropeOwn.z,this.ropeTheirs.z*o))}headRestChar(e){let t=this.boxer.rig.metrics;return this.headWorld.set(-.08,t.headHeight-t.hipsHeight+this.torso.hips.y,.02)}syncAction(e,t,n,r){this.shownFighter=e,this.shownOpponent=t;let i=this.ownQueued;if(i!==null&&e.action_id===i.action.id&&(this.ownQueued=null,this.retirePunch(),this.startOwnPunch(i),this.ownPress=!1),e.action_id!==null&&e.action_id!==this.actionId&&e.action_id!==this.completedActionId&&!this.retiredOwnIds.includes(e.action_id)){let t=e.action;if(t!==null){let r=e.action_hand??(e.stance===`orthodox`?`left`:`right`),i=this.ownActionId===e.action_id&&this.punchActive,a=this.punchTiming;this.actionId=e.action_id,this.punchClass=t,this.punchHand=r,this.punchTarget=e.action_target??`head`,this.punchPower=e.action_power??`normal`,this.punchTiming={...se(this.punchClass,this.punchTarget,this.punchPower),startup:e.action_startup_ticks,active:e.action_active_ticks,recovery:e.action_recovery_ticks},this.punchTotalTicks=Math.max(1,e.action_startup_ticks+e.action_active_ticks+e.action_recovery_ticks);let o=Math.max(0,n-e.action_start_tick);i?(this.punchAgeTicks=yD(this.punchAgeTicks,a,this.punchTiming),this.ownAuthoritativeAge=o,this.ownRefused||(this.ownPulled=!1,this.ownCut=!1,o-this.punchAgeTicks>1&&(this.punchAgeTicks=o))):(this.punchAgeTicks=o,this.ownActionId=null,this.ownPress=!1,this.ownLeadTicks=0,this.ownAuthoritativeAge=null),this.ownWaitedTicks=0,this.punchActive=!0}}if(e.action_id===null)this.actionId=null,this.completedActionId=null;else if(e.action_id===this.actionId&&this.punchActive){let t=Math.max(0,n-e.action_start_tick);this.ownActionId===this.actionId?(this.ownAuthoritativeAge=t,!this.ownPulled&&t-this.punchAgeTicks-this.hitstopLag>1.5&&(this.punchAgeTicks=t)):Math.abs(this.punchAgeTicks+this.hitstopLag-t)>1.5&&(this.punchAgeTicks=t,this.hitstopLag=0)}if(this.punchActive&&this.ownActionId!==null&&this.ownAuthoritativeAge===null&&!this.ownPulled&&!this.ownCut&&(this.ownWaitedTicks+=r*30,this.ownWaitedTicks>this.ownExpectedTicks*1.5+QE&&(this.ownPress?!this.ownStarted:this.punchAgeTicks=e,n=this.hitstop>0?0:Math.min(this.hitstopLag,r*30*tD);this.hitstopLag-=n,this.punchAgeTicks+=r*30*(t?eD:this.ownPunchRate())+n,this.ownPress&&this.ownActionId!==null&&!this.ownCut&&this.punchAgeTicks>=this.punchTiming.startup&&this.pressesLanded.at(-1)!==this.ownActionId&&(this.pressesLanded.push(this.ownActionId),this.pressesLanded.length>6&&this.pressesLanded.shift()),this.punchAgeTicks>=this.punchTotalTicks&&this.retirePunch()}e.is_downed&&(this.punchActive&&this.retirePunch(),this.ownQueued=null),this.releaseQueuedPress(r);let a=this.actionId??this.ownActionId;a!==this.aimActionId&&(this.aimActionId=a,this.followHead=0),this.followHead=aw(this.followHead,+(a!==null&&a===this.contactId),_D,r),this.followReferee=aw(this.followReferee,+(a!==null&&a===this.refereeContactId),_D,r)}trackOpponentHead(e,t,n){let r=this.guardOpponentHead.set(this.mapping.x(e.x),0,this.mapping.z(e.y));this.opponentSteadySeconds=pD.has(e.defense)?0:this.opponentSteadySeconds+n,(!this.hasLiveHead||this.opponentSteadySeconds>=gD)&&this.opponentHeadOffset.copy(t).sub(r),r.add(this.opponentHeadOffset),this.liveOpponentHead.copy(t),this.hasLiveHead=!0}ownPunchRate(){if(this.ownActionId===null||this.ownPress)return 1;let e=this.punchTiming.startup,t=this.ownAuthoritativeAge;return t===null?this.punchAgeTicks0,_=g?t:n,v=g?n:t,y=(g?1:-1)*e,b=+(this.punchPower===`power`),x=+(this.punchTarget===`body`),S,C,w,T=1,E=1,D=0,O=1,k=1,A=0,j=0;if(ue&&Ne.set(Ne.x*e/t,Ne.y,Ne.z*e/t),Ne.add(ke)}else Ne.multiplyScalar(Math.min(1,je/Math.max(1e-6,n))).add(ke)}if(pe>i.heel&&(i.heel+=(pe-i.heel)*O),me>r.heel&&(r.heel+=(me-r.heel)*O),ge>0){let t=this.scratchQ.setFromAxisAngle(XE,-ge*e*O);r.toe.applyQuaternion(t),r.pole.applyQuaternion(t)}if(he>0){let t=this.scratchQ.setFromAxisAngle(XE,he*e*O);i.toe.applyQuaternion(t),i.pole.applyQuaternion(t)}let Fe=this.scratchE;switch(m){case`hook`:Fe.set((.1+.03*b)*y,-.05,-.06);break;case`uppercut`:Fe.set(.03*y,-.26,-.04);break;case`straight`:Fe.set(.02*y,-.02,-.04-.05*b);break;default:Fe.set(0,-.01,-.02-.07*b)}Fe.y-=.05*b,Fe.z-=(h?.07:.12)*b;let Ie=this.punchStart.copy(re).addScaledVector(Fe,Math.max(C,h?(1-M)*.6*T:0)),Le=j*this.punchMiss;if(m===`hook`){let e=Math.hypot(Ie.x-ke.x,Ie.z-ke.z),t=Math.hypot(Ne.x-ke.x,Ne.z-ke.z),n=this.punchSweepFrom.copy(Ie).sub(ke).setY(0).normalize(),r=this.punchSweepTo.copy(Ne).sub(ke).setY(0).normalize(),i=Math.acos(sw(n.dot(r),-1,1)),a=n.z*r.x-n.x*r.z>=0?1:-1,o=rx(0,1,M),s=n.applyAxisAngle(XE,(i*o+.5*Le)*a).normalize();_.position.copy(ke).addScaledVector(s,L.lerp(e,t,o)),_.position.y=L.lerp(Ie.y,Ne.y,o),_.pole.set(.9*y,.2+.5*(1-x),.25).normalize(),_.knuckles.copy(s).applyAxisAngle(XE,a*Math.PI/2).setY(.05).normalize(),_.palm.set(0,-1,0)}else if(m===`uppercut`){let e=rx(0,1,M),t=this.punchMid.set(Ie.x+(Ne.x-Ie.x)*.6,Math.min(Ie.y,Ne.y-.12),Ie.z+(Ne.z-Ie.z)*.75);_.position.copy(Ie).multiplyScalar((1-e)*(1-e)).addScaledVector(t,2*(1-e)*e).addScaledVector(Ne,e*e),_.position.y+=.05*A+.14*Le,_.pole.set(.3*y,-1,-.1).normalize(),_.knuckles.set(.05*y,.9,.35).normalize(),_.palm.set(-.2*y,.3,-.95).normalize()}else{_.position.copy(Ie).lerp(Ne,Math.min(1,M)).addScaledVector(Ae,.14*Le),_.position.y+=Math.sin(sw(M,0,1)*Math.PI)*.025,_.pole.set(.55*y,-.9,.35);let e=rx(.55,1,M);_.knuckles.copy(Ae).lerp(this.scratchC.set(.1*y,.55,.8),1-e).normalize(),_.palm.set(-.9*y,.2,-.3).lerp(this.scratchC.set(0,-1,.1),e).normalize()}if(te>0&&(_.position.lerp(re,te),_.knuckles.lerp(ie,te).normalize(),_.palm.lerp(ae,te).normalize(),_.pole.lerp(oe,te).normalize()),E<1){let e=(1-_.pole.dot(oe)/Math.max(1e-6,_.pole.length()*oe.length()))/2,t=Math.sin(Math.PI*E);_.knuckles.lerp(ie,1-E).normalize(),_.palm.lerp(ae,1-E).normalize(),_.pole.lerp(oe,1-E).addScaledVector(this.scratchC.set(y,0,0),vD*e*t*t).normalize()}let Re=this.scratchE.set(-.11*y,a.y-.13,.13+a.z);v.position.lerp(Re,Math.max(k,ee)*.8).add(this.headTravel(this.scratchC,ye,be,xe,Se,Ce,we));let ze=this.hasLiveHead?rx(.08,.2,this.guardOpponentHead.distanceTo(this.liveOpponentHead))*(1-this.followHead):0;return this.punchMiss=Math.max(rx(.02,.12,Pe),ze),ee}hurtRandom(){return this.hurtSeed=Math.imul(this.hurtSeed,1664525)+1013904223>>>0,this.hurtSeed/4294967296}applyReactions(e,t,n,r){let i=this.torso,a=this.headKick.value;i.headOffset.addScaledVector(a,.4),this.leanHead(a.x*.6,a.z*.6),i.headPitch+=a.z*2.6-a.y*2,i.headYaw+=a.x*2.6,i.headRoll+=-a.x*1.1,i.shouldersYaw+=this.torsoKick.value.y,i.hipsYaw+=this.torsoKick.value.y*.4,i.spinePitch+=this.torsoKick.value.x,i.spineRoll+=this.torsoKick.value.z*.5,i.hips.x+=this.rootKick.value.x,i.hips.z+=this.rootKick.value.z,i.hips.y-=Math.max(0,this.torsoKick.value.x)*.08,this.torsoKick.value.x>.05&&(e.position.y-=this.torsoKick.value.x*.25,t.position.y-=this.torsoKick.value.x*.2,e.position.z-=this.torsoKick.value.x*.1);let o=Math.max(0,this.rootKick.value.y);i.hips.y+=this.downState===`up`?this.rootKick.value.y:o,n.heel+=o*6,r.heel+=o*6;let s=this.coverKick.value.x;if(Math.abs(s)>.002){let e=s>0?this.hand.R:this.hand.L;e.position.y-=Math.abs(s)*.9,e.position.x+=s*.2,e.position.z-=Math.abs(s)*.25,e.pole.y-=Math.abs(s)*3}let c=this.hand.L.position,l=this.hand.R.position;c.add(this.armKick.value),l.addScaledVector(this.armKick.value,.8);let u=rx(0,1,this.handsDrop);c.set(c.x+.07*u,c.y-.24*u,c.z-.04*u),l.set(l.x-.07*u,l.y-.22*u,l.z-.03*u),i.hips.y-=this.guardKick*.02;let d=this.downState===`up`&&!this.referee?this.stunAmount:0;if(d>.01){let e=this.rockedTime,t=this.rockedPhase,n=Math.max(0,Math.sin(e*3.3+t)*Math.sin(e*1.9+t*1.7)),r=.5+.5*Math.sin(e*1.1+t*1.7);i.hips.y-=d*(.02+.08*n),i.hips.x+=d*.04*Math.sin(e*2.1+t*2.9),i.hips.z+=d*.03*Math.sin(e*1.3+t),i.headRoll+=d*.2*Math.sin(e*2.1+t*2.9-1.1),i.headPitch+=d*.1*Math.sin(e*1.3+t-.9),c.set(c.x+d*.07*r,c.y-d*.05*r,c.z),l.set(l.x-d*.07*r,l.y-d*.08*(1-r),l.z)}}legRoom(e,t){let n=this.torso,r=e.position.x-n.hips.x-t*$b.x*Math.cos(n.hipsYaw),i=e.position.z-n.hips.z+t*$b.x*Math.sin(n.hipsYaw);return e.position.y+Math.sqrt(Math.max(.04,Gw*Gw-r*r-i*i))-$b.y}applyRefereePose(e,t,n,r,i,a,o,s,c=0){let l=this.torso,u=L.lerp,d=this.countWeight=aw(this.countWeight,+!!this.refereeCounting,5,s),f=Math.sin(a*.7)*.08,p=this.refereeCounting?.75:.06;if(this.breakAimed){let e=W.copy(this.watching?this.watchPoint:this.breakFighters[Math.sin(this.weightPhase*.32)+Math.sin(this.weightPhase*.125)>0?0:1]);this.watching||(e.y=qw-.1),e.x-=this.rootX??0,e.z-=this.rootZ,e.applyAxisAngle(XE,-this.yaw),f=sw(Math.atan2(e.x,e.z),-1,1)*.85,p=sw(Math.atan2(qw-e.y,Math.hypot(e.x,e.z)),-.2,.85)}this.gazeYaw=aw(this.gazeYaw,f,6,s),this.gazePitch=aw(this.gazePitch,p,6,s);let m=d*rx(.2,.6,this.gazePitch),h=Math.sin(a*1.6),g=Math.sin(this.weightPhase*.35)*.02+Math.sin(this.weightPhase*.9+1)*.006,_=Math.hypot(this.travel.x,this.travel.z),v=Math.min(1,_/.4);l.hipsYaw=this.strideYaw*.7,l.shouldersYaw=this.strideYaw*.2+this.gazeYaw*.25,l.hipsPitch=.04+m*.2,l.hipsRoll=0,l.spinePitch=.1+h*.008+sw(this.travel.z,-1,1.5)*.04+d*.06+m*.3,l.spineRoll=-g*.6-this.travel.x*.03,l.headYaw=this.gazeYaw,l.headPitch=.04+this.gazePitch,l.headRoll=0,l.hips.set(g,0,-m*.1);let y=this.footYaw[e>0?0:1]-this.yaw,b=this.footYaw[+(e>0)]-this.yaw;r.toe.set(Math.sin(y),0,Math.cos(y)),i.toe.set(Math.sin(b),0,Math.cos(b)),r.pole.copy(r.toe).setY(.3).normalize(),i.pole.copy(i.toe).setY(.3).normalize();let x=_>.001?v/_:0;r.heel=sw((-(r.position.x*this.travel.x+r.position.z*this.travel.z)*x-.08)*3.5,0,.75),i.heel=sw((-(i.position.x*this.travel.x+i.position.z*this.travel.z)*x-.08)*3.5,0,.75);let S=((r.position.x-i.position.x)*this.travel.x+(r.position.z-i.position.z)*this.travel.z)*(x/Math.max(_,.001))*.1;l.hips.y=Math.max(Ww-.14,Math.min(Ww-m*.05,this.legRoom(r,e),this.legRoom(i,-e)));let C=l.hips.y+.24+h*.004;if(t.position.set(.16*e-this.travel.x*S,C,.3-this.travel.z*S),n.position.set(-.16*e+this.travel.x*S,C-.015,.28+this.travel.z*S),t.pole.set(.7*e,-.5,-.5).normalize(),n.pole.set(-.7*e,-.5,-.5).normalize(),t.knuckles.set(-.35*e,.05,.9).normalize(),n.knuckles.set(.35*e,.05,.9).normalize(),t.palm.set(-.65*e,-.75,.05).normalize(),n.palm.set(.65*e,-.75,.05).normalize(),d>.001){if(this.refereeCounting){this.countChangedTick??=o;let e=sw((o-this.countChangedTick)/ee,0,1);this.countPump=e.001&&(l.spinePitch=u(l.spinePitch,-.04,w),t.position.lerp(W.set(.32*e,l.hips.y+.6,.2),w),n.position.lerp(W.set(-.32*e,l.hips.y+.6,.2),w),t.knuckles.lerp(W.set(.1*e,1,.1),w).normalize(),n.knuckles.lerp(W.set(-.1*e,1,.1),w).normalize(),t.palm.lerp(W.set(0,.1,1),w).normalize(),n.palm.lerp(W.set(0,.1,1),w).normalize(),t.pole.lerp(W.set(.6*e,-.8,-.1),w).normalize(),n.pole.lerp(W.set(-.6*e,-.8,-.1),w).normalize()),c>0){let r=Math.min(1,c/12),i=Math.sin(a*9.5);l.hips.y-=.09*r,l.hips.x+=i*.05*r,l.spineRoll+=i*.18*r,l.headRoll-=i*.35*r,l.headPitch+=.25*r,t.position.x+=.18*e*r,n.position.x-=.18*e*r,t.position.y-=.1*r,n.position.y-=.1*r}return .05+h*.025}updateDownState(e,t,n,r){if(this.riseBlendAge+=t,e.is_downed||this.forcedDown||this.dead){if(this.downState===`up`||this.downState===`rising`||this.deathFall)this.deathFall=!1,this.fallFromGetUp=this.downState!==`up`,this.fallFromGetUp&&(HE(this.fallStart,this.downResult),this.fallStartStand=this.downStand),this.downState=`falling`,this.fallAge=0,this.riseProgress=0,this.riseRootFrom.copy(this.riseRoot),this.landSettled=!1,this.fallenFromPhysics=!1,this.downPolesSet=!1,this.ragdoll?.clearRise(),this.authoredNextFall?this.ragdoll?.forget():n||this.startFall(e),this.authoredNextFall=!1;else if(this.downState===`falling`)this.fallAge+=t,this.fallAge>=Ow&&(this.downState=`down`);else if(this.fallKneel)this.riseProgress=Aw;else{let n=(!this.forcedDown&&!this.heldDown&&!this.dead&&e.get_up_required>0?sw(e.get_up_meter/e.get_up_required,0,1):0)*Aw;if(this.ragdoll?.active===!0&&!this.ragdoll.handingOver){if(n<=0)return;this.handOverFall(e)}this.riseProgress+=sw(n-this.riseProgress,-.4*t,Nw*t)}return}if((this.downState===`down`||this.downState===`falling`)&&(this.downState=`rising`,this.ragdoll?.active===!0&&!this.ragdoll.handingOver&&this.handOverFall(e),this.fallKneel&&(this.riseProgress=Math.max(this.riseProgress,Aw)),this.riseFrom=this.riseProgress,this.feetInitialized=!1),this.downState!==`rising`)return;let i=r>.3||this.punchActive,a=(1-this.riseFrom)/(i?Mw:jw);this.riseProgress=Math.min(1,this.riseProgress+(this.riseProgress=1&&(this.downState=`up`,this.fallKneel=!1)}startFall(e){let t=this.ragdoll;t!==null&&(this.rootX!==null&&Math.hypot(this.place.x-this.rootX,this.place.z-this.rootZ)>zw&&(this.rootX=this.place.x,this.rootZ=this.place.z,this.boxer.root.position.set(this.rootX,0,this.rootZ)),t.start(this.dead?this.deathStyle:`crumple`),e.get_up_count>0&&!this.dead&&(t.settle(),this.fallAge=Ow))}handOverFall(e){let t=this.ragdoll;if(t===null||!t.active||t.handingOver)return;let n=e.stance===`orthodox`?1:-1,r=this.boxer.rig.bones;this.boxer.root.updateMatrixWorld(!0);let i=this.scratchC.set(this.rootX??0,0,this.rootZ),a=this.scratchQ.setFromAxisAngle(XE,-this.yaw),o=this.fallen,s=(e,t)=>t.setFromMatrixPosition(e.matrixWorld).sub(i).applyQuaternion(a),c=(e,t,n,r)=>NE(vE.setFromQuaternion(e.getWorldQuaternion(_E).premultiply(a),`YXZ`),t,n,r);s(r.hips,o.hips),this.landProne=t.faceDown();let l=Math.abs(o.hips.x)>.12?Math.sign(o.hips.x):0,u=this.landProne?kE(this.downTo,TE,EE,n,l,this.boxer.rig.metrics.ankleHeight):kE(this.downTo,CE,wE,n,l,this.boxer.rig.metrics.ankleHeight);this.landSide=l,this.landShift.set(o.hips.x-u.hips.x,0,o.hips.z-u.hips.z);let d=c(r.hips,u.hipsPitch,u.hipsYaw,u.hipsRoll);o.hipsPitch=d.x,o.hipsYaw=d.y,o.hipsRoll=d.z;let f=c(r.upperChest,o.hipsPitch,o.hipsYaw,o.hipsRoll);o.shouldersYaw=f.y,o.spinePitch=f.x-o.hipsPitch,o.spineRoll=f.z-o.hipsRoll;let p=c(r.head,f.x,f.y,f.z);o.headPitch=p.x,o.turn=p.y,o.headRoll=p.z,s(n>0?r.gloveL:r.gloveR,o.leadHand),s(n>0?r.gloveR:r.gloveL,o.rearHand),s(n>0?r.ankleL:r.ankleR,o.leadFoot),s(n>0?r.ankleR:r.ankleL,o.rearFoot);let m=this.boxer.rig.metrics.ankleHeight;o.leadFoot.y=Math.max(o.leadFoot.y,m),o.rearFoot.y=Math.max(o.rearFoot.y,m);let h=(e,t,n,r,i)=>{let o=s(e,this.scratchB),c=s(n,this.scratchD).sub(o).normalize();s(t,r).sub(o),r.addScaledVector(uE.copy(i).applyQuaternion(e.getWorldQuaternion(_E)).applyQuaternion(a),gE),r.addScaledVector(c,-r.dot(c)),r.lengthSq()>1e-6?r.normalize():r.copy(i===pE?dE:fE)},g=n>0;h(g?r.hipL:r.hipR,g?r.kneeL:r.kneeR,g?r.ankleL:r.ankleR,o.leadKnee,pE),h(g?r.hipR:r.hipL,g?r.kneeR:r.kneeL,g?r.ankleR:r.ankleL,o.rearKnee,pE),h(g?r.shoulderL:r.shoulderR,g?r.elbowL:r.elbowR,g?r.gloveL:r.gloveR,o.leadElbow,g?mE:hE),h(g?r.shoulderR:r.shoulderL,g?r.elbowR:r.elbowL,g?r.gloveR:r.gloveL,o.rearElbow,g?hE:mE);let _=(e,t,n)=>{let r=e.getWorldQuaternion(_E).premultiply(a);t.set(0,1,0).applyQuaternion(r),n.set(0,0,1).applyQuaternion(r)};_(g?r.gloveL:r.gloveR,o.leadKnuckles,o.leadPalm),_(g?r.gloveR:r.gloveL,o.rearKnuckles,o.rearPalm),o.ownJoints=1,o.leadHeel=0,o.rearHeel=0,o.palmsDown=+!!this.landProne,this.fallenFromPhysics=!0,this.landSettled=!0,this.downPolesSet=!1,t.handOver(),this.riseBlendAge=0;let v=this.scratchE.set(t.pelvis(this.scratchD).x-(this.rootX??0),0,this.scratchD.z-this.rootZ),y=this.scratchB.copy(v).applyQuaternion(a);for(let e of[o.hips,o.leadHand,o.rearHand,o.leadFoot,o.rearFoot])e.x-=y.x,e.z-=y.z;t.shiftRise(this.scratchC.copy(v).negate()),this.rootX=(this.rootX??0)+v.x,this.rootZ+=v.z,this.boxer.root.position.set(this.rootX,0,this.rootZ),this.riseRoot.set(this.rootX-this.mapping.x(e.x)-this.touchOffset.x,0,this.rootZ-this.mapping.z(e.y)-this.touchOffset.z),this.riseRootFrom.copy(this.riseRoot)}walkBackFromTheFall(e){let t=this.downState===`rising`?1-rx(Aw,1,this.riseProgress):this.downState===`up`?0:1,n=this.riseRootFrom.x*t,r=this.riseRootFrom.z*t;e>0?this.riseRootVelocity.set((n-this.riseRoot.x)/e,0,(r-this.riseRoot.z)/e):this.riseRootVelocity.set(0,0,0),this.riseRoot.set(n,0,r),t===0&&this.riseRootFrom.set(0,0,0)}steadyJointPoles(e,t,n,r,i,a){if(this.poleSettle=this.downState===`up`?Math.max(0,this.poleSettle-a):Iw,this.poleSettle<=0||this.ragdoll?.active===!0&&!this.ragdoll.handingOver){this.downPolesSet=!1;return}let o=this.boxer.rig.bones,s=e>0;this.characterInverse.copy(this.boxer.root.matrixWorld).invert();for(let e=0;e<4;e+=1){let c=e<2,l=e%2==0,u=l===s,d=c?u?o.hipL:o.hipR:u?o.shoulderL:o.shoulderR,f=c?l?r:i:l?t:n,p=f.position,m=f.pole,h=this.downPoles[e];if(!this.downPolesSet){h.copy(m);continue}let g=this.scratchB.setFromMatrixPosition(d.matrixWorld).applyMatrix4(this.characterInverse).sub(p).negate();if(g.lengthSq()<1e-6){h.copy(m);continue}g.normalize();let _=this.scratchD.copy(h).addScaledVector(g,-h.dot(g)),v=this.scratchE.copy(m).addScaledVector(g,-m.dot(g));if(_.lengthSq()<1e-4||v.lengthSq()<1e-4){h.copy(m);continue}let y=Math.atan2(this.scratch.crossVectors(_,v).dot(g),_.dot(v)),b=Fw*Math.max(a,1/120);Math.abs(y)<=b||m.copy(_.normalize().applyAxisAngle(g,Math.sign(y)*b)),h.copy(m)}this.downPolesSet=!0}applyWindedPose(e,t,n,r,i){let a=this.torso,o=L.lerp,s=this.windedSide,c=Math.sin(t*23)*.006;a.hips.y=o(a.hips.y,vx.hipsHeight-.1,e),a.hips.z=o(a.hips.z,-.04,e),a.hipsPitch=o(a.hipsPitch,.2,e),a.spinePitch=o(a.spinePitch,.62+c,e),a.spineRoll=o(a.spineRoll,s*.16,e),a.headPitch=o(a.headPitch,.38,e);let l=s>0?this.hand.L:this.hand.R,u=l===r?i:r;l.position.lerp(W.set(s*.13,.98,.17),e),l.palm.lerp(W.set(-s*.6,0,-.8),e).normalize(),l.knuckles.lerp(W.set(-s*.5,.5,.2),e).normalize(),l.pole.lerp(W.set(s*.9,-.3,-.3),e).normalize(),u.position.lerp(W.set(-s*.2,.86,.3),e),u.pole.lerp(W.set(-s*.8,-.6,0),e).normalize()}applyTouchGlovesPose(e,t,n,r){let i=this.torso,a=L.lerp;i.hips.z=a(i.hips.z,.06,e),i.hipsYaw=a(i.hipsYaw,i.hipsYaw*.4,e),i.shouldersYaw=a(i.shouldersYaw,0,e),i.spinePitch=a(i.spinePitch,.12,e),i.headPitch=a(i.headPitch,.1,e),n.position.lerp(W.set(.11*t,1.24,.5),e),r.position.lerp(W.set(-.11*t,1.22,.47),e),n.palm.lerp(W.set(-t,0,0),e).normalize(),r.palm.lerp(W.set(t,0,0),e).normalize(),n.knuckles.lerp(W.set(0,.15,1),e).normalize(),r.knuckles.lerp(W.set(0,.15,1),e).normalize(),n.pole.lerp(W.set(.7*t,-.7,0),e).normalize(),r.pole.lerp(W.set(-.7*t,-.7,0),e).normalize()}touchWalk(e,t,n,r){this.countdownEnd=GE(this.countdownEnd,r,this.countdownTicks);let i=this.countdownEnd===null?0:KE(this.countdownEnd-r),a=this.mapping.x(t.x)-this.mapping.x(e.x),o=this.mapping.z(t.y)-this.mapping.z(e.y),s=Math.hypot(a,o),c=s>Qw?(s-Qw)/2/s*i:0;return this.touchVelocity.set(a*c-this.touchOffset.x,0,o*c-this.touchOffset.z).divideScalar(Math.max(n,.001)).clampLength(0,rT),this.touchOffset.set(a*c,0,o*c)}applyCelebratePose(e,t,n,r,i,a,o){let s=this.torso,c=L.lerp,l=Math.sin(t*6)*.04;s.hips.y=c(s.hips.y,vx.hipsHeight+.035+l*.5,e),s.hipsYaw=c(s.hipsYaw,0,e),s.hipsPitch=c(s.hipsPitch,-.12,e),s.hipsRoll=c(s.hipsRoll,0,e),s.shouldersYaw=c(s.shouldersYaw,0,e),s.spinePitch=c(s.spinePitch,-.1,e),s.headPitch=c(s.headPitch,-.25,e),r.position.lerp(W.set(.3*n,1.86+l,.08),e),i.position.lerp(W.set(-.3*n,1.84+l,.06),e),r.palm.lerp(W.set(0,0,1),e).normalize(),i.palm.lerp(W.set(0,0,1),e).normalize(),r.knuckles.lerp(W.set(.15*n,1,0),e).normalize(),i.knuckles.lerp(W.set(-.15*n,1,0),e).normalize(),r.pole.lerp(W.set(n,.1,-.3),e).normalize(),i.pole.lerp(W.set(-n,.1,-.3),e).normalize(),a.heel=c(a.heel,.45,e),o.heel=c(o.heel,.45,e)}kneelLegs(e,t,n,r,i){let a=L.lerp;n.position.x=a(n.position.x,.24*t,e),n.position.z=a(n.position.z,i+.3,e),r.position.x=a(r.position.x,-.18*t,e),r.position.z=a(r.position.z,i-.66,e),n.heel=a(n.heel,0,e),r.heel=a(r.heel,1.25,e),n.toe.lerp(this.treatScratch.set(.2*t,0,1),e).normalize(),r.toe.lerp(this.treatScratch.set(-.1*t,0,1),e).normalize(),n.pole.lerp(this.treatScratch.set(.25*t,.4,1),e).normalize(),r.pole.lerp(this.treatScratch.set(-.05*t,-.8,.6),e).normalize()}applyAttendPose(e,t,n,r,i){let a=this.torso,o=L.lerp,s=Math.sin(t*3.1)*.5+Math.sin(t*5.3+1)*.5;a.hips.z=o(a.hips.z,.12,e),a.hips.y=o(a.hips.y,Ww-.06,e),a.hipsPitch=o(a.hipsPitch,.3,e),a.spinePitch=o(a.spinePitch,.42,e),a.headPitch=o(a.headPitch,.4+s*.05,e),a.headYaw=o(a.headYaw,Math.sin(t*1.3)*.08,e),r.position.lerp(W.set(.2*n,1.36+s*.06,.6+s*.04),e),i.position.lerp(W.set(-.14*n,1.23,.6),e),r.palm.lerp(W.set(-.8*n,-.2,.5),e).normalize(),i.palm.lerp(W.set(0,-.9,.3),e).normalize(),r.knuckles.lerp(W.set(.1*n,.5,1),e).normalize(),i.knuckles.lerp(W.set(.8*n,.1,.6),e).normalize(),r.pole.lerp(W.set(.8*n,-.5,-.1),e).normalize(),i.pole.lerp(W.set(-n,-.1,.1),e).normalize();let c=this.mournWeight*e;if(c>.001){a.hipsPitch=o(a.hipsPitch,.1,c),a.spinePitch=o(a.spinePitch,.28,c),a.headPitch=o(a.headPitch,.55,c),a.headYaw=o(a.headYaw,0,c);let e=a.hips.y+.76;r.position.lerp(W.set(.14*n,e,.4),c),i.position.lerp(W.set(-.14*n,e,.4),c),r.knuckles.lerp(W.set(-.35*n,.9,0),c).normalize(),i.knuckles.lerp(W.set(.35*n,.9,0),c).normalize(),r.palm.lerp(W.set(-n,-.2,0),c).normalize(),i.palm.lerp(W.set(n,-.2,0),c).normalize(),r.pole.lerp(W.set(n,-.2,.3),c).normalize(),i.pole.lerp(W.set(-n,-.2,.3),c).normalize()}let l=this.cheerWeight*e;if(l>.001){let e=Math.sin(t*8.5);a.hips.z=o(a.hips.z,.04,l),a.hipsPitch=o(a.hipsPitch,-.02,l),a.spinePitch=o(a.spinePitch,-.06,l),a.spineRoll=o(a.spineRoll,e*.05,l),a.headPitch=o(a.headPitch,-.2,l);let s=a.hips.y+.93+e*.05;r.position.lerp(W.set(.36*n,s,.06),l),i.position.lerp(W.set(-.36*n,s-e*.06,.06),l),r.knuckles.lerp(W.set(.15*n,1,0),l).normalize(),i.knuckles.lerp(W.set(-.15*n,1,0),l).normalize(),r.palm.lerp(W.set(0,0,1),l).normalize(),i.palm.lerp(W.set(0,0,1),l).normalize(),r.pole.lerp(W.set(n,-.3,-.2),l).normalize(),i.pole.lerp(W.set(-n,-.3,-.2),l).normalize()}}applyTreatPose(e,t,n,r,i,a,o){let s=this.torso,c=L.lerp,l=this.treatScratch.set(this.rootX??0,0,this.rootZ),u=this.scratchQ.setFromAxisAngle(XE,-this.yaw),d=W.copy(this.treatTarget).sub(l).applyQuaternion(u),f=this.treatFacingLocal.copy(this.treatFacing).applyQuaternion(u),p=f.z,m=-f.x,h=this.treatUrgency,g=t*c(2.6,7,h),_=Math.sin(g)*c(.006,.016,h),v=Math.cos(g)*.03*h;s.hips.lerp(this.treatScratch.set(0,.5,.1),e),s.hipsYaw=c(s.hipsYaw,0,e),s.hipsPitch=c(s.hipsPitch,.14,e),s.hipsRoll=c(s.hipsRoll,0,e),s.shouldersYaw=c(s.shouldersYaw,0,e),s.spinePitch=c(s.spinePitch,.26,e),s.headYaw=c(s.headYaw,sw(Math.atan2(d.x,d.z-.25),-.6,.6),e),s.headPitch=c(s.headPitch,sw(Math.atan2(1.12-d.y,Math.hypot(d.x,d.z-.25)),-.5,.6),e),this.kneelLegs(e,n,a,o,.1);let y=this.treatProp===`bottle`,b=y?.3:.08-_;r.position.lerp(this.treatScratch.set(d.x+f.x*b+p*v,d.y+(y?.02:-.07),d.z+f.z*b+m*v),e),y?r.knuckles.lerp(this.treatScratch.set(-f.x,-.25,-f.z),e).normalize():r.knuckles.lerp(this.treatScratch.set(0,1,.05),e).normalize(),r.palm.lerp(y?this.treatScratch.set(0,-1,0):this.treatScratch.set(-f.x,0,-f.z),e).normalize(),r.pole.lerp(this.treatScratch.set(.85*n,-.35,.1),e).normalize();let x=this.treatSide*.135;i.position.lerp(this.treatScratch.set(d.x-p*x+f.x*.05,d.y-.2,d.z-m*x+f.z*.05),e),i.knuckles.lerp(this.treatScratch.set(0,.9,.4),e).normalize(),i.palm.lerp(this.treatScratch.set(p*this.treatSide*.8-f.x*.6,.1,m*this.treatSide*.8-f.z*.6),e).normalize(),i.pole.lerp(this.treatScratch.set(-.85*n,-.4,.1),e).normalize()}applyBreakPose(e,t,n,r){let i=this.torso,a=L.lerp;i.hipsPitch=a(i.hipsPitch,.14,e),i.spinePitch=a(i.spinePitch,.2,e);let o=this.scratchC.set(.48*t,1.22,.52),s=this.scratchD.set(-.48*t,1.22,.52);if(this.breakAimed){let[e,n]=this.breakFighters,r=this.scratch.subVectors(n,e).setY(0).normalize(),i=this.scratchQ.setFromAxisAngle(XE,-this.yaw),a=this.scratchB.set(this.rootX??0,0,this.rootZ);o.copy(e).addScaledVector(r,Jw).sub(a).applyQuaternion(i),s.copy(n).addScaledVector(r,-Jw).sub(a).applyQuaternion(i),o.x*tOw*.15;let s=this.downResult;if(this.downState!==`falling`){let a=this.riseProgress,c=0;if(this.fallKneel)c=rx(Aw,1,a),UE(s,this.placeKneel(this.downFrom,e),o,c);else if(a0==t>0;return e.hips.set(.02*t,.53,-.06),e.hipsYaw=vx.bladeYaw*t*.3,e.hipsPitch=.24,e.hipsRoll=0,e.shouldersYaw=vx.bladeYaw*t*.2,e.spinePitch=.62,e.headPitch=.48,(r?e.leadHand:e.rearHand).set(n*.13,.66,.2),(r?e.rearHand:e.leadHand).set(.13*t,.66,.37),e.leadFoot.set(.16*t,.125,.32),e.rearFoot.set(-.12*t,.12,-.5),e.leadHeel=0,e.rearHeel=0,e.palmsDown=1,e}placeLying(e){let t=this.boxer.rig.metrics.ankleHeight;return PE(this.landProne?kE(this.downFrom,TE,EE,e,this.landSide,t):kE(this.downFrom,CE,wE,e,this.landSide,t),this.landShift)}placeDown(e,t,n){return kE(e,t,null,n,0,this.boxer.rig.metrics.ankleHeight)}chooseLanding(e){let t=this.boxer.rig.metrics.ankleHeight,n=1/0;for(let r=0;r=n||(n=u.length()+o,this.landProne=s,this.landSide=c,this.landShift.copy(u))}}ropeShift(e,t){let n=this.scratchQ.setFromAxisAngle(XE,this.yaw);vE.set(e.hipsPitch+e.spinePitch*.7,e.hipsYaw,e.hipsRoll,`YXZ`),RE[0].set(0,IE,0).applyEuler(vE).add(e.hips),RE[1].set(.2,LE,0).applyEuler(vE).add(e.hips),RE[2].set(-.2,LE,0).applyEuler(vE).add(e.hips),RE[3].copy(e.leadHand),RE[4].copy(e.rearHand),RE[5].copy(e.leadFoot).z+=e.leadHeel>0?.25:.19,RE[6].copy(e.rearFoot).z+=e.rearHeel>0?.25:.19,RE[7].copy(e.hips);let r=1/0,i=-1/0,a=1/0,o=-1/0;for(let e=0;e0==t>0,c=s?n:r,l=s?r:n;i.pole.lerp(W.set(.15*t,.35,1),e).normalize(),a.pole.lerp(W.set(-.1*t,-1,.3),e).normalize(),i.toe.lerp(W.set(.15*t,0,1),e).normalize(),a.toe.lerp(W.set(0,-.35,-1),e).normalize(),c.palm.lerp(W.set(-o*.75,0,-.65),e).normalize(),c.knuckles.lerp(W.set(-o*.35,.25,.9),e).normalize(),c.pole.lerp(W.set(o*.9,-.35,-.25),e).normalize(),l.palm.lerp(W.set(0,-1,.1),e).normalize(),l.knuckles.lerp(W.set(.2*t,-.2,1),e).normalize(),l.pole.lerp(W.set(t*.7,.1,-.7),e).normalize()}writeDown(e,t,n,r,i,a,o,s){let c=this.torso,l=1-s;this.downStand=s,c.hips.copy(e.hips),c.hipsYaw=e.hipsYaw,c.hipsPitch=e.hipsPitch,c.hipsRoll=e.hipsRoll,c.shouldersYaw=e.shouldersYaw,c.spinePitch=e.spinePitch,c.spineRoll=c.spineRoll*s+e.spineRoll,c.headPitch=e.headPitch,c.headYaw=c.headYaw*s+e.turn,c.headRoll=c.headRoll*s+e.headRoll,c.headOffset.multiplyScalar(s),c.headOffset.z-=o,n.position.copy(e.leadHand),r.position.copy(e.rearHand),xE(n,t,e.palmsDown,l),xE(r,-t,e.palmsDown,l),i.position.copy(e.leadFoot),a.position.copy(e.rearFoot),i.toe.lerp(uE.set(.2*t,0,1).normalize(),l).normalize(),a.toe.lerp(uE.set(-.2*t,0,1).normalize(),l).normalize(),i.heel=e.leadHeel,a.heel=e.rearHeel;let u=uE.set(0,0,1).applyEuler(vE.set(e.hipsPitch,e.hipsYaw,e.hipsRoll,`YXZ`));if(i.pole.lerp(u,l),a.pole.lerp(u,l),e.ownJoints>0){let t=e.ownJoints*l;ME(i.pole,e.leadKnee,t),ME(a.pole,e.rearKnee,t),ME(n.pole,e.leadElbow,t),ME(r.pole,e.rearElbow,t),ME(n.knuckles,e.leadKnuckles,t),ME(n.palm,e.leadPalm,t),ME(r.knuckles,e.rearKnuckles,t),ME(r.palm,e.rearPalm,t)}}calmInjuries(){this.armLimp.fill(0),this.armSnap.fill(0),this.kneeGive.fill(0),this.lostLean=0,this.cover=0,this.hunch=0,this.curl=0,this.faint=0,this.retching=0,this.daze=0,this.stepPace.fill(1),this.stepLift.fill(1),this.stepSlack=1,this.hurt=!1,this.dropDangles()}dropDangles(){for(let e=0;e<2;e+=1)this.armDangle[e].live=!1,this.forearmDangle[e].live=!1}stepInjuries(e){this.retchTime=Math.max(0,this.retchTime-e);let t=this.posedInjuries>1||this.faintTarget>0||this.retchTime>0||this.dazed;if(!t&&!this.hurt)return;let n=this.downState===`up`,r=0;for(let t=0;t<2;t+=1){let n=this.armCarry[t];this.armLimp[t]=aw(this.armLimp[t],+(n===`dead`||n===`gone`),OT,e),this.armSnap[t]=aw(this.armSnap[t],+(n===`snapped`),OT,e),this.kneeGive[t]=aw(this.kneeGive[t],+!!this.kneeBlown[t],8,e),r=Math.max(r,this.armLimp[t],this.armSnap[t],this.kneeGive[t])}let i=this.armCarry[0],a=this.armCarry[1],o=i===`whole`||i===`stump`,s=a===`whole`||a===`stump`;this.cover=aw(this.cover,o===s?0:o?1:-1,6,e),this.lostLean=aw(this.lostLean,(i===`gone`)-+(a===`gone`),4,e),this.hunch=aw(this.hunch,+!!this.gutted,5,e),this.curl=aw(this.curl,+!!this.liver,4,e),this.faint=aw(this.faint,this.faintTarget,2.5,e);let c=this.retchTime>0&&n;this.retching=aw(this.retching,+!!c,c?12:5,e);let l=this.dazed&&n;if(this.daze=aw(this.daze,+!!l,l?8:5,e),this.dazeTime=this.daze>.001?this.dazeTime+e:0,r=Math.max(r,Math.abs(this.cover),Math.abs(this.lostLean),this.hunch,this.curl,this.faint,this.retching,this.daze),!t&&r<.001){this.calmInjuries();return}this.hurt=!0;let u=this.hunch,d=this.faint,f=this.daze;this.stepSlack=(1-.3*u)*(1-.55*f);for(let e=0;e<2;e+=1){let t=this.kneeGive[e],n=this.kneeGive[1-e];this.stepPace[e]=(1-.4*n)*(1+.25*t)*(1-.25*u)*(1+.15*d)*(1+.2*f),this.stepLift[e]=(1-.5*t)*(1-.6*u)*(1-.75*d)*(1-.4*f)}}stepDeath(e){if(!(!this.dead||this.throe>=DT.length))for(this.deathAge+=e;this.throe=DT[this.throe].at;){let e=DT[this.throe];this.ragdoll?.twitch(e.part,(this.throe+this.throeSide)%2,e.speed),this.throe+=1}}stumble(e,t,n){let r=this.dazeTime;t.add(this.scratchD.set(Math.sin(r*1.7+e*2.1)*.07,0,Math.sin(r*1.25+e*1.3)*.06).multiplyScalar(this.daze).applyAxisAngle(XE,n))}applyHurtStance(e,t,n,r,i){let a=this.torso,o=0,s=0,c=0,l=this.hunch;l>.001&&(s+=.3*l,o+=.045*l,a.hipsPitch+=.06*l,a.headPitch+=.12*l);let u=this.curl;u>.001&&(s+=.1*u,a.spineRoll+=.21*u,a.headRoll+=.08*u,c+=.02*u,this.hand.R.position.y-=.08*u);let d=this.lostLean;Math.abs(d)>.001&&(a.spineRoll+=.15*d,c+=.025*d,a.headRoll-=.05*d);let f=this.faint;if(f>.001){let t=Math.sin(e*1.15),i=Math.sin(e*.83+1.3);a.hips.x+=t*.09*f,a.hips.z+=i*.06*f,a.hipsRoll+=t*.05*f,a.spineRoll+=Math.sin(e*1.15-.7)*.2*f,s+=(.17+i*.06)*f,o+=.03*f+(.06+.04*(.5+.5*Math.sin(e*2.6)))*f*f,a.headPitch+=(.4+Math.sin(e*.9+.4)*.14)*f,a.headRoll+=Math.sin(e*.7)*.36*f,a.headYaw+=Math.sin(e*.53+2)*.18*f,n.position.y-=.32*f,r.position.y-=.27*f,n.position.z-=.07*f}for(let e=0;e<2;e+=1){let t=this.kneeGive[e];if(t<=.001)continue;let n=e===0?1:-1,r=e===0?this.foot.L:this.foot.R,i=e===0?this.foot.R:this.foot.L,s=this.feet[1-e],c=s.stepping?Math.sin(s.progress*Math.PI)*t:0,l=t-c;a.hips.x+=(i.position.x-a.hips.x)*.25*l,a.hips.z+=(i.position.z-a.hips.z)*.18*l,o+=.085*c+.01*l,a.hipsRoll-=n*.16*c,a.spineRoll+=n*.13*c,r.heel+=.3*l,r.pole.x-=n*(.35*t+.9*c),r.pole.normalize()}if(a.hips.x+=Math.cos(a.hipsYaw)*c,a.hips.z-=Math.sin(a.hipsYaw)*c,o!==0||s!==0){a.hips.y-=o,a.spinePitch+=s;let e=o+s*XT,t=s*YT;i.y-=e,i.z+=t,n.position.y-=e,n.position.z+=t,r.position.y-=e,r.position.z+=t}let p=this.cover;if(Math.abs(p)>.001){let e=p>0?this.hand.L:this.hand.R,n=Math.abs(p);e.position.x+=(ZT*t-e.position.x)*.7*n,e.position.y+=.03*n,e.position.z+=.03*n}}applyHurtActs(e,t,n,r){let i=this.torso,a=L.lerp,o=+(t>0),s=this.armCarry[o]===`whole`?o:this.armCarry[1-o]===`whole`?1-o:-1,c=this.retching*(1-.7*this.punchCommit);if(c>.001){let t=Math.max(0,Math.sin(e*10.5))**2;i.hips.y=a(i.hips.y,vx.hipsHeight-.13-t*.02,c),i.hips.z=a(i.hips.z,-.08,c),i.hipsPitch=a(i.hipsPitch,.36,c),i.spinePitch=a(i.spinePitch,.78+t*.12,c),i.spineRoll=a(i.spineRoll,0,c),i.headPitch=a(i.headPitch,1.3+t*.15,c),i.headYaw=a(i.headYaw,0,c),i.headRoll=a(i.headRoll,0,c),i.headOffset.multiplyScalar(1-c);let n=s<0?o:1-s;if(this.armCarry[n]===`whole`){let e=n===0?1:-1,t=n===0?this.hand.L:this.hand.R;t.position.lerp(W.set(e*.19,.62,n===o?-.02:.15),c),t.pole.lerp(W.set(e*.9,.1,-.4),c).normalize(),t.knuckles.lerp(W.set(-e*.2,-.7,.6),c).normalize(),t.palm.lerp(W.set(0,-.6,-.8),c).normalize()}}let l=Math.max(Math.abs(this.slip),this.weave,this.pull),u=sw(1-this.guardHigh-this.guardLow,0,1)*(1-this.punchCommit)*(1-l)*(1-this.clinchWeight),d=this.punchActive&&s===(this.punchHand===`left`?0:1)?sw(this.punchReach*4,0,1):0,f=Math.max(c,this.hunch*u)*(1-d);f>.001&&s>=0&&this.clutchBelly(s,f);let p=this.daze;if(p>.001){let e=this.dazeTime,o=rx(.7,1.6,e),s=Math.sin(e*2.2),c=Math.sin(e*1.45+.9),l=vx.bladeYaw*t;i.hips.x=a(i.hips.x,s*.06,p),i.hips.z=a(i.hips.z,c*.045,p),i.hips.y=a(i.hips.y,vx.hipsHeight-.08-Math.sin(e*4.4+1)*.02,p),i.hipsYaw=a(i.hipsYaw,l*.8,p),i.hipsPitch=a(i.hipsPitch,.04,p),i.hipsRoll=a(i.hipsRoll,s*.05,p),i.shouldersYaw=a(i.shouldersYaw,l*.65,p),i.spinePitch=a(i.spinePitch,.24+c*.07,p),i.spineRoll=a(i.spineRoll,Math.sin(e*2.2-.9)*.13,p),i.headYaw=a(i.headYaw,o*Math.sin(e*1.1+2)*.3,p),i.headPitch=a(i.headPitch,.95-o*(.28+Math.sin(e*1.3)*.25),p),i.headRoll=a(i.headRoll,o*Math.sin(e*1.9)*.42,p),i.headOffset.multiplyScalar(1-p),n.heel=a(n.heel,0,p),r.heel=a(r.heel,0,p)}}clutchBelly(e,t){let n=this.torso,r=e===0?this.hand.L:this.hand.R,i=e===0?1:-1,a=n.hipsYaw+(n.shouldersYaw-n.hipsYaw)*.25,o=n.hipsPitch+n.spinePitch*.2;r.position.lerp(W.set(i*.05,.17,.19+o*.08).applyAxisAngle(XE,a).add(n.hips),t),r.knuckles.lerp(W.set(-i*.9,-.3,.2).applyAxisAngle(XE,a),t).normalize(),r.palm.lerp(W.set(-i*.1,.15,-1).applyAxisAngle(XE,a),t).normalize(),r.pole.lerp(W.set(i*.85,-.35,-.4).applyAxisAngle(XE,a),t).normalize()}dangleArms(e){let t=this.daze,n=this.boxer.rig,r=n.bones;Yb(r.hips,this.trunkLow),Yb(r.upperChest,this.trunkHigh),this.trunkLow.addScaledVector(QT.subVectors(this.trunkLow,this.trunkHigh).normalize(),KT);let i=this.ragdoll?.handingOver===!0;for(let a=0;a<2;a+=1){let o=Math.max(this.armLimp[a],t),s=this.armSnap[a],c=this.armDangle[a],l=this.forearmDangle[a];if(o<=.001&&(c.live=!1),s<=.001&&(l.live=!1),o<=.001&&s<=.001)continue;let u=a===0,d=u?1:-1,f=u?r.shoulderL:r.shoulderR,p=u?r.elbowL:r.elbowR,m=u?r.gloveL:r.gloveR,h=u?n.metrics.armL:n.metrics.armR;if(o>.001){let t=Yb(m,$T);if(Xb(m,cE),this.armCarry[a]===`dead`){let e=Yb(f,eE);e.y-=kT*this.armLimp[a],n.aimAt(u?r.clavicleL:r.clavicleR,e,`z`),f.updateWorldMatrix(!1,!1)}let s=Yb(f,eE),l=(h.upper+h.lower)*AT;if(!c.live){let e=o>WT&&!i;TT(c,e?QT.set(s.x,s.y-l,s.z):t,s),e&&this.holdDangle(c.at,s,l,!1,null)}let g=this.punchActive&&this.punchHand===`left`===u?this.punchReach:0;this.swing(c,s,l,!1,e,jT,MT,t,g*PT);let _=tE.set(d*.3,.15+3*sw(1-s.y/JT,0,1),-1).lerp(u?this.hand.L.pole:this.hand.R.pole,1-o).applyAxisAngle(XE,this.yaw);n.solveLimb(f,p,h,t.lerp(c.at,o),_,`z`,u?1:-1,.012),m.updateWorldMatrix(!1,!1),Zb(nE.subVectors(Yb(m,$T),Yb(p,QT)).normalize(),tE.set(-d,0,.2).applyAxisAngle(XE,this.yaw),`z`,lE),n.setWorldRotation(m,cE.slerp(lE,o))}if(s>.001){let t=Yb(p,eE),r=Yb(m,$T);Xb(m,cE);let a=Math.max(0,-(t.y-Yb(f,QT).y)/h.upper),o=sw((t.y-qT)/h.lower,0,1),c=sE.set(d*(FT+IT*a*a),-o,0).applyAxisAngle(XE,this.yaw).normalize();l.live||(TT(l,s>WT&&!i?QT.set(t.x,t.y-h.lower,t.z):r,t),this.holdDangle(l.at,t,h.lower,!0,c)),this.swing(l,t,h.lower,!0,e,jT,NT,null,0,c);let u=nE.subVectors(r,t).lerp(QT.subVectors(l.at,t),s).normalize(),g=tE.setFromMatrixColumn(p.matrixWorld,2).lerp(QT.setFromMatrixColumn(p.matrixWorld,0).multiplyScalar(d),s);n.setWorldFrame(p,u,g,`z`),m.updateWorldMatrix(!1,!1),Zb(QT.copy(u).addScaledVector(fE,.9).normalize(),tE.set(-d,.2,-.4).applyAxisAngle(XE,this.yaw),`z`,lE),n.setWorldRotation(m,cE.slerp(lE,s))}}}swing(e,t,n,r,i,a,o,s,c,l=null){let u=e.at,d=e.velocity;(e.carried||t.distanceToSquared(e.pivot)>UT*UT)&&(u.add(t).sub(e.pivot),d.set(0,0,0),e.pivot.copy(t),e.carried=!1);let f=i>0?Math.min(VT,Math.ceil(i/BT)):0,p=f>0?i/f:0;for(let i=1;i<=f;i+=1)rE.copy(u),d.addScaledVector(a,p),s!==null&&c>0&&d.addScaledVector(iE.subVectors(s,u),c*p),d.multiplyScalar(Math.exp(-o*p)),u.addScaledVector(d,p),this.holdDangle(u,iE.lerpVectors(e.pivot,t,i/f),n,r,l),d.subVectors(u,rE).divideScalar(p).clampLength(0,HT);f===0&&this.holdDangle(u,t,n,r,l),e.pivot.copy(t)}holdDangle(e,t,n,r,i){let a=this.trunkLow,o=aE.subVectors(this.trunkHigh,a);for(let s=0;s<2;s+=1){let s=sw(oE.subVectors(e,a).dot(o)/Math.max(1e-6,o.lengthSq()),0,1),c=oE.addScaledVector(o,-s).length();c1e-4&&e.addScaledVector(oE,(GT-c)/c),e.y=Math.max(e.y,qT);let l=oE.subVectors(e,t),u=l.length();if(u<1e-6?e.set(t.x,t.y-n,t.z):(r||u>n)&&e.copy(t).addScaledVector(l,n/u),i===null)continue;l.subVectors(e,t);let d=l.dot(i);if(d>=n*RT)continue;let f=l.addScaledVector(i,-d).length();e.copy(t).addScaledVector(i,n*(f>1e-6?RT:1)),f>1e-6&&e.addScaledVector(l,n*zT/f)}}applyDislocation(){if(this.dislocation!==`jaw`)return;let e=this.boxer.bone(`head`);e!==null&&(e.quaternion.multiply(ST),e.updateWorldMatrix(!1,!0))}dispose(){this.stool.dispose(),this.enswell.dispose(),this.bottle.dispose(),this.boxer.dispose()}},Vw=.44,Hw=.2,Uw=.75,Ww=.94,Gw=.836,Kw=.12,qw=1.72,Jw=.2,Yw=1.26,Xw=48,Zw=14,Qw=1.34,$w=80,eT=56,tT=24,nT=4,rT=1.5,iT=60,aT=4,oT=.15,sT=.8,cT=1.3,lT=.35,uT=.93,dT=500,fT=900,pT=.15,mT=.05,hT=.07,gT=.14,_T=.05,vT=.2,yT=.04,bT=.36;function xT(e){let t=7;for(let n=0;nMath.atan2(Math.sin(e),Math.cos(e)),jE=new z;function ME(e,t,n){if(n<=0)return e;e.normalize();let r=e.angleTo(t);return r<1e-4?e:(jE.crossVectors(e,t),jE.lengthSq()<1e-8&&jE.crossVectors(e,Math.abs(e.y)<.9?XE:dE),e.applyAxisAngle(jE.normalize(),r*Math.min(1,n)))}function NE(e,t,n,r){let i=t+AE(e.x-t),a=n+AE(e.y-n),o=r+AE(e.z-r),s=t+AE(Math.PI-e.x-t),c=n+AE(e.y+Math.PI-n),l=r+AE(e.z+Math.PI-r);return Math.abs(i-t)+Math.abs(a-n)+Math.abs(o-r)<=Math.abs(s-t)+Math.abs(c-n)+Math.abs(l-r)?e.set(i,a,o,`YXZ`):e.set(s,c,l,`YXZ`)}function PE(e,t){return e.hips.add(t),e.leadHand.add(t),e.rearHand.add(t),e.leadFoot.add(t),e.rearFoot.add(t),e}var FE=h_*.72-.05,IE=.78,LE=.5,RE=Array.from({length:8},()=>new z),zE=[.17,.22,.22,.13,.13,.12,.12,.2],BE=[[!1,1,0],[!1,0,.15],[!1,-1,.3],[!0,1,.4],[!0,0,.5],[!0,-1,.6]];function VE(e,t){return e<-FE&&t>FE?-(e+t)/2:e<-FE?-FE-e:t>FE?FE-t:0}function HE(e,t){return UE(e,t,t,0)}function UE(e,t,n,r){let i=L.lerp;return e.hips.copy(t.hips).lerp(n.hips,r),e.hipsYaw=i(t.hipsYaw,n.hipsYaw,r),e.hipsPitch=i(t.hipsPitch,n.hipsPitch,r),e.hipsRoll=i(t.hipsRoll,n.hipsRoll,r),e.shouldersYaw=i(t.shouldersYaw,n.shouldersYaw,r),e.spinePitch=i(t.spinePitch,n.spinePitch,r),e.spineRoll=i(t.spineRoll,n.spineRoll,r),e.headPitch=i(t.headPitch,n.headPitch,r),e.headRoll=i(t.headRoll,n.headRoll,r),e.leadHand.copy(t.leadHand).lerp(n.leadHand,r),e.rearHand.copy(t.rearHand).lerp(n.rearHand,r),e.leadFoot.copy(t.leadFoot).lerp(n.leadFoot,r),e.rearFoot.copy(t.rearFoot).lerp(n.rearFoot,r),e.leadHeel=i(t.leadHeel,n.leadHeel,r),e.rearHeel=i(t.rearHeel,n.rearHeel,r),e.palmsDown=i(t.palmsDown,n.palmsDown,r),e.turn=i(t.turn,n.turn,r),ME(e.leadKnee.copy(t.leadKnee),n.leadKnee,r),ME(e.rearKnee.copy(t.rearKnee),n.rearKnee,r),ME(e.leadElbow.copy(t.leadElbow),n.leadElbow,r),ME(e.rearElbow.copy(t.rearElbow),n.rearElbow,r),ME(e.leadKnuckles.copy(t.leadKnuckles),n.leadKnuckles,r),ME(e.leadPalm.copy(t.leadPalm),n.leadPalm,r),ME(e.rearKnuckles.copy(t.rearKnuckles),n.rearKnuckles,r),ME(e.rearPalm.copy(t.rearPalm),n.rearPalm,r),e.ownJoints=i(t.ownJoints,n.ownJoints,r),e}var WE=3;function GE(e,t,n){if(n===null)return null;let r=t+n;return e===null||Math.abs(r-e)>WE?r:e}function KE(e){return(1-rx(eT,$w,e))*rx(nT,tT,e)}function qE(){let e=new gs;e.name=`enswell`,e.visible=!1;let t=new Zl(3.2,3.2,.9,20),n=new Zl(.8,.8,6,10),r=new Ku({color:13159634,roughness:.3,metalness:.9}),i=new V(t,r);i.rotation.x=Math.PI/2,i.position.set(0,9.5,3.4),e.add(i);let a=new V(n,r);return a.position.set(0,5.5,2.4),e.add(a),{group:e,dispose:()=>{t.dispose(),n.dispose(),r.dispose()}}}function JE(){let e=new gs;e.name=`bottle`,e.visible=!1;let t=new Zl(3.3,3.3,15,18),n=new Zl(1.3,3.3,3,18),r=new Zl(.7,1.1,3.2,10),i=new Ku({color:14280430,roughness:.32,metalness:0}),a=new Ku({color:1920728,roughness:.5,metalness:0}),o=new V(t,i);o.position.set(0,9,2.6);let s=new V(n,i);s.position.set(0,18,2.6);let c=new V(r,a);return c.position.set(0,21,2.6),e.add(o,s,c),{group:e,dispose:()=>{t.dispose(),n.dispose(),r.dispose(),i.dispose(),a.dispose()}}}function YE(){let e=new gs;e.name=`stool`,e.visible=!1;let t=new Zl(.17,.17,.035,18),n=new Zl(.012,.014,.42,8),r=new Ku({color:13222581,roughness:.85}),i=new Ku({color:2764083,roughness:.45,metalness:.6}),a=new V(t,r);a.position.y=.4225,a.castShadow=!0,e.add(a);for(let t=0;t<4;t+=1){let r=Math.PI/4+t*Math.PI/2,a=new V(n,i);a.position.set(Math.cos(r)*.13,.42/2,Math.sin(r)*.13),a.rotation.set(-Math.sin(r)*.12,0,Math.cos(r)*.12),a.castShadow=!0,e.add(a)}return{group:e,dispose:()=>{t.dispose(),n.dispose(),r.dispose(),i.dispose()}}}var XE=new z(0,1,0),ZE=6,QE=3,$E=1.5,eD=2.5,tD=1.5,nD=.55,rD=2.1,iD=.42,aD=.22,oD=.08,sD=.15,cD=.42,lD=.12,uD=.5,dD=.5,fD=new Set([`hit`,`counter_hit`,`block`,`perfect_block`,`referee_hit`]),pD=new Set([`slip_left`,`slip_right`,`weave`,`pull`]),mD=40,hD=y/a,gD=.12,_D=30,vD=2;function yD(e,t,n){if(e0;case`forearm_left`:return t===`glove_left`||o&&pg(r,i,a,1)>0;case`forearm_right`:return t===`glove_right`||o&&pg(r,i,a,-1)>0;case`arm_left`:return t===`glove_left`||o&&mg(r,i,a,1)>0;case`arm_right`:return t===`glove_right`||o&&mg(r,i,a,-1)>0;case`leg_left`:return r>=0&&(t===`shoes`||o&&i<60);case`leg_right`:return r<0&&(t===`shoes`||o&&i<60);case`upper_body`:return t===`head`||t===`glove_left`||t===`glove_right`||o&&hg(r,i,a)>0;case`torso`:return t===`pants`||o&&i>=60&&mg(r,i,a,1)<=0&&mg(r,i,a,-1)<=0}}var SD={head:`BoxerHead`,body:`BoxerBody`,glove_left:`BoxerGloveLeft`,glove_right:`BoxerGloveRight`,pants:`BoxerPants`,shoes:`BoxerShoes`},CD=new WeakMap;function wD(e,t){let n=CD.get(e);if(n===void 0){n={};let t=new Map(Object.entries(SD).map(([e,t])=>[t,e]));e.root.traverse(e=>{let r=e instanceof rl?t.get(e.name):void 0;r!==void 0&&(n[r]=e)}),CD.set(e,n)}return n[t]??null}var TD=[`left`,`right`],ED=new z(0,1,0),DD=new z(0,-1,0),OD=15129792,kD=6032400,AD=9313310,jD=4982537,MD=14200392,ND=2228997,PD=14263970,FD=8270912,ID=11618383,LD=15524550,RD=12866653,zD=13602176,BD=9384504,VD=new B,HD=new B,UD=new z,WD=L.smoothstep;function GD(e,t){e.deleteAttribute(`uv`);let n=e.getAttribute(`position`),r=new Float32Array(n.count*3);for(let e=0;eo/2-.001){let t=Math.atan2(UD.z,UD.x);UD.y+=i<1e-4?-n*.8:n*(.5*Math.sin(t*3+e[1])+.35*Math.sin(t*5+e[2]))}c.setXYZ(t,UD.x,UD.y+o/2,UD.z*r)}return s.computeVertexNormals(),GD(s,(t,r)=>{let i=1-WD(t.y/o,.15,.42)*(.85+.15*Math.sin(Math.atan2(t.z,t.x)*4+e[0]));r.setHex(OD).lerp(HD.setHex(jD),i),Math.hypot(t.x,t.z)o*.5&&r.setHex(kD)}),s.applyQuaternion(new vo().setFromUnitVectors(ED,a.normalize())),s.translate(i.x,i.y,i.z),s}function JD(e,t,n,r=!1){return GD(new Fu(new lu(e.map(e=>new z(...e)),r),e.length*5,t,7,r),n)}var YD=[0,123.6,-3.2],XD=[4.5,4,5];function ZD(){let e=new Mu(1,40,24,0,Math.PI*2,0,Math.PI*.6),t=e.getAttribute(`position`),n=new Float32Array(t.count);for(let e=0;e{let i=n[r];r+=1,t.setHex(FD).lerp(HD.setHex(PD),WD(i,-.5,.45)),(i<-1||Math.sin(e.x*.9+e.z*1.3)>.72)&&t.lerp(HD.setHex(AD),.7)})}function QD(){let e=[[1,.2,OD],[.9,0,OD],[.82,0,kD],[.74,0,OD],[.66,-.9,jD]],t=[],n=[],r=[];for(let[i,[a,o,s]]of e.entries())for(let e=0;e<32;e+=1){let c=e/32*Math.PI*2;if(t.push(Math.cos(c)*5.6*a,124+o,-3.3+Math.sin(c)*6.4*a),VD.setHex(s).multiplyScalar(.85+.15*Math.sin(c*11+i)),n.push(VD.r,VD.g,VD.b),i===0)continue;let l=(e+1)%32;r.push((i-1)*32+e,i*32+e,(i-1)*32+l,(i-1)*32+l,i*32+e,i*32+l)}let i=new yc;return i.setAttribute(`position`,new sc(t,3)),i.setAttribute(`color`,new sc(n,3)),i.setIndex(r),i.computeVertexNormals(),i}var $D=[0,112.9,-.4],eO=9,tO=new z(0,-.93,.37).normalize(),nO=.95;function rO(){let e=new Yl(1.5,6,6,16,8),t=e.getAttribute(`position`);for(let e=0;e0?.5*(1-WD(r,0,.45)):0,a=.5*Math.sin(n*5)*(1-n);t.setXYZ(e,UD.x*L.lerp(.9,1.1,Math.sin(n*Math.PI))+a*.4,UD.y-eO/2,(UD.z-i)*.3+.35*r*r+1.3*n*n)}return e.computeVertexNormals(),GD(e,(e,t)=>{let n=-e.y/eO,r=Math.sin(e.y*2.6+e.x*2.1)*Math.sin(e.x*3.3-e.y*1.2);t.setHex(RD).multiplyScalar(.8+.2*r).lerp(HD.setHex(jD),.8*(1-WD(n,0,.35))),(r>.45||n>.88)&&t.lerp(HD.setHex(AD),.65)})}function iO(){let e=[],t=new Mu(1,18,12,Math.PI,Math.PI);t.scale(3.3,2.5,3.2),t.translate(0,113.3,-.5),e.push(GD(t,(e,t)=>{t.setHex(ND).lerp(HD.setHex(AD),WD(Math.hypot(e.x,e.y-112.6,(e.z+3)*.7),.7,2.6))}));let n=new Xl(1,20);n.rotateX(Math.PI/2),n.scale(3.3,1,3.9),n.translate(0,115.25,.5),e.push(GD(n,(e,t)=>{t.setHex(BD).multiplyScalar(.75+.25*Math.sin(e.z*5)).lerp(HD.setHex(ND),1-WD(e.z,-3,.5))}));let r=[];for(let t=0;t<14;t+=1){let n=-1.75+t/13*3.5,i=1-Math.abs(n)/1.75,a=t===4||t===9?1.35:L.lerp(.85,1.2,i),o=new Zl(.3,t===4||t===9?.16:.37,a,6);o.scale(1,1,L.lerp(1.15,.55,i)),o.rotateY(n);let s=Math.sin(n)*2.75,c=.9+Math.cos(n)*3.1;o.translate(s,114.9-a/2,c),e.push(GD(o,(e,t)=>{t.setHex(LD).lerp(HD.setHex(AD),.8*WD(e.y,114.3,114.9))})),r.push([s,114.95,c])}return e.push(JD(r,.45,ID)),KD(e)}function aO(e){return KD([qD([e*29.4,103.8,-4.2],[e*32.9,104.1,-4],.85),qD([e*29.4,102,-6.2],[e*32.3,101.8,-6.5],.7)])}function oO(e){let t=new Mu(1,12,9);return t.scale(.9,1.7,1.5),t.translate(e*13.3,103.4,-5.5),GD(t,(e,t)=>{t.setHex(15327954).lerp(HD.setHex(AD),Math.sin(e.y*3.1+e.z*2.3)>.4?.75:.1)})}function sO(){return KD([GD(new Zl(2,2.1,1.8,10).translate(0,80.4,-5.4),OD),GD(new Zl(1.8,1.8,.6,10).translate(0,81.6,-5.4),12563866),qD([0,81.9,-5.4],[.4,85.4,-5.8],1.9),JD([[.2,84.6,-5.6],[.3,86.6,-5.8],[.9,87.8,-5.2]],.55,15255984),JD([[-6.5,81.6,.5],[-3,82.6,3.6],[1.5,81.8,4.4],[6,82.8,2],[7,81.6,-2],[3.5,82.9,-1],[-1,81.7,.6],[-5,82.9,-2.6],[-7.2,81.5,-4]],1.25,zD,!0),JD([[4.5,83.6,1.6],[1,84.4,2.4],[-3,83.5,.6],[-2,84.2,-2.6],[2.5,83.6,-2.2]],1.05,12548720,!0),GD(new Mu(1,10,7).scale(3.2,1.6,2.6).translate(-6,82.2,1.5),4854808)])}function cO(e){return KD(Dg.map((t,n)=>{let r=new z(-t[0],0,-2-t[2]).normalize();return qD([e*(t[0]+r.x*3),t[1]-.3,t[2]+r.z*3],[e*(t[0]-r.x*1.3),t[1]+.7-.3*n,t[2]-r.z*1.3+.7],.75,.5)}))}function lO(){let e=[];for(let t=0;t<5;t+=1){let n=.5+t*1.26,r=Math.cos(n),i=Math.sin(n);e.push(qD([r*5.8,99.5+i*5.8,3.9],[r*2.9,99.5+i*2.9,2.4],.7,.5)),e.push(qD([i*5.6,99.5-r*5.6,-9.6],[i*4.3,99.5-r*4.3,-12.8],.7,.5))}return KD(e)}var uO=new z,dO=new z,fO=new z,pO=new z,mO=new WeakMap;function hO(e,t,n){let r=e.getAttribute(`position`),i=e.getAttribute(`skinIndex`),a=e.getAttribute(`skinWeight`),o=new Map,s=new z;for(let e of t)o.has(e)||(o.set(e,o.size),s.add(UD.fromBufferAttribute(r,e)));s.multiplyScalar(1/o.size);let c=n.layers.length,l=[],u=[],d=[],f=[],p=new Map;for(let e of o.keys()){for(let[t,[o,c]]of n.layers.entries()){n.place(UD.fromBufferAttribute(r,e),s,o,uO),l.push(uO.x,uO.y,uO.z),VD.setHex(c).multiplyScalar(.8+.4*Math.abs(Math.sin(e*12.9898+t*4.1))),u.push(VD.r,VD.g,VD.b);for(let t=0;t<4;t+=1)d.push(i.getComponent(e,t)),f.push(a.getComponent(e,t))}for(let t=0;t<4;t+=1)p.set(i.getComponent(e,t),(p.get(i.getComponent(e,t))??0)+a.getComponent(e,t))}let m=o.size*c;if(n.middle!==null){n.place(s,s,1,uO),l.push(uO.x,uO.y,uO.z),VD.setHex(n.middle),u.push(VD.r,VD.g,VD.b);let e=[...p].sort((e,t)=>t[1]-e[1]).slice(0,4),t=e.reduce((e,[,t])=>e+t,0);for(let n=0;n<4;n+=1)d.push(e[n]?.[0]??0),f.push((e[n]?.[1]??0)/t)}let h=[],g=(e,t,r)=>{uO.fromArray(l,e*3),dO.fromArray(l,t*3),fO.fromArray(l,r*3),n.facing(UD.copy(uO).add(dO).add(fO).multiplyScalar(1/3),s,pO);let i=dO.sub(uO).cross(fO.sub(uO)).dot(pO)>=0;h.push(e,i?t:r,i?r:t)};for(let e=0;evoid a.copy(n).lerp(r,i).addScaledVector(e,-t*i),facing:(t,n,r)=>void r.copy(e),middle:ND}}var _O={layers:[[0,jD],[.4,jD],[1,ND]],place:(e,t,n,r)=>void r.set(L.lerp(e.x,t.x,.22*n),L.lerp(e.y,t.y,.22*n),L.lerp(e.z,t.z-Math.sign(e.z-t.z)*.6,n)),facing:(e,t,n)=>void n.set(t.x-e.x,t.y-e.y,0),middle:null},vO={nose:{bone:`head`,mesh:`head`,at:[0,117,5.3],axis:[0,-.3,1]},mouth:{bone:`head`,mesh:`head`,at:[0,114.3,4.6],axis:[0,-.35,1]},eye_left:{bone:`head`,mesh:`head`,at:Fg[0],axis:[.2,0,1]},eye_right:{bone:`head`,mesh:`head`,at:Fg[1],axis:[-.2,0,1]},ear_left:{bone:`head`,mesh:`head`,at:Eg,axis:[1,-.2,0]},ear_right:{bone:`head`,mesh:`head`,at:[-Eg[0],Eg[1],Eg[2]],axis:[-1,-.2,0]},skull:{bone:`head`,mesh:`head`,at:[0,127.5,-3],axis:[0,1,0]},neck:{bone:`neck`,mesh:`body`,at:[0,109,-2],axis:[0,1,0]},shoulder_left:{bone:`clavicleL`,mesh:`body`,at:[15,103.5,-5.5],axis:[1,0,0]},shoulder_right:{bone:`clavicleR`,mesh:`body`,at:[-15,103.5,-5.5],axis:[-1,0,0]},elbow_left:{bone:`shoulderL`,mesh:`body`,at:[31,102.8,-5.2],axis:[1,0,0]},elbow_right:{bone:`shoulderR`,mesh:`body`,at:[-31,102.8,-5.2],axis:[-1,0,0]},chest:{bone:`chest`,mesh:`body`,at:[0,99.5,5.6],axis:[0,0,1]},ribs_left:{bone:`chest`,mesh:`body`,at:Dg[1],axis:[1,0,.3]},ribs_right:{bone:`chest`,mesh:`body`,at:[-Dg[1][0],Dg[1][1],Dg[1][2]],axis:[-1,0,.3]},liver:{bone:`chest`,mesh:`body`,at:[-8.5,89.5,4.4],axis:[-.5,0,1]},belly:{bone:`spine`,mesh:`body`,at:Ag,axis:[0,-.2,1]},waist:{bone:`spine`,mesh:`body`,at:[0,81.5,-1],axis:[0,1,0]},crotch:{bone:`hips`,mesh:`body`,at:[0,72,2],axis:[0,-1,.15]},knee_left:{bone:`kneeL`,mesh:`body`,at:kg,axis:[1,0,.2]},knee_right:{bone:`kneeR`,mesh:`body`,at:[-kg[0],kg[1],kg[2]],axis:[-1,0,.2]}},yO=[`skull`,`maw`,`chest`,`waist`,...TD.flatMap(e=>[`fracture`,`ribs`,`knee`,`elbow`,`shoulder`].map(t=>`${t}_${e}`))],bO={left:{sign:1,bone:`L`,ear:`leftEar`,face:`leftFace`,cheek:`leftCheek`,eye:`leftEye`,arm:`leftArm`,shoulder:`leftShoulder`,elbow:`leftElbow`,ribs:`leftRibs`,knee:`leftKnee`,smear:`leftShoulderSmear`},right:{sign:-1,bone:`R`,ear:`rightEar`,face:`rightFace`,cheek:`rightCheek`,eye:`rightEye`,arm:`rightArm`,shoulder:`rightShoulder`,elbow:`rightElbow`,ribs:`rightRibs`,knee:`rightKnee`,smear:`rightShoulderSmear`}},xO=class{boxer;headRaises=[];bodyRaises=[];gloveGone={left:!1,right:!1};eyeOut={left:!1,right:!1};eyeShut={left:!1,right:!1};gloved;flesh;owned=[];tongueTip=new z;tongueVelocity=new z;root=new z;rest=new z;reach=new z;matrix=new Ho;fit=new Ho;upperGone=!1;headHidden=!1;injuries=0;blood=`full`;hole=!1;jawHung=!1;pieces=new Map;geometries=[];skull=null;skullMount=new Ho;brain=null;tongue=null;bodyShadow=null;standIns=null;tongueHung=!1;constructor(e){this.boxer=e,this.gloved={left:e.gloveMesh(`left`).visible,right:e.gloveMesh(`right`).visible},this.flesh=new Ku({vertexColors:!0,roughness:.3,metalness:0,side:2}),tw(this.flesh)}apply(e,t){let n=0;for(let t=0;tc*3)&&(this.tongueHung=!0,l.copy(o).addScaledVector(s,c),u.set(0,0,0));let d=this.reach.copy(l);e>1e-4&&(u.y-=9.8*e,u.addScaledVector(UD.copy(o).addScaledVector(s,c).sub(l),60*e).multiplyScalar(Math.exp(-5*e)),d.addScaledVector(u,e)),d.sub(o).setLength(c),d.angleTo(s)>nO&&(UD.copy(d).addScaledVector(s,-d.dot(s)).setLength(Math.sin(nO)*c),d.copy(s).multiplyScalar(Math.cos(nO)*c).add(UD)),d.add(o),e>1e-4&&u.copy(d).sub(l).multiplyScalar(1/e),l.copy(d),r.quaternion.setFromUnitVectors(DD,UD.copy(l).sub(o).transformDirection(a.invert()))}compileStandIns(){if(this.standIns!==null)return this.standIns;let e=this.boxer;for(let e of yO)this.built(e);let t=[],n=[[e.headMesh,e.headInjury],[wD(e,`body`),e.bodyInjury]];for(let[e,r]of n)for(let n of[!1,!0]){let i=e===null?null:r.variant(n);if(e===null||i===null)continue;this.owned.push(i);let a=new rl(e.geometry,i);if(a.bind(e.skeleton,e.bindMatrix),a.frustumCulled=!1,a.castShadow=e.castShadow,n){let e=r.shadowVariant();this.owned.push(e),a.customDepthMaterial=e}t.push(a)}this.brain!==null&&t.push(new V(this.brain.geometry,this.flesh));let r=this.built(`waist`).find(e=>e instanceof rl);if(r!==void 0){let e=new rl(r.geometry,this.flesh);e.bind(r.skeleton,r.bindMatrix),e.frustumCulled=!1,t.push(e)}return this.standIns=t,t}clear(){this.upperGone=!1,this.hole=!1,this.injuries=0,this.show(),this.setPallor(0)}dispose(){this.clear();for(let e of this.standIns??[])e.removeFromParent();this.standIns=null;for(let e of this.pieces.values())for(let t of e)t.removeFromParent();for(let e of this.geometries)e.dispose();this.pieces.clear(),this.geometries.length=0,this.skull=this.brain=this.tongue=null,this.bodyShadow?.dispose(),this.bodyShadow=null;for(let e of this.owned)e.dispose();this.owned.length=0,this.flesh.dispose()}has(e){return!!(this.injuries&1<this.blood!==`off`&&this.has(e),o=r&&this.upperGone,s=this.isPartGone(`jaw`),c=r&&this.has(`skull_fractured`);t.setExplicit(r),n.setExplicit(r);let l=this.headRaises,u=this.bodyRaises;l.length=0,u.length=0;let d=(e,t,n,r=0,a=0)=>void e.push({site:t,bruise:n,blood:r*i,cut:a});if(t.setWound(`nose`,+!!a(`broken_nose`)),a(`broken_nose`)&&d(l,`nose`,1.1,1.4),a(`broken_jaw`)||a(`jaw_torn`)){let e=a(`jaw_torn`);d(l,`chin`,1.2),d(l,`leftJaw`,e?1.2:1),d(l,`rightJaw`,e?1.2:1),d(l,`mouth`,.7,e?1.4:.9,.7),d(u,`neckSmear`,0,e?1.4:.6)}a(`skull_fractured`)&&(d(l,`forehead`,1.1,1.4,+!r),d(u,`neckSmear`,0,1.1)),t.setGone(`jaw`,+!!s),t.setGone(`skull`,+!!c);let f=!1;for(let i of TD){let s=bO[i];t.setWound(s.ear,+!!a(`ear_${i}_torn`));let c=a(`face_${i}_flayed`);t.setWound(s.face,+!!c),c&&(d(l,s.cheek,.8,1.2),d(u,`neckSmear`,0,.9));let p=a(`eye_${i}_out`);p&&d(l,s.eye,1.1,+!r),this.eyeOut[i]&&!(p&&r)&&(f=!0),this.eyeOut[i]=p&&r,this.eyeShut[i]=p&&!r;let m=o?0:this.isPartGone(`arm_${i}`)?2:+!!this.isPartGone(`forearm_${i}`),h=!r&&a(`arm_${i}_torn`),g=!r&&a(`forearm_${i}_severed`);n.setGone(s.arm,m),n.setWound(s.shoulder,a(`shoulder_${i}_dislocated`)||h?1:0),n.setWound(s.elbow,a(`arm_${i}_broken`)||g?1:0),n.setWound(s.ribs,+!!a(`ribs_${i}_broken`)),n.setWound(s.knee,+!!a(`knee_${i}_blown`)),(m===2||h)&&d(u,s.smear,0,1.2),a(`ribs_${i}_broken`)&&d(u,s.ribs,1.2);let _=m>0||o;_?e.gloveMesh(i).visible=!1:this.gloveGone[i]&&(e.gloveMesh(i).visible=this.gloved[i]&&!e.isHandDismembered(i)),this.gloveGone[i]=_,this.piece(`fracture_${i}`,r&&!o&&m===0&&this.has(`arm_${i}_broken`)),this.piece(`ribs_${i}`,r&&!o&&this.has(`ribs_${i}_broken`)),this.piece(`knee_${i}`,r&&this.has(`knee_${i}_blown`)),this.piece(`elbow_${i}`,m===1),this.piece(`shoulder_${i}`,m===2)}f&&t.setEyeOut(this.eyeOut.left&&this.eyeOut.right?`both`:this.eyeOut.left?`left`:this.eyeOut.right?`right`:null),n.setWound(`liver`,+!!a(`liver_ruptured`)),n.setWound(`belly`,+!!a(`disemboweled`)),n.setGone(`waist`,+!!o),n.setGone(`chestHole`,r&&this.hole&&!o?1:0);let p=r&&this.has(`broken_jaw`)&&!s;this.jawHung&&!p&&t.setJaw(0),this.jawHung=p,o?e.headMesh.visible=!1:this.headHidden&&(e.headMesh.visible=!0),this.headHidden=o,this.piece(`skull`,c&&!o),this.piece(`maw`,s&&!o),this.piece(`chest`,r&&this.hole&&!o),this.piece(`waist`,o),c&&!o&&this.fitSkull();let m=wD(e,`body`);m!==null&&n.material!==null&&(n.open?m.customDepthMaterial=this.bodyShadow??=n.shadowMaterial():m.customDepthMaterial===this.bodyShadow&&(m.customDepthMaterial=void 0))}assert(){let e=this.boxer,t=e.headInjury,n=this.headRaises,r=this.bodyRaises;for(let e=0;e0,o=this.eyeOut.right||i.y>0;(this.eyeOut.left&&i.x===0||this.eyeOut.right&&i.y===0)&&t.setEyeOut(a&&o?`both`:a?`left`:`right`);let s=t.uniforms.uInjuryLid.value;(this.eyeShut.left||this.eyeShut.right)&&t.setEyesShut(this.eyeShut.left?1:s[0].w,this.eyeShut.right?1:s[1].w),this.gloveGone.left&&(e.gloveMesh(`left`).visible=!1),this.gloveGone.right&&(e.gloveMesh(`right`).visible=!1)}piece(e,t){if(t||this.pieces.has(e))for(let n of this.built(e))n.visible=t}built(e){let t=this.pieces.get(e);return t===void 0&&(t=this.make(e),this.pieces.set(e,t)),t}bindToWorld(e,t,n){let r=this.boxer.rig.bones[t],i=e.skeleton.bones.indexOf(r);return i<0?!1:(n.multiplyMatrices(r.matrixWorld,e.skeleton.boneInverses[i]).multiply(e.bindMatrix),!0)}skinMatrix(e,t,n){let r=e===`head`?this.boxer.headMesh:wD(this.boxer,`body`);return r!==null&&this.bindToWorld(r,t,n)}fitSkull(){let e=this.skull;if(e===null)return;let t=this.boxer.look,n=Fy(UD.set(5.9,124.6,-3.3),t,this.root).x,r=Fy(UD.set(-5.9,124.6,-3.3),t,this.root).x,i=Fy(UD.set(0,124.6,3.3),t,this.root).z,a=Fy(UD.set(0,124.6,-9.9),t,this.root).z,o=(i-a)/13.2;this.fit.makeScale((n-r)/11.8,1,o).setPosition((n+r)/2,0,(i+a)/2+3.3*o),e.matrix.multiplyMatrices(this.skullMount,this.fit)}solid(e){this.geometries.push(e);let t=new V(e,this.flesh);return t.receiveShadow=!0,t}mount(e,t,n=wD(this.boxer,`body`)){let r=this.boxer.rig.bones[e],i=n===null?-1:n.skeleton.bones.indexOf(r);return n!==null&&i>=0&&t.matrix.multiplyMatrices(n.skeleton.boneInverses[i],n.bindMatrix),t.matrixAutoUpdate=!1,t.visible=!1,r.add(t),t}closing(e,t,n){let r=wD(this.boxer,`body`);if(r===null)return[];let i=mO.get(r.geometry);i===void 0&&mO.set(r.geometry,i=new Map);let a=i.get(e);if(a===void 0&&i.set(e,a=J_(r.geometry,t)),a.length===0)return[];let o=new rl(hO(r.geometry,a,n),this.flesh);return this.geometries.push(o.geometry),o.bind(r.skeleton,r.bindMatrix),o.frustumCulled=!1,o.receiveShadow=!0,o.visible=!1,(r.parent??this.boxer.root).add(o),[o]}make(e){let t=this.boxer.headMesh;if(e===`skull`){let e=new gs,n=this.solid(ZD());return n.position.set(...YD),e.add(n,this.solid(QD())),this.mount(`head`,e,t),this.skullMount.copy(e.matrix),this.skull=e,this.brain=n,[e]}if(e===`maw`){let e=new gs,n=this.solid(rO());return n.position.set(...$D),e.add(this.solid(iO()),n),this.tongue=n,[this.mount(`head`,e,t)]}if(e===`chest`)return[...this.closing(e,e=>gg(e.x,e.y,e.z)<=0,_O),this.mount(`chest`,this.solid(lO()))];if(e===`waist`)return[...this.closing(e,e=>!xD(`upper_body`,`body`,e),gO(ED,.8)),this.mount(`spine`,this.solid(sO()))];let n=e.endsWith(`_left`)?`left`:`right`,{sign:r,bone:i}=bO[n];switch(e.slice(0,e.indexOf(`_`))){case`fracture`:return[this.mount(`shoulder${i}`,this.solid(qD([r*27.6,103.3,-5],[r*(Og[0]+2.4),Og[1]+2.6,Og[2]+1.4],1.05))),this.mount(`elbow${i}`,this.solid(KD([qD([r*34.6,102.3,-4.8],[r*30,98.6,-.8],.8),qD([r*34,103.2,-5.6],[r*30.6,100.6,-9.8],.6)])))];case`ribs`:return[this.mount(`chest`,this.solid(cO(r)))];case`knee`:return[this.mount(`knee${i}`,this.solid(qD([r*8.8,37.8,-4.6],[r*(kg[0]+3.8),kg[1]-1.2,kg[2]-.2],1.2)))];case`elbow`:return[...this.closing(e,e=>!xD(`forearm_${n}`,`body`,e),gO(new z(r,0,0),0)),this.mount(`shoulder${i}`,this.solid(aO(r)))];case`shoulder`:return[...this.closing(e,e=>!xD(`arm_${n}`,`body`,e),gO(new z(r,0,0),1.6)),this.mount(`clavicle${i}`,this.solid(oO(r)))]}}};function SO(e){switch(e){case`skull_fractured`:return`skull`;case`broken_jaw`:return`jaw`;case`broken_nose`:return`nose`;case`ribs_left_broken`:return`ribs_left`;case`ribs_right_broken`:return`ribs_right`;case`arm_left_broken`:return`arm_left`;case`arm_right_broken`:return`arm_right`;case`knee_left_blown`:return`knee_left`;case`knee_right_blown`:return`knee_right`;case`shoulder_left_dislocated`:return`shoulder_left`;case`shoulder_right_dislocated`:return`shoulder_right`;default:return null}}var CO=.3,wO=1.35,TO=.07,EO=.25,DO=.4,OO=.13,kO=.6,AO=.66,jO=1.05,MO=new B(10474751),NO=new B(16777215),PO=new B(132105),FO=5,IO=8,LO=(e,t)=>[t===`left`?e[0]:-e[0],e[1],e[2]];function RO(e){let t=e.endsWith(`_right`)?`right`:`left`,n=t===`left`?`L`:`R`;return e===`skull`?{center:[0,123.5,-1],radius:13,anchor:`skull`}:e===`jaw`?{center:[0,113.5,2],radius:10,anchor:`mouth`}:e===`nose`?{center:[0,118,3],radius:9,anchor:`nose`}:e.startsWith(`ribs`)?{center:LO(Dg[1],t),radius:26,anchor:`ribs_${t}`}:e.startsWith(`arm`)?{center:LO(Og,t),radius:17,anchor:`elbow_${t}`,joint:`elbow${n}`}:e.startsWith(`knee`)?{center:LO(kg,t),radius:20,anchor:`knee_${t}`,joint:`knee${n}`}:{center:LO([15,103.5,-5.5],t),radius:15,anchor:`shoulder_${t}`,joint:`shoulder${n}`}}var zO=[1,1,1],BO=[.06,.07,.09],VO=[.3,.32,.36],HO=[1,0,0],UO=new z(0,1,0);function WO(e,t){e.deleteAttribute(`uv`);let n=e.getAttribute(`position`).count,r=new Float32Array(n*3);for(let e=0;e0?.25:-1.75,e>0?1.75:-.25)])}function ik(){let e=WO(new Mu(1,8,5,Math.PI/2-.55,1.1,.35,.7).scale(5.75,6.25,7.45).translate(0,121.6,-3),VO),t=(e,t)=>[-5.8*Math.cos(e)*Math.sin(t),121.6+6.3*Math.cos(t),-3+7.5*Math.sin(e)*Math.sin(t)],n=[];for(let[e,r,i,a]of[[1,.35,.7,.05],[2.1,.4,2.7,.2],[2.1,1.05,2.8,1.2],[1,1.05,.4,1.3],[1.57,1.05,1.5,1.5],[1.57,.35,1.9,.02]]){let o=t((e+i)/2+.12,(r+a)/2+.05);n.push(XO(t(e,r),o,.22,BO),XO(o,t(i,a),.16,BO))}return ZO([e,...n])}function ak(e,t,n){let r=[];for(let i=e;i + #include +} +`,lk=class{root=new gs;uniforms={uCenter:{value:new z},uRadius:{value:0},uOpacity:{value:0},uFlash:{value:0}};material=new Wu({uniforms:this.uniforms,vertexShader:sk,fragmentShader:ck,vertexColors:!0,transparent:!0});framed=[];longs=[];chips=[];sprays=[];pieces=null;boxer=null;mutilation=null;site=null;spot=RO(`skull`);center=new z;fighter=-1;elapsed=0;held=!1;push=new z;matrix=new Ho;local=new Ho;turn=new vo;from=new z;to=new z;along=new z;across=new z;axis=new z;outward=new z;offset=new z;one=new z(1,1,1);insetCamera=new Wd(30,1,.05,40);canvasSize=new R;clearColor=new B;frameColor=new B;compiled=null;constructor(){this.root.visible=!1,this.root.name=`BoneXray`}get owner(){return this.site===null?-1:this.fighter}get breaking(){return this.site}get snapped(){return this.site!==null&&this.elapsed>=.3}drawInset(e,t,n){if(this.site===null||this.held||this.elapsed<=0)return;let r=e.getSize(this.canvasSize),i=Math.round(Math.min(r.x,r.y)*DO),a=Math.max(2,Math.round(i*.012)),o=this.fighter===0?Math.round(i*.08):r.x-i-Math.round(i*.08),s=r.y-i-Math.round(r.y*(r.y>r.x?kO:OO)),c=this.uniforms.uCenter.value,l=this.insetCamera,u=l.position.subVectors(n.position,c).setY(0).normalize();u.addScaledVector(this.push,-u.dot(this.push)),u.lengthSq()<.12&&u.set(-this.push.z,0,this.push.x),u.normalize().addScaledVector(this.outward,.4).setY(0).normalize(),l.position.multiplyScalar(this.spot.joint===void 0&&this.spot.radius<15?AO:jO).add(c),l.position.y+=.12,l.lookAt(c);let d=e.getClearAlpha(),f=e.shadowMap.autoUpdate;e.getClearColor(this.clearColor),e.shadowMap.autoUpdate=!1,e.setScissorTest(!0);let p=this.uniforms.uFlash.value;e.setClearColor(this.frameColor.copy(MO).lerp(NO,Math.min(1,p*2)),1),e.setScissor(o-a,s-a,i+a*2,i+a*2),e.clear(!0,!0,!1),e.setClearColor(PO,1),e.setScissor(o,s,i,i),e.setViewport(o,s,i,i),e.render(t,l),e.setScissorTest(!1),e.setViewport(0,0,r.x,r.y),e.setClearColor(this.clearColor,d),e.shadowMap.autoUpdate=f}start(e,t,n,r,i,a,o=!1){this.stop(),this.prepare(t),this.fighter=e,this.boxer=t,this.mutilation=n,this.site=r,this.spot=RO(r),this.center.set(this.spot.center[0],this.spot.center[1],this.spot.center[2]);let s=wD(t,`body`),c=this.spot.joint===void 0||s===null?-1:s.skeleton.bones.indexOf(t.rig.bones[this.spot.joint]);c>=0&&this.center.setFromMatrixPosition(this.matrix.multiplyMatrices(s.skeleton.boneInverses[c],s.bindMatrix).invert()),this.elapsed=o?wO*.5:0,this.held=o,this.push.set(i,0,a),this.push.lengthSq()<1e-6&&this.push.set(1,0,0),this.push.normalize();let l=r.length*7+3,u=()=>(l=l*16807%2147483647,l/2147483647);for(let e of this.sprays)e.set(this.push.x*.9+u()*1.6-.8,u()*1.5-.2,this.push.z*.9+u()*1.6-.8).multiplyScalar(.5+u()*.9);this.root.visible=!0}stop(){this.site!==null&&(this.boxer?.headInjury.setXray(0,0,0,0,0),this.boxer?.bodyInjury.setXray(0,0,0,0,0),this.site=null,this.boxer=null,this.mutilation=null,this.root.visible=!1)}update(e){let{site:t,boxer:n,mutilation:r,pieces:i}=this;if(t===null||n===null||r===null||i===null)return;this.held||(this.elapsed+=e);let a=this.elapsed;if(a>=1.35||!r.anchor(this.spot.anchor,this.uniforms.uCenter.value,this.outward)){this.stop();return}this.spot.joint!==void 0&&n.rig.bones[this.spot.joint].getWorldPosition(this.uniforms.uCenter.value);let o=a-CO,s=o<0?0:1-Math.exp(-o*20),c=o<0||this.held?0:Math.exp(-o*11),l=Math.min(1,a/TO,(wO-a)/EO),u=this.spot,d=this.center,f=1/n.rig.metrics.unitsPerMeter,p=this.held?1e3:u.radius*(1+FO*c);n.headInjury.setXray(d.x,d.y,d.z,p,l),n.bodyInjury.setXray(d.x,d.y,d.z,p,l),this.uniforms.uRadius.value=p*f*1.1,this.uniforms.uOpacity.value=l,this.uniforms.uFlash.value=c*.55;let m=+!!t.endsWith(`_right`),h=m===1?-1:1;for(let e of this.framed)e.mesh.visible=r.skinMatrix(e.skin,e.bone,e.mesh.matrix),e.mesh.matrixWorldNeedsUpdate=!0;let g=(e,t,n,r,i)=>{this.turn.setFromAxisAngle(this.axis.set(n[0],n[1],n[2]),r),this.local.compose(this.offset.set(t[0]+i[0],t[1]+i[1],t[2]+i[2]),this.turn,this.one),e.matrix.multiply(this.local).multiply(this.matrix.makeTranslation(-t[0],-t[1],-t[2]))};i.plate.visible&&=t===`skull`&&s>0,t===`jaw`?(g(i.jaw[0],[0,111.7,3.9],[0,1,0],.3*s,[.9*s,-.7*s,0]),g(i.jaw[1],[-5,116.8,-2.1],[0,0,1],-.16*s,[.5*s,0,0])):t===`nose`?g(i.nasal,[0,120.4,3.6],[0,0,1],.7*s,[.5*s,-.2*s,-.5*s]):t.startsWith(`ribs`)&&g(i.ribsFront[m],[h*11.2,96,-1.2],[0,1,0],-h*.5*s,[-h*.9*s,0,0]);let _=n.rig.bones;for(let e of this.longs){_[e.from].getWorldPosition(this.from),_[e.to].getWorldPosition(this.to);let n=e.mesh===i.humerus[m]&&(t.startsWith(`arm`)||t.startsWith(`shoulder`))||e.mesh===i.shin[m]&&t.startsWith(`knee`);e.mesh.visible=!0,n&&t.startsWith(`arm`)?(e.mesh.visible=!1,this.along.subVectors(this.to,this.from),this.across.crossVectors(this.along,this.push).normalize(),this.across.lengthSq()<.5&&this.across.set(0,1,0),this.span(i.stump,this.from,this.to,e.length,f),this.to.copy(this.from).addScaledVector(this.along,.62),this.offset.crossVectors(this.across,this.along).normalize(),i.shard.position.copy(this.to).addScaledVector(this.offset,.022*s),this.turn.setFromAxisAngle(this.across,.75*s),i.shard.quaternion.copy(i.stump.quaternion).premultiply(this.turn),i.shard.scale.copy(i.stump.scale)):(n&&t.startsWith(`shoulder`)&&(this.from.addScaledVector(this.push,.035*s).y-=.04*s),n&&t.startsWith(`knee`)&&this.from.addScaledVector(this.outward,.05*s),this.span(e.mesh,this.from,this.to,e.length,f))}let v=t.startsWith(`arm`);i.stump.visible=v,i.shard.visible=v;let y=this.uniforms.uCenter.value;for(let[e,t]of this.chips.entries()){if(t.visible=o>0,o<=0)continue;let n=this.sprays[e];t.position.copy(y).addScaledVector(n,o*.55),t.position.y-=1.6*o*o,t.rotation.set(o*9+e,o*7,e),t.scale.setScalar((e{let t=new V(e,this.material);return t.frustumCulled=!1,t.renderOrder=40,this.root.add(t),t},n=(e,n,r)=>{let i=t(e);return i.matrixAutoUpdate=!1,this.framed.push({mesh:i,skin:n,bone:r}),i},r=e.rig.metrics,i=r.unitsPerMeter,a=(e,n,r,i)=>{let a=t(e);return this.longs.push({mesh:a,from:n,to:r,length:i}),a};n(nk(),`head`,`head`);let o=n(ik(),`head`,`head`),s=n(XO([0,120.4,3.6],[0,118.3,5],.55,zO,.5),`head`,`head`),c=[n(rk(1),`head`,`head`),n(rk(-1),`head`,`head`)];n(ak(108.5,116.5,-3.4),`body`,`neck`),n(ak(88,108,-6.2),`body`,`chest`),n(ak(76,87.5,-3.6),`body`,`spine`),n(ok(),`body`,`hips`),n(ZO([WO(new Jl(2.2,10.5,.9).translate(0,99,4.3),zO),XO([1.4,106.4,2.8],[13.6,105.2,-3.4],.55),XO([-1.4,106.4,2.8],[-13.6,105.2,-3.4],.55),GO([11,101,-7.6],[3.6,4.6,.7]),GO([-11,101,-7.6],[3.6,4.6,.7])]),`body`,`chest`),n(ek(1,!1),`body`,`chest`),n(ek(-1,!1),`body`,`chest`);let l=[n(ek(1,!0),`body`,`chest`),n(ek(-1,!0),`body`,`chest`)],u=r.armL.upper*i,d=r.armL.lower*i,f=r.legL.upper*i,p=r.legL.lower*i,m=QO(u,.95,1.5),h=QO(d,.62,1.15,.9),g=QO(f,1.25,2),_=QO(p,1.05,1.75,1.5),v=XO([0,0,0],[0,10,0],.9,zO,.6),y=[a(m,`shoulderL`,`elbowL`,u),a(m,`shoulderR`,`elbowR`,u)];a(h,`elbowL`,`gloveL`,d),a(h,`elbowR`,`gloveR`,d),a(g,`hipL`,`kneeL`,f),a(g,`hipR`,`kneeR`,f);let b=[a(_,`kneeL`,`ankleL`,p),a(_,`kneeR`,`ankleR`,p)];a(v,`ankleL`,`toeL`,10),a(v,`ankleR`,`toeR`,10);let x=u*.62,S=t(ZO([XO([0,0,0],[0,x,0],.95,zO,.85),GO([0,0,0],1.5),XO([0,x,0],[.5,x+1.6,.2],.7,zO,.1),GO([0,x,0],.6,HO)])),C=t(ZO([XO([0,.4,0],[0,u-x,0],.85),GO([0,u-x,0],1.3),XO([0,.6,0],[-.4,-1.5,-.3],.7,zO,.1),GO([0,.5,0],.55,HO)])),w=WO(new Nu(1),zO),T=WO(new Du(1,1),HO);for(let e=0;e<14;e+=1)this.chips.push(t(e{let e=this.context;e!==null&&e.state!==`running`&&e.resume().catch(()=>void 0),this.unlock().catch(()=>void 0)};visibility=()=>{let e=this.context;if(e===null)return;let t=document.hidden?e.suspend():this.unlocked?e.resume():null;t!==null&&t.catch(()=>void 0)};constructor(e){this.settings=e;for(let e of Tk)window.addEventListener(e,this.unlockListener);document.addEventListener(`visibilitychange`,this.visibility)}unlock(){return this.destroyed||this.unlocked?Promise.resolve():(this.unlockPromise===null&&(this.unlockPromise=this.performUnlock().finally(()=>{this.unlockPromise=null})),this.unlockPromise)}async performUnlock(){let e=this.context;if(e===null){e=new AudioContext;let t=e.createGain();t.gain.value=Math.min(.8,Math.max(0,this.settings().volume));let n=e.createBiquadFilter();n.type=`lowpass`,n.frequency.value=Ck,n.Q.value=.7,t.connect(n).connect(e.destination),this.context=e,this.master=t,this.muffle=n}if(e.state===`suspended`&&await e.resume(),this.destroyed||this.context!==e)return;let t=await this.decodeInjuryBuffers(e);if(!(this.destroyed||this.context!==e)){this.injuryBuffers=t,this.unlocked=!0;for(let e of Tk)window.removeEventListener(e,this.unlockListener);this.crowdStarted||(this.crowdStarted=!0,this.crowdBed())}}setVolume(){this.master!==null&&(this.master.gain.value=Math.min(.8,Math.max(0,this.settings().volume)))}event(e,t=!1){if(this.unlocked)switch(e.kind){case`punch_start`:this.whoosh(e.detail.split(`:`)[1]??`jab`,t);break;case`whiff`:this.noise({duration:.11,frequency:850,sweepTo:320,gain:.07,type:`bandpass`,q:1.1});break;case`hit`:case`counter_hit`:{let n=e.detail.endsWith(`body`),r=Math.min(1,e.amount/260),i=Math.min(.36,.14+r*.2)*(e.kind===`counter_hit`?1.25:1);this.impact(i,n,r,t),(e.kind===`counter_hit`||r>.7||t)&&this.crowdSwell(.35+r*.4),(e.kind===`counter_hit`&&e.amount>=50||e.amount>=90)&&this.ooh(Math.min(1,e.amount/160));break}case`referee_hit`:{let t=Math.min(1,e.amount/260);this.impact(Math.min(.36,.16+t*.2),e.detail.endsWith(`body`),t),this.ooh(.7+t*.3),this.crowdSwell(.5+t*.3);break}case`referee_down`:this.impact(.36,!1,1),this.crowdRoar(1),this.ooh(1);break;case`block`:this.noise({duration:.045,frequency:1200,sweepTo:600,gain:.14,type:`bandpass`,q:1.1}),this.noise({duration:.09,frequency:260,gain:.08}),this.tone({from:160,to:110,duration:.06,type:`triangle`,gain:.05}),t&&this.tone({from:96,to:44,duration:.2,type:`sine`,gain:.2});break;case`perfect_block`:this.noise({duration:.05,frequency:1800,sweepTo:900,gain:.16,type:`bandpass`,q:1.6}),this.tone({from:280,to:210,duration:.06,type:`triangle`,gain:.06});break;case`guard_break`:this.impact(.3,!1,.9),this.tone({from:230,to:78,duration:.2,type:`sawtooth`,gain:.08}),this.crowdSwell(.5),this.ooh(.6);break;case`stun`:this.tone({from:96,to:74,duration:.22,type:`sine`,gain:.1}),this.crowdSwell(.3);break;case`parry`:this.noise({duration:.06,frequency:2400,sweepTo:1100,gain:.18,type:`bandpass`,q:1.8}),this.tone({from:330,to:180,duration:.09,type:`triangle`,gain:.07}),this.crowdSwell(.35);break;case`body_collapse`:this.tone({from:118,to:52,duration:.42,type:`sine`,gain:.16}),this.noise({duration:.26,frequency:420,sweepTo:180,gain:.05,type:`bandpass`,q:.9}),this.crowdSwell(.6);break;case`eye_shut`:this.crowdSwell(.25);break;case`corner`:this.noise({duration:.22,frequency:2600,sweepTo:1500,gain:.05,type:`bandpass`,q:.8});break;case`knockdown`:this.impact(.34,!1,1),this.tone({from:60,to:28,duration:.42,type:`sine`,gain:.3}),this.noise({duration:.3,frequency:140,gain:.24}),this.crowdRoar(1),this.hush();break;case`bell`:{let t=e.detail===`round_start`?3:1;for(let e=0;e10*r||this.clapperRound===t||(this.clapperRound=t,!this.unlocked))return;this.noise({duration:.05,frequency:2600,gain:.42,type:`bandpass`,q:1.4}),this.noise({duration:.09,frequency:700,gain:.18,type:`bandpass`,q:.8});let i=window.setTimeout(()=>{this.timers.delete(i),this.noise({duration:.05,frequency:2400,gain:.4,type:`bandpass`,q:1.4}),this.noise({duration:.09,frequency:660,gain:.16,type:`bandpass`,q:.8})},120);this.timers.add(i)}chant(){let e=this.context;if(!(!this.unlocked||e===null||e.currentTime-this.lastChantAtthis.murmurLevel;this.murmurLevel=r,n.gain.setTargetAtTime(r*xk,t.currentTime,i?.3:.8)}rocked(e,t){this.follow(t);let n=this.context,r=this.muffle;if(!this.unlocked||n===null||r===null)return;let i=Math.max(0,Math.min(1,e));if(Math.abs(i-this.rockedLevel)>=.02||i===0&&this.rockedLevel!==0){let e=i>this.rockedLevel;this.rockedLevel=i,r.frequency.setTargetAtTime(Ck*(wk/Ck)**+i,n.currentTime,e?.05:.9)}i>.15&&t-this.lastRockedBeat>=Dk(i)&&(this.lastRockedBeat=t,this.tone({from:58,to:40,duration:.12,type:`sine`,gain:.09+i*.08}),this.tone({from:50,to:36,duration:.14,type:`sine`,gain:.07+i*.06,delay:.16}))}snapshot(e,t,n,r){if(this.follow(e),!this.unlocked)return;let i=1-t/Math.max(1,n);i>.55&&e-this.lastBreathTick>=75&&(this.lastBreathTick=e,this.noise({duration:.18,frequency:420,gain:.045+i*.04})),(i>.72||r>500)&&this.rockedLevel<=.15&&e-this.lastHeartbeatTick>=24&&(this.lastHeartbeatTick=e,this.tone({from:52,duration:.09,type:`sine`,gain:.055}))}result(e){if(this.openMuffle(),!this.unlocked)return;this.crowdSwell(1),this.tone({from:e.winner_id===null?280:520,duration:.45,type:`triangle`,gain:.18});let t=window.setTimeout(()=>{this.timers.delete(t),this.tone({from:650,duration:.5,type:`triangle`,gain:.14})},160);this.timers.add(t)}injury(e){let t=this.context,n=this.master,r=this.injuryBuffers.get(uk[e]??e),i=this.settings();if(!this.unlocked||t===null||n===null||i.blood!==`full`||i.reducedMotion||(this.tearing(),r===void 0))return;let a=t.createBufferSource(),o=t.createGain();a.buffer=r,o.gain.value=.2,a.connect(o).connect(n),a.start()}tearing(){this.noise({duration:.09,frequency:2600,sweepTo:700,gain:.22,type:`bandpass`,q:1.6}),this.noise({duration:.4,frequency:900,sweepTo:150,gain:.28,type:`lowpass`,q:6,offset:.35});for(let[e,t]of[.3,.9,1.5].entries())this.noise({duration:.2,frequency:480-e*60,sweepTo:170,gain:.13-e*.03,type:`bandpass`,q:4,delay:t,offset:.2+t})}gore(e){let t=this.settings();if(!this.unlocked||t.volume<=0)return;let n=t.blood===`full`&&!t.reducedMotion;switch(e.kind){case`injury`:{let t=dk[N(e.injury)];n?(this.wound(t,0),t===`crack`&&this.xray()):this.impact(.3,!1,.9),this.ooh(1),this.crowdSwell(.8),t!==`crack`&&this.crowdVoice({..._k,delay:.45});break}case`vomit`:n&&this.retch(),this.crowdVoice({..._k,gain:.09,delay:.5});break;case`finish_him`:this.omen(),this.crowdRoar(1);break;case`fatality`:this.sting(),n&&fk[e.fatality].forEach((e,t)=>this.wound(e,t*.2)),this.crowdRoar(1),this.ooh(1);break;case`death`:ke(e.cause)===null?(this.flatline(0),this.hush(!0)):this.flatline(hk)}}wound(e,t){e===`crack`?this.crack(t):e===`rip`?this.rip(t):e===`squelch`?this.squelch(t):this.chop(t)}xray(){this.tone({from:90,to:440,duration:CO,type:`sine`,gain:.1,delay:0}),this.crack(CO),this.noise({duration:.16,frequency:520,sweepTo:170,gain:.2,type:`lowpass`,q:4,delay:CO+.03,offset:.3})}crack(e){this.noise({duration:.03,frequency:3400,sweepTo:1800,gain:.34,type:`bandpass`,q:2.2,delay:e}),this.tone({from:190,to:70,duration:.09,type:`triangle`,gain:.22,delay:e});for(let[t,n]of mk.entries())this.noise({duration:.018,frequency:2800-t*260,gain:.2-t*.03,type:`highpass`,q:1.4,delay:e+n,offset:.17*(t+1)})}rip(e){this.noise({duration:.5,frequency:420,sweepTo:2600,gain:.3,type:`bandpass`,q:3.2,delay:e,offset:.4}),this.noise({duration:.45,frequency:180,sweepTo:520,gain:.2,type:`lowpass`,q:5,delay:e+.03,offset:.7});for(let t=0;t<6;t+=1)this.noise({duration:.035,frequency:900+t*280,gain:.16,type:`bandpass`,q:6,delay:e+.05+t*.07,offset:.09*t});this.noise({duration:.12,frequency:700,sweepTo:160,gain:.24,type:`lowpass`,q:4,delay:e+.52,offset:.55})}squelch(e){this.noise({duration:.3,frequency:1100,sweepTo:140,gain:.32,type:`lowpass`,q:9,delay:e,offset:.25}),this.noise({duration:.22,frequency:300,sweepTo:900,gain:.18,type:`bandpass`,q:7,delay:e+.1,offset:.6}),this.tone({from:150,to:60,duration:.12,type:`sine`,gain:.16,delay:e}),this.spatter(e+.25)}spatter(e){for(let[t,n]of pk.entries())this.noise({duration:.03,frequency:1500+t%3*600,sweepTo:500,gain:.14-t*.012,type:`bandpass`,q:3,delay:e+n,offset:.13*t})}chop(e){this.tone({from:120,to:38,duration:.2,type:`sine`,gain:.32,delay:e}),this.noise({duration:.05,frequency:2200,sweepTo:500,gain:.3,type:`bandpass`,q:1.2,delay:e}),this.noise({duration:.16,frequency:600,sweepTo:150,gain:.26,type:`lowpass`,q:5,delay:e+.02,offset:.3});for(let[t,n]of[.3,.75,1.2,1.65].entries())this.noise({duration:.22,frequency:520-t*60,sweepTo:170,gain:.15-t*.03,type:`bandpass`,q:4,delay:e+n,offset:.2+n})}retch(){for(let[e,t]of[0,.45].entries())this.tone({from:150-e*25,to:80,duration:.3,type:`sawtooth`,gain:.09,delay:t}),this.crowdVoice({duration:.36,first:[650,360],second:[1150,780],gain:.22,delay:t});this.noise({duration:.45,frequency:2400,sweepTo:300,gain:.24,type:`lowpass`,q:3,delay:.9,offset:.5}),this.spatter(1.05)}drum(e){this.tone({from:95,to:30,duration:.7,type:`sine`,gain:.35,delay:e}),this.noise({duration:.2,frequency:160,gain:.3,delay:e}),this.noise({duration:.03,frequency:1800,sweepTo:600,gain:.18,type:`bandpass`,q:1,delay:e})}omen(){this.drum(0),this.held({frequency:27.5,duration:1.4,gain:.3,attack:1.1,type:`sine`,delay:.1}),this.held({frequency:55,duration:1.4,gain:.12,attack:1.2,type:`sawtooth`,delay:.1}),this.held({frequency:58.3,duration:1.4,gain:.1,attack:1.2,type:`sawtooth`,delay:.1}),this.drum(1.5)}sting(){this.drum(0);for(let[e,t]of[196,185,147,110].entries())this.tone({from:t,to:t*.97,duration:.5,type:`sawtooth`,gain:.14,delay:e*.2}),this.tone({from:t/2,duration:.5,type:`square`,gain:.1,delay:e*.2});this.tone({from:73.4,to:69,duration:1.4,type:`sawtooth`,gain:.2,delay:.8}),this.tone({from:36.7,to:34.5,duration:1.4,type:`sine`,gain:.32,delay:.8}),this.drum(.8)}flatline(e){for(let t of[0,.38])this.held({frequency:880,duration:.09,gain:.1,attack:.005,type:`sine`,delay:e+t});this.held({frequency:880,duration:2.6,gain:.1,attack:.01,type:`sine`,delay:e+.76})}held(e){let t=this.context,n=this.master;if(t===null||n===null)return;let r=t.currentTime+(e.delay??0),i=Math.min(3,e.duration),a=Math.min(.35,e.gain),o=t.createOscillator(),s=t.createGain();o.type=e.type,o.frequency.setValueAtTime(Math.max(20,e.frequency),r),s.gain.setValueAtTime(1e-4,r),s.gain.exponentialRampToValueAtTime(a,r+Math.min(i-.03,e.attack)),s.gain.setValueAtTime(a,r+i-.03),s.gain.exponentialRampToValueAtTime(1e-4,r+i),o.connect(s).connect(n),o.start(r),o.stop(r+i+.03)}async decodeInjuryBuffers(e){let t=await Promise.all($r.map(async t=>{let n=atob(t.wav),r=new Uint8Array(n.length);for(let e=0;evoid 0)}},kk=class extends Error{code;reloadRequired;name=`ClientError`;constructor(e,t=!1){super(e),this.code=e,this.reloadRequired=t}};async function Ak(e,t){if(!e.ok)throw new kk(e.status===429?`rate_limited`:t);if(!(e.headers.get(`content-type`)??``).toLowerCase().startsWith(`application/json`))throw new kk(t);try{return Ke(await e.text())}catch{throw new kk(t)}}function jk(e=window.location.search){let t=new URLSearchParams(e).getAll(`instance_id`);if(t.length!==1||!/^[A-Za-z0-9_-]{1,255}$/u.test(t[0]??``))throw new kk(`invalid_launch`);return t[0]}function Mk(e){if(typeof e==`object`&&e&&`protocol`in e&&e.protocol!==6)throw new kk(`client_outdated`,!0)}async function Nk(e,t){let n=new URL(`/api/hands/bootstrap`,window.location.origin);try{let r=await Ak(await fetch(n,{method:`POST`,credentials:`same-origin`,cache:`no-store`,headers:{"Content-Type":`application/json`},body:JSON.stringify({instance_id:e}),...t===void 0?{}:{signal:t}}),`bootstrap_failed`);return Mk(r),Ft(r)}catch(e){throw e instanceof kk?e:e instanceof He?new kk(`invalid_bootstrap`):new kk(`bootstrap_failed`)}}async function Pk(e,t,n){try{return It(await Ak(await fetch(new URL(`/api/hands/token`,window.location.origin),{method:`POST`,credentials:`same-origin`,cache:`no-store`,headers:{"Content-Type":`application/json`},body:JSON.stringify({code:e,state:t}),...n===void 0?{}:{signal:n}}),`token_failed`))}catch(e){throw e instanceof kk?e:e instanceof He?new kk(`invalid_token_response`):new kk(`token_failed`)}}function Fk(e){return e instanceof kk?e.code:e instanceof He?`protocol_error`:`unexpected_error`}var Ik=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};function Lk(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}var Rk={exports:{}},zk;function Bk(){return zk||(zk=1,(function(e){var t=Object.prototype.hasOwnProperty,n=`~`;function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function i(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function a(e,t,r,a,o){if(typeof r!=`function`)throw TypeError(`The listener must be a function`);var s=new i(r,a||e,o),c=n?n+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function o(e,t){--e._eventsCount===0?e._events=new r:delete e._events[t]}function s(){this._events=new r,this._eventsCount=0}s.prototype.eventNames=function(){var e=[],r,i;if(this._eventsCount===0)return e;for(i in r=this._events)t.call(r,i)&&e.push(n?i.slice(1):i);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(r)):e},s.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,a=r.length,o=Array(a);ie;function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(Hk||={});var Uk;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(Uk||={});var G=Hk.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),Wk=e=>{switch(typeof e){case`undefined`:return G.undefined;case`string`:return G.string;case`number`:return isNaN(e)?G.nan:G.number;case`boolean`:return G.boolean;case`function`:return G.function;case`bigint`:return G.bigint;case`symbol`:return G.symbol;case`object`:return Array.isArray(e)?G.array:e===null?G.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?G.promise:typeof Map<`u`&&e instanceof Map?G.map:typeof Set<`u`&&e instanceof Set?G.set:typeof Date<`u`&&e instanceof Date?G.date:G.object;default:return G.unknown}},K=Hk.arrayToEnum([`invalid_type`,`invalid_literal`,`custom`,`invalid_union`,`invalid_union_discriminator`,`invalid_enum_value`,`unrecognized_keys`,`invalid_arguments`,`invalid_return_type`,`invalid_date`,`invalid_string`,`too_small`,`too_big`,`invalid_intersection_types`,`not_multiple_of`,`not_finite`]),Gk=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,`$1:`),Kk=class e extends Error{constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}get errors(){return this.issues}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;re.message){let t={},n=[];for(let r of this.issues)r.path.length>0?(t[r.path[0]]=t[r.path[0]]||[],t[r.path[0]].push(e(r))):n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};Kk.create=e=>new Kk(e);var qk=(e,t)=>{let n;switch(e.code){case K.invalid_type:n=e.received===G.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case K.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,Hk.jsonStringifyReplacer)}`;break;case K.unrecognized_keys:n=`Unrecognized key(s) in object: ${Hk.joinValues(e.keys,`, `)}`;break;case K.invalid_union:n=`Invalid input`;break;case K.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Hk.joinValues(e.options)}`;break;case K.invalid_enum_value:n=`Invalid enum value. Expected ${Hk.joinValues(e.options)}, received '${e.received}'`;break;case K.invalid_arguments:n=`Invalid function arguments`;break;case K.invalid_return_type:n=`Invalid function return type`;break;case K.invalid_date:n=`Invalid date`;break;case K.invalid_string:typeof e.validation==`object`?`includes`in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==`number`&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):`startsWith`in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:`endsWith`in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:Hk.assertNever(e.validation):n=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case K.too_small:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at least`:`more than`} ${e.minimum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at least`:`over`} ${e.minimum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${e.minimum}`:e.type===`date`?`Date must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(e.minimum))}`:`Invalid input`;break;case K.too_big:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at most`:`less than`} ${e.maximum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at most`:`under`} ${e.maximum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`bigint`?`BigInt must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`date`?`Date must be ${e.exact?`exactly`:e.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(e.maximum))}`:`Invalid input`;break;case K.custom:n=`Invalid input`;break;case K.invalid_intersection_types:n=`Intersection results could not be merged`;break;case K.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case K.not_finite:n=`Number must be finite`;break;default:n=t.defaultError,Hk.assertNever(e)}return{message:n}},Jk=qk;function Yk(e){Jk=e}function Xk(){return Jk}var Zk=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}},Qk=[];function q(e,t){let n=Xk(),r=Zk({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===qk?void 0:qk].filter(e=>!!e)});e.common.issues.push(r)}var $k=class e{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return eA;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return eA;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}},eA=Object.freeze({status:`aborted`}),tA=e=>({status:`dirty`,value:e}),nA=e=>({status:`valid`,value:e}),rA=e=>e.status===`aborted`,iA=e=>e.status===`dirty`,aA=e=>e.status===`valid`,oA=e=>typeof Promise<`u`&&e instanceof Promise;function sA(e,t,n,r){if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return t.get(e)}function cA(e,t,n,r,i){if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return t.set(e,n),n}var lA;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(lA||={});var uA,dA,fA=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},pA=(e,t)=>{if(aA(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){if(this._error)return this._error;let t=new Kk(e.common.issues);return this._error=t,this._error}}};function mA(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var hA=class{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return Wk(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Wk(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new $k,ctx:{common:e.parent.common,data:e.data,parsedType:Wk(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(oA(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Wk(e)};return pA(n,this._parseSync({data:e,path:n.path,parent:n}))}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Wk(e)},r=this._parse({data:e,path:n.path,parent:n});return pA(n,await(oA(r)?r:Promise.resolve(r)))}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let i=e(t),a=()=>r.addIssue({code:K.custom,...n(t)});return typeof Promise<`u`&&i instanceof Promise?i.then(e=>e?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new fj({schema:this,typeName:wj.ZodEffects,effect:{type:`refinement`,refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return pj.create(this,this._def)}nullable(){return mj.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return qA.create(this,this._def)}promise(){return dj.create(this,this._def)}or(e){return XA.create([this,e],this._def)}and(e){return ej.create(this,e,this._def)}transform(e){return new fj({...mA(this._def),schema:this,typeName:wj.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new hj({...mA(this._def),innerType:this,defaultValue:t,typeName:wj.ZodDefault})}brand(){return new yj({typeName:wj.ZodBranded,type:this,...mA(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new gj({...mA(this._def),innerType:this,catchValue:t,typeName:wj.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return bj.create(this,e)}readonly(){return xj.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},gA=/^c[^\s-]{8,}$/i,_A=/^[0-9a-z]+$/,vA=/^[0-9A-HJKMNP-TV-Z]{26}$/,yA=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-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d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`,kA=RegExp(`^${OA}$`);function AA(e){let t=`([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;return e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`),t}function jA(e){return RegExp(`^${AA(e)}$`)}function MA(e){let t=`${OA}T${AA(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function NA(e,t){return!((t!==`v4`&&t||!TA.test(e))&&(t!==`v6`&&t||!EA.test(e)))}var PA=class e extends hA{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==G.string){let t=this._getOrReturnCtx(e);return q(t,{code:K.invalid_type,expected:G.string,received:t.parsedType}),eA}let t=new $k,n;for(let r of this._def.checks)if(r.kind===`min`)e.data.lengthr.value&&(n=this._getOrReturnCtx(e,n),q(n,{code:K.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`length`){let i=e.data.length>r.value,a=e.data.lengthe.test(t),{validation:t,code:K.invalid_string,...lA.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...lA.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...lA.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...lA.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...lA.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...lA.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...lA.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...lA.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...lA.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...lA.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...lA.errToObj(e)})}datetime(e){return typeof e==`string`?this._addCheck({kind:`datetime`,precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:`datetime`,precision:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...lA.errToObj(e?.message)})}date(e){return this._addCheck({kind:`date`,message:e})}time(e){return typeof e==`string`?this._addCheck({kind:`time`,precision:null,message:e}):this._addCheck({kind:`time`,precision:e?.precision===void 0?null:e?.precision,...lA.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...lA.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...lA.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...lA.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...lA.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...lA.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...lA.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...lA.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...lA.errToObj(t)})}nonempty(e){return this.min(1,lA.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toUpperCase`}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind===`datetime`)}get isDate(){return!!this._def.checks.find(e=>e.kind===`date`)}get isTime(){return!!this._def.checks.find(e=>e.kind===`time`)}get isDuration(){return!!this._def.checks.find(e=>e.kind===`duration`)}get isEmail(){return!!this._def.checks.find(e=>e.kind===`email`)}get isURL(){return!!this._def.checks.find(e=>e.kind===`url`)}get isEmoji(){return!!this._def.checks.find(e=>e.kind===`emoji`)}get isUUID(){return!!this._def.checks.find(e=>e.kind===`uuid`)}get isNANOID(){return!!this._def.checks.find(e=>e.kind===`nanoid`)}get isCUID(){return!!this._def.checks.find(e=>e.kind===`cuid`)}get isCUID2(){return!!this._def.checks.find(e=>e.kind===`cuid2`)}get isULID(){return!!this._def.checks.find(e=>e.kind===`ulid`)}get isIP(){return!!this._def.checks.find(e=>e.kind===`ip`)}get isBase64(){return!!this._def.checks.find(e=>e.kind===`base64`)}get minLength(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.valuenew PA({checks:[],typeName:wj.ZodString,coerce:e?.coerce??!1,...mA(e)});function FA(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return parseInt(e.toFixed(i).replace(`.`,``))%parseInt(t.toFixed(i).replace(`.`,``))/10**i}var IA=class e extends hA{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==G.number){let t=this._getOrReturnCtx(e);return q(t,{code:K.invalid_type,expected:G.number,received:t.parsedType}),eA}let t,n=new $k;for(let r of this._def.checks)r.kind===`int`?Hk.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),q(t,{code:K.invalid_type,expected:`integer`,received:`float`,message:r.message}),n.dirty()):r.kind===`min`?(r.inclusive?e.datar.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),q(t,{code:K.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`multipleOf`?FA(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),q(t,{code:K.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),q(t,{code:K.not_finite,message:r.message}),n.dirty()):Hk.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,lA.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,lA.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,lA.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,lA.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:lA.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:lA.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:lA.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:lA.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:lA.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:lA.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:lA.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:lA.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:lA.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:lA.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.valuee.kind===`int`||e.kind===`multipleOf`&&Hk.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.valuenew IA({checks:[],typeName:wj.ZodNumber,coerce:e?.coerce||!1,...mA(e)});var LA=class e extends hA{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==G.bigint){let t=this._getOrReturnCtx(e);return q(t,{code:K.invalid_type,expected:G.bigint,received:t.parsedType}),eA}let t,n=new $k;for(let r of this._def.checks)r.kind===`min`?(r.inclusive?e.datar.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),q(t,{code:K.too_big,type:`bigint`,maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`multipleOf`?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),q(t,{code:K.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):Hk.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,lA.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,lA.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,lA.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,lA.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:lA.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:lA.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:lA.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:lA.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:lA.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:lA.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.valuenew LA({checks:[],typeName:wj.ZodBigInt,coerce:e?.coerce??!1,...mA(e)});var RA=class extends hA{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==G.boolean){let t=this._getOrReturnCtx(e);return q(t,{code:K.invalid_type,expected:G.boolean,received:t.parsedType}),eA}return nA(e.data)}};RA.create=e=>new RA({typeName:wj.ZodBoolean,coerce:e?.coerce||!1,...mA(e)});var zA=class e extends hA{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==G.date){let t=this._getOrReturnCtx(e);return q(t,{code:K.invalid_type,expected:G.date,received:t.parsedType}),eA}if(isNaN(e.data.getTime()))return q(this._getOrReturnCtx(e),{code:K.invalid_date}),eA;let t=new $k,n;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()r.value&&(n=this._getOrReturnCtx(e,n),q(n,{code:K.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),t.dirty()):Hk.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:lA.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:lA.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.valuenew zA({checks:[],coerce:e?.coerce||!1,typeName:wj.ZodDate,...mA(e)});var BA=class extends hA{_parse(e){if(this._getType(e)!==G.symbol){let t=this._getOrReturnCtx(e);return q(t,{code:K.invalid_type,expected:G.symbol,received:t.parsedType}),eA}return nA(e.data)}};BA.create=e=>new BA({typeName:wj.ZodSymbol,...mA(e)});var VA=class extends hA{_parse(e){if(this._getType(e)!==G.undefined){let t=this._getOrReturnCtx(e);return q(t,{code:K.invalid_type,expected:G.undefined,received:t.parsedType}),eA}return nA(e.data)}};VA.create=e=>new VA({typeName:wj.ZodUndefined,...mA(e)});var HA=class extends hA{_parse(e){if(this._getType(e)!==G.null){let t=this._getOrReturnCtx(e);return q(t,{code:K.invalid_type,expected:G.null,received:t.parsedType}),eA}return nA(e.data)}};HA.create=e=>new HA({typeName:wj.ZodNull,...mA(e)});var UA=class extends hA{constructor(){super(...arguments),this._any=!0}_parse(e){return nA(e.data)}};UA.create=e=>new UA({typeName:wj.ZodAny,...mA(e)});var WA=class extends hA{constructor(){super(...arguments),this._unknown=!0}_parse(e){return nA(e.data)}};WA.create=e=>new WA({typeName:wj.ZodUnknown,...mA(e)});var GA=class extends hA{_parse(e){let t=this._getOrReturnCtx(e);return q(t,{code:K.invalid_type,expected:G.never,received:t.parsedType}),eA}};GA.create=e=>new GA({typeName:wj.ZodNever,...mA(e)});var KA=class extends hA{_parse(e){if(this._getType(e)!==G.undefined){let t=this._getOrReturnCtx(e);return q(t,{code:K.invalid_type,expected:G.void,received:t.parsedType}),eA}return nA(e.data)}};KA.create=e=>new KA({typeName:wj.ZodVoid,...mA(e)});var qA=class e extends hA{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==G.array)return q(t,{code:K.invalid_type,expected:G.array,received:t.parsedType}),eA;if(r.exactLength!==null){let e=t.data.length>r.exactLength.value,i=t.data.lengthr.maxLength.value&&(q(t,{code:K.too_big,maximum:r.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new fA(t,e,t.path,n)))).then(e=>$k.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new fA(t,e,t.path,n)));return $k.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:lA.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:lA.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:lA.toString(n)}})}nonempty(e){return this.min(1,e)}};qA.create=(e,t)=>new qA({type:e,minLength:null,maxLength:null,exactLength:null,typeName:wj.ZodArray,...mA(t)});function JA(e){if(e instanceof YA){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=pj.create(JA(r))}return new YA({...e._def,shape:()=>t})}return e instanceof qA?new qA({...e._def,type:JA(e.element)}):e instanceof pj?pj.create(JA(e.unwrap())):e instanceof mj?mj.create(JA(e.unwrap())):e instanceof tj?tj.create(e.items.map(e=>JA(e))):e}var YA=class e extends hA{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=Hk.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==G.object){let t=this._getOrReturnCtx(e);return q(t,{code:K.invalid_type,expected:G.object,received:t.parsedType}),eA}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof GA&&this._def.unknownKeys===`strip`))for(let e in n.data)i.includes(e)||a.push(e);let o=[];for(let e of i){let t=r[e],i=n.data[e];o.push({key:{status:`valid`,value:e},value:t._parse(new fA(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof GA){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of a)o.push({key:{status:`valid`,value:e},value:{status:`valid`,value:n.data[e]}});else if(e===`strict`)a.length>0&&(q(n,{code:K.unrecognized_keys,keys:a}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of a){let r=n.data[t];o.push({key:{status:`valid`,value:t},value:e._parse(new fA(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of o){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>$k.mergeObjectSync(t,e)):$k.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return lA.errToObj,new e({...this._def,unknownKeys:`strict`,...t===void 0?{}:{errorMap:(e,n)=>{var r;let i=(r=this._def).errorMap?.call(r,e,n).message??n.defaultError;return e.code===`unrecognized_keys`?{message:lA.errToObj(t).message??i}:{message:i}}}})}strip(){return new e({...this._def,unknownKeys:`strip`})}passthrough(){return new e({...this._def,unknownKeys:`passthrough`})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:wj.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};return Hk.objectKeys(t).forEach(e=>{t[e]&&this.shape[e]&&(n[e]=this.shape[e])}),new e({...this._def,shape:()=>n})}omit(t){let n={};return Hk.objectKeys(this.shape).forEach(e=>{t[e]||(n[e]=this.shape[e])}),new e({...this._def,shape:()=>n})}deepPartial(){return JA(this)}partial(t){let n={};return Hk.objectKeys(this.shape).forEach(e=>{let r=this.shape[e];t&&!t[e]?n[e]=r:n[e]=r.optional()}),new e({...this._def,shape:()=>n})}required(t){let n={};return Hk.objectKeys(this.shape).forEach(e=>{if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof pj;)t=t._def.innerType;n[e]=t}}),new e({...this._def,shape:()=>n})}keyof(){return cj(Hk.objectKeys(this.shape))}};YA.create=(e,t)=>new YA({shape:()=>e,unknownKeys:`strip`,catchall:GA.create(),typeName:wj.ZodObject,...mA(t)}),YA.strictCreate=(e,t)=>new YA({shape:()=>e,unknownKeys:`strict`,catchall:GA.create(),typeName:wj.ZodObject,...mA(t)}),YA.lazycreate=(e,t)=>new YA({shape:e,unknownKeys:`strip`,catchall:GA.create(),typeName:wj.ZodObject,...mA(t)});var XA=class extends hA{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new Kk(e.ctx.common.issues));return q(t,{code:K.invalid_union,unionErrors:n}),eA}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(r);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=r.map(e=>new Kk(e));return q(t,{code:K.invalid_union,unionErrors:i}),eA}}get options(){return this._def.options}};XA.create=(e,t)=>new XA({options:e,typeName:wj.ZodUnion,...mA(t)});var ZA=e=>e instanceof oj?ZA(e.schema):e instanceof fj?ZA(e.innerType()):e instanceof sj?[e.value]:e instanceof lj?e.options:e instanceof uj?Hk.objectValues(e.enum):e instanceof hj?ZA(e._def.innerType):e instanceof VA?[void 0]:e instanceof HA?[null]:e instanceof pj?[void 0,...ZA(e.unwrap())]:e instanceof mj?[null,...ZA(e.unwrap())]:e instanceof yj||e instanceof xj?ZA(e.unwrap()):e instanceof gj?ZA(e._def.innerType):[],QA=class e extends hA{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==G.object)return q(t,{code:K.invalid_type,expected:G.object,received:t.parsedType}),eA;let n=this.discriminator,r=t.data[n],i=this.optionsMap.get(r);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(q(t,{code:K.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),eA)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=new Map;for(let e of n){let n=ZA(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:wj.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...mA(r)})}};function $A(e,t){let n=Wk(e),r=Wk(t);if(e===t)return{valid:!0,data:e};if(n===G.object&&r===G.object){let n=Hk.objectKeys(t),r=Hk.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=$A(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}if(n===G.array&&r===G.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let r=0;r{if(rA(e)||rA(r))return eA;let i=$A(e.value,r.value);return i.valid?((iA(e)||iA(r))&&t.dirty(),{status:t.value,value:i.data}):(q(n,{code:K.invalid_intersection_types}),eA)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};ej.create=(e,t,n)=>new ej({left:e,right:t,typeName:wj.ZodIntersection,...mA(n)});var tj=class e extends hA{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.array)return q(n,{code:K.invalid_type,expected:G.array,received:n.parsedType}),eA;if(n.data.lengththis._def.items.length&&(q(n,{code:K.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let r=[...n.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new fA(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>$k.mergeArray(t,e)):$k.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};tj.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new tj({items:e,typeName:wj.ZodTuple,rest:null,...mA(t)})};var nj=class e extends hA{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.object)return q(n,{code:K.invalid_type,expected:G.object,received:n.parsedType}),eA;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new fA(n,e,n.path,e)),value:a._parse(new fA(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?$k.mergeObjectAsync(t,r):$k.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof hA?new e({keyType:t,valueType:n,typeName:wj.ZodRecord,...mA(r)}):new e({keyType:PA.create(),valueType:t,typeName:wj.ZodRecord,...mA(n)})}},rj=class extends hA{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.map)return q(n,{code:K.invalid_type,expected:G.map,received:n.parsedType}),eA;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new fA(n,e,n.path,[a,`key`])),value:i._parse(new fA(n,t,n.path,[a,`value`]))}));if(n.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of a){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return eA;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}{let e=new Map;for(let n of a){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return eA;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};rj.create=(e,t,n)=>new rj({valueType:t,keyType:e,typeName:wj.ZodMap,...mA(n)});var ij=class e extends hA{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.set)return q(n,{code:K.invalid_type,expected:G.set,received:n.parsedType}),eA;let r=this._def;r.minSize!==null&&n.data.sizer.maxSize.value&&(q(n,{code:K.too_big,maximum:r.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());let i=this._def.valueType;function a(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return eA;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let o=[...n.data.values()].map((e,t)=>i._parse(new fA(n,e,n.path,t)));return n.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(t,n){return new e({...this._def,minSize:{value:t,message:lA.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:lA.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};ij.create=(e,t)=>new ij({valueType:e,minSize:null,maxSize:null,typeName:wj.ZodSet,...mA(t)});var aj=class e extends hA{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==G.function)return q(t,{code:K.invalid_type,expected:G.function,received:t.parsedType}),eA;function n(e,n){return Zk({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Xk(),qk].filter(e=>!!e),issueData:{code:K.invalid_arguments,argumentsError:n}})}function r(e,n){return Zk({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Xk(),qk].filter(e=>!!e),issueData:{code:K.invalid_return_type,returnTypeError:n}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof dj){let e=this;return nA(async function(...t){let o=new Kk([]),s=await e._def.args.parseAsync(t,i).catch(e=>{throw o.addIssue(n(t,e)),o}),c=await Reflect.apply(a,this,s);return await e._def.returns._def.type.parseAsync(c,i).catch(e=>{throw o.addIssue(r(c,e)),o})})}{let e=this;return nA(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new Kk([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new Kk([r(s,c.error)]);return c.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:tj.create(t).rest(WA.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,r){return new e({args:t||tj.create([]).rest(WA.create()),returns:n||WA.create(),typeName:wj.ZodFunction,...mA(r)})}},oj=class extends hA{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};oj.create=(e,t)=>new oj({getter:e,typeName:wj.ZodLazy,...mA(t)});var sj=class extends hA{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return q(t,{received:t.data,code:K.invalid_literal,expected:this._def.value}),eA}return{status:`valid`,value:e.data}}get value(){return this._def.value}};sj.create=(e,t)=>new sj({value:e,typeName:wj.ZodLiteral,...mA(t)});function cj(e,t){return new lj({values:e,typeName:wj.ZodEnum,...mA(t)})}var lj=class e extends hA{constructor(){super(...arguments),uA.set(this,void 0)}_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return q(t,{expected:Hk.joinValues(n),received:t.parsedType,code:K.invalid_type}),eA}if(sA(this,uA)||cA(this,uA,new Set(this._def.values)),!sA(this,uA).has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return q(t,{received:t.data,code:K.invalid_enum_value,options:n}),eA}return nA(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(e=>!t.includes(e)),{...this._def,...n})}};uA=new WeakMap,lj.create=cj;var uj=class extends hA{constructor(){super(...arguments),dA.set(this,void 0)}_parse(e){let t=Hk.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==G.string&&n.parsedType!==G.number){let e=Hk.objectValues(t);return q(n,{expected:Hk.joinValues(e),received:n.parsedType,code:K.invalid_type}),eA}if(sA(this,dA)||cA(this,dA,new Set(Hk.getValidEnumValues(this._def.values))),!sA(this,dA).has(e.data)){let e=Hk.objectValues(t);return q(n,{received:n.data,code:K.invalid_enum_value,options:e}),eA}return nA(e.data)}get enum(){return this._def.values}};dA=new WeakMap,uj.create=(e,t)=>new uj({values:e,typeName:wj.ZodNativeEnum,...mA(t)});var dj=class extends hA{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==G.promise&&t.common.async===!1?(q(t,{code:K.invalid_type,expected:G.promise,received:t.parsedType}),eA):nA((t.parsedType===G.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};dj.create=(e,t)=>new dj({type:e,typeName:wj.ZodPromise,...mA(t)});var fj=class extends hA{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===wj.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:e=>{q(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),r.type===`preprocess`){let e=r.transform(n.data,i);if(n.common.async)return Promise.resolve(e).then(async e=>{if(t.value===`aborted`)return eA;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?eA:r.status===`dirty`||t.value===`dirty`?tA(r.value):r});{if(t.value===`aborted`)return eA;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?eA:r.status===`dirty`||t.value===`dirty`?tA(r.value):r}}if(r.type===`refinement`){let e=e=>{let t=r.refinement(e,i);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(n.common.async===!1){let r=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return r.status===`aborted`?eA:(r.status===`dirty`&&t.dirty(),e(r.value),{status:t.value,value:r.value})}return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>n.status===`aborted`?eA:(n.status===`dirty`&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if(r.type===`transform`){if(n.common.async===!1){let e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!aA(e))return e;let a=r.transform(e.value,i);if(a instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:t.value,value:a}}return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>aA(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):e)}Hk.assertNever(r)}};fj.create=(e,t,n)=>new fj({schema:e,typeName:wj.ZodEffects,effect:t,...mA(n)}),fj.createWithPreprocess=(e,t,n)=>new fj({schema:t,effect:{type:`preprocess`,transform:e},typeName:wj.ZodEffects,...mA(n)});var pj=class extends hA{_parse(e){return this._getType(e)===G.undefined?nA(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};pj.create=(e,t)=>new pj({innerType:e,typeName:wj.ZodOptional,...mA(t)});var mj=class extends hA{_parse(e){return this._getType(e)===G.null?nA(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};mj.create=(e,t)=>new mj({innerType:e,typeName:wj.ZodNullable,...mA(t)});var hj=class extends hA{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===G.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};hj.create=(e,t)=>new hj({innerType:e,typeName:wj.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...mA(t)});var gj=class extends hA{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return oA(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new Kk(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new Kk(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};gj.create=(e,t)=>new gj({innerType:e,typeName:wj.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...mA(t)});var _j=class extends hA{_parse(e){if(this._getType(e)!==G.nan){let t=this._getOrReturnCtx(e);return q(t,{code:K.invalid_type,expected:G.nan,received:t.parsedType}),eA}return{status:`valid`,value:e.data}}};_j.create=e=>new _j({typeName:wj.ZodNaN,...mA(e)});var vj=Symbol(`zod_brand`),yj=class extends hA{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},bj=class e extends hA{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?eA:e.status===`dirty`?(t.dirty(),tA(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?eA:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:wj.ZodPipeline})}},xj=class extends hA{_parse(e){let t=this._def.innerType._parse(e),n=e=>(aA(e)&&(e.value=Object.freeze(e.value)),e);return oA(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};xj.create=(e,t)=>new xj({innerType:e,typeName:wj.ZodReadonly,...mA(t)});function Sj(e,t={},n){return e?UA.create().superRefine((r,i)=>{if(!e(r)){let e=typeof t==`function`?t(r):typeof t==`string`?{message:t}:t,a=e.fatal??n??!0,o=typeof e==`string`?{message:e}:e;i.addIssue({code:`custom`,...o,fatal:a})}}):UA.create()}var Cj={object:YA.lazycreate},wj;(function(e){e.ZodString=`ZodString`,e.ZodNumber=`ZodNumber`,e.ZodNaN=`ZodNaN`,e.ZodBigInt=`ZodBigInt`,e.ZodBoolean=`ZodBoolean`,e.ZodDate=`ZodDate`,e.ZodSymbol=`ZodSymbol`,e.ZodUndefined=`ZodUndefined`,e.ZodNull=`ZodNull`,e.ZodAny=`ZodAny`,e.ZodUnknown=`ZodUnknown`,e.ZodNever=`ZodNever`,e.ZodVoid=`ZodVoid`,e.ZodArray=`ZodArray`,e.ZodObject=`ZodObject`,e.ZodUnion=`ZodUnion`,e.ZodDiscriminatedUnion=`ZodDiscriminatedUnion`,e.ZodIntersection=`ZodIntersection`,e.ZodTuple=`ZodTuple`,e.ZodRecord=`ZodRecord`,e.ZodMap=`ZodMap`,e.ZodSet=`ZodSet`,e.ZodFunction=`ZodFunction`,e.ZodLazy=`ZodLazy`,e.ZodLiteral=`ZodLiteral`,e.ZodEnum=`ZodEnum`,e.ZodEffects=`ZodEffects`,e.ZodNativeEnum=`ZodNativeEnum`,e.ZodOptional=`ZodOptional`,e.ZodNullable=`ZodNullable`,e.ZodDefault=`ZodDefault`,e.ZodCatch=`ZodCatch`,e.ZodPromise=`ZodPromise`,e.ZodBranded=`ZodBranded`,e.ZodPipeline=`ZodPipeline`,e.ZodReadonly=`ZodReadonly`})(wj||={});var Tj=(e,t={message:`Input not instance of ${e.name}`})=>Sj(t=>t instanceof e,t),J=PA.create,Ej=IA.create,Dj=_j.create,Oj=LA.create,kj=RA.create,Aj=zA.create,jj=BA.create,Mj=VA.create,Nj=HA.create,Pj=UA.create,Fj=WA.create,Ij=GA.create,Lj=KA.create,Rj=qA.create,Y=YA.create,zj=YA.strictCreate,Bj=XA.create,Vj=QA.create,Hj=ej.create,Uj=tj.create,Wj=nj.create,Gj=rj.create,Kj=ij.create,qj=aj.create,Jj=oj.create,Yj=sj.create,Xj=lj.create,Zj=uj.create,Qj=dj.create,$j=fj.create,eM=pj.create,tM=mj.create,nM=fj.createWithPreprocess,rM=bj.create,X=Object.freeze({__proto__:null,defaultErrorMap:qk,setErrorMap:Yk,getErrorMap:Xk,makeIssue:Zk,EMPTY_PATH:Qk,addIssueToContext:q,ParseStatus:$k,INVALID:eA,DIRTY:tA,OK:nA,isAborted:rA,isDirty:iA,isValid:aA,isAsync:oA,get util(){return Hk},get objectUtil(){return Uk},ZodParsedType:G,getParsedType:Wk,ZodType:hA,datetimeRegex:MA,ZodString:PA,ZodNumber:IA,ZodBigInt:LA,ZodBoolean:RA,ZodDate:zA,ZodSymbol:BA,ZodUndefined:VA,ZodNull:HA,ZodAny:UA,ZodUnknown:WA,ZodNever:GA,ZodVoid:KA,ZodArray:qA,ZodObject:YA,ZodUnion:XA,ZodDiscriminatedUnion:QA,ZodIntersection:ej,ZodTuple:tj,ZodRecord:nj,ZodMap:rj,ZodSet:ij,ZodFunction:aj,ZodLazy:oj,ZodLiteral:sj,ZodEnum:lj,ZodNativeEnum:uj,ZodPromise:dj,ZodEffects:fj,ZodTransformer:fj,ZodOptional:pj,ZodNullable:mj,ZodDefault:hj,ZodCatch:gj,ZodNaN:_j,BRAND:vj,ZodBranded:yj,ZodPipeline:bj,ZodReadonly:xj,custom:Sj,Schema:hA,ZodSchema:hA,late:Cj,get ZodFirstPartyTypeKind(){return wj},coerce:{string:(e=>PA.create({...e,coerce:!0})),number:(e=>IA.create({...e,coerce:!0})),boolean:(e=>RA.create({...e,coerce:!0})),bigint:(e=>LA.create({...e,coerce:!0})),date:(e=>zA.create({...e,coerce:!0}))},any:Pj,array:Rj,bigint:Oj,boolean:kj,date:Aj,discriminatedUnion:Vj,effect:$j,enum:Xj,function:qj,instanceof:Tj,intersection:Hj,lazy:Jj,literal:Yj,map:Gj,nan:Dj,nativeEnum:Zj,never:Ij,null:Nj,nullable:tM,number:Ej,object:Y,oboolean:()=>kj().optional(),onumber:()=>Ej().optional(),optional:eM,ostring:()=>J().optional(),pipeline:rM,preprocess:nM,promise:Qj,record:Wj,set:Kj,strictObject:zj,string:J,symbol:jj,transformer:$j,tuple:Uj,undefined:Mj,union:Bj,unknown:Fj,void:Lj,NEVER:eA,ZodIssueCode:K,quotelessJson:Gk,ZodError:Kk}),iM={exports:{}},aM;function oM(){return aM||(aM=1,(function(e){var t=(function(e){var n=1e7,r=9007199254740992,i=f(r),a=`0123456789abcdefghijklmnopqrstuvwxyz`,o=typeof BigInt==`function`;function s(e,t,n,r){return e===void 0?s[0]:t===void 0||+t==10&&!n?N(e):ve(e,t,n,r)}function c(e,t){this.value=e,this.sign=t,this.isSmall=!1}c.prototype=Object.create(s.prototype);function l(e){this.value=e,this.sign=e<0,this.isSmall=!0}l.prototype=Object.create(s.prototype);function u(e){this.value=e}u.prototype=Object.create(s.prototype);function d(e){return-r0?Math.floor(e):Math.ceil(e)}function _(e,t){for(var r=e.length,i=t.length,a=Array(r),o=0,s=n,c,l=0;l=s),a[l]=c-o*s;for(;l0&&a.push(o),a}function v(e,t){return e.length>=t.length?_(e,t):_(t,e)}function y(e,t){for(var r=e.length,i=Array(r),a=n,o,s=0;s0;)i[s++]=t%a,t=Math.floor(t/a);return i}c.prototype.add=function(e){var t=N(e);if(this.sign!==t.sign)return this.subtract(t.negate());var n=this.value,r=t.value;return t.isSmall?new c(y(n,Math.abs(r)),this.sign):new c(v(n,r),this.sign)},c.prototype.plus=c.prototype.add,l.prototype.add=function(e){var t=N(e),n=this.value;if(n<0!==t.sign)return this.subtract(t.negate());var r=t.value;if(t.isSmall){if(d(n+r))return new l(n+r);r=f(Math.abs(r))}return new c(y(r,Math.abs(n)),n<0)},l.prototype.plus=l.prototype.add,u.prototype.add=function(e){return new u(this.value+N(e).value)},u.prototype.plus=u.prototype.add;function b(e,t){for(var r=e.length,i=t.length,a=Array(r),o=0,s=n,c=0,l;c=0?r=b(e,t):(r=b(t,e),n=!n),r=p(r),typeof r==`number`?(n&&(r=-r),new l(r)):new c(r,n)}function S(e,t,r){for(var i=e.length,a=Array(i),o=-t,s=n,u=0,d;u=0)},l.prototype.minus=l.prototype.subtract,u.prototype.subtract=function(e){return new u(this.value-N(e).value)},u.prototype.minus=u.prototype.subtract,c.prototype.negate=function(){return new c(this.value,!this.sign)},l.prototype.negate=function(){var e=this.sign,t=new l(-this.value);return t.sign=!e,t},u.prototype.negate=function(){return new u(-this.value)},c.prototype.abs=function(){return new c(this.value,!1)},l.prototype.abs=function(){return new l(Math.abs(this.value))},u.prototype.abs=function(){return new u(this.value>=0?this.value:-this.value)};function C(e,t){for(var r=e.length,i=t.length,a=h(r+i),o=n,s,c,l=0,u,d;l0;)i[c++]=o%a,o=Math.floor(o/a);return i}function T(e,t){for(var n=[];t-->0;)n.push(0);return n.concat(e)}function E(e,t){var n=Math.max(e.length,t.length);if(n<=30)return C(e,t);n=Math.ceil(n/2);var r=e.slice(n),i=e.slice(0,n),a=t.slice(n),o=t.slice(0,n),s=E(i,o),c=E(r,a),l=v(v(s,T(b(b(E(v(i,r),v(o,a)),s),c),n)),T(c,2*n));return m(l),l}function D(e,t){return-.012*e-.012*t+15e-6*e*t>0}c.prototype.multiply=function(e){var t=N(e),r=this.value,i=t.value,a=this.sign!==t.sign,o;if(t.isSmall){if(i===0)return s[0];if(i===1)return this;if(i===-1)return this.negate();if(o=Math.abs(i),o=0;f--){for(d=a-1,l[f+i]!==s&&(d=Math.floor((l[f+i]*a+l[f+i-1])/s)),m=0,g=0,v=u.length,_=0;_i&&(u=(u+1)*s),c=Math.ceil(u/d);do{if(f=w(t,c),te(f,o)<=0)break;c--}while(c);a.push(c),o=b(o,f)}return a.reverse(),[p(a),p(o)]}function ee(e,t){var r=e.length,i=h(r),a=n,o,s,c=0,l;for(o=r-1;o>=0;--o)l=c*a+e[o],s=g(l/t),c=l-s*t,i[o]=s|0;return[i,c|0]}function M(e,t){var r,i=N(t);if(o)return[new u(e.value/i.value),new u(e.value%i.value)];var a=e.value,d=i.value,m;if(d===0)throw Error(`Cannot divide by zero`);if(e.isSmall)return i.isSmall?[new l(g(a/d)),new l(a%d)]:[s[0],e];if(i.isSmall){if(d===1)return[e,s[0]];if(d==-1)return[e.negate(),s[0]];var h=Math.abs(d);if(ht.length?1:-1;for(var n=e.length-1;n>=0;n--)if(e[n]!==t[n])return e[n]>t[n]?1:-1;return 0}c.prototype.compareAbs=function(e){var t=N(e),n=this.value,r=t.value;return t.isSmall?1:te(n,r)},l.prototype.compareAbs=function(e){var t=N(e),n=Math.abs(this.value),r=t.value;return t.isSmall?(r=Math.abs(r),n===r?0:n>r?1:-1):-1},u.prototype.compareAbs=function(e){var t=this.value,n=N(e).value;return t=t>=0?t:-t,n=n>=0?n:-n,t===n?0:t>n?1:-1},c.prototype.compare=function(e){if(e===1/0)return-1;if(e===-1/0)return 1;var t=N(e),n=this.value,r=t.value;return this.sign===t.sign?t.isSmall?this.sign?-1:1:te(n,r)*(this.sign?-1:1):t.sign?1:-1},c.prototype.compareTo=c.prototype.compare,l.prototype.compare=function(e){if(e===1/0)return-1;if(e===-1/0)return 1;var t=N(e),n=this.value,r=t.value;return t.isSmall?n==r?0:n>r?1:-1:n<0===t.sign?n<0?1:-1:n<0?-1:1},l.prototype.compareTo=l.prototype.compare,u.prototype.compare=function(e){if(e===1/0)return-1;if(e===-1/0)return 1;var t=this.value,n=N(e).value;return t===n?0:t>n?1:-1},u.prototype.compareTo=u.prototype.compare,c.prototype.equals=function(e){return this.compare(e)===0},u.prototype.eq=u.prototype.equals=l.prototype.eq=l.prototype.equals=c.prototype.eq=c.prototype.equals,c.prototype.notEquals=function(e){return this.compare(e)!==0},u.prototype.neq=u.prototype.notEquals=l.prototype.neq=l.prototype.notEquals=c.prototype.neq=c.prototype.notEquals,c.prototype.greater=function(e){return this.compare(e)>0},u.prototype.gt=u.prototype.greater=l.prototype.gt=l.prototype.greater=c.prototype.gt=c.prototype.greater,c.prototype.lesser=function(e){return this.compare(e)<0},u.prototype.lt=u.prototype.lesser=l.prototype.lt=l.prototype.lesser=c.prototype.lt=c.prototype.lesser,c.prototype.greaterOrEquals=function(e){return this.compare(e)>=0},u.prototype.geq=u.prototype.greaterOrEquals=l.prototype.geq=l.prototype.greaterOrEquals=c.prototype.geq=c.prototype.greaterOrEquals,c.prototype.lesserOrEquals=function(e){return this.compare(e)<=0},u.prototype.leq=u.prototype.lesserOrEquals=l.prototype.leq=l.prototype.lesserOrEquals=c.prototype.leq=c.prototype.lesserOrEquals,c.prototype.isEven=function(){return!(this.value[0]&1)},l.prototype.isEven=function(){return!(this.value&1)},u.prototype.isEven=function(){return(this.value&BigInt(1))===BigInt(0)},c.prototype.isOdd=function(){return(this.value[0]&1)==1},l.prototype.isOdd=function(){return(this.value&1)==1},u.prototype.isOdd=function(){return(this.value&BigInt(1))===BigInt(1)},c.prototype.isPositive=function(){return!this.sign},l.prototype.isPositive=function(){return this.value>0},u.prototype.isPositive=l.prototype.isPositive,c.prototype.isNegative=function(){return this.sign},l.prototype.isNegative=function(){return this.value<0},u.prototype.isNegative=l.prototype.isNegative,c.prototype.isUnit=function(){return!1},l.prototype.isUnit=function(){return Math.abs(this.value)===1},u.prototype.isUnit=function(){return this.abs().value===BigInt(1)},c.prototype.isZero=function(){return!1},l.prototype.isZero=function(){return this.value===0},u.prototype.isZero=function(){return this.value===BigInt(0)},c.prototype.isDivisibleBy=function(e){var t=N(e);return t.isZero()?!1:t.isUnit()?!0:t.compareAbs(2)===0?this.isEven():this.mod(t).isZero()},u.prototype.isDivisibleBy=l.prototype.isDivisibleBy=c.prototype.isDivisibleBy;function ne(e){var t=e.abs();if(t.isUnit())return!1;if(t.equals(2)||t.equals(3)||t.equals(5))return!0;if(t.isEven()||t.isDivisibleBy(3)||t.isDivisibleBy(5))return!1;if(t.lesser(49))return!0}function re(e,n){for(var r=e.prev(),i=r,a=0,o,s,c;i.isEven();)i=i.divide(2),a++;next:for(s=0;s-r?new l(e-1):new c(i,!0)},u.prototype.prev=function(){return new u(this.value-BigInt(1))};for(var ie=[1];2*ie[ie.length-1]<=n;)ie.push(2*ie[ie.length-1]);var ae=ie.length,oe=ie[ae-1];function se(e){return Math.abs(e)<=n}c.prototype.shiftLeft=function(e){var t=N(e).toJSNumber();if(!se(t))throw Error(String(t)+` is too large for shifting.`);if(t<0)return this.shiftRight(-t);var n=this;if(n.isZero())return n;for(;t>=ae;)n=n.multiply(oe),t-=ae-1;return n.multiply(ie[t])},u.prototype.shiftLeft=l.prototype.shiftLeft=c.prototype.shiftLeft,c.prototype.shiftRight=function(e){var t,n=N(e).toJSNumber();if(!se(n))throw Error(String(n)+` is too large for shifting.`);if(n<0)return this.shiftLeft(-n);for(var r=this;n>=ae;){if(r.isZero()||r.isNegative()&&r.isUnit())return r;t=M(r,oe),r=t[1].isNegative()?t[0].prev():t[0],n-=ae-1}return t=M(r,ie[n]),t[1].isNegative()?t[0].prev():t[0]},u.prototype.shiftRight=l.prototype.shiftRight=c.prototype.shiftRight;function ce(e,n,r){n=N(n);for(var i=e.isNegative(),a=n.isNegative(),o=i?e.not():e,s=a?n.not():n,c=0,l=0,u=null,d=null,f=[];!o.isZero()||!s.isZero();)u=M(o,oe),c=u[1].toJSNumber(),i&&(c=oe-1-c),d=M(s,oe),l=d[1].toJSNumber(),a&&(l=oe-1-l),o=u[0],s=d[0],f.push(r(c,l));for(var p=r(+!!i,+!!a)===0?t(0):t(-1),m=f.length-1;m>=0;--m)p=p.multiply(oe).add(t(f[m]));return p}c.prototype.not=function(){return this.negate().prev()},u.prototype.not=l.prototype.not=c.prototype.not,c.prototype.and=function(e){return ce(this,e,function(e,t){return e&t})},u.prototype.and=l.prototype.and=c.prototype.and,c.prototype.or=function(e){return ce(this,e,function(e,t){return e|t})},u.prototype.or=l.prototype.or=c.prototype.or,c.prototype.xor=function(e){return ce(this,e,function(e,t){return e^t})},u.prototype.xor=l.prototype.xor=c.prototype.xor;var le=1<<30,ue=(n&-n)*(n&-n)|le;function de(e){var t=e.value,r=typeof t==`number`?t|le:typeof t==`bigint`?t|BigInt(le):t[0]+t[1]*n|ue;return r&-r}function fe(e,n){if(n.compareTo(e)<=0){var r=fe(e,n.square(n)),i=r.p,a=r.e,o=i.multiply(n);return o.compareTo(e)<=0?{p:o,e:a*2+1}:{p:i,e:a*2}}return{p:t(1),e:0}}c.prototype.bitLength=function(){var e=this;return e.compareTo(t(0))<0&&(e=e.negate().subtract(t(1))),e.compareTo(t(0))===0?t(0):t(fe(e,t(2)).e).add(t(1))},u.prototype.bitLength=l.prototype.bitLength=c.prototype.bitLength;function pe(e,t){return e=N(e),t=N(t),e.greater(t)?e:t}function me(e,t){return e=N(e),t=N(t),e.lesser(t)?e:t}function he(e,t){if(e=N(e).abs(),t=N(t).abs(),e.equals(t))return e;if(e.isZero())return t;if(t.isZero())return e;for(var n=s[1],r,i;e.isEven()&&t.isEven();)r=me(de(e),de(t)),e=e.divide(r),t=t.divide(r),n=n.multiply(r);for(;e.isEven();)e=e.divide(de(e));do{for(;t.isEven();)t=t.divide(de(t));e.greater(t)&&(i=t,t=e,e=i),t=t.subtract(e)}while(!t.isZero());return n.isUnit()?e:e.multiply(n)}function ge(e,t){return e=N(e).abs(),t=N(t).abs(),e.divide(he(e,t)).multiply(t)}function _e(e,t,r){e=N(e),t=N(t);var i=r||Math.random,a=me(e,t),o=pe(e,t).subtract(a).add(1);if(o.isSmall)return a.add(Math.floor(i()*o));for(var c=xe(o,n).value,l=[],u=!0,d=0;d=s){if(l===`1`&&s===1)continue;throw Error(l+` is not a valid digit in base `+t+`.`)}}t=N(t);var u=[],d=e[0]===`-`;for(o=+!!d;o`&&o=0;a--)r=r.add(e[a].times(i)),i=i.times(t);return n?r.negate():r}function be(e,t){return t||=a,e`}function xe(e,n){if(n=t(n),n.isZero()){if(e.isZero())return{value:[0],isNegative:!1};throw Error(`Cannot convert nonzero numbers to base 0.`)}if(n.equals(-1)){if(e.isZero())return{value:[0],isNegative:!1};if(e.isNegative())return{value:[].concat.apply([],Array.apply(null,Array(-e.toJSNumber())).map(Array.prototype.valueOf,[1,0])),isNegative:!1};var r=Array.apply(null,Array(e.toJSNumber()-1)).map(Array.prototype.valueOf,[0,1]);return r.unshift([1]),{value:[].concat.apply([],r),isNegative:!1}}var i=!1;if(e.isNegative()&&n.isPositive()&&(i=!0,e=e.abs()),n.isUnit())return e.isZero()?{value:[0],isNegative:!1}:{value:Array.apply(null,Array(e.toJSNumber())).map(Number.prototype.valueOf,1),isNegative:i};for(var a=[],o=e,s;o.isNegative()||o.compareAbs(n)>=0;){s=o.divmod(n),o=s.quotient;var c=s.remainder;c.isNegative()&&(c=n.minus(c).abs(),o=o.next()),a.push(c.toJSNumber())}return a.push(o.toJSNumber()),{value:a.reverse(),isNegative:i}}function Se(e,t,n){var r=xe(e,t);return(r.isNegative?`-`:``)+r.value.map(function(e){return be(e,n)}).join(``)}c.prototype.toArray=function(e){return xe(this,e)},l.prototype.toArray=function(e){return xe(this,e)},u.prototype.toArray=function(e){return xe(this,e)},c.prototype.toString=function(t,n){if(t===e&&(t=10),t!==10||n)return Se(this,t,n);for(var r=this.value,i=r.length,a=String(r[--i]),o=`0000000`,s;--i>=0;)s=String(r[i]),a+=o.slice(s.length)+s;return(this.sign?`-`:``)+a},l.prototype.toString=function(t,n){return t===e&&(t=10),t!=10||n?Se(this,t,n):String(this.value)},u.prototype.toString=l.prototype.toString,u.prototype.toJSON=c.prototype.toJSON=l.prototype.toJSON=function(){return this.toString()},c.prototype.valueOf=function(){return parseInt(this.toString(),10)},c.prototype.toJSNumber=c.prototype.valueOf,l.prototype.valueOf=function(){return this.value},l.prototype.toJSNumber=l.prototype.valueOf,u.prototype.valueOf=u.prototype.toJSNumber=function(){return parseInt(this.toString(),10)};function Ce(e){if(d(+e)){var t=+e;if(t===g(t))return o?new u(BigInt(t)):new l(t);throw Error(`Invalid integer: `+e)}var n=e[0]===`-`;n&&(e=e.slice(1));var r=e.split(/e/i);if(r.length>2)throw Error(`Invalid integer: `+r.join(`e`));if(r.length===2){var i=r[1];if(i[0]===`+`&&(i=i.slice(1)),i=+i,i!==g(i)||!d(i))throw Error(`Invalid integer: `+i+` is not a valid exponent.`);var a=r[0],s=a.indexOf(`.`);if(s>=0&&(i-=a.length-s-1,a=a.slice(0,s)+a.slice(s+1)),i<0)throw Error(`Cannot include negative exponent part for integers`);a+=Array(i+1).join(`0`),e=a}if(!/^([0-9][0-9]*)$/.test(e))throw Error(`Invalid integer: `+e);if(o)return new u(BigInt(n?`-`+e:e));for(var f=[],p=e.length,h=7,_=p-h;p>0;)f.push(+e.slice(_,p)),_-=h,_<0&&(_=0),p-=h;return m(f),new c(f,n)}function we(e){if(o)return new u(BigInt(e));if(d(e)){if(e!==g(e))throw Error(e+` is not an integer.`);return new l(e)}return Ce(e.toString())}function N(e){return typeof e==`number`?we(e):typeof e==`string`?Ce(e):typeof e==`bigint`?new u(e):e}for(var Te=0;Te<1e3;Te++)s[Te]=N(Te),Te>0&&(s[-Te]=N(-Te));return s.one=s[1],s.zero=s[0],s.minusOne=s[-1],s.max=pe,s.min=me,s.gcd=he,s.lcm=ge,s.isInstance=function(e){return e instanceof c||e instanceof l||e instanceof u},s.randBetween=_e,s.fromArray=function(e,t,n){return ye(e.map(N),N(t||10),n)},s})();e.hasOwnProperty(`exports`)&&(e.exports=t)})(iM)),iM.exports}var sM=Lk(oM()),cM=64,lM=16,uM=cM/lM;function dM(){try{return!0}catch{return!1}}function fM(e,t,n){let r=0;for(let i=0;ie&t[n]))}or({parts:t}){return new e(this.parts.map((e,n)=>e|t[n]))}xor({parts:t}){return new e(this.parts.map((e,n)=>e^t[n]))}not(){return new e(this.parts.map(e=>~e))}equals({parts:e}){return this.parts.every((t,n)=>t===e[n])}toString(){if(this.str!=null)return this.str;let e=Array(cM/4);return this.parts.forEach((t,n)=>{let r=pM(t.toString());for(let t=0;t<4;t++)e[t+n*4]=r[3-t]||0}),this.str=sM.fromArray(e,16).toString()}toJSON(){return this.toString()}},gM=dM();gM&&BigInt.prototype.toJSON==null&&(BigInt.prototype.toJSON=function(){return this.toString()});var _M={},vM=gM?function(e){return BigInt(e)}:function(e){return e instanceof hM?e:(typeof e==`number`&&(e=e.toString()),_M[e]??(_M[e]=hM.fromString(e)),_M[e])},yM=vM(0),bM=gM?function(e=yM,t=yM){return e&t}:function(e=yM,t=yM){return e.and(t)},xM=gM?function(e=yM,t=yM){return e|t}:function(e=yM,t=yM){return e.or(t)},SM=gM?function(e=yM,t=yM){return e^t}:function(e=yM,t=yM){return e.xor(t)},CM=gM?function(e=yM){return~e}:function(e=yM){return e.not()},wM=gM?function(e,t){return e===t}:function(e,t){return e==null||t==null?e==t:e.equals(t)};function TM(...e){let t=e[0];for(let n=1;n{let[n]=Object.entries(e).find(([,e])=>e===t)??[];return t!=null&&n===void 0?e.UNHANDLED:t},J().or(Ej()))}function IM(e){let t=Sj().transform(t=>{let n=e.safeParse(t);return n.success?n.data:e._def.defaultValue()});return t.overlayType=e,t}var LM=X.object({image_url:X.string()}).describe(`Response for "INITIATE_IMAGE_UPLOAD" Command`),RM=X.object({mediaUrl:X.string().max(1024)}).describe(`Request for "OPEN_SHARE_MOMENT_DIALOG" Command`),zM=X.object({access_token:X.union([X.string(),X.null()]).optional()}).describe(`Request for "AUTHENTICATE" Command`),BM=X.object({access_token:X.string(),user:X.object({username:X.string(),discriminator:X.string(),id:X.string(),avatar:X.union([X.string(),X.null()]).optional(),public_flags:X.number(),global_name:X.union([X.string(),X.null()]).optional()}),scopes:X.array(IM(X.enum(`identify,identify.premium,email,connections,guilds,guilds.join,guilds.members.read,guilds.channels.read,gdm.join,bot,rpc,rpc.notifications.read,rpc.voice.read,rpc.voice.write,rpc.video.read,rpc.video.write,rpc.screenshare.read,rpc.screenshare.write,rpc.activities.write,webhook.incoming,messages.read,applications.builds.upload,applications.builds.read,applications.commands,applications.commands.permissions.update,applications.commands.update,applications.store.update,applications.entitlements,activities.read,activities.write,activities.invites.write,relationships.read,relationships.write,voice,dm_channels.read,role_connections.write,presences.read,presences.write,openid,dm_channels.messages.read,dm_channels.messages.write,gateway.connect,account.global_name.update,payment_sources.country_code,sdk.social_layer_presence,sdk.social_layer,lobbies.write,application_identities.write`.split(`,`)).or(X.literal(-1)).default(-1))),expires:X.string(),application:X.object({description:X.string(),icon:X.union([X.string(),X.null()]).optional(),id:X.string(),rpc_origins:X.array(X.string()).optional(),name:X.string()})}).describe(`Response for "AUTHENTICATE" Command`),VM=X.object({participants:X.array(X.object({id:X.string(),username:X.string(),global_name:X.union([X.string(),X.null()]).optional(),discriminator:X.string(),avatar:X.union([X.string(),X.null()]).optional(),flags:X.number(),bot:X.boolean(),avatar_decoration_data:X.union([X.object({asset:X.union([X.string(),X.null()]).optional(),skuId:X.string().optional(),expiresAt:X.number().optional()}),X.null()]).optional(),premium_type:X.union([X.number(),X.null()]).optional(),nickname:X.string().optional()}))}).describe(`Response for "GET_ACTIVITY_INSTANCE_CONNECTED_PARTICIPANTS" Command`),HM=X.object({command:X.string(),options:X.array(X.object({name:X.string(),value:X.string()})).optional(),content:X.string().max(2e3).optional(),require_launch_channel:X.boolean().optional(),preview_image:X.object({height:X.number(),url:X.string(),width:X.number()}).optional(),components:X.array(X.object({type:X.literal(1),components:X.array(X.object({type:X.literal(2),style:X.number().gte(1).lte(5),label:X.string().max(80).optional(),custom_id:X.string().max(100).describe(`Developer-defined identifier for the button; max 100 characters`).optional()})).max(5).optional()})).optional(),pid:X.number().optional()}).describe(`Request for "SHARE_INTERACTION" Command`),UM=X.object({success:X.boolean()}).describe(`Response for "SHARE_INTERACTION" Command`),WM=X.object({custom_id:X.string().max(64).optional(),message:X.string().max(1e3),link_id:X.string().max(64).optional()}).describe(`Request for "SHARE_LINK" Command`),GM=X.object({success:X.boolean(),didCopyLink:X.boolean(),didSendMessage:X.boolean()}).describe(`Response for "SHARE_LINK" Command`),KM=X.object({relationships:X.array(X.object({type:X.number(),user:X.object({id:X.string(),username:X.string(),global_name:X.union([X.string(),X.null()]).optional(),discriminator:X.string(),avatar:X.union([X.string(),X.null()]).optional(),flags:X.number(),bot:X.boolean(),avatar_decoration_data:X.union([X.object({asset:X.union([X.string(),X.null()]).optional(),skuId:X.string().optional(),expiresAt:X.number().optional()}),X.null()]).optional(),premium_type:X.union([X.number(),X.null()]).optional()}),presence:X.object({status:X.string(),activity:X.union([X.object({session_id:X.string().optional(),type:X.number().optional(),name:X.string(),url:X.union([X.string(),X.null()]).optional(),application_id:X.string().optional(),status_display_type:X.number().optional(),state:X.string().optional(),state_url:X.string().optional(),details:X.string().optional(),details_url:X.string().optional(),emoji:X.union([X.object({name:X.string(),id:X.union([X.string(),X.null()]).optional(),animated:X.union([X.boolean(),X.null()]).optional()}),X.null()]).optional(),assets:X.object({large_image:X.string().optional(),large_text:X.string().optional(),large_url:X.string().optional(),small_image:X.string().optional(),small_text:X.string().optional(),small_url:X.string().optional()}).optional(),timestamps:X.object({start:X.number().optional(),end:X.number().optional()}).optional(),party:X.object({id:X.string().optional(),size:X.array(X.number()).min(2).max(2).optional(),privacy:X.number().optional()}).optional(),secrets:X.object({match:X.string().optional(),join:X.string().optional()}).optional(),sync_id:X.string().optional(),created_at:X.number().optional(),instance:X.boolean().optional(),flags:X.number().optional(),metadata:X.object({}).optional(),platform:X.string().optional(),supported_platforms:X.array(X.string()).optional(),buttons:X.array(X.string()).optional(),hangStatus:X.string().optional()}),X.null()]).optional()}).optional()}))}).describe(`Response for "GET_RELATIONSHIPS" Command`),qM=X.object({user_id:X.string(),content:X.string().min(0).max(1024).optional()}).describe(`Request for "INVITE_USER_EMBEDDED" Command`),JM=X.object({id:X.string().max(64)}).describe(`Request for "GET_USER" Command`),YM=X.union([X.object({id:X.string(),username:X.string(),global_name:X.union([X.string(),X.null()]).optional(),discriminator:X.string(),avatar:X.union([X.string(),X.null()]).optional(),flags:X.number(),bot:X.boolean(),avatar_decoration_data:X.union([X.object({asset:X.union([X.string(),X.null()]).optional(),skuId:X.string().optional(),expiresAt:X.number().optional()}),X.null()]).optional(),premium_type:X.union([X.number(),X.null()]).optional()}),X.null()]),XM=X.object({quest_id:X.string()}).describe(`Request for "GET_QUEST_ENROLLMENT_STATUS" Command`),ZM=X.object({quest_id:X.string(),is_enrolled:X.boolean(),enrolled_at:X.union([X.string(),X.null()]).optional()}).describe(`Response for "GET_QUEST_ENROLLMENT_STATUS" Command`),QM=X.object({quest_id:X.string()}).describe(`Request for "QUEST_START_TIMER" Command`),$M=X.object({success:X.boolean()}).describe(`Response for "QUEST_START_TIMER" Command`),eN=X.object({quest_id:X.string(),enrolled_at:X.union([X.string(),X.null()]).optional(),completed_at:X.union([X.string(),X.null()]).optional(),external_cta_url:X.string()}).describe(`Response for "GET_QUEST" Command`),tN=X.object({ticket:X.string()}).describe(`Response for "REQUEST_PROXY_TICKET_REFRESH" Command`),nN;(function(e){e.INITIATE_IMAGE_UPLOAD=`INITIATE_IMAGE_UPLOAD`,e.OPEN_SHARE_MOMENT_DIALOG=`OPEN_SHARE_MOMENT_DIALOG`,e.AUTHENTICATE=`AUTHENTICATE`,e.GET_ACTIVITY_INSTANCE_CONNECTED_PARTICIPANTS=`GET_ACTIVITY_INSTANCE_CONNECTED_PARTICIPANTS`,e.SHARE_INTERACTION=`SHARE_INTERACTION`,e.SHARE_LINK=`SHARE_LINK`,e.GET_RELATIONSHIPS=`GET_RELATIONSHIPS`,e.INVITE_USER_EMBEDDED=`INVITE_USER_EMBEDDED`,e.GET_USER=`GET_USER`,e.GET_QUEST_ENROLLMENT_STATUS=`GET_QUEST_ENROLLMENT_STATUS`,e.QUEST_START_TIMER=`QUEST_START_TIMER`,e.GET_QUEST=`GET_QUEST`,e.REQUEST_PROXY_TICKET_REFRESH=`REQUEST_PROXY_TICKET_REFRESH`})(nN||={});var rN=X.object({}).optional().nullable(),iN=X.void(),aN={[nN.INITIATE_IMAGE_UPLOAD]:{request:iN,response:LM},[nN.OPEN_SHARE_MOMENT_DIALOG]:{request:RM,response:rN},[nN.AUTHENTICATE]:{request:zM,response:BM},[nN.GET_ACTIVITY_INSTANCE_CONNECTED_PARTICIPANTS]:{request:iN,response:VM},[nN.SHARE_INTERACTION]:{request:HM,response:UM},[nN.SHARE_LINK]:{request:WM,response:GM},[nN.GET_RELATIONSHIPS]:{request:iN,response:KM},[nN.INVITE_USER_EMBEDDED]:{request:qM,response:rN},[nN.GET_USER]:{request:JM,response:YM},[nN.GET_QUEST_ENROLLMENT_STATUS]:{request:XM,response:ZM},[nN.QUEST_START_TIMER]:{request:QM,response:$M},[nN.GET_QUEST]:{request:iN,response:eN},[nN.REQUEST_PROXY_TICKET_REFRESH]:{request:iN,response:tN}},oN=t({Activity:()=>xN,Attachment:()=>AN,CertifiedDevice:()=>XN,CertifiedDeviceTypeObject:()=>YN,Channel:()=>TN,ChannelMention:()=>kN,ChannelTypesObject:()=>wN,Commands:()=>cN,DISPATCH:()=>sN,Embed:()=>LN,EmbedAuthor:()=>FN,EmbedField:()=>IN,EmbedFooter:()=>jN,EmbedProvider:()=>PN,Emoji:()=>gN,Entitlement:()=>eP,EntitlementTypesObject:()=>$N,Guild:()=>ON,GuildMember:()=>mN,GuildMemberRPC:()=>hN,Image:()=>MN,KeyTypesObject:()=>WN,LayoutMode:()=>cP,LayoutModeTypeObject:()=>sP,Message:()=>HN,MessageActivity:()=>zN,MessageApplication:()=>BN,MessageReference:()=>VN,Orientation:()=>oP,OrientationLockState:()=>nP,OrientationLockStateTypeObject:()=>tP,OrientationTypeObject:()=>aP,PermissionOverwrite:()=>CN,PermissionOverwriteTypeObject:()=>SN,PresenceUpdate:()=>EN,Reaction:()=>RN,ReceiveFramePayload:()=>lN,Relationship:()=>fN,Role:()=>DN,Scopes:()=>dN,ScopesObject:()=>uN,ShortcutKey:()=>GN,Sku:()=>QN,SkuTypeObject:()=>ZN,Status:()=>bN,StatusObject:()=>yN,ThermalState:()=>iP,ThermalStateTypeObject:()=>rP,User:()=>pN,UserVoiceState:()=>vN,Video:()=>NN,VoiceDevice:()=>UN,VoiceSettingModeTypeObject:()=>KN,VoiceSettingsIO:()=>JN,VoiceSettingsMode:()=>qN,VoiceState:()=>_N}),sN=`DISPATCH`,cN;(function(e){e.AUTHORIZE=`AUTHORIZE`,e.GET_GUILDS=`GET_GUILDS`,e.GET_GUILD=`GET_GUILD`,e.GET_CHANNEL=`GET_CHANNEL`,e.GET_CHANNELS=`GET_CHANNELS`,e.SELECT_VOICE_CHANNEL=`SELECT_VOICE_CHANNEL`,e.SELECT_TEXT_CHANNEL=`SELECT_TEXT_CHANNEL`,e.SUBSCRIBE=`SUBSCRIBE`,e.UNSUBSCRIBE=`UNSUBSCRIBE`,e.CAPTURE_SHORTCUT=`CAPTURE_SHORTCUT`,e.SET_CERTIFIED_DEVICES=`SET_CERTIFIED_DEVICES`,e.SET_ACTIVITY=`SET_ACTIVITY`,e.GET_SKUS=`GET_SKUS`,e.GET_ENTITLEMENTS=`GET_ENTITLEMENTS`,e.GET_SKUS_EMBEDDED=`GET_SKUS_EMBEDDED`,e.GET_ENTITLEMENTS_EMBEDDED=`GET_ENTITLEMENTS_EMBEDDED`,e.START_PURCHASE=`START_PURCHASE`,e.SET_CONFIG=`SET_CONFIG`,e.SEND_ANALYTICS_EVENT=`SEND_ANALYTICS_EVENT`,e.USER_SETTINGS_GET_LOCALE=`USER_SETTINGS_GET_LOCALE`,e.OPEN_EXTERNAL_LINK=`OPEN_EXTERNAL_LINK`,e.ENCOURAGE_HW_ACCELERATION=`ENCOURAGE_HW_ACCELERATION`,e.CAPTURE_LOG=`CAPTURE_LOG`,e.SET_ORIENTATION_LOCK_STATE=`SET_ORIENTATION_LOCK_STATE`,e.OPEN_INVITE_DIALOG=`OPEN_INVITE_DIALOG`,e.GET_PLATFORM_BEHAVIORS=`GET_PLATFORM_BEHAVIORS`,e.GET_CHANNEL_PERMISSIONS=`GET_CHANNEL_PERMISSIONS`,e.AUTHENTICATE=`AUTHENTICATE`,e.GET_ACTIVITY_INSTANCE_CONNECTED_PARTICIPANTS=`GET_ACTIVITY_INSTANCE_CONNECTED_PARTICIPANTS`,e.GET_QUEST=`GET_QUEST`,e.GET_QUEST_ENROLLMENT_STATUS=`GET_QUEST_ENROLLMENT_STATUS`,e.GET_RELATIONSHIPS=`GET_RELATIONSHIPS`,e.GET_USER=`GET_USER`,e.INITIATE_IMAGE_UPLOAD=`INITIATE_IMAGE_UPLOAD`,e.INVITE_USER_EMBEDDED=`INVITE_USER_EMBEDDED`,e.OPEN_SHARE_MOMENT_DIALOG=`OPEN_SHARE_MOMENT_DIALOG`,e.QUEST_START_TIMER=`QUEST_START_TIMER`,e.REQUEST_PROXY_TICKET_REFRESH=`REQUEST_PROXY_TICKET_REFRESH`,e.SHARE_INTERACTION=`SHARE_INTERACTION`,e.SHARE_LINK=`SHARE_LINK`})(cN||={});var lN=Y({cmd:J(),data:Fj(),evt:Nj(),nonce:J()}).passthrough(),uN=Object.assign(Object.assign({},BM.shape.scopes.element.overlayType._def.innerType.options[0].Values),{UNHANDLED:-1}),dN=FM(uN),fN=KM.shape.relationships.element,pN=Y({id:J(),username:J(),discriminator:J(),global_name:J().optional().nullable(),avatar:J().optional().nullable(),avatar_decoration_data:Y({asset:J(),sku_id:J().optional()}).nullable(),bot:kj(),flags:Ej().optional().nullable(),premium_type:Ej().optional().nullable()}),mN=Y({user:pN,nick:J().optional().nullable(),roles:Rj(J()),joined_at:J(),deaf:kj(),mute:kj()}),hN=Y({user_id:J(),nick:J().optional().nullable(),guild_id:J(),avatar:J().optional().nullable(),avatar_decoration_data:Y({asset:J(),sku_id:J().optional().nullable()}).optional().nullable(),color_string:J().optional().nullable()}),gN=Y({id:J(),name:J().optional().nullable(),roles:Rj(J()).optional().nullable(),user:pN.optional().nullable(),require_colons:kj().optional().nullable(),managed:kj().optional().nullable(),animated:kj().optional().nullable(),available:kj().optional().nullable()}),_N=Y({mute:kj(),deaf:kj(),self_mute:kj(),self_deaf:kj(),suppress:kj()}),vN=Y({mute:kj(),nick:J(),user:pN,voice_state:_N,volume:Ej()}),yN={UNHANDLED:-1,IDLE:`idle`,DND:`dnd`,ONLINE:`online`,OFFLINE:`offline`},bN=FM(yN),xN=Y({name:J(),type:Ej(),url:J().optional().nullable(),created_at:Ej().optional().nullable(),timestamps:Y({start:Ej(),end:Ej()}).partial().optional().nullable(),application_id:J().optional().nullable(),details:J().optional().nullable(),details_url:J().url().optional().nullable(),state:J().optional().nullable(),state_url:J().url().optional().nullable(),emoji:gN.optional().nullable(),party:Y({id:J().optional().nullable(),size:Rj(Ej()).optional().nullable()}).optional().nullable(),assets:Y({large_image:J().nullable(),large_text:J().nullable(),large_url:J().url().optional().nullable(),small_image:J().nullable(),small_text:J().nullable(),small_url:J().url().optional().nullable()}).partial().optional().nullable(),secrets:Y({join:J(),match:J()}).partial().optional().nullable(),instance:kj().optional().nullable(),flags:Ej().optional().nullable()}),SN={UNHANDLED:-1,ROLE:0,MEMBER:1},CN=Y({id:J(),type:FM(SN),allow:J(),deny:J()}),wN={UNHANDLED:-1,DM:1,GROUP_DM:3,GUILD_TEXT:0,GUILD_VOICE:2,GUILD_CATEGORY:4,GUILD_ANNOUNCEMENT:5,GUILD_STORE:6,ANNOUNCEMENT_THREAD:10,PUBLIC_THREAD:11,PRIVATE_THREAD:12,GUILD_STAGE_VOICE:13,GUILD_DIRECTORY:14,GUILD_FORUM:15},TN=Y({id:J(),type:FM(wN),guild_id:J().optional().nullable(),position:Ej().optional().nullable(),permission_overwrites:Rj(CN).optional().nullable(),name:J().optional().nullable(),topic:J().optional().nullable(),nsfw:kj().optional().nullable(),last_message_id:J().optional().nullable(),bitrate:Ej().optional().nullable(),user_limit:Ej().optional().nullable(),rate_limit_per_user:Ej().optional().nullable(),recipients:Rj(pN).optional().nullable(),icon:J().optional().nullable(),owner_id:J().optional().nullable(),application_id:J().optional().nullable(),parent_id:J().optional().nullable(),last_pin_timestamp:J().optional().nullable()}),EN=Y({user:pN,guild_id:J(),status:bN,activities:Rj(xN),client_status:Y({desktop:bN,mobile:bN,web:bN}).partial()}),DN=Y({id:J(),name:J(),color:Ej(),hoist:kj(),position:Ej(),permissions:J(),managed:kj(),mentionable:kj()}),ON=Y({id:J(),name:J(),owner_id:J(),icon:J().nullable(),icon_hash:J().optional().nullable(),splash:J().nullable(),discovery_splash:J().nullable(),owner:kj().optional().nullable(),permissions:J().optional().nullable(),region:J(),afk_channel_id:J().nullable(),afk_timeout:Ej(),widget_enabled:kj().optional().nullable(),widget_channel_id:J().optional().nullable(),verification_level:Ej(),default_message_notifications:Ej(),explicit_content_filter:Ej(),roles:Rj(DN),emojis:Rj(gN),features:Rj(J()),mfa_level:Ej(),application_id:J().nullable(),system_channel_id:J().nullable(),system_channel_flags:Ej(),rules_channel_id:J().nullable(),joined_at:J().optional().nullable(),large:kj().optional().nullable(),unavailable:kj().optional().nullable(),member_count:Ej().optional().nullable(),voice_states:Rj(_N).optional().nullable(),members:Rj(mN).optional().nullable(),channels:Rj(TN).optional().nullable(),presences:Rj(EN).optional().nullable(),max_presences:Ej().optional().nullable(),max_members:Ej().optional().nullable(),vanity_url_code:J().nullable(),description:J().nullable(),banner:J().nullable(),premium_tier:Ej(),premium_subscription_count:Ej().optional().nullable(),preferred_locale:J(),public_updates_channel_id:J().nullable(),max_video_channel_users:Ej().optional().nullable(),approximate_member_count:Ej().optional().nullable(),approximate_presence_count:Ej().optional().nullable()}),kN=Y({id:J(),guild_id:J(),type:Ej(),name:J()}),AN=Y({id:J(),filename:J(),size:Ej(),url:J(),proxy_url:J(),height:Ej().optional().nullable(),width:Ej().optional().nullable()}),jN=Y({text:J(),icon_url:J().optional().nullable(),proxy_icon_url:J().optional().nullable()}),MN=Y({url:J().optional().nullable(),proxy_url:J().optional().nullable(),height:Ej().optional().nullable(),width:Ej().optional().nullable()}),NN=MN.omit({proxy_url:!0}),PN=Y({name:J().optional().nullable(),url:J().optional().nullable()}),FN=Y({name:J().optional().nullable(),url:J().optional().nullable(),icon_url:J().optional().nullable(),proxy_icon_url:J().optional().nullable()}),IN=Y({name:J(),value:J(),inline:kj()}),LN=Y({title:J().optional().nullable(),type:J().optional().nullable(),description:J().optional().nullable(),url:J().optional().nullable(),timestamp:J().optional().nullable(),color:Ej().optional().nullable(),footer:jN.optional().nullable(),image:MN.optional().nullable(),thumbnail:MN.optional().nullable(),video:NN.optional().nullable(),provider:PN.optional().nullable(),author:FN.optional().nullable(),fields:Rj(IN).optional().nullable()}),RN=Y({count:Ej(),me:kj(),emoji:gN}),zN=Y({type:Ej(),party_id:J().optional().nullable()}),BN=Y({id:J(),cover_image:J().optional().nullable(),description:J(),icon:J().optional().nullable(),name:J()}),VN=Y({message_id:J().optional().nullable(),channel_id:J().optional().nullable(),guild_id:J().optional().nullable()}),HN=Y({id:J(),channel_id:J(),guild_id:J().optional().nullable(),author:pN.optional().nullable(),member:mN.optional().nullable(),content:J(),timestamp:J(),edited_timestamp:J().optional().nullable(),tts:kj(),mention_everyone:kj(),mentions:Rj(pN),mention_roles:Rj(J()),mention_channels:Rj(kN),attachments:Rj(AN),embeds:Rj(LN),reactions:Rj(RN).optional().nullable(),nonce:Bj([J(),Ej()]).optional().nullable(),pinned:kj(),webhook_id:J().optional().nullable(),type:Ej(),activity:zN.optional().nullable(),application:BN.optional().nullable(),message_reference:VN.optional().nullable(),flags:Ej().optional().nullable(),stickers:Rj(Fj()).optional().nullable(),referenced_message:Fj().optional().nullable()}),UN=Y({id:J(),name:J()}),WN={UNHANDLED:-1,KEYBOARD_KEY:0,MOUSE_BUTTON:1,KEYBOARD_MODIFIER_KEY:2,GAMEPAD_BUTTON:3},GN=Y({type:FM(WN),code:Ej(),name:J()}),KN={UNHANDLED:-1,PUSH_TO_TALK:`PUSH_TO_TALK`,VOICE_ACTIVITY:`VOICE_ACTIVITY`},qN=Y({type:FM(KN),auto_threshold:kj(),threshold:Ej(),shortcut:Rj(GN),delay:Ej()}),JN=Y({device_id:J(),volume:Ej(),available_devices:Rj(UN)}),YN={UNHANDLED:-1,AUDIO_INPUT:`AUDIO_INPUT`,AUDIO_OUTPUT:`AUDIO_OUTPUT`,VIDEO_INPUT:`VIDEO_INPUT`},XN=Y({type:FM(YN),id:J(),vendor:Y({name:J(),url:J()}),model:Y({name:J(),url:J()}),related:Rj(J()),echo_cancellation:kj().optional().nullable(),noise_suppression:kj().optional().nullable(),automatic_gain_control:kj().optional().nullable(),hardware_mute:kj().optional().nullable()}),ZN={UNHANDLED:-1,APPLICATION:1,DLC:2,CONSUMABLE:3,BUNDLE:4,SUBSCRIPTION:5},QN=Y({id:J(),name:J(),type:FM(ZN),price:Y({amount:Ej(),currency:J()}),application_id:J(),flags:Ej(),release_date:J().nullable()}),$N={UNHANDLED:-1,PURCHASE:1,PREMIUM_SUBSCRIPTION:2,DEVELOPER_GIFT:3,TEST_MODE_PURCHASE:4,FREE_PURCHASE:5,USER_GIFT:6,PREMIUM_PURCHASE:7},eP=Y({id:J(),sku_id:J(),application_id:J(),user_id:J(),gift_code_flags:Ej(),type:FM($N),gifter_user_id:J().optional().nullable(),branches:Rj(J()).optional().nullable(),starts_at:J().optional().nullable(),ends_at:J().optional().nullable(),parent_id:J().optional().nullable(),consumed:kj().optional().nullable(),deleted:kj().optional().nullable(),gift_code_batch_id:J().optional().nullable()}),tP={UNHANDLED:-1,UNLOCKED:1,PORTRAIT:2,LANDSCAPE:3},nP=FM(tP),rP={UNHANDLED:-1,NOMINAL:0,FAIR:1,SERIOUS:2,CRITICAL:3},iP=FM(rP),aP={UNHANDLED:-1,PORTRAIT:0,LANDSCAPE:1},oP=FM(aP),sP={UNHANDLED:-1,FOCUSED:0,PIP:1,GRID:2},cP=FM(sP),lP=`ERROR`,uP;(function(e){e.READY=`READY`,e.VOICE_STATE_UPDATE=`VOICE_STATE_UPDATE`,e.SPEAKING_START=`SPEAKING_START`,e.SPEAKING_STOP=`SPEAKING_STOP`,e.ACTIVITY_LAYOUT_MODE_UPDATE=`ACTIVITY_LAYOUT_MODE_UPDATE`,e.ORIENTATION_UPDATE=`ORIENTATION_UPDATE`,e.CURRENT_USER_UPDATE=`CURRENT_USER_UPDATE`,e.CURRENT_GUILD_MEMBER_UPDATE=`CURRENT_GUILD_MEMBER_UPDATE`,e.ENTITLEMENT_CREATE=`ENTITLEMENT_CREATE`,e.THERMAL_STATE_UPDATE=`THERMAL_STATE_UPDATE`,e.ACTIVITY_INSTANCE_PARTICIPANTS_UPDATE=`ACTIVITY_INSTANCE_PARTICIPANTS_UPDATE`,e.RELATIONSHIP_UPDATE=`RELATIONSHIP_UPDATE`,e.ACTIVITY_JOIN=`ACTIVITY_JOIN`,e.QUEST_ENROLLMENT_STATUS_UPDATE=`QUEST_ENROLLMENT_STATUS_UPDATE`})(uP||={});var dP=lN.extend({evt:Zj(uP),nonce:J().nullable(),cmd:Yj(sN),data:Y({}).passthrough()}),fP=lN.extend({evt:Yj(lP),data:Y({code:Ej(),message:J().optional()}).passthrough(),cmd:Zj(cN),nonce:J().nullable()}),pP=Bj([dP,dP.extend({evt:J()}),fP]);function mP(e){let t=e.evt;if(!(t in uP))throw Error(`Unrecognized event type ${e.evt}`);return hP[t].payload.parse(e)}var hP={[uP.READY]:{payload:dP.extend({evt:Yj(uP.READY),data:Y({v:Ej(),config:Y({cdn_host:J().optional(),api_endpoint:J(),environment:J()}),user:Y({id:J(),username:J(),discriminator:J(),avatar:J().optional()}).optional()})})},[uP.VOICE_STATE_UPDATE]:{payload:dP.extend({evt:Yj(uP.VOICE_STATE_UPDATE),data:vN}),subscribeArgs:Y({channel_id:J()})},[uP.SPEAKING_START]:{payload:dP.extend({evt:Yj(uP.SPEAKING_START),data:Y({lobby_id:J().optional(),channel_id:J().optional(),user_id:J()})}),subscribeArgs:Y({lobby_id:J().nullable().optional(),channel_id:J().nullable().optional()})},[uP.SPEAKING_STOP]:{payload:dP.extend({evt:Yj(uP.SPEAKING_STOP),data:Y({lobby_id:J().optional(),channel_id:J().optional(),user_id:J()})}),subscribeArgs:Y({lobby_id:J().nullable().optional(),channel_id:J().nullable().optional()})},[uP.ACTIVITY_LAYOUT_MODE_UPDATE]:{payload:dP.extend({evt:Yj(uP.ACTIVITY_LAYOUT_MODE_UPDATE),data:Y({layout_mode:FM(sP)})})},[uP.ORIENTATION_UPDATE]:{payload:dP.extend({evt:Yj(uP.ORIENTATION_UPDATE),data:Y({screen_orientation:FM(aP),orientation:Zj(NM)})})},[uP.CURRENT_USER_UPDATE]:{payload:dP.extend({evt:Yj(uP.CURRENT_USER_UPDATE),data:pN})},[uP.CURRENT_GUILD_MEMBER_UPDATE]:{payload:dP.extend({evt:Yj(uP.CURRENT_GUILD_MEMBER_UPDATE),data:hN}),subscribeArgs:Y({guild_id:J()})},[uP.ENTITLEMENT_CREATE]:{payload:dP.extend({evt:Yj(uP.ENTITLEMENT_CREATE),data:Y({entitlement:eP})})},[uP.THERMAL_STATE_UPDATE]:{payload:dP.extend({evt:Yj(uP.THERMAL_STATE_UPDATE),data:Y({thermal_state:iP})})},[uP.ACTIVITY_INSTANCE_PARTICIPANTS_UPDATE]:{payload:dP.extend({evt:Yj(uP.ACTIVITY_INSTANCE_PARTICIPANTS_UPDATE),data:Y({participants:VM.shape.participants})})},[uP.RELATIONSHIP_UPDATE]:{payload:dP.extend({evt:Yj(uP.RELATIONSHIP_UPDATE),data:fN})},[uP.ACTIVITY_JOIN]:{payload:dP.extend({evt:Yj(uP.ACTIVITY_JOIN),data:Y({applicationId:J(),secret:J()})})},[uP.QUEST_ENROLLMENT_STATUS_UPDATE]:{payload:dP.extend({evt:Yj(uP.QUEST_ENROLLMENT_STATUS_UPDATE),data:Y({quest_id:J(),is_enrolled:kj(),enrolled_at:J().date()})})}};function gP(e,t){throw t}var _P=Y({}).nullable(),vP=Y({code:J()}),yP=Y({guilds:Rj(Y({id:J(),name:J()}))}),bP=Y({id:J(),name:J(),icon_url:J().optional(),members:Rj(mN)}),xP=Y({id:J(),type:FM(wN),guild_id:J().optional().nullable(),name:J().optional().nullable(),topic:J().optional().nullable(),bitrate:Ej().optional().nullable(),user_limit:Ej().optional().nullable(),position:Ej().optional().nullable(),voice_states:Rj(vN),messages:Rj(HN)}),SP=Y({channels:Rj(TN)});xP.nullable();var CP=xP.nullable(),wP=xP.nullable();Y({input:JN,output:JN,mode:qN,automatic_gain_control:kj(),echo_cancellation:kj(),noise_suppression:kj(),qos:kj(),silence_warning:kj(),deaf:kj(),mute:kj()});var TP=Y({evt:J()}),EP=Y({shortcut:GN}),DP=xN,OP=Y({skus:Rj(QN)}),kP=Y({entitlements:Rj(eP)}),AP=Rj(eP).nullable(),jP=Y({use_interactive_pip:kj()}),MP=Y({locale:J()}),NP=Y({enabled:kj()}),PP=Y({permissions:Oj().or(J())}),FP=IM(Y({opened:kj().or(Nj())}).default({opened:null})),IP=Y({iosKeyboardResizesView:eM(kj())}),LP=lN.extend({cmd:Zj(cN),evt:Nj()});function RP({cmd:e,data:t}){switch(e){case cN.AUTHORIZE:return vP.parse(t);case cN.CAPTURE_SHORTCUT:return EP.parse(t);case cN.ENCOURAGE_HW_ACCELERATION:return NP.parse(t);case cN.GET_CHANNEL:return xP.parse(t);case cN.GET_CHANNELS:return SP.parse(t);case cN.GET_CHANNEL_PERMISSIONS:return PP.parse(t);case cN.GET_GUILD:return bP.parse(t);case cN.GET_GUILDS:return yP.parse(t);case cN.GET_PLATFORM_BEHAVIORS:return IP.parse(t);case cN.GET_CHANNEL:return xP.parse(t);case cN.SELECT_TEXT_CHANNEL:return wP.parse(t);case cN.SELECT_VOICE_CHANNEL:return CP.parse(t);case cN.SET_ACTIVITY:return DP.parse(t);case cN.GET_SKUS_EMBEDDED:return OP.parse(t);case cN.GET_ENTITLEMENTS_EMBEDDED:return kP.parse(t);case cN.SET_CONFIG:return jP.parse(t);case cN.START_PURCHASE:return AP.parse(t);case cN.SUBSCRIBE:case cN.UNSUBSCRIBE:return TP.parse(t);case cN.USER_SETTINGS_GET_LOCALE:return MP.parse(t);case cN.OPEN_EXTERNAL_LINK:return FP.parse(t);case cN.SET_ORIENTATION_LOCK_STATE:case cN.SET_CERTIFIED_DEVICES:case cN.SEND_ANALYTICS_EVENT:case cN.OPEN_INVITE_DIALOG:case cN.CAPTURE_LOG:case cN.GET_SKUS:case cN.GET_ENTITLEMENTS:return _P.parse(t);case cN.AUTHENTICATE:case cN.GET_ACTIVITY_INSTANCE_CONNECTED_PARTICIPANTS:case cN.GET_QUEST:case cN.GET_QUEST_ENROLLMENT_STATUS:case cN.GET_RELATIONSHIPS:case cN.GET_USER:case cN.INITIATE_IMAGE_UPLOAD:case cN.INVITE_USER_EMBEDDED:case cN.OPEN_SHARE_MOMENT_DIALOG:case cN.QUEST_START_TIMER:case cN.REQUEST_PROXY_TICKET_REFRESH:case cN.SHARE_INTERACTION:case cN.SHARE_LINK:let{response:n}=aN[e];return n.parse(t);default:gP(e,Error(`Unrecognized command ${e}`))}}function zP(e){return Object.assign(Object.assign({},e),{data:RP(e)})}Y({frame_id:J(),platform:Zj(PM).optional().nullable()}),Y({v:Yj(1),encoding:Yj(`json`).optional(),client_id:J(),frame_id:J()});var BP=Y({code:Ej(),message:J().optional()}),VP=Y({evt:J().nullable(),nonce:J().nullable(),data:Fj().nullable(),cmd:J()}).passthrough();function HP(e){let t=VP.parse(e);return t.evt==null?zP(LP.passthrough().parse(t)):t.evt===`ERROR`?fP.parse(t):mP(pP.parse(t))}function UP(e,t,n,r=()=>void 0){let i=lN.extend({cmd:Yj(t),data:n});return async n=>{let a=await e({cmd:t,args:n,transfer:r(n)});return i.parse(a).data}}function WP(e,t=()=>void 0){let n=aN[e].response,r=lN.extend({cmd:Yj(e),data:n});return n=>async i=>{let a=await n({cmd:e,args:i,transfer:t(i)});return r.parse(a).data}}var GP=e=>UP(e,cN.AUTHORIZE,vP),KP=e=>UP(e,cN.CAPTURE_LOG,_P),qP=e=>UP(e,cN.ENCOURAGE_HW_ACCELERATION,NP),JP=e=>UP(e,cN.GET_CHANNEL,xP),YP=e=>UP(e,cN.GET_ENTITLEMENTS_EMBEDDED,kP),XP=e=>UP(e,cN.GET_SKUS_EMBEDDED,OP),ZP=e=>UP(e,cN.GET_CHANNEL_PERMISSIONS,PP),QP=e=>UP(e,cN.GET_PLATFORM_BEHAVIORS,IP),$P=e=>UP(e,cN.OPEN_EXTERNAL_LINK,FP),eF=e=>UP(e,cN.OPEN_INVITE_DIALOG,_P);xN.pick({state:!0,state_url:!0,details:!0,details_url:!0,timestamps:!0,assets:!0,party:!0,secrets:!0,instance:!0,type:!0}).extend({type:xN.shape.type.optional(),instance:xN.shape.instance.optional()}).nullable();var tF=e=>UP(e,cN.SET_ACTIVITY,DP),nF=e=>UP(e,cN.SET_CONFIG,jP);function rF({sendCommand:e,cmd:t,response:n,fallbackTransform:r,transferTransform:i=()=>void 0}){let a=lN.extend({cmd:Yj(t),data:n});return async n=>{try{let r=await e({cmd:t,args:n,transfer:i(n)});return a.parse(r).data}catch(o){if(o.code===MM.INVALID_PAYLOAD){let o=r(n),s=await e({cmd:t,args:o,transfer:i(o)});return a.parse(s).data}throw o}}}var iF=e=>({lock_state:e.lock_state,picture_in_picture_lock_state:e.picture_in_picture_lock_state}),aF=e=>rF({sendCommand:e,cmd:cN.SET_ORIENTATION_LOCK_STATE,response:_P,fallbackTransform:iF}),oF=e=>UP(e,cN.START_PURCHASE,AP),sF=e=>UP(e,cN.USER_SETTINGS_GET_LOCALE,MP),cF=WP(nN.AUTHENTICATE),lF=WP(nN.GET_ACTIVITY_INSTANCE_CONNECTED_PARTICIPANTS),uF=WP(nN.GET_QUEST),dF=WP(nN.GET_QUEST_ENROLLMENT_STATUS),fF=WP(nN.GET_RELATIONSHIPS),pF=WP(nN.GET_USER),mF=WP(nN.INITIATE_IMAGE_UPLOAD),hF=WP(nN.INVITE_USER_EMBEDDED),gF=WP(nN.OPEN_SHARE_MOMENT_DIALOG),_F=WP(nN.QUEST_START_TIMER),vF=WP(nN.REQUEST_PROXY_TICKET_REFRESH),yF=WP(nN.SHARE_INTERACTION),bF=WP(nN.SHARE_LINK);function xF(e){return{authorize:GP(e),captureLog:KP(e),encourageHardwareAcceleration:qP(e),getChannel:JP(e),getChannelPermissions:ZP(e),getEntitlements:YP(e),getPlatformBehaviors:QP(e),getSkus:XP(e),openExternalLink:$P(e),openInviteDialog:eF(e),setActivity:tF(e),setConfig:nF(e),setOrientationLockState:aF(e),startPurchase:oF(e),userSettingsGetLocale:sF(e),getInstanceConnectedParticipants:lF(e),authenticate:cF(e),getActivityInstanceConnectedParticipants:lF(e),getQuest:uF(e),getQuestEnrollmentStatus:dF(e),getRelationships:fF(e),getUser:pF(e),initiateImageUpload:mF(e),inviteUserEmbedded:hF(e),openShareMomentDialog:gF(e),questStartTimer:_F(e),requestProxyTicketRefresh:vF(e),shareInteraction:yF(e),shareLink:bF(e)}}var SF=class extends Error{constructor(e,t=``){super(t),this.code=e,this.message=t,this.name=`Discord SDK Error`}};function CF(){return{disableConsoleLogOverride:!1}}var wF=[`log`,`warn`,`debug`,`info`,`error`];function TF(e,t,n){let r=e[t],i=e;r&&(e[t]=function(){let e=[].slice.call(arguments);n(t,``+e.join(` `)),r.apply(i,e)})}var EF=`2.5.0`,DF={randomUUID:typeof crypto<`u`&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)},OF,kF=new Uint8Array(16);function AF(){if(!OF){if(typeof crypto>`u`||!crypto.getRandomValues)throw Error(`crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported`);OF=crypto.getRandomValues.bind(crypto)}return OF(kF)}var jF=[];for(let e=0;e<256;++e)jF.push((e+256).toString(16).slice(1));function MF(e,t=0){return(jF[e[t+0]]+jF[e[t+1]]+jF[e[t+2]]+jF[e[t+3]]+`-`+jF[e[t+4]]+jF[e[t+5]]+`-`+jF[e[t+6]]+jF[e[t+7]]+`-`+jF[e[t+8]]+jF[e[t+9]]+`-`+jF[e[t+10]]+jF[e[t+11]]+jF[e[t+12]]+jF[e[t+13]]+jF[e[t+14]]+jF[e[t+15]]).toLowerCase()}function NF(e,t,n){if(DF.randomUUID&&!t&&!e)return DF.randomUUID();e||={};let r=e.random??e.rng?.()??AF();if(r.length<16)throw Error(`Random bytes length must be >= 16`);return r[6]=r[6]&15|64,r[8]=r[8]&63|128,MF(r)}var PF;(function(e){e[e.HANDSHAKE=0]=`HANDSHAKE`,e[e.FRAME=1]=`FRAME`,e[e.CLOSE=2]=`CLOSE`,e[e.HELLO=3]=`HELLO`})(PF||={});var FF=new Set(IF());function IF(){return typeof window>`u`?[]:[window.location.origin,`https://discord.com`,`https://discordapp.com`,`https://ptb.discord.com`,`https://ptb.discordapp.com`,`https://canary.discord.com`,`https://canary.discordapp.com`,`https://staging.discord.co`,`http://localhost:3333`,`https://pax.discord.com`,`null`]}function LF(){return[window.parent.opener??window.parent,document.referrer?document.referrer:`*`]}var RF=class{getTransfer(e){switch(e.cmd){case cN.SUBSCRIBE:case cN.UNSUBSCRIBE:return;default:return e.transfer??void 0}}constructor(e,t){if(this.sdkVersion=EF,this.mobileAppVersion=null,this.source=null,this.sourceOrigin=``,this.eventBus=new Vk,this.pendingCommands=new Map,this.sendCommand=e=>{var t;if(this.source==null)throw Error(`Attempting to send message before initialization`);let n=NF();return(t=this.source)==null||t.postMessage([PF.FRAME,Object.assign(Object.assign({},e),{nonce:n})],this.sourceOrigin,this.getTransfer(e)),new Promise((e,t)=>{this.pendingCommands.set(n,{resolve:e,reject:t})})},this.commands=xF(this.sendCommand),this.handleMessage=e=>{if(!FF.has(e.origin))return;let t=e.data;if(!Array.isArray(t))return;let[n,r]=t;switch(n){case PF.HELLO:return;case PF.CLOSE:return this.handleClose(r);case PF.HANDSHAKE:return this.handleHandshake();case PF.FRAME:return this.handleFrame(r);default:throw Error(`Invalid message format`)}},this.isReady=!1,this.clientId=e,this.configuration=t??CF(),typeof window<`u`&&window.addEventListener(`message`,this.handleMessage),typeof window>`u`){this.frameId=``,this.instanceId=``,this.customId=null,this.referrerId=null,this.platform=PM.DESKTOP,this.guildId=null,this.channelId=null,this.locationId=null;return}let n=new URLSearchParams(this._getSearch()),r=n.get(`frame_id`);if(!r)throw Error(`frame_id query param is not defined`);this.frameId=r;let i=n.get(`instance_id`);if(!i)throw Error(`instance_id query param is not defined`);this.instanceId=i;let a=n.get(`platform`);if(!a)throw Error(`platform query param is not defined`);if(a!==PM.DESKTOP&&a!==PM.MOBILE)throw Error(`Invalid query param "platform" of "${a}". Valid values are "${PM.DESKTOP}" or "${PM.MOBILE}"`);this.platform=a,this.customId=n.get(`custom_id`),this.referrerId=n.get(`referrer_id`),this.guildId=n.get(`guild_id`),this.channelId=n.get(`channel_id`),this.locationId=n.get(`location_id`),this.mobileAppVersion=n.get(`mobile_app_version`),[this.source,this.sourceOrigin]=LF(),this.addOnReadyListener(),this.handshake()}close(e,t){var n;window.removeEventListener(`message`,this.handleMessage);let r=NF();(n=this.source)==null||n.postMessage([PF.CLOSE,{code:e,message:t,nonce:r}],this.sourceOrigin)}async subscribe(e,t,...n){let[r]=n,i=this.eventBus.listenerCount(e),a=this.eventBus.on(e,t);return Object.values(uP).includes(e)&&e!==uP.READY&&i===0&&await this.sendCommand({cmd:cN.SUBSCRIBE,args:r,evt:e}),a}async unsubscribe(e,t,...n){let[r]=n;return e!==uP.READY&&this.eventBus.listenerCount(e)===1&&await this.sendCommand({cmd:cN.UNSUBSCRIBE,evt:e,args:r}),this.eventBus.off(e,t)}async ready(){this.isReady||await new Promise(e=>{this.eventBus.once(uP.READY,e)})}parseMajorMobileVersion(){if(this.mobileAppVersion&&this.mobileAppVersion.includes(`.`))try{return parseInt(this.mobileAppVersion.split(`.`)[0])}catch{return-1}return-1}handshake(){var e;let t={v:1,encoding:`json`,client_id:this.clientId,frame_id:this.frameId},n=this.parseMajorMobileVersion();(this.platform===PM.DESKTOP||n>=250)&&(t.sdk_version=this.sdkVersion),(e=this.source)==null||e.postMessage([PF.HANDSHAKE,t],this.sourceOrigin)}addOnReadyListener(){this.eventBus.once(uP.READY,()=>{this.overrideConsoleLogging(),this.isReady=!0})}overrideConsoleLogging(){if(this.configuration.disableConsoleLogOverride)return;let e=(e,t)=>{this.commands.captureLog({level:e,message:t})};wF.forEach(t=>{TF(console,t,e)})}handleClose(e){BP.parse(e)}handleHandshake(){}handleFrame(e){var t,n;let r;try{r=HP(e)}catch(t){console.error(`Failed to parse`,e),console.error(t);return}if(r.cmd===`DISPATCH`)this.eventBus.emit(r.evt,r.data);else{if(r.evt===`ERROR`){if(r.nonce!=null){(t=this.pendingCommands.get(r.nonce))==null||t.reject(r.data),this.pendingCommands.delete(r.nonce);return}this.eventBus.emit(`error`,new SF(r.data.code,r.data.message))}if(r.nonce==null){console.error(`Missing nonce`,e);return}(n=this.pendingCommands.get(r.nonce))==null||n.resolve(r),this.pendingCommands.delete(r.nonce)}}_getSearch(){return typeof window>`u`?``:window.location.search}},zF=1e9,BF={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:`2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286`},VF=!0,HF=`[DecimalError] `,UF=HF+`Invalid argument: `,WF=HF+`Exponent out of range: `,GF=Math.floor,KF=Math.pow,qF=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,JF,YF=1e7,XF=7,ZF=9007199254740991,QF=GF(ZF/XF),Z={};Z.absoluteValue=Z.abs=function(){var e=new this.constructor(this);return e.s&&=1,e},Z.comparedTo=Z.cmp=function(e){var t,n,r,i,a=this;if(e=new a.constructor(e),a.s!==e.s)return a.s||-e.s;if(a.e!==e.e)return a.e>e.e^a.s<0?1:-1;for(r=a.d.length,i=e.d.length,t=0,n=re.d[t]^a.s<0?1:-1;return r===i?0:r>i^a.s<0?1:-1},Z.decimalPlaces=Z.dp=function(){var e=this,t=e.d.length-1,n=(t-e.e)*XF;if(t=e.d[t],t)for(;t%10==0;t/=10)n--;return n<0?0:n},Z.dividedBy=Z.div=function(e){return nI(this,new this.constructor(e))},Z.dividedToIntegerBy=Z.idiv=function(e){var t=this,n=t.constructor;return lI(nI(t,new n(e),0,1),n.precision)},Z.equals=Z.eq=function(e){return!this.cmp(e)},Z.exponent=function(){return iI(this)},Z.greaterThan=Z.gt=function(e){return this.cmp(e)>0},Z.greaterThanOrEqualTo=Z.gte=function(e){return this.cmp(e)>=0},Z.isInteger=Z.isint=function(){return this.e>this.d.length-2},Z.isNegative=Z.isneg=function(){return this.s<0},Z.isPositive=Z.ispos=function(){return this.s>0},Z.isZero=function(){return this.s===0},Z.lessThan=Z.lt=function(e){return this.cmp(e)<0},Z.lessThanOrEqualTo=Z.lte=function(e){return this.cmp(e)<1},Z.logarithm=Z.log=function(e){var t,n=this,r=n.constructor,i=r.precision,a=i+5;if(e===void 0)e=new r(10);else if(e=new r(e),e.s<1||e.eq(JF))throw Error(HF+`NaN`);if(n.s<1)throw Error(HF+(n.s?`NaN`:`-Infinity`));return n.eq(JF)?new r(0):(VF=!1,t=nI(sI(n,a),sI(e,a),a),VF=!0,lI(t,i))},Z.minus=Z.sub=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?uI(t,e):$F(t,(e.s=-e.s,e))},Z.modulo=Z.mod=function(e){var t,n=this,r=n.constructor,i=r.precision;if(e=new r(e),!e.s)throw Error(HF+`NaN`);return n.s?(VF=!1,t=nI(n,e,0,1).times(e),VF=!0,n.minus(t)):lI(new r(n),i)},Z.naturalExponential=Z.exp=function(){return rI(this)},Z.naturalLogarithm=Z.ln=function(){return sI(this)},Z.negated=Z.neg=function(){var e=new this.constructor(this);return e.s=-e.s||0,e},Z.plus=Z.add=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?$F(t,e):uI(t,(e.s=-e.s,e))},Z.precision=Z.sd=function(e){var t,n,r,i=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(UF+e);if(t=iI(i)+1,r=i.d.length-1,n=r*XF+1,r=i.d[r],r){for(;r%10==0;r/=10)n--;for(r=i.d[0];r>=10;r/=10)n++}return e&&t>n?t:n},Z.squareRoot=Z.sqrt=function(){var e,t,n,r,i,a,o,s=this,c=s.constructor;if(s.s<1){if(!s.s)return new c(0);throw Error(HF+`NaN`)}for(e=iI(s),VF=!1,i=Math.sqrt(+s),i==0||i==1/0?(t=tI(s.d),(t.length+e)%2==0&&(t+=`0`),i=Math.sqrt(t),e=GF((e+1)/2)-(e<0||e%2),i==1/0?t=`5e`+e:(t=i.toExponential(),t=t.slice(0,t.indexOf(`e`)+1)+e),r=new c(t)):r=new c(i.toString()),n=c.precision,i=o=n+3;;)if(a=r,r=a.plus(nI(s,a,o+2)).times(.5),tI(a.d).slice(0,o)===(t=tI(r.d)).slice(0,o)){if(t=t.slice(o-3,o+1),i==o&&t==`4999`){if(lI(a,n+1,0),a.times(a).eq(s)){r=a;break}}else if(t!=`9999`)break;o+=4}return VF=!0,lI(r,n)},Z.times=Z.mul=function(e){var t,n,r,i,a,o,s,c,l,u=this,d=u.constructor,f=u.d,p=(e=new d(e)).d;if(!u.s||!e.s)return new d(0);for(e.s*=u.s,n=u.e+e.e,c=f.length,l=p.length,c=0;){for(t=0,i=c+r;i>r;)s=a[i]+p[r]*f[i-r-1]+t,a[i--]=s%YF|0,t=s/YF|0;a[i]=(a[i]+t)%YF|0}for(;!a[--o];)a.pop();return t?++n:a.shift(),e.d=a,e.e=n,VF?lI(e,d.precision):e},Z.toDecimalPlaces=Z.todp=function(e,t){var n=this,r=n.constructor;return n=new r(n),e===void 0?n:(eI(e,0,zF),t===void 0?t=r.rounding:eI(t,0,8),lI(n,e+iI(n)+1,t))},Z.toExponential=function(e,t){var n,r=this,i=r.constructor;return e===void 0?n=dI(r,!0):(eI(e,0,zF),t===void 0?t=i.rounding:eI(t,0,8),r=lI(new i(r),e+1,t),n=dI(r,!0,e+1)),n},Z.toFixed=function(e,t){var n,r,i=this,a=i.constructor;return e===void 0?dI(i):(eI(e,0,zF),t===void 0?t=a.rounding:eI(t,0,8),r=lI(new a(i),e+iI(i)+1,t),n=dI(r.abs(),!1,e+iI(r)+1),i.isneg()&&!i.isZero()?`-`+n:n)},Z.toInteger=Z.toint=function(){var e=this,t=e.constructor;return lI(new t(e),iI(e)+1,t.rounding)},Z.toNumber=function(){return+this},Z.toPower=Z.pow=function(e){var t,n,r,i,a,o,s=this,c=s.constructor,l=12,u=+(e=new c(e));if(!e.s)return new c(JF);if(s=new c(s),!s.s){if(e.s<1)throw Error(HF+`Infinity`);return s}if(s.eq(JF))return s;if(r=c.precision,e.eq(JF))return lI(s,r);if(t=e.e,n=e.d.length-1,o=t>=n,a=s.s,!o){if(a<0)throw Error(HF+`NaN`)}else if((n=u<0?-u:u)<=ZF){for(i=new c(JF),t=Math.ceil(r/XF+4),VF=!1;n%2&&(i=i.times(s),fI(i.d,t)),n=GF(n/2),n!==0;)s=s.times(s),fI(s.d,t);return VF=!0,e.s<0?new c(JF).div(i):lI(i,r)}return a=a<0&&e.d[Math.max(t,n)]&1?-1:1,s.s=1,VF=!1,i=e.times(sI(s,r+l)),VF=!0,i=rI(i),i.s=a,i},Z.toPrecision=function(e,t){var n,r,i=this,a=i.constructor;return e===void 0?(n=iI(i),r=dI(i,n<=a.toExpNeg||n>=a.toExpPos)):(eI(e,1,zF),t===void 0?t=a.rounding:eI(t,0,8),i=lI(new a(i),e,t),n=iI(i),r=dI(i,e<=n||n<=a.toExpNeg,e)),r},Z.toSignificantDigits=Z.tosd=function(e,t){var n=this,r=n.constructor;return e===void 0?(e=r.precision,t=r.rounding):(eI(e,1,zF),t===void 0?t=r.rounding:eI(t,0,8)),lI(new r(n),e,t)},Z.toString=Z.valueOf=Z.val=Z.toJSON=Z[Symbol.for(`nodejs.util.inspect.custom`)]=function(){var e=this,t=iI(e),n=e.constructor;return dI(e,t<=n.toExpNeg||t>=n.toExpPos)};function $F(e,t){var n,r,i,a,o,s,c,l,u=e.constructor,d=u.precision;if(!e.s||!t.s)return t.s||(t=new u(e)),VF?lI(t,d):t;if(c=e.d,l=t.d,o=e.e,i=t.e,c=c.slice(),a=o-i,a){for(a<0?(r=c,a=-a,s=l.length):(r=l,i=o,s=c.length),o=Math.ceil(d/XF),s=o>s?o+1:s+1,a>s&&(a=s,r.length=1),r.reverse();a--;)r.push(0);r.reverse()}for(s=c.length,a=l.length,s-a<0&&(a=s,r=l,l=c,c=r),n=0;a;)n=(c[--a]=c[a]+l[a]+n)/YF|0,c[a]%=YF;for(n&&(c.unshift(n),++i),s=c.length;c[--s]==0;)c.pop();return t.d=c,t.e=i,VF?lI(t,d):t}function eI(e,t,n){if(e!==~~e||en)throw Error(UF+e)}function tI(e){var t,n,r,i=e.length-1,a=``,o=e[0];if(i>0){for(a+=o,t=1;tr?1:-1;else for(i=a=0;it[i]?1:-1;break}return a}function n(e,t,n){for(var r=0;n--;)e[n]-=r,r=+(e[n]1;)e.shift()}return function(r,i,a,o){var s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T=r.constructor,E=r.s==i.s?1:-1,D=r.d,O=i.d;if(!r.s)return new T(r);if(!i.s)throw Error(HF+`Division by zero`);for(c=r.e-i.e,C=O.length,x=D.length,p=new T(E),m=p.d=[],l=0;O[l]==(D[l]||0);)++l;if(O[l]>(D[l]||0)&&--c,v=a==null?a=T.precision:o?a+(iI(r)-iI(i))+1:a,v<0)return new T(0);if(v=v/XF+2|0,l=0,C==1)for(u=0,O=O[0],v++;(l1&&(O=e(O,u),D=e(D,u),C=O.length,x=D.length),b=C,h=D.slice(0,C),g=h.length;g=YF/2&&++S;do u=0,s=t(O,h,C,g),s<0?(_=h[0],C!=g&&(_=_*YF+(h[1]||0)),u=_/S|0,u>1?(u>=YF&&(u=YF-1),d=e(O,u),f=d.length,g=h.length,s=t(d,h,f,g),s==1&&(u--,n(d,C16)throw Error(WF+iI(e));if(!e.s)return new u(JF);for(t==null?(VF=!1,s=d):s=t,o=new u(.03125);e.abs().gte(.1);)e=e.times(o),l+=5;for(r=Math.log(KF(2,l))/Math.LN10*2+5|0,s+=r,n=i=a=new u(JF),u.precision=s;;){if(i=lI(i.times(e),s),n=n.times(++c),o=a.plus(nI(i,n,s)),tI(o.d).slice(0,s)===tI(a.d).slice(0,s)){for(;l--;)a=lI(a.times(a),s);return u.precision=d,t==null?(VF=!0,lI(a,d)):a}a=o}}function iI(e){for(var t=e.e*XF,n=e.d[0];n>=10;n/=10)t++;return t}function aI(e,t,n){if(t>e.LN10.sd())throw VF=!0,n&&(e.precision=n),Error(HF+`LN10 precision limit exceeded`);return lI(new e(e.LN10),t)}function oI(e){for(var t=``;e--;)t+=`0`;return t}function sI(e,t){var n,r,i,a,o,s,c,l,u,d=1,f=10,p=e,m=p.d,h=p.constructor,g=h.precision;if(p.s<1)throw Error(HF+(p.s?`NaN`:`-Infinity`));if(p.eq(JF))return new h(0);if(t==null?(VF=!1,l=g):l=t,p.eq(10))return t??(VF=!0),aI(h,l);if(l+=f,h.precision=l,n=tI(m),r=n.charAt(0),a=iI(p),Math.abs(a)<0x5543df729c000){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)p=p.times(e),n=tI(p.d),r=n.charAt(0),d++;a=iI(p),r>1?(p=new h(`0.`+n),a++):p=new h(r+`.`+n.slice(1))}else return c=aI(h,l+2,g).times(a+``),p=sI(new h(r+`.`+n.slice(1)),l-f).plus(c),h.precision=g,t==null?(VF=!0,lI(p,g)):p;for(s=o=p=nI(p.minus(JF),p.plus(JF),l),u=lI(p.times(p),l),i=3;;){if(o=lI(o.times(u),l),c=s.plus(nI(o,new h(i),l)),tI(c.d).slice(0,l)===tI(s.d).slice(0,l))return s=s.times(2),a!==0&&(s=s.plus(aI(h,l+2,g).times(a+``))),s=nI(s,new h(d),l),h.precision=g,t==null?(VF=!0,lI(s,g)):s;s=c,i+=2}}function cI(e,t){var n,r,i;for((n=t.indexOf(`.`))>-1&&(t=t.replace(`.`,``)),(r=t.search(/e/i))>0?(n<0&&(n=r),n+=+t.slice(r+1),t=t.substring(0,r)):n<0&&(n=t.length),r=0;t.charCodeAt(r)===48;)++r;for(i=t.length;t.charCodeAt(i-1)===48;)--i;if(t=t.slice(r,i),t){if(i-=r,n=n-r-1,e.e=GF(n/XF),e.d=[],r=(n+1)%XF,n<0&&(r+=XF),rQF||e.e<-QF))throw Error(WF+n)}else e.s=0,e.e=0,e.d=[0];return e}function lI(e,t,n){var r,i,a,o,s,c,l,u,d=e.d;for(o=1,a=d[0];a>=10;a/=10)o++;if(r=t-o,r<0)r+=XF,i=t,l=d[u=0];else{if(u=Math.ceil((r+1)/XF),a=d.length,u>=a)return e;for(l=a=d[u],o=1;a>=10;a/=10)o++;r%=XF,i=r-XF+o}if(n!==void 0&&(a=KF(10,o-i-1),s=l/a%10|0,c=t<0||d[u+1]!==void 0||l%a,c=n<4?(s||c)&&(n==0||n==(e.s<0?3:2)):s>5||s==5&&(n==4||c||n==6&&(r>0?i>0?l/KF(10,o-i):0:d[u-1])%10&1||n==(e.s<0?8:7))),t<1||!d[0])return c?(a=iI(e),d.length=1,t=t-a-1,d[0]=KF(10,(XF-t%XF)%XF),e.e=GF(-t/XF)||0):(d.length=1,d[0]=e.e=e.s=0),e;if(r==0?(d.length=u,a=1,u--):(d.length=u+1,a=KF(10,XF-r),d[u]=i>0?(l/KF(10,o-i)%KF(10,i)|0)*a:0),c)for(;;)if(u==0){(d[0]+=a)==YF&&(d[0]=1,++e.e);break}else{if(d[u]+=a,d[u]!=YF)break;d[u--]=0,a=1}for(r=d.length;d[--r]===0;)d.pop();if(VF&&(e.e>QF||e.e<-QF))throw Error(WF+iI(e));return e}function uI(e,t){var n,r,i,a,o,s,c,l,u,d,f=e.constructor,p=f.precision;if(!e.s||!t.s)return t.s?t.s=-t.s:t=new f(e),VF?lI(t,p):t;if(c=e.d,d=t.d,r=t.e,l=e.e,c=c.slice(),o=l-r,o){for(u=o<0,u?(n=c,o=-o,s=d.length):(n=d,r=l,s=c.length),i=Math.max(Math.ceil(p/XF),s)+2,o>i&&(o=i,n.length=1),n.reverse(),i=o;i--;)n.push(0);n.reverse()}else{for(i=c.length,s=d.length,u=i0;--i)c[s++]=0;for(i=d.length;i>o;){if(c[--i]0?a=a.charAt(0)+`.`+a.slice(1)+oI(r):o>1&&(a=a.charAt(0)+`.`+a.slice(1)),a=a+(i<0?`e`:`e+`)+i):i<0?(a=`0.`+oI(-i-1)+a,n&&(r=n-o)>0&&(a+=oI(r))):i>=o?(a+=oI(i+1-o),n&&(r=n-i-1)>0&&(a=a+`.`+oI(r))):((r=i+1)0&&(i+1===o&&(a+=`.`),a+=oI(r))),e.s<0?`-`+a:a}function fI(e,t){if(e.length>t)return e.length=t,!0}function pI(e){var t,n,r;function i(e){var t=this;if(!(t instanceof i))return new i(e);if(t.constructor=i,e instanceof i)t.s=e.s,t.e=e.e,t.d=(e=e.d)?e.slice():e;else{if(typeof e==`number`){if(e*0!=0)throw Error(UF+e);if(e>0)t.s=1;else if(e<0)e=-e,t.s=-1;else{t.s=0,t.e=0,t.d=[0];return}if(e===~~e&&e<1e7){t.e=0,t.d=[e];return}return cI(t,e.toString())}if(typeof e!=`string`)throw Error(UF+e);if(e.charCodeAt(0)===45?(e=e.slice(1),t.s=-1):t.s=1,qF.test(e))cI(t,e);else throw Error(UF+e)}}if(i.prototype=Z,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.clone=pI,i.config=i.set=mI,e===void 0&&(e={}),e)for(r=[`precision`,`rounding`,`toExpNeg`,`toExpPos`,`LN10`],t=0;t=i[t+1]&&r<=i[t+2])this[n]=r;else throw Error(UF+n+`: `+r)}if((r=e[n=`LN10`])!==void 0){if(r==Math.LN10)this[n]=new this(r);else throw Error(UF+n+`: `+r)}return this}JF=new(pI(BF))(1);var Q;(function(e){e.AED=`aed`,e.AFN=`afn`,e.ALL=`all`,e.AMD=`amd`,e.ANG=`ang`,e.AOA=`aoa`,e.ARS=`ars`,e.AUD=`aud`,e.AWG=`awg`,e.AZN=`azn`,e.BAM=`bam`,e.BBD=`bbd`,e.BDT=`bdt`,e.BGN=`bgn`,e.BHD=`bhd`,e.BIF=`bif`,e.BMD=`bmd`,e.BND=`bnd`,e.BOB=`bob`,e.BOV=`bov`,e.BRL=`brl`,e.BSD=`bsd`,e.BTN=`btn`,e.BWP=`bwp`,e.BYN=`byn`,e.BYR=`byr`,e.BZD=`bzd`,e.CAD=`cad`,e.CDF=`cdf`,e.CHE=`che`,e.CHF=`chf`,e.CHW=`chw`,e.CLF=`clf`,e.CLP=`clp`,e.CNY=`cny`,e.COP=`cop`,e.COU=`cou`,e.CRC=`crc`,e.CUC=`cuc`,e.CUP=`cup`,e.CVE=`cve`,e.CZK=`czk`,e.DJF=`dj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Symbol]`,v=`[object WeakMap]`,y=`[object ArrayBuffer]`,b=`[object DataView]`,x=`[object Float32Array]`,S=`[object Float64Array]`,C=`[object Int8Array]`,w=`[object Int16Array]`,T=`[object Int32Array]`,E=`[object Uint8Array]`,D=`[object Uint8ClampedArray]`,O=`[object Uint16Array]`,k=`[object Uint32Array]`,A=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,j=/^\w*$/,ee=/^\./,M=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,te=/[\\^$.*+?()[\]{}|]/g,ne=/\\(\\)?/g,re=/^\[object .+?Constructor\]$/,ie=/^(?:0|[1-9]\d*)$/,ae={};ae[x]=ae[S]=ae[C]=ae[w]=ae[T]=ae[E]=ae[D]=ae[O]=ae[k]=!0,ae[i]=ae[a]=ae[y]=ae[o]=ae[b]=ae[s]=ae[c]=ae[l]=ae[u]=ae[d]=ae[f]=ae[m]=ae[h]=ae[g]=ae[v]=!1;var oe=typeof Ik==`object`&&Ik&&Ik.Object===Object&&Ik,se=typeof self==`object`&&self&&self.Object===Object&&self,ce=oe||se||globalThis,le=t&&!t.nodeType&&t,ue=le&&e&&!e.nodeType&&e,de=ue&&ue.exports===le&&oe.process,fe=function(){try{return de&&de.binding(`util`)}catch{}}(),pe=fe&&fe.isTypedArray;function me(e,t){for(var n=-1,r=e?e.length:0;++n-1}function st(e,t){var n=this.__data__,r=wt(n,e);return r<0?n.push([e,t]):n[r][1]=t,this}nt.prototype.clear=rt,nt.prototype.delete=it,nt.prototype.get=at,nt.prototype.has=ot,nt.prototype.set=st;function ct(e){var t=-1,n=e?e.length:0;for(this.clear();++ts))return!1;var l=a.get(e);if(l&&a.get(t))return l==t;var u=-1,d=!0,f=i&1?new mt:void 0;for(a.set(e,t),a.set(t,e);++u-1&&e%1==0&&e-1&&e%1==0&&e<=r}function _n(e){var t=typeof e;return!!e&&(t==`object`||t==`function`)}function vn(e){return!!e&&typeof e==`object`}function yn(e){return typeof e==`symbol`||vn(e)&&Oe.call(e)==_}var bn=pe?ve(pe):Ft;function xn(e){return e==null?``:Vt(e)}function Sn(e,t,n){var r=e==null?void 0:Ot(e,t);return r===void 0?n:r}function Cn(e,t){return e!=null&&Zt(e,t,At)}function wn(e){return pn(e)?Ct(e):Lt(e)}function Tn(e,t,n){var r=fn(e)||bn(e);if(t=It(t),n==null){if(r||_n(e)){var i=e.constructor;n=r?fn(e)?new i:[]:hn(i)?Tt(Me(e)):{}}else n={}}return(r?me:Dt)(e,function(e,r,i){return t(n,e,r,i)}),n}function En(e){return e}function Dn(e){return $t(e)?ge(sn(e)):Bt(e)}e.exports=Tn})(hI,hI.exports)),hI.exports}_I();var{Commands:vI}=oN,yI=[`identify`,`guilds.members.read`];function bI(e,t){if(e instanceof kk)return e;if(typeof e==`object`&&e&&`code`in e){let n=e.code,r=Object.values(MM).filter(e=>typeof e==`number`);if(typeof n==`number`&&r.includes(n))return new kk(`${t}_${n}`)}return new kk(t)}var xI=15e3,SI=12e4,CI=15e3;function wI(e=window.location.search){let t=new URLSearchParams(e),n=t.getAll(`frame_id`),r=t.getAll(`platform`);if(n.length!==1||n[0]===void 0||n[0].length===0||n[0].length>255||r.length!==1||![`desktop`,`mobile`].includes(r[0]??``))throw new kk(`invalid_launch`)}async function TI(e,t,n,r,i){let a=null,o=new Promise((e,n)=>{t!==void 0&&(a=()=>n(new kk(`cancelled`)),t.addEventListener(`abort`,a,{once:!0}),t.aborted&&a())}),s=null,c=new Promise((e,t)=>{s=setTimeout(()=>t(new kk(r)),i)}),l=Promise.resolve().then(()=>{if(t?.aborted)throw new kk(`cancelled`);return e()}).catch(e=>{throw bI(e,n)});try{return await Promise.race([l,o,c])}finally{s!==null&&clearTimeout(s),t!==void 0&&a!==null&&t.removeEventListener(`abort`,a)}}var EI=class{makeSDK;sdk=null;authenticated=!1;closed=!1;constructor(e=e=>new RF(e)){this.makeSDK=e}async authorize(e){let t=jk();wI();let n=await Nk(t,e),r=this.open(n.client_id),i=()=>{if(e?.aborted)throw new kk(`cancelled`)};try{if(i(),await TI(()=>r.ready(),e,`sdk_ready_failed`,`sdk_ready_timeout`,xI),i(),r.instanceId!==t)throw new kk(`instance_mismatch`);let a=await TI(()=>r.commands.authorize({client_id:n.client_id,response_type:`code`,state:n.state,prompt:`none`,scope:[...yI]}),e,`authorize_failed`,`authorize_timeout`,SI);i();let o=await Pk(a.code,n.state,e);if(i(),!this.authenticated){if(await TI(()=>r.commands.authenticate({access_token:o.access_token}),e,`sdk_authenticate_failed`,`sdk_authenticate_timeout`,CI)==null)throw new kk(`sdk_authenticate_failed`);this.authenticated=!0,i()}let s=o.ticket;return{sdk:r,bootstrap:n,player:o.player,takeTicket:()=>{let e=s;return s=null,e},destroy:()=>{s=null}}}catch(t){throw e?.aborted?new kk(`cancelled`):new kk(bI(t,`authorization_failed`).code,!0)}}close(){if(!this.closed&&(this.closed=!0,this.sdk!==null))try{this.sdk.close(jM.CLOSE_NORMAL,`Hands session closed`)}catch{}}open(e){if(this.closed)throw new kk(`cancelled`);if(this.sdk!==null)return this.sdk;try{this.sdk=this.makeSDK(e)}catch(e){throw new kk(bI(e,`sdk_initialization_failed`).code,!0)}return this.sdk}},DI={Digit1:`corner_cut`,Numpad1:`corner_cut`,Digit2:`corner_swelling`,Numpad2:`corner_swelling`,Digit3:`corner_breath`,Numpad3:`corner_breath`},OI={2:`corner_cut`,3:`corner_swelling`,1:`corner_breath`},kI=[{kind:`corner_cut`,choice:`cut`,key:`1`,title:`Close the cut`},{kind:`corner_swelling`,choice:`swelling`,key:`2`,title:`Bring down the swelling`},{kind:`corner_breath`,choice:`breath`,key:`3`,title:`Catch your breath`}],AI={cut:`Your corner is closing the cut.`,swelling:`Your corner is bringing the swelling down.`,breath:`Your corner is getting your breath back.`,balanced:`Your corner did a little of everything.`},jI=1500,MI=1e3;function NI(e){return e<150?`small`:e<350?`nasty`:e<550?`deep`:`dangerous`}var PI=(e,t)=>Math.round(Math.max(0,Math.min(1,e/t))*100);function FI(e){let{trauma:t}=e,n=Math.max(t.left_cut,t.right_cut),r=Math.max(0,n-x.cut.worse_cut),i=Math.max(t.left_eye,t.right_eye),a=Math.max(0,i-x.swelling.eyes),o=i>=p?a0,swelling:Math.max(t.left_eye,t.right_eye)>0||t.swelling>0,breath:!0,balanced:!1}}function LI(){try{return[...navigator.getGamepads?.()??[]].find(e=>e!==null&&e.connected&&e.mapping===`standard`)??null}catch{return null}}var RI=class{pick;now;element;buttons=new Map;details=new Map;status;visible=!1;choice=null;pending=null;shown=null;frozen=null;available=null;padFrame=0;padPrevious=new Set;measuredTop=null;resize=()=>{this.measuredTop=null};keydown=e=>{let t=DI[e.code];t!==void 0&&this.visible&&!e.repeat&&(e.preventDefault(),this.choose(t))};constructor(e,t,n=()=>performance.now()){this.pick=t,this.now=n;let r=document.createElement(`section`);r.className=`corner`,r.dataset.corner=``,r.hidden=!0,r.setAttribute(`aria-label`,`Instructions for your corner`);let i=document.createElement(`p`);i.className=`corner-title`,i.textContent=`YOUR CORNER`;let a=document.createElement(`div`);a.className=`corner-choices`;for(let{kind:e,key:t,title:n}of kI){let r=document.createElement(`button`);r.type=`button`,r.dataset.cornerPick=e;let i=document.createElement(`kbd`);i.textContent=t;let o=document.createElement(`strong`);o.textContent=n;let s=document.createElement(`span`);r.append(i,o,s),r.addEventListener(`click`,()=>this.choose(e)),a.append(r),this.buttons.set(e,r),this.details.set(e,s)}this.status=document.createElement(`p`),this.status.className=`corner-status`,this.status.setAttribute(`role`,`status`),r.append(i,a,this.status),e.append(r),this.element=r,window.addEventListener(`keydown`,this.keydown),window.addEventListener(`resize`,this.resize)}update(e,t,n){let r=e?.fighters.find(e=>e.player_id===t);if(!(n&&e!==null&&e.phase===`rest`&&r!==void 0)||r===void 0){this.setVisible(!1),this.choice=null,this.pending=null,this.shown=null,this.frozen=null;return}this.setVisible(!0),this.choice=r.corner_choice,(this.choice!==null||this.pending!==null&&this.now()-this.pending.at>jI)&&(this.pending=null);let i=this.choice!==null||this.pending!==null;i||(this.frozen=null);let a=i&&this.frozen!==null?this.frozen:FI(r);this.shown=a;let o=II(r);this.available=o;for(let{kind:e,choice:t}of kI){let n=this.buttons.get(e),r=this.details.get(e);r.textContent!==a[t]&&(r.textContent=a[t]),n.disabled=i||!o[t],n.toggleAttribute(`data-picked`,this.choice===t||this.pending?.kind===e)}let s=this.choice===null?this.pending===null?`Tell your corner what to work on before the bell.`:`Calling it to your corner…`:AI[this.choice];this.status.textContent!==s&&(this.status.textContent=s)}choose(e){if(!this.visible||this.choice!==null||this.pending!==null)return;let t=kI.find(t=>t.kind===e)?.choice;if(t!==void 0&&this.available?.[t]!==!1&&this.pick(e)){this.frozen=this.shown,this.pending={kind:e,at:this.now()};for(let[t,n]of this.buttons)n.disabled=!0,n.toggleAttribute(`data-picked`,t===e);this.status.textContent=`Calling it to your corner…`}}setVisible(e){if(e!==this.visible){if(this.visible=e,this.element.hidden=!e,this.measuredTop=null,this.padPrevious.clear(),e){let e=LI();for(let t of Object.keys(OI))e?.buttons[Number(t)]?.pressed===!0&&this.padPrevious.add(Number(t));this.padFrame=requestAnimationFrame(()=>this.pollPad())}else cancelAnimationFrame(this.padFrame)}}top(){if(!this.visible)return null;if(this.measuredTop===null){let e=this.element.getBoundingClientRect();if(e.height<=0)return null;this.measuredTop=e.top-(this.element.parentElement?.getBoundingClientRect().top??0)}return this.measuredTop}pollPad(){if(!this.visible)return;let e=LI();if(e!==null)for(let[t,n]of Object.entries(OI)){let r=Number(t),i=e.buttons[r]?.pressed===!0;i&&!this.padPrevious.has(r)&&this.choose(n),i?this.padPrevious.add(r):this.padPrevious.delete(r)}this.padFrame=requestAnimationFrame(()=>this.pollPad())}destroy(){this.setVisible(!1),window.removeEventListener(`keydown`,this.keydown),window.removeEventListener(`resize`,this.resize),this.element.remove()}},zI={invalid_launch:`open Hands from a Discord voice channel with Play now`,cancelled:`the session was cancelled`,authorization_failed:`Discord did not authorize the session`,authorize_failed:`Discord did not authorize the session`,authorize_timeout:`Discord took too long to authorize the session`,sdk_ready_failed:`the Discord client did not respond`,sdk_ready_timeout:`the Discord client took too long to respond`,sdk_authenticate_failed:`Discord did not confirm your identity`,sdk_authenticate_timeout:`Discord took too long to confirm your identity`,sdk_initialization_failed:`the Discord client could not start the activity`,instance_mismatch:`this window belongs to a different activity instance`,bootstrap_failed:`the Hands server could not be reached`,token_failed:`the Hands server rejected the sign-in`,invalid_bootstrap:`the Hands server sent an unexpected reply`,invalid_token_response:`the Hands server sent an unexpected reply`,ticket_unavailable:`the session ticket was already used`,protocol_error:`the server and client disagree on the protocol`,unexpected_error:`something unexpected went wrong`,authentication_timeout:`the connection took too long to authenticate`,authentication_required:`the connection was not authenticated`,invalid_ticket:`the session ticket was rejected`,invalid_request:`the server rejected the request`,invalid_input:`the server rejected an input frame`,input_queue_full:`the server could not keep up with the inputs`,rate_limited:`too many requests were sent; wait a moment`,service_busy:`the server is busy right now`,service_unavailable:`the server is unavailable right now`,upstream_unavailable:`Discord is unavailable right now`,room_closed:`the bout has already ended; use Play now to start another`,room_full:`both seats in this bout are taken`,already_in_room:`you are already in a bout in another channel`,match_not_started:`the bout has not started yet`,connection_replaced:`this seat was taken over by a newer connection`,spectator_read_only:`spectators cannot send input`,server_shutting_down:`the server is restarting`,internal_error:`the server hit an internal error`,not_in_activity:`you are not a participant of this activity`,invalid_activity:`this activity instance is not valid`,invalid_state:`the sign-in state expired; retry`,invalid_guild:`this activity belongs to another server`,persistence_failed:`the result could not be saved`,rematch_unavailable:`the ring could not be cleared for a rematch; use Play now to start another bout`,network_unavailable:`the connection to the Hands server could not be opened`,match_abandoned:`both fighters lost their connection and the bout was called off`};function BI(e){if(e===`client_outdated`)return`Hands was updated. Reload to continue (client_outdated).`;let t=zI[e]??zI[e.replace(/_\d+$/u,``)];return t===void 0?`Unable to continue (${e}).`:`Unable to continue: ${t} (${e}).`}function VI(){try{if(window.matchMedia?.(`(pointer: coarse)`).matches)return!0}catch{}return(navigator.maxTouchPoints??0)>0&&new URLSearchParams(window.location.search).get(`platform`)===`mobile`}var HI=[{label:`JAB`,punchClass:`jab`},{label:`STRAIGHT`,punchClass:`straight`},{label:`HOOK`,punchClass:`hook`},{label:`UPPER`,punchClass:`uppercut`}],UI=[{label:`◀ SLIP`,name:`Slip left`,kind:`slip_left`},{label:`WEAVE`,name:`Weave`,kind:`weave`},{label:`SLIP ▶`,name:`Slip right`,kind:`slip_right`},{label:`PULL`,name:`Pull`,kind:`pull`},{label:`CLINCH`,name:`Clinch`,kind:`clinch`}],WI=class{sharedActions;root;stickZone;stickBase;stickKnob;pads=[];moves=[];stickPointer=null;stickOrigin={x:0,y:0};moveX=0;moveY=0;body=!1;power=!1;guard=`none`;knockdown=!1;enabled=!0;heldPointers=new Map;heldListener=null;constructor(e,t){this.sharedActions=t,this.root=document.createElement(`div`),this.root.className=`touch-controls`,this.root.setAttribute(`aria-label`,`Touch controls`),this.root.innerHTML=`
+
+
${UI.map(e=>``).join(``)}
+
+ + + + +
+
${HI.map(e=>``).join(``)}
+
`,e.append(this.root),this.stickZone=this.root.querySelector(`[data-stick]`),this.stickBase=this.root.querySelector(`[data-stick-base]`),this.stickKnob=this.root.querySelector(`[data-stick-knob]`),this.pads.push(...this.root.querySelectorAll(`[data-punch]`)),this.moves.push(...this.root.querySelectorAll(`[data-move]`)),this.bind()}bind(){let e=this.stickZone;e.addEventListener(`pointerdown`,t=>{if(this.stickPointer!==null)return;t.preventDefault(),this.stickPointer=t.pointerId,this.stickOrigin={x:t.clientX,y:t.clientY},e.setPointerCapture(t.pointerId);let n=e.getBoundingClientRect();this.stickBase.style.left=`${t.clientX-n.left}px`,this.stickBase.style.top=`${t.clientY-n.top}px`,this.stickBase.classList.add(`active`),this.updateStick(t.clientX,t.clientY)}),e.addEventListener(`pointermove`,e=>{e.pointerId===this.stickPointer&&(e.preventDefault(),this.updateStick(e.clientX,e.clientY))});let t=e=>{e.pointerId===this.stickPointer&&(this.stickPointer=null,this.moveX=0,this.moveY=0,this.stickKnob.style.transform=`translate(-50%, -50%)`,this.stickBase.classList.remove(`active`),this.heldListener?.())};e.addEventListener(`pointerup`,t),e.addEventListener(`pointercancel`,t);for(let e of this.pads)e.addEventListener(`pointerdown`,t=>{if(!this.enabled)return;t.preventDefault();let n=e.getBoundingClientRect(),r=t.clientX-n.lefte.classList.remove(`pressed`),120)});for(let e of this.moves)e.addEventListener(`pointerdown`,t=>{this.enabled&&!this.knockdown&&(t.preventDefault(),this.sharedActions.push(`touch`,{kind:e.dataset.move}),e.classList.add(`pressed`),window.setTimeout(()=>e.classList.remove(`pressed`),120))});for(let e of this.root.querySelectorAll(`[data-mod], [data-guard]`)){let t=e.dataset.mod??e.dataset.guard??``,n=n=>{n.preventDefault(),e.setPointerCapture(n.pointerId),this.heldPointers.set(n.pointerId,t),this.syncHeld(),e.classList.add(`pressed`)},r=n=>{this.heldPointers.delete(n.pointerId)&&(this.syncHeld(),e.classList.toggle(`pressed`,[...this.heldPointers.values()].includes(t)))};e.addEventListener(`pointerdown`,n),e.addEventListener(`pointerup`,r),e.addEventListener(`pointercancel`,r)}}syncHeld(){let e=[...this.heldPointers.values()];this.body=e.includes(`body`),this.power=e.includes(`power`);let t=e.findLast(e=>e===`guard_high`||e===`guard_low`)??`none`,n=t!==this.guard;this.guard=t,n&&this.heldListener?.()}get powerHeld(){return this.enabled&&this.power}onHeldChange(e){this.heldListener=e}updateStick(e,t){let n=e-this.stickOrigin.x,r=t-this.stickOrigin.y,i=Math.hypot(n,r);i>56&&(n=n/i*56,r=r/i*56),this.stickKnob.style.transform=`translate(calc(-50% + ${n}px), calc(-50% + ${r}px))`;let a=Math.min(1,i/56),o=a<.15?0:(a-.15)/.85,s=i>0?n/Math.max(i,1e-6):0,c=i>0?r/Math.max(i,1e-6):0;this.moveX=Math.round(s*o*1e3)||0,this.moveY=Math.round(-c*o*1e3)||0,this.heldListener?.()}setKnockdown(e){if(this.knockdown!==e){this.knockdown=e,this.root.classList.toggle(`knockdown`,e);for(let[t,n]of this.pads.entries()){let r=n.querySelector(`.touch-pad-label`);r!==null&&(r.textContent=e?t%2==0?`GET UP`:`RHYTHM`:HI[t].label)}}}setEnabled(e,t=e){this.enabled=e,this.root.classList.toggle(`disabled`,!t),this.root.classList.toggle(`resting`,t&&!e),t?e||this.sharedActions.clearSource(`touch`):this.reset()}frame(){return this.enabled?{moveX:this.moveX,moveY:this.moveY,defense:this.guard,actions:[]}:{moveX:0,moveY:0,defense:`none`,actions:[]}}reset(){this.stickPointer=null,this.moveX=0,this.moveY=0,this.body=!1,this.power=!1,this.guard=`none`,this.heldPointers.clear(),this.stickBase.classList.remove(`active`);for(let e of this.root.querySelectorAll(`.pressed`))e.classList.remove(`pressed`);this.sharedActions.clearSource(`touch`)}destroy(){this.reset(),this.root.remove()}},GI={block:[55,.12,.22],hit:[85,.3,.42],counter_hit:[105,.38,.5],stun:[125,.42,.55],knockdown:[180,.62,.65],parry:[60,.18,.4],body_collapse:[170,.55,.3]},KI={injury:[150,.55,.6],vomit:[90,.15,.45],finish_him:[180,.65,.3],fatality:[180,.65,.65],death:[170,.5,.12]},qI=[120,.65,.5],JI=class{settings;constructor(e){this.settings=e}event(e,t=!1){if(!this.settings().haptics)return;let n=GI[e.kind];n!==void 0&&this.rumble(t?[n[0]*1.6,n[1]+.2,n[2]+.15]:n)}gore(e){if(!this.settings().haptics||e.kind===`death`&&ke(e.cause)!==null)return;this.rumble(KI[e.kind]);let t=this.settings();e.kind===`injury`&&SO(e.injury)!==null&&t.blood===`full`&&!t.reducedMotion&&setTimeout(()=>this.rumble(qI),CO*1e3)}rumble(e){let t=this.padActuator();if(t===null)this.vibrate(e[0]);else try{Promise.resolve(t.playEffect(`dual-rumble`,{duration:Math.min(180,Math.max(0,e[0])),strongMagnitude:Math.min(.65,Math.max(0,e[1])),weakMagnitude:Math.min(.65,Math.max(0,e[2]))})).catch(()=>void 0)}catch{}}padActuator(){if(typeof navigator.getGamepads!=`function`)return null;let e;try{e=[...navigator.getGamepads.call(navigator)]}catch{return null}let t=e.find(e=>e!==null&&e.connected&&`vibrationActuator`in e)?.vibrationActuator;return t==null||typeof t.playEffect!=`function`?null:t}vibrate(e){if(VI()&&typeof navigator.vibrate==`function`)try{navigator.vibrate(Math.min(180,Math.max(0,e)))}catch{}}},YI={KeyF:[`left`,`jab`],KeyJ:[`right`,`jab`],KeyR:[`left`,`straight`],KeyU:[`right`,`straight`],KeyG:[`left`,`hook`],KeyH:[`right`,`hook`],KeyT:[`left`,`uppercut`],KeyY:[`right`,`uppercut`]},XI={KeyZ:{kind:`slip_left`},KeyX:{kind:`slip_right`},KeyC:{kind:`weave`},KeyV:{kind:`pull`},KeyB:{kind:`clinch`},KeyN:{kind:`switch_stance`},KeyM:{kind:`taunt`},Digit1:{kind:`foul`,foul:`low_blow`},Digit2:{kind:`foul`,foul:`headbutt`},ArrowLeft:{kind:`get_up_left`},ArrowRight:{kind:`get_up_right`}},ZI=new Set([...Object.keys(YI),...Object.keys(XI),`KeyW`,`KeyA`,`KeyS`,`KeyD`,`KeyQ`,`KeyE`,`ShiftLeft`,`ShiftRight`,`AltLeft`,`AltRight`]),QI=[`Move: W up · S down · A left · D right`,`High / low guard: Q / E`,`Left/right jab: F / J`,`Left/right straight: R / U`,`Left/right hook: G / H`,`Left/right uppercut: T / Y`,`Body: Shift · Power: hold Alt (Option ⌥ on a Mac) with the punch, slower to throw and far heavier`,`Slip: Z / X · Weave: C · Pull: V`,`Clinch: B · Stance: N · Taunt: M · Fouls (on purpose): Shift+1 low blow / Shift+2 headbutt`,`Get-up rhythm: ← / →`,`Camera: K cycles broadcast, close and over the shoulder (behind your fighter, W walks at the opponent and A / D circle him).`,`Style pick before the bout: arrow keys choose · Enter settles · 1–5 settle on that card at once.`,`Controller move: left stick. High / low guard: left / right shoulder (independent of punches).`,`Controller face classes: bottom jab · right straight · left hook · top uppercut.`,`Controller face hand: hold D-pad left for left hand or D-pad right for right hand, then press a face punch; otherwise punches use the right hand. A direction used for a punch is consumed and does not evade.`,`Controller modifiers: left trigger body · right trigger power.`,`Controller actions: left stick press clinch · right stick press switch stance · hold right trigger + right stick press to taunt · D-pad up weave · D-pad down pull · tap and release D-pad left/right to slip; while down, D-pad left/right performs the private get-up rhythm immediately.`,`Controller fouls: View/Back low blow · Menu/Start headbutt.`,`Controller style pick: D-pad or left stick to choose · bottom face button settles.`,`Right-stick gesture: horizontal 0–22.5° hook · 22.5–45° jab · 45–70° straight · 70–90° uppercut; left/right direction selects hand.`,`Between rounds, tell your corner what to work on: 1 close the cut · 2 bring down the swelling · 3 catch your breath (controller: left, top or right face button; or tap).`,`Touch: drag the left side to move · tap a punch pad's left or right half for that hand · hold BODY, POWER, GUARD or LOW · tap ◀ SLIP, SLIP ▶, WEAVE, PULL or CLINCH.`],$I=`Move WASD · Jab F/J · Straight R/U · Hook G/H · Uppercut T/Y · Guard Q/E · Body Shift · Power Alt/Option ⌥`,eL=`Drag on the left to move · Tap the pads to punch, L or R hand · Hold BODY, POWER or GUARD · Tap SLIP, WEAVE, PULL or CLINCH`,tL=`Drag left to move · Tap pads to punch · Hold GUARD`,nL=(e,t)=>e?t<480?tL:eL:$I,rL=[{title:`Keyboard`,items:QI.filter(e=>!e.startsWith(`Controller`)&&!e.startsWith(`Right-stick`)&&!e.startsWith(`Between rounds`)&&!e.startsWith(`Touch`))},{title:`Between rounds`,items:QI.filter(e=>e.startsWith(`Between rounds`))},{title:`Controller`,items:QI.filter(e=>e.startsWith(`Controller`)||e.startsWith(`Right-stick`))},{title:`Touch`,items:QI.filter(e=>e.startsWith(`Touch`))}];function iL(e,t){return e.kind===t.kind?e.kind===`punch`&&t.kind===`punch`?e.hand===t.hand&&e.class===t.class&&e.target===t.target&&e.power===t.power:e.kind===`foul`&&t.kind===`foul`?e.foul===t.foul:!0:!1}function aL(e,t,n){if(n<1||e.length>0&&iL(e.at(-1),t))return;let r=e.length-n+1;r>0&&e.splice(0,r),e.push(t)}var oL=class{maximum;queue=[];counter=0;listener=null;constructor(e=1){this.maximum=e}setListener(e){this.listener=e}push(e,t){if(this.maximum<1)return;let n=this.queue.at(-1);if(n!==void 0&&iL(n.action,t)){n.source=e;return}let r={...t,id:`c${this.counter+=1}`},i=this.queue.length-this.maximum+1;i>0&&this.queue.splice(0,i),this.queue.push({action:r,source:e}),this.listener?.(r)}clear(){this.queue.length=0}clearSource(e){let t=this.queue.filter(t=>t.source!==e);this.queue.splice(0,this.queue.length,...t)}drain(e){return this.queue.splice(0,e).map(e=>e.action)}};function sL(e,t,n=.18){let r=Math.hypot(e,t);if(!Number.isFinite(r)||r<=n)return{x:0,y:0};let i=(Math.min(1,r)-n)/(1-n);return{x:e/r*i,y:t/r*i}}var cL=(e,t)=>{let n=Math.atan2(Math.abs(t),Math.abs(e))*180/Math.PI;return n<22.5?`hook`:n<45?`jab`:n<70?`straight`:`uppercut`},lL=class{active=!1;hand=`right`;target=`head`;power=`normal`;peak={x:0,y:0};peakMagnitude=0;update(e,t,n,r){let i=Math.hypot(e,t);if(!this.active&&i>=.55&&Math.abs(e)>=.12)return this.active=!0,this.hand=e<0?`left`:`right`,this.target=n?`body`:`head`,this.power=r?`power`:`normal`,this.peak={x:e,y:t},this.peakMagnitude=i,null;if(!this.active)return null;if(i>this.peakMagnitude&&(this.peak={x:e,y:t},this.peakMagnitude=i),i<=.25){let e={kind:`punch`,hand:this.hand,class:cL(this.peak.x,this.peak.y),target:this.target,power:this.power};return this.reset(),e}return null}reset(){this.active=!1,this.peak={x:0,y:0},this.peakMagnitude=0}},uL=[`jab`,`straight`,`hook`,`uppercut`],dL=(e,t)=>e.buttons[t]?.pressed===!0;function fL(){let e=navigator.getGamepads;if(typeof e!=`function`)return null;try{return[...e.call(navigator)].find(e=>e!==null&&e.connected&&e.mapping===`standard`)??null}catch{return null}}var pL=class{maximumQueue;sharedActions;gesture=new lL;queue=[];previous=new Set;selectorConsumed=new Map;raf=0;currentId=null;moveX=0;moveY=0;defense=`none`;knockdown=!1;enabled=!0;trigger=!1;heldListener=null;disconnect=e=>{e.gamepad.id===this.currentId&&this.reset()};constructor(e=1,t){this.maximumQueue=e,this.sharedActions=t,window.addEventListener(`gamepaddisconnected`,this.disconnect),this.raf=requestAnimationFrame(()=>this.poll())}onHeldChange(e){this.heldListener=e}push(e){this.sharedActions===void 0?aL(this.queue,e,this.maximumQueue):this.sharedActions.push(`gamepad`,e)}poll(){if(!this.enabled){this.reset(),this.schedulePoll();return}let e=fL();if(e===null){this.currentId!==null&&this.reset(),this.schedulePoll();return}this.currentId!==null&&this.currentId!==e.id&&this.reset(),this.currentId=e.id;let t=sL(e.axes[0]??0,e.axes[1]??0),n=Math.round(t.x*1e3),r=Math.round(-t.y*1e3),i=dL(e,4)?`guard_high`:dL(e,5)?`guard_low`:`none`,a=n!==this.moveX||r!==this.moveY||i!==this.defense;this.moveX=n,this.moveY=r,this.defense=i,a&&this.heldListener?.(),this.trigger=dL(e,7);let o=this.gesture.update(e.axes[2]??0,e.axes[3]??0,dL(e,6),this.trigger);o!==null&&this.push(o);let s=uL.some((t,n)=>dL(e,n)&&!this.previous.has(n));for(let t of[14,15]){let n=dL(e,t),r=this.previous.has(t);this.knockdown?(n&&!r&&this.push({kind:t===14?`get_up_left`:`get_up_right`}),this.selectorConsumed.delete(t)):n?(r||this.selectorConsumed.set(t,!1),s&&this.selectorConsumed.set(t,!0)):r&&(this.selectorConsumed.get(t)===!1&&this.push({kind:t===14?`slip_left`:`slip_right`}),this.selectorConsumed.delete(t))}for(let t=0;tthis.poll())}setKnockdown(e){this.knockdown=e}get powerHeld(){return this.enabled&&this.trigger}setEnabled(e){this.enabled=e,e||this.reset()}frame(e=4){let t=this.sharedActions===void 0?this.queue.splice(0,e):[];return{moveX:this.moveX,moveY:this.moveY,defense:this.defense,actions:t}}reset(){this.currentId=null,this.moveX=this.moveY=0,this.defense=`none`,this.trigger=!1,this.queue.length=0,this.sharedActions?.clearSource(`gamepad`),this.previous.clear(),this.selectorConsumed.clear(),this.gesture.reset()}destroy(){cancelAnimationFrame(this.raf),window.removeEventListener(`gamepaddisconnected`,this.disconnect),this.reset()}},mL=new Set([`KeyW`,`KeyA`,`KeyS`,`KeyD`,`KeyQ`,`KeyE`]),hL=new Set([`ShiftLeft`,`ShiftRight`,`AltLeft`,`AltRight`]),gL=class{target;maximumQueue;sharedActions;held=new Set;queue=[];enabled=!0;altFlag=!1;heldListener=null;keydown=e=>{if(this.altFlag=e.altKey,!ZI.has(e.code))return;if(!this.enabled){this.hold(e.code,e.repeat);return}if(e.preventDefault(),this.hold(e.code,e.repeat),e.repeat)return;let t=YI[e.code];if(t!==void 0)this.push({kind:`punch`,hand:t[0],class:t[1],target:this.hasShift(e)?`body`:`head`,power:this.alt?`power`:`normal`});else{let t=XI[e.code];t!==void 0&&(t.kind!==`foul`||this.hasShift(e))&&this.push(t)}};keyup=e=>{this.altFlag=e.altKey,e.code===`MetaLeft`||e.code===`MetaRight`?this.letGo(e=>!hL.has(e)):ZI.has(e.code)&&(this.enabled&&e.preventDefault(),this.letGo(t=>t===e.code))};visibility=()=>{document.hidden&&this.reset()};blur=()=>this.reset();constructor(e=window,t=1,n){this.target=e,this.maximumQueue=t,this.sharedActions=n,e.addEventListener(`keydown`,this.keydown),e.addEventListener(`keyup`,this.keyup),e.addEventListener(`blur`,this.blur),document.addEventListener(`visibilitychange`,this.visibility)}onHeldChange(e){this.heldListener=e}hold(e,t){t&&this.held.has(e)||(this.held.delete(e),this.held.add(e),mL.has(e)&&this.heldListener?.())}letGo(e){let t=!1;for(let n of this.held)e(n)&&(this.held.delete(n),t||=mL.has(n));t&&this.heldListener?.()}axis(e,t){let n=0;for(let r of this.held)r===e?n=1:r===t&&(n=-1);return n}hasShift(e){return e.shiftKey||this.held.has(`ShiftLeft`)||this.held.has(`ShiftRight`)}get alt(){return this.altFlag||this.held.has(`AltLeft`)||this.held.has(`AltRight`)}get powerHeld(){return this.enabled&&this.alt}push(e){this.sharedActions===void 0?aL(this.queue,e,this.maximumQueue):this.sharedActions.push(`keyboard`,e)}setEnabled(e){this.enabled=e,e||(this.queue.length=0,this.sharedActions?.clearSource(`keyboard`))}frame(e=4){if(!this.enabled)return{moveX:0,moveY:0,defense:`none`,actions:[]};let t=this.axis(`KeyD`,`KeyA`)*1e3,n=this.axis(`KeyW`,`KeyS`)*1e3;t!==0&&n!==0&&(t=Math.sign(t)*707,n=Math.sign(n)*707);let r=this.axis(`KeyQ`,`KeyE`);return{moveX:t,moveY:n,defense:r>0?`guard_high`:r<0?`guard_low`:`none`,actions:this.sharedActions===void 0?this.queue.splice(0,e):[]}}reset(){this.letGo(()=>!0),this.altFlag=!1,this.queue.length=0,this.sharedActions?.clearSource(`keyboard`)}destroy(){this.reset(),this.target.removeEventListener(`keydown`,this.keydown),this.target.removeEventListener(`keyup`,this.keyup),this.target.removeEventListener(`blur`,this.blur),document.removeEventListener(`visibilitychange`,this.visibility)}};function _L(e,t,n,r){let i=e=>Math.max(-1e3,Math.min(1e3,Math.round(e)))||0;return{moveX:i(-r*e+n*t),moveY:i(-n*e-r*t)}}var vL=(e,t,n,r)=>Math.abs(Math.atan2(e*r-t*n,e*n+t*r)),yL=Math.PI/4-.01,bL=Math.PI/8,xL=300,SL=class{actions=new oL(1);keyboard;gamepad;touch=null;reset=()=>{this.keyboard.reset(),this.gamepad.reset(),this.touch?.reset(),this.actions.clear(),this.gamepad.setKnockdown(!1)};heldChanged=()=>{let e=this.held(),t=this.sentHeld,n=e.moveX!==0||e.moveY!==0,r=t.moveX!==0||t.moveY!==0;(e.defense!==t.defense||n!==r||n&&(vL(e.moveX,e.moveY,t.moveX,t.moveY)>bL||Math.abs(Math.hypot(e.moveX,e.moveY)-Math.hypot(t.moveX,t.moveY))>xL))&&(this.sentHeld=e,this.heldListener?.())};constructor(){this.keyboard=new gL(window,1,this.actions),this.gamepad=new pL(1,this.actions),this.keyboard.onHeldChange(this.heldChanged),this.gamepad.onHeldChange(this.heldChanged),window.addEventListener(`blur`,this.reset),document.addEventListener(`visibilitychange`,this.visibility)}visibility=()=>{document.hidden&&this.reset()};attachTouch(e,t=VI()){this.touch===null&&t&&(this.touch=new WI(e,this.actions),this.touch.onHeldChange(this.heldChanged))}setActive(e,t=e){this.keyboard.setEnabled(e),this.gamepad.setEnabled(e),this.touch?.setEnabled(e,t)}setKnockdown(e){this.gamepad.setKnockdown(e),this.touch?.setKnockdown(e)}onAction(e){this.actions.setListener(e)}get powerHeld(){return this.keyboard.powerHeld||this.gamepad.powerHeld||this.touch?.powerHeld===!0}onHeldChange(e){this.heldListener=e}heldListener=null;sentHeld={moveX:0,moveY:0,defense:`none`};setViewForward(e){this.viewForward=e}viewForward=null;latched=null;held(){let e=this.keyboard.frame(0),t=this.gamepad.frame(0),n=this.touch?.frame()??null,r=t.moveX===0?n!==null&&n.moveX!==0?n.moveX:e.moveX:t.moveX,i=t.moveY===0?n!==null&&n.moveY!==0?n.moveY:e.moveY:t.moveY,a=t.defense===`none`?n!==null&&n.defense!==`none`?n.defense:e.defense:t.defense;if(r===0&&i===0)return this.latched=null,{moveX:r,moveY:i,defense:a};let o=this.viewForward?.()??null,s=this.latched;s===null||vL(r,i,s.moveX,s.moveY)>yL?this.latched={moveX:r,moveY:i,forward:o===null?null:{x:o.x,z:o.z}}:s.forward!==null&&o!==null&&(s.forward.x=o.x,s.forward.z=o.z);let c=this.latched.forward;if(c===null)return{moveX:r,moveY:i,defense:a};let l=_L(r,i,c.x,c.z);return{moveX:l.moveX,moveY:l.moveY,defense:a}}frame(){return{...this.held(),actions:this.actions.drain(4)}}destroy(){window.removeEventListener(`blur`,this.reset),document.removeEventListener(`visibilitychange`,this.visibility),this.keyboard.destroy(),this.gamepad.destroy(),this.touch?.destroy()}},CL=(e,t,n)=>e+(t-e)*n,wL=(e,t,n)=>({...t,x:CL(e.x,t.x,n),y:CL(e.y,t.y,n),facing:CL(e.facing,t.facing,n),facing_x:CL(e.facing_x,t.facing_x,n),facing_y:CL(e.facing_y,t.facing_y,n),velocity_x:CL(e.velocity_x,t.velocity_x,n),velocity_y:CL(e.velocity_y,t.velocity_y,n),stamina:CL(e.stamina,t.stamina,n),maximum_stamina:CL(e.maximum_stamina,t.maximum_stamina,n),conditioning:CL(e.conditioning,t.conditioning,n),guard:CL(e.guard,t.guard,n),poise:CL(e.poise,t.poise,n)}),TL=(e,t,n)=>({...t,x:CL(e.x,t.x,n),y:CL(e.y,t.y,n),facing_x:CL(e.facing_x,t.facing_x,n),facing_y:CL(e.facing_y,t.facing_y,n),velocity_x:CL(e.velocity_x,t.velocity_x,n),velocity_y:CL(e.velocity_y,t.velocity_y,n)}),EL=1.5,DL=6,OL=.5,kL=2500,AL=1,jL=.04,ML=100,NL=.01,PL=4,FL=class{maximum;tickRate;initialDelayTicks;snapshots=[];offsetTicks=null;delayTicks;lastStarvationMs=-1/0;lastFrameMs=null;behindPushes=0;needs=[];constructor(e=8,t=30,n=2){this.maximum=e,this.tickRate=t,this.initialDelayTicks=n,this.delayTicks=n}get interpolationDelayTicks(){return this.delayTicks}push(e,t){let n=this.snapshots.at(-1);if(n!==void 0&&e.tick<=n.tick)return!1;if(this.snapshots.push(e),this.snapshots.length>this.maximum&&this.snapshots.shift(),t!==void 0&&Number.isFinite(t)){let n=e.tick-t*this.tickRate/1e3;this.offsetTicks!==null&&n=PL&&this.restartClock(),this.offsetTicks===null?(this.offsetTicks=n,this.need(t,this.initialDelayTicks)):this.offsetTicks=Math.max(n,this.offsetTicks-NL),this.need(t,this.offsetTicks-n+AL)}return!0}resync(){this.restartClock()}restartClock(){this.offsetTicks=null,this.delayTicks=this.initialDelayTicks,this.lastStarvationMs=-1/0,this.behindPushes=0,this.needs.length=0}need(e,t){for(;this.needs.length>0&&this.needs.at(-1).ticks<=t;)this.needs.pop();this.needs.push({atMs:e,ticks:t})}recentNeed(e){for(;this.needs.length>0&&this.needs[0].atMs<=e-kL;)this.needs.shift();return this.needs[0]?.ticks??0}latest(){return this.snapshots.at(-1)??null}renderTick(e){let t=this.latest();if(t===null)return 0;let n=this.snapshots[0].tick;if(this.offsetTicks===null)return Math.max(n,t.tick-1);let r=this.lastFrameMs===null?0:Math.min(ML,Math.max(0,e-this.lastFrameMs));this.lastFrameMs=e;let i=e*this.tickRate/1e3+this.offsetTicks-this.delayTicks;if(i>t.tick+.25)e-this.lastStarvationMs>250&&(this.lastStarvationMs=e,this.delayTicks=Math.min(DL,this.delayTicks+OL),this.need(e,this.delayTicks));else{let t=Math.max(EL,this.recentNeed(e));this.delayTicks>t&&(this.delayTicks=Math.max(t,this.delayTicks-jL*r*this.tickRate/1e3))}return Math.min(t.tick,Math.max(n,i))}sample(e){let t=this.snapshots.findIndex(t=>t.tick>=e);if(t<=0)return this.snapshots[Math.max(0,t)]??this.latest();let n=this.snapshots[t-1],r=this.snapshots[t];if(n.phase!==r.phase||n.fighters.some((e,t)=>e.knockdowns!==r.fighters[t]?.knockdowns))return r;let i=Math.max(0,Math.min(1,(e-n.tick)/Math.max(1,r.tick-n.tick)));return{...r,fighters:[wL(n.fighters[0],r.fighters[0],i),wL(n.fighters[1],r.fighters[1],i)],referee:TL(n.referee,r.referee,i)}}clear(){this.snapshots.length=0,this.offsetTicks=null}},IL=class{highest=-1;accept(e){let t=new Set,n=e.filter(e=>e.event_id<=this.highest||t.has(e.event_id)?!1:(t.add(e.event_id),!0)).sort((e,t)=>e.event_id-t.event_id);for(let e of n)this.highest=Math.max(this.highest,e.event_id);return n}reset(){this.highest=-1}};function LL(e=window.location){let t=new URL(`/api/hands/ws`,e.origin);if(e.protocol===`https:`)t.protocol=`wss:`;else if(e.protocol===`http:`&&[`localhost`,`127.0.0.1`,`::1`].includes(e.hostname))t.protocol=`ws:`;else throw Error(`insecure_websocket_origin`);return t.search=``,t.hash=``,t.toString()}var RL=1,zL={moveX:0,moveY:0,defense:`none`,actions:[]},BL=33,VL=8,HL=50,UL=20,WL=10,GL=2048;function KL(e){try{return Ot(e)}catch(t){let n;try{let t=Ke(e);n=typeof t==`object`&&t&&`version`in t?t.version:void 0}catch{}throw typeof n==`number`&&n!==6?new kk(`client_outdated`,!0):t}}var qL=class{getInput;callbacks;makeSocket;now;socket=null;reconnectTicket;reconnectTimer=null;opponentPauseTimer=null;inputTimer=null;reconnectDeadline=0;opponentPauseDeadline=0;opponentPaused=!1;attempts=0;nextSequence=0;playerId=null;sentAt=new Map;actionSequences=new Map;latencyMs=null;serverTick=0;role=null;active=!1;resting=!1;boutStarted=!1;disposed=!1;terminal=!1;inputSuppressed=!1;pointerFocus=!1;listenersBound=!1;lastInputSentAt=-1/0;sendTimes=[];edgeSendTimes=[];heldSendTimes=[];heldTimer=null;pressWaiting=!1;constructor(e,t,n,r=e=>new WebSocket(e),i=()=>performance.now()){this.getInput=t,this.callbacks=n,this.makeSocket=r,this.now=i,this.reconnectTicket=e}start(){this.disposed||this.listenersBound||(this.bindInputListeners(),this.connect(),!this.disposed&&!this.terminal&&(this.inputTimer=window.setInterval(()=>this.periodicFlush(),BL)))}bindInputListeners(){this.listenersBound=!0,window.addEventListener(`blur`,this.onInputLoss),window.addEventListener(`focus`,this.onInputRegain),window.addEventListener(`pointerdown`,this.onPagePointer,!0),document.addEventListener(`visibilitychange`,this.onVisibilityChange)}setActive(e){this.setInputActive(e)}setInputActive(e){let t=this.active;this.active=e,e?this.boutStarted=!0:t&&this.sendInput(zL,!0)}notifyAction(){this.pressWaiting=!0,this.now()-(this.edgeSendTimes.at(-1)??-1/0)=UL||this.flushInput()&&this.edgeSendTimes.push(this.lastInputSentAt)}notifyHeld(){let e=VL-(this.now()-Math.max(this.edgeSendTimes.at(-1)??-1/0,this.heldSendTimes.at(-1)??-1/0));e>0?this.heldTimer??=window.setTimeout(()=>{this.heldTimer=null,this.notifyHeld()},e):this.withinLastSecond(this.heldSendTimes)>=WL||this.sendsInLastSecond()>=40||this.flushInput()&&this.heldSendTimes.push(this.lastInputSentAt)}periodicFlush(){this.now()-Math.max(this.edgeSendTimes.at(-1)??-1/0,this.heldSendTimes.at(-1)??-1/0)=40||this.flushInput()}sendsInLastSecond(){return this.withinLastSecond(this.sendTimes)}withinLastSecond(e){let t=this.now()-1e3;for(;e.length>0&&e[0]<=t;)e.shift();return e.length}onInputLoss=()=>{this.inputSuppressed||(this.sendInput(zL,this.boutStarted),this.inputSuppressed=!0,this.pointerFocus=!1)};onInputRegain=()=>{!document.hidden&&document.hasFocus()&&(this.inputSuppressed=!1)};onPagePointer=()=>{if(!document.hidden&&(this.pointerFocus=!0,this.inputSuppressed=!1,!document.hasFocus()))try{window.focus()}catch{}};onVisibilityChange=()=>{document.hidden?this.onInputLoss():this.onInputRegain()};connect(){if(this.disposed||this.terminal)return;let e=this.reconnectTicket;if(e===null){this.terminal=!0,this.stopInputLifecycle(),this.callbacks.onFreshAuth();return}let t;try{t=this.makeSocket(LL())}catch{this.terminal=!0,this.stopInputLifecycle(),this.callbacks.onFatal(`network_unavailable`);return}this.socket=t,t.binaryType=`arraybuffer`,t.onopen=()=>{if(!(this.socket!==t||this.disposed))try{t.send(JSON.stringify({version:6,type:`authenticate`,ticket:e})),this.reconnectTicket=null}catch{this.handleClose(t)}},t.onmessage=e=>this.handleMessage(t,e),t.onerror=()=>void 0,t.onclose=()=>this.handleClose(t)}handleMessage(e,t){if(!(this.socket!==e||this.disposed||this.terminal))try{if(typeof t.data!=`string`&&!(t.data instanceof ArrayBuffer))throw Error(`unsupported_frame`);let n=KL(t.data);if(this.applyMessage(n),n.type===`ticket`){try{e.send(JSON.stringify({version:6,type:`ticket_ack`,refresh_id:n.refresh_id}))}catch{this.handleClose(e)}return}this.callbacks.onMessage(n),n.type===`error`?this.terminate(n.code,e):n.type===`final`&&(this.terminal=!0,this.clearTransportReconnect(!0),this.clearOpponentPause(!0),this.stopInputLifecycle(),this.socket===e&&(this.socket=null),e.onopen=e.onmessage=e.onclose=e.onerror=null,e.close(1e3,`complete`))}catch(e){this.callbacks.onFatal(Fk(e)),this.dispose()}}applyMessage(e){if(e.type===`welcome`){if(e.reconnect_ticket===void 0)throw Error(`missing_reconnect_ticket`);this.reconnectTicket=e.reconnect_ticket,this.serverTick=e.server_tick;let t=this.role===`spectator`&&e.role===`fighter`;this.role=e.role,this.playerId=e.role===`fighter`?e.player_id:null,this.sentAt.clear(),e.role===`fighter`?this.nextSequence=Math.max(this.nextSequence,e.next_sequence):this.stopInputLifecycle(),t&&(this.listenersBound||this.bindInputListeners(),this.inputTimer??=window.setInterval(()=>this.periodicFlush(),BL)),this.attempts=0,this.clearTransportReconnect(!0)}else e.type===`ticket`?this.reconnectTicket=e.reconnect_ticket:e.type===`snapshot`?(this.serverTick=Math.max(this.serverTick,e.payload.tick),this.setInputActive([`countdown`,`fight`,`knockdown`,`foul_recovery`,`referee_down`,`finish`].includes(e.payload.phase)),this.resting=e.payload.phase===`rest`,this.observeAcknowledgement(e.payload)):e.type===`paused`?(this.setInputActive(!1),this.startOpponentPause(e.grace_ms)):e.type===`resumed`?(this.setInputActive(!0),this.attempts=0,this.clearOpponentPause(!0)):e.type===`select`?this.clearOpponentPause(!0):e.type===`ready`?(this.clearOpponentPause(!0),this.setInputActive(!0)):e.type===`waiting`?(this.clearOpponentPause(!0),this.setInputActive(!1)):(e.type===`final`||e.type===`error`)&&(this.active=!1,this.clearOpponentPause(!0))}terminate(e,t){this.terminal=!0,this.active=!1,this.clearTransportReconnect(!0),this.clearOpponentPause(!0),this.stopInputLifecycle(),this.callbacks.onFatal(e),this.socket===t&&(this.socket=null,t.onopen=t.onmessage=t.onclose=t.onerror=null,t.close(1e3,`terminal`))}handleClose(e){if(this.socket!==e||(this.socket=null,this.active=!1,this.disposed||this.terminal))return;if(this.reconnectTicket===null){this.terminal=!0,this.stopInputLifecycle(),this.callbacks.onFreshAuth();return}this.clearOpponentPause(!1),this.reconnectDeadline===0&&(this.reconnectDeadline=this.now()+2e4);let t=Math.max(0,this.reconnectDeadline-this.now());if(this.callbacks.onReconnect(t),t<=0){this.terminal=!0,this.stopInputLifecycle(),this.callbacks.onFreshAuth();return}let n=Math.min(3e3,250*2**Math.min(this.attempts,4),t);this.attempts+=1,this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=null,this.callbacks.onReconnect(Math.max(0,this.reconnectDeadline-this.now())),this.connect()},n)}requestCpu(e){let t=this.socket;if(this.role!==`fighter`||this.disposed||this.terminal||t?.readyState!==RL)return!1;try{return t.send(Pt(e)),!0}catch{return this.handleClose(t),!1}}chooseStyle(e,t){let n=this.socket;if(this.role!==`fighter`||this.disposed||this.terminal||n?.readyState!==RL)return!1;try{return n.send(Mt(e,t)),!0}catch{return this.handleClose(n),!1}}get inputLatencyMs(){return this.latencyMs}sequenceOf(e){return this.actionSequences.get(e)??null}observeAcknowledgement(e){if(this.playerId===null)return;let t=e.fighters.find(e=>e.player_id===this.playerId);if(t===void 0||t.last_input_sequence<0)return;let n=this.sentAt.get(t.last_input_sequence);if(n!==void 0){let e=Math.max(0,this.now()-n);this.latencyMs=this.latencyMs===null?e:this.latencyMs*.8+e*.2}for(let e of this.sentAt.keys())e<=t.last_input_sequence&&this.sentAt.delete(e)}sendInput(e,t=!1){return(this.active||t)&&this.transmit(e)}sendCornerChoice(e){return this.resting?this.transmit({moveX:0,moveY:0,defense:`none`,actions:[{kind:e}]}):!1}transmit(e){let t=this.socket;if(this.role!==`fighter`||this.disposed||this.terminal||t?.readyState!==RL)return!1;try{let n=e.actions.slice(0,4);t.send(jt(this.nextSequence,this.serverTick,{...e,actions:n})),this.sentAt.set(this.nextSequence,this.now()),this.sentAt.size>128&&this.sentAt.delete(this.sentAt.keys().next().value);for(let e of n)e.id!==void 0&&this.actionSequences.set(e.id,this.nextSequence);for(;this.actionSequences.size>64;)this.actionSequences.delete(this.actionSequences.keys().next().value);return this.nextSequence+=1,this.lastInputSentAt=this.now(),this.sendTimes.push(this.lastInputSentAt),!0}catch{return this.handleClose(t),!1}}flushInput(){return this.inputSuppressed||document.hidden||!(this.pointerFocus||document.hasFocus())||this.sendsInLastSecond()>=HL||(this.socket?.bufferedAmount??0)>GL||!this.sendInput(this.getInput())?!1:(this.pressWaiting=!1,!0)}startOpponentPause(e){this.clearOpponentPause(!1),this.opponentPaused=!0,this.opponentPauseDeadline=this.now()+e,this.callbacks.onReconnect(e),e>0&&this.scheduleOpponentPauseTick()}scheduleOpponentPauseTick(){let e=Math.max(0,this.opponentPauseDeadline-this.now());e<=0?(this.opponentPauseDeadline=0,this.callbacks.onReconnect(0)):this.opponentPauseTimer=window.setTimeout(()=>{this.opponentPauseTimer=null;let e=Math.max(0,this.opponentPauseDeadline-this.now());this.callbacks.onReconnect(e),e>0?this.scheduleOpponentPauseTick():this.opponentPauseDeadline=0},Math.min(250,e))}clearOpponentPause(e){let t=this.opponentPaused;this.opponentPaused=!1,this.opponentPauseDeadline=0,this.opponentPauseTimer!==null&&(clearTimeout(this.opponentPauseTimer),this.opponentPauseTimer=null),e&&t&&this.callbacks.onReconnect(0)}cancelReconnect(){this.reconnectTimer!==null&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}clearTransportReconnect(e){let t=this.reconnectDeadline!==0;this.reconnectDeadline=0,this.cancelReconnect(),e&&t&&this.callbacks.onReconnect(0)}stopInputLifecycle(){this.inputTimer!==null&&(clearInterval(this.inputTimer),this.inputTimer=null),this.heldTimer!==null&&(clearTimeout(this.heldTimer),this.heldTimer=null),this.listenersBound&&=(window.removeEventListener(`blur`,this.onInputLoss),window.removeEventListener(`focus`,this.onInputRegain),window.removeEventListener(`pointerdown`,this.onPagePointer,!0),document.removeEventListener(`visibilitychange`,this.onVisibilityChange),!1)}dispose(){if(this.disposed)return;this.disposed=!0,this.active=!1,this.reconnectTicket=null,this.clearTransportReconnect(!0),this.clearOpponentPause(!0),this.stopInputLifecycle();let e=this.socket;this.socket=null,e!==null&&(e.onopen=e.onmessage=e.onclose=e.onerror=null,e.close(1e3,`teardown`))}},JL={play:`CALLAHAN`,colour:`OKAFOR`,announcer:`RING ANNOUNCER`},YL=.3,XL=.9,ZL=.25,QL=2.6,$L=4.5,eR=12,tR=.8,nR=6,rR=9,iR=6,aR=42,oR=8,sR=15,cR=10,lR=[60,480,640],uR=500,dR=.2,fR=.3,pR=120,mR={knockdown:[`Down goes {b}!`,`{a} drops {b}!`,`{b} is down! What a shot from {a}!`,`Down goes {b}! {a} found the chin!`],knockdownAgain:[`{b} is down again!`,`Down for the second time! {b} is in deep trouble!`,`{a} puts {b} down again!`],knockdownCounter:[`Down goes {b}, off a perfect counter!`,`{a} times it, and {b} is down!`],struggle:[`{b} is struggling to get up...`,`{b} is trying to beat the count...`,`Can {b} get up?`],upLate:[`{b} beats the count at {n}!`,`Up at {n}! {b} is still in this!`,`{b} makes it up at {n}, but the legs look heavy.`],upEarly:[`{b} is up at {n}.`,`{b} is back up at the count of {n}.`,`Up at {n}. {b} wants to keep fighting.`],finishCall:[`{a} has to go for the finish now.`,`{b} needs to survive the next minute.`,`{b} has to hold and clear the head.`],hurt:[`{b} is hurt!`,`{a} has {b} in trouble!`,`{b}'s legs just buckled!`,`Big shot! {b} is wobbled!`,`{b} is rocked! Keep the pressure on, {a}!`],hurtBadly:[`{b} is out on their feet!`,`{b} is in all sorts of trouble!`,`{b} is badly hurt!`],guardBreak:[`{a} blasts right through the guard!`,`The guard is gone! {b} can't keep those hands up!`,`{a} breaks the guard down!`],counter:[`What a counter from {a}!`,`{a} times it perfectly! A {punch} on the counter!`,`{b} walked right into that {punch}!`,`Counter {punch} from {a}! Beautiful timing.`],bigShot:[`Big {punch} from {a}!`,`{a} lands a thudding {punch}!`,`That {punch} landed flush!`,`Huge {punch}! {b} felt that one.`],cut:[`{b} is cut over the {side} eye.`,`There's blood now. A cut over {b}'s {side} eye.`,`That's opened a cut over the {side} eye of {b}.`],cutWorse:[`That cut over {b}'s {side} eye is getting worse.`,`The blood is pouring from that {side} eye now.`,`{b} is bleeding badly from the {side} eye.`],cutGushing:[`That cut is gushing now! {b} is covered in it.`,`{b}'s face is a crimson mask, and nobody is stopping this!`],eyeSwelling:[`{b}'s {side} eye is swelling badly.`,`{b} is having trouble seeing out of that {side} eye.`],eyeShut:[`{b}'s {side} eye has closed completely!`,`That {side} eye is shut! {b} can't see them coming from that side.`,`{b} is fighting with one eye now.`],blindSide:[`{a} is working the blind side.`,`{b} never saw that one. Nothing is getting through that {side} eye.`,`Smart from {a}, punching where {b} can't see.`],parried:[`{a} picks it off and {b} is wide open!`,`Beautiful parry from {a}! {b} is off balance.`,`{a} slaps it away and {b} is left stranded.`],bodyCollapse:[`Body shot! {b} is going down!`,`{a} digs to the body and {b} is folding!`,`Oh, that body shot! {b} is in agony!`],knockdownBody:[`Down goes {b} from the body shot!`,`{b} takes a knee! That body shot took everything out!`,`{a} goes downstairs and {b} can't take it!`],cornerCut:[`{a}'s cutman is working on that cut.`,`They're working hard on the cut in {a}'s corner.`],cornerSwelling:[`{a}'s corner is getting the swelling down.`,`Ice and the enswell on that eye in {a}'s corner.`],cornerBreath:[`{a}'s corner wants the breath back first. Big drink of water.`,`{a} is told to breathe and settle down.`],combo:[`A three-punch combination from {a}!`,`{a} puts it together beautifully.`,`Lovely combination from {a}!`],unanswered:[`Five unanswered punches from {a}!`,`{a} is unloading! {b} has to fire back!`,`{b} is just covering up as {a} lets the hands go!`],jab:[`{a}'s jab is finding a home.`,`Stiff jab from {a}, and another.`,`{a} keeps popping that jab in {b}'s face.`],body:[`{a} is going to work on the body.`,`{a} keeps digging to the body.`,`Another one downstairs from {a}.`],payoff:[`The body work is paying off. {b} is slowing down.`,`Those body shots are taking it out of {b}.`,`{a} has invested in the body, and {b} is paying for it now.`],tiring:[`{b} is running on empty.`,`{b} is breathing hard. Those punches have nothing on them.`,`{b} has punched out. The tank is empty.`],takeover:[`{a} is taking over this round.`,`This is all {a} right now.`,`{a} is in complete control.`],clinch:[`{a} ties {b} up.`,`{a} grabs hold.`,`They're tied up in the clinch.`],holdingOn:[`{a} is hurt and holding on!`,`{a} grabs on for dear life!`,`Smart from {a}, holding on to clear the head.`],refBreak:[`The referee breaks them.`,`The referee steps in to separate them.`,`Break! The referee pulls them apart.`],refHit:[`{a} just tagged the referee!`,`Oh no, {a} has caught the referee!`,`That one landed on the referee!`],refDown:[`The referee is down! {a} has killed the referee!`,`Oh my goodness, the referee isn't moving! I think he's dead!`,`{a} has flattened the official for good! Absolute chaos!`],refBledOut:[`The referee has collapsed! He's bled out right there in the ring!`,`The referee goes down! He's lost too much blood!`],noRef:[`Nobody left to break them up!`,`No referee to part them, so they just let go.`],taunt:[`{a} drops the hands and invites {b} in!`,`Showboating from {a}! The crowd loves it.`,`{a} is taunting {b} now!`,`{a} sticks the chin out. Come and get it!`],lowBlow:[`Low blow from {a}! The referee steps in.`,`That's below the belt! {b} is doubled over.`,`{a} goes low, and the referee calls time.`],headbutt:[`Headbutt from {a}! The referee calls time.`,`{a} leads with the head! That's a foul.`],warning:[`A warning for {a}. One more and it costs a point.`,`The referee warns {a}. That can't happen again.`],deduction:[`The referee takes a point from {a}!`,`That costs {a} a point!`,`Point deduction! {a} has been warned enough.`],resume:[`And we're back underway.`,`Time in. Let's box.`],box:[`The referee waves them on. {b} has to survive now.`,`Box! {a} will be looking to finish it.`,`{b} has convinced the referee. Here comes {a}.`],evade:[`{a} slips it! Lovely head movement.`,`{b} misses, and {a} was never there.`,`Great defence from {a}.`],parry:[`{a} picks that off with the gloves.`,`{a} parries it away.`,`Tight defence from {a}.`],whiff:[`{a} misses wildly with the {punch}.`,`Big swing and a miss from {a}.`,`{a} throws everything into that {punch} and hits nothing but air.`],southpaw:[`{a} switches to southpaw.`,`{a} turns southpaw now.`],orthodox:[`{a} goes back to orthodox.`,`{a} switches back to orthodox.`],roundStart:[`Round {r}. Here we go.`,`We're underway in round {r}.`,`Round {r} is on.`],roundEnd:[`That's the bell to end round {r}.`,`The bell ends round {r}.`,`And that's round {r} in the books.`],savedByBell:[`Saved by the bell! {b} was in real trouble.`,`{b} is saved by the bell!`,`The bell rescues {b}!`],finalBell:[`That's the final bell!`,`The final bell! We go to the scorecards.`],summary:[`Round {r}: {a} landed {x} of {y}, {b} {z} of {w}.`],roundFor:[`I had that round for {a}.`,`{a} took that round.`,`That was {a}'s round.`],roundBig:[`The knockdown makes that a big round for {a}.`,`{a} wins that round big with the knockdown.`],roundClose:[`Close round. That one could go either way.`,`Tough round to score.`,`Nothing between them in that round.`],pullingAway:[`{a} is pulling away on the cards.`,`{b} needs something big. {a} is building a lead.`],ko:[`It's all over! {a} wins by knockout!`,`{b} can't beat the count! {a} wins it!`,`That's it! {a} has knocked out {b}!`],flashKo:[`Lights out! {b} is out cold!`,`One punch, and it's over! {a} wins!`,`Good night! {a} ends it with one shot!`],tko:[`Three knockdowns, and it's over! {a} wins!`,`The referee waves it off! {a} wins by stoppage!`],disqualified:[`{b} is disqualified!`,`That's it! {b} has been thrown out!`],forfeit:[`{b} has left the ring. {a} wins by forfeit.`],replay:[`Here it is again.`,`Let's see that one more time.`,`Watch {a} set it up...`],injBrokenNose:[`{b}'s nose is now mostly a suggestion.`,`That nose is broken. It is pointing at the exit, and so should {b}.`,`{a} has moved {b}'s nose to a different part of his face.`],injBrokenJaw:[`{b}'s jaw is broken. It is hanging off his face like a drawer left open.`,`That jaw has gone sideways. {b} will be eating through a straw, if he lives.`,`You can hear {b}'s jaw clicking from up here. That is not a good sound.`],injJawTorn:[`That is his jaw in the third row.`,`{a} has torn {b}'s jaw clean off! Somebody at ringside just caught a souvenir.`,`{b} has no lower jaw. His tongue is just hanging there like a necktie.`],injEyeOut:[`{b}'s {side} eye is out of his head! It is swinging on the nerve like a yo-yo.`,`The {side} eye has popped its socket. It is looking at {b}'s own cheek.`,`{a} has punched {b}'s {side} eye clean out. He can see his own shoes with it.`],injEarTorn:[`That is {b}'s {side} ear on the canvas. Somebody just trod on it.`,`{a} has taken the {side} ear clean off. {b} did not want to hear this anyway.`,`The {side} ear is gone. I think it is stuck to {a}'s glove.`],injFaceFlayed:[`The {side} half of {b}'s face has come off like a wet sock.`,`I can see {b}'s teeth through his {side} cheek. All of them.`,`{a} has peeled {b}'s face. That is muscle. That is bone. That is my lunch coming back up.`],injSkull:[`{b}'s skull has split open. That is his brain. I can see it thinking.`,`The top of {b}'s head is open like a boiled egg, and he is still standing.`,`That is brain, folks. One more upstairs and {b} forgets everything, permanently.`],injShoulder:[`{b}'s {side} shoulder has popped out. The arm is hanging like a coat on a hook.`,`The {side} shoulder is out of its socket. It is not supposed to be down there.`,`{b}'s {side} arm has come unplugged. His corner can shove it back in at the bell.`],injArmBroken:[`{b}'s {side} arm has snapped! The bone is out and waving at the crowd.`,`That {side} elbow now bends both ways. It is only meant to bend the one.`,`Compound fracture! {b}'s {side} forearm is dangling by the meat.`],injForearmSevered:[`{b}'s {side} forearm is off! The glove is still making a fist over there on the canvas.`,`{a} has taken the {side} arm off at the elbow, and {b} is punching with the stump!`,`There goes the {side} forearm. Somebody put it on ice. Actually, do not bother.`],injArmTorn:[`{a} has ripped {b}'s {side} arm off at the shoulder! It is on the canvas, still twitching!`,`The whole {side} arm is gone. That shoulder is a fire hose.`,`{b} has lost the {side} arm. The judges will take that into account.`],injRibs:[`{b}'s {side} ribs have caved in. One is sticking out of him like a coat hanger.`,`Those {side} ribs are through the skin. You can count them. I make it four.`,`The {side} side of {b} just folded like a lawn chair.`],injLiver:[`That is the liver, and it has burst. {b} is about to show us everything he ate today.`,`{b}'s liver just exploded inside him. He is turning a colour I have only seen on old fruit.`,`Liver shot, and it popped. {b} is filling up with blood on the inside.`],injDisemboweled:[`{b}'s belly is open and his guts are on the canvas! He is treading on them!`,`He is holding his intestines in with his glove and he still wants to fight.`,`{a} has unzipped {b} from hip to hip. That is twenty feet of intestine, and it is all coming out.`],injKnee:[`{b}'s {side} knee is bending the wrong way. Knees should not have a reverse gear.`,`The {side} knee has blown apart. I can see the kneecap. It is over by the ropes.`,`{b}'s {side} leg is held on by skin and optimism.`],ghastly:[`I would stop this fight. Nobody is going to stop this fight.`,`In any other sport that is a penalty.`,`{b} will feel that in the morning, if he gets one.`,`There are children watching this. They are cheering.`],shoulderBack:[`{b}'s corner has shoved the {side} shoulder back in. You could hear it from the cheap seats.`,`The {side} shoulder is back in its socket. {b} screamed, and then he said thank you.`,`They have popped {b}'s {side} shoulder back in. Good as new. It is not, but good as new.`],vomit:[`{a} is throwing up blood and bile all over the canvas. Mind your step.`,`There it goes. {a} is vomiting something black. That is the liver talking.`,`{a} is sick down his own chest. Blood, bile, and I think that was a tooth.`],finishHim:[`{b} is out on his feet and nobody is stopping it! Finish him!`,`{b} is just standing there, dead behind the eyes. {a} can do anything he likes with him.`,`This is it. {a} gets one free punch, and {b} will not be getting up from it. Ever.`],armless:[`{a} is trying to punch with arms he no longer has.`,`{a} just threw a punch. I will let somebody else tell him.`,`No arms, and {a} is still swinging. You have to admire it. You do not have to watch it.`,`{a} is waving two stumps at him. That is not a guard. That is a cry for help.`],fatEyesOut:[`{a} has punched both of {b}'s eyes out through the back of his head!`,`Two eyes, one punch! They are rolling across the ring. One of them is looking at me.`,`{b}'s eyes are out, and so is {b}. There is daylight coming through his face.`],fatHeadBurst:[`{b}'s head has exploded! It is just gone! It is all over the first three rows!`,`{a} hit him so hard his head burst like a dropped melon. The front row is wearing {b}.`],fatDecapitation:[`{a} has taken {b}'s head clean off! It is in the crowd! Somebody is holding it up!`,`Off comes the head! The body is still standing there, looking for it.`],fatSpineRip:[`The uppercut takes {b}'s head off, and his spine comes with it! All of it! Like boning a fish!`,`{b}'s head is in the air with the whole spine dangling off it. I have never seen that. Nobody has.`],fatHeartPunch:[`{a}'s fist has gone straight through {b}'s chest! That is his heart on the canvas, and it is still beating!`,`In through the chest and out the back! {a} is wearing {b} like a bracelet.`],fatGutting:[`{a} has emptied {b} onto the canvas! Everything he kept inside is now outside!`,`One straight to the gut and it all falls out. Liver, stomach, the lot. {b} is hollow.`],fatBisection:[`{a} has torn {b} in half at the waist! The legs are still standing! The top half is trying to crawl away!`,`{b} is in two pieces. The judges will have to score each half separately.`],fatTotalGib:[`{b} has exploded! There is nothing left! It is raining {b}!`,`{a} hit him and he just came apart. There are bits of {b} on the lights. There is a foot in my coffee.`],deathBledOut:[`{b} has bled to death, right there in the ring. There is more of him on the canvas than in him.`,`{b} is gone. He ran out of blood. You do need some.`,`And {b} just drops. Bled out. They will need a mop and a priest.`],deathBrain:[`That was the last of {b}'s brain, and {a} has punched it into soup. He is dead before he lands.`,`{b} is dead. His brain has left through the hole in his skull.`,`{b} is dead. You cannot fight without a brain. Plenty have tried.`],deathGutted:[`{b} is dead. {a} has punched what was left of his insides clean out of him.`,`That body shot went in one side and out the other. {b} is done, and I mean buried.`,`{b} has been gutted like a fish, and he has died like one, flapping.`],deathFatality:[`He is dead. I would like that on the record. {b} is extremely dead.`,`I have been doing this thirty years. I am going to need a different job.`,`Somebody tell {b}'s corner they can stop shouting advice.`],doubleDeath:[`They are both dead. Both of them. I do not know who to interview.`,`Two fighters, no survivors. The judges are going to hate this.`,`{a} and {b} have killed each other. Call it a draw. Call somebody.`]},hR={ko:`ko`,flash_ko:`flashKo`,tko:`tko`,disqualification:`disqualified`,forfeit:`forfeit`},gR={broken_nose:`injBrokenNose`,broken_jaw:`injBrokenJaw`,jaw_torn:`injJawTorn`,eye_out:`injEyeOut`,ear_torn:`injEarTorn`,face_flayed:`injFaceFlayed`,skull_fractured:`injSkull`,shoulder_dislocated:`injShoulder`,arm_broken:`injArmBroken`,forearm_severed:`injForearmSevered`,arm_torn:`injArmTorn`,ribs_broken:`injRibs`,liver_ruptured:`injLiver`,disemboweled:`injDisemboweled`,knee_blown:`injKnee`},_R={eyes_out:`fatEyesOut`,head_burst:`fatHeadBurst`,decapitation:`fatDecapitation`,spine_rip:`fatSpineRip`,heart_punch:`fatHeartPunch`,gutting:`fatGutting`,bisection:`fatBisection`,total_gib:`fatTotalGib`},vR={bled_out:`deathBledOut`,brain:`deathBrain`,gutted:`deathGutted`},yR=new Set([`injJawTorn`,`injEyeOut`,`injFaceFlayed`,`injSkull`,`injForearmSevered`,`injArmTorn`,`injDisemboweled`,`finishHim`,`fatEyesOut`,`fatHeadBurst`,`fatDecapitation`,`fatSpineRip`,`fatHeartPunch`,`fatGutting`,`fatBisection`,`fatTotalGib`,`deathBledOut`,`deathBrain`,`deathGutted`,`deathFatality`,`doubleDeath`]),bR={struggle:new Set([`knockdown`]),finishHim:new Set([`finish`])},xR=3.2,SR=4,CR=`struggle`,wR=new Set([`countdown`]),TR=3.2,ER=new Set([`knockdown`,`knockdownAgain`,`knockdownCounter`,`knockdownBody`,`bodyCollapse`,`upLate`,`upEarly`,`hurt`,`hurtBadly`,`lowBlow`,`headbutt`,`deduction`,`ko`,`flashKo`,`tko`,`disqualified`,`forfeit`,`replay`,`refDown`,`refBledOut`,`savedByBell`,`finalBell`,`roundEnd`,`roundStart`,`injBrokenNose`,`injBrokenJaw`,`injEarTorn`,`injShoulder`,`injArmBroken`,`injRibs`,`injLiver`,`injKnee`,...yR]),DR=new Set([`lowBlow`,`headbutt`,`warning`,`deduction`,`box`,`tko`]),OR={fatEyesOut:99,fatHeadBurst:99,fatDecapitation:99,fatSpineRip:99,fatHeartPunch:99,fatGutting:99,fatBisection:99,fatTotalGib:99,doubleDeath:99,deathBledOut:98,deathBrain:98,deathGutted:98,deathFatality:98,finishHim:97,injJawTorn:96,injEyeOut:96,injFaceFlayed:96,injSkull:96,injForearmSevered:96,injArmTorn:96,injDisemboweled:96,injBrokenNose:85,injBrokenJaw:85,injEarTorn:85,injShoulder:85,injArmBroken:85,injRibs:85,injLiver:85,injKnee:85,vomit:66,shoulderBack:47,ghastly:44,armless:40,ko:98,flashKo:98,tko:98,disqualified:98,forfeit:98,refDown:97,refBledOut:97,refHit:72,knockdown:95,knockdownAgain:95,knockdownCounter:95,knockdownBody:95,bodyCollapse:86,upLate:90,upEarly:90,replay:88,deduction:84,lowBlow:82,headbutt:82,hurt:80,box:78,hurtBadly:80,holdingOn:76,savedByBell:74,finalBell:72,struggle:70,guardBreak:65,eyeShut:62,counter:60,parried:58,bigShot:55,roundEnd:52,cut:50,cutWorse:50,summary:50,cutGushing:48,eyeSwelling:48,cornerCut:47,cornerSwelling:47,cornerBreath:47,blindSide:42,roundFor:46,roundBig:46,roundClose:46,pullingAway:46,unanswered:45,finishCall:44,warning:42,combo:40,payoff:40,takeover:38,body:35,jab:30,tiring:30,roundStart:28,taunt:25,parry:22,evade:20,clinch:20,whiff:18,refBreak:12,noRef:12,southpaw:10,orthodox:10,resume:10},kR={finishCall:`colour`,payoff:`colour`,tiring:`colour`,takeover:`colour`,holdingOn:`colour`,taunt:`colour`,parry:`colour`,evade:`colour`,warning:`colour`,blindSide:`colour`,cornerCut:`colour`,cornerSwelling:`colour`,cornerBreath:`colour`,roundFor:`colour`,roundBig:`colour`,roundClose:`colour`,pullingAway:`colour`,cutGushing:`colour`,noRef:`colour`,jab:`colour`,ghastly:`colour`,shoulderBack:`colour`,vomit:`colour`,deathFatality:`colour`,doubleDeath:`colour`,armless:`colour`},AR={combo:6,jab:20,body:18,evade:12,parry:15,parried:8,blindSide:20,whiff:12,clinch:15,refBreak:20,taunt:10,southpaw:15,orthodox:15,bigShot:4,counter:3,unanswered:15,takeover:25,vomit:20,ghastly:14,armless:12},jR=[`zero`,`one`,`two`,`three`,`four`,`five`,`six`,`seven`,`eight`,`nine`,`ten`,`eleven`,`twelve`,`thirteen`,`fourteen`,`fifteen`],MR=e=>jR[e]??String(e),NR=[...jR,`sixteen`,`seventeen`,`eighteen`,`nineteen`],PR=[``,``,`twenty`,`thirty`,`forty`,`fifty`,`sixty`,`seventy`,`eighty`,`ninety`];function FR(e){return!Number.isInteger(e)||e<0||e>=1e3?String(e):e<20?NR[e]:e<100?`${PR[Math.floor(e/10)]}${e%10==0?``:`-${NR[e%10]}`}`:`${NR[Math.floor(e/100)]} hundred${e%100==0?``:` and ${FR(e%100)}`}`}function IR(e,t=!0){if(Be(e))return`making a pro debut`;let n=e.draws>0?`${FR(e.wins)}, ${FR(e.losses)} and ${FR(e.draws)}`:`${FR(e.wins)} and ${e.losses===0?`oh`:FR(e.losses)}`;return t&&e.knockouts>0?`${n}, ${FR(e.knockouts)} by knockout`:n}function LR(e){return .85+e.length*.077+(e.split(`...`).length-1)*.35}var RR=.3;function zR(e,t){let n=t-RR,r=[e=>[e.record===void 0?null:IR(e.record),Vt(e.style)],e=>[Vt(e.style)],()=>[]];for(let t of r){let r=e.map((e,n)=>{let r=n===0?`In the blue corner`:`And in the red corner`,i=t(e).filter(e=>e!==null);return i.length===0?`${r}, ${e.name}!`:`${r}, ${i.join(`, `)}... ${e.name}!`});if(r.reduce((e,t)=>e+LR(t),0)<=n)return r}let i=`${e[0].name}... versus ${e[1].name}!`;return LR(i)<=n?[i]:[]}function BR(e,t){let n=e.replace(/\{(a|b|n|side|punch|r|x|y|z|w)\}/gu,(e,n)=>String(t[n]??``));return n.charAt(0).toUpperCase()+n.slice(1)}var VR=(e,t)=>{let n=Math.imul((e|0)^Math.imul(t,2654435761),2246822507);return n^=n>>>13,n=Math.imul(n,3266489909),(n^n>>>16)>>>0};function HR(e){let t=e.split(`:`);return[t.at(-2),t.at(-1)]}function UR(e,t){let[n=`punch`,r=`head`]=HR(e),i=t!==void 0&&t.action===n?t.action_hand:null,a=n===`jab`?`jab`:n===`straight`?i===null?`straight`:`${i} hand`:i===null?n:`${i} ${n}`;return r===`body`?`${a} to the body`:a}function WR(e){if(e.phase===`knockdown`){let t=Math.max(...e.fighters.map(e=>e.get_up_count));return Math.min(1,.3+t*.07)}if(e.phase===`finish`)return 1;if(e.phase!==`fight`)return 0;let t=0;for(let[n,r]of e.fighters.entries()){let i=e.fighters[1-n];r.is_downed||(r.stunned_ticks>0?t=Math.max(t,.75):r.poise<150&&(t=Math.max(t,.45)),(Math.max(Math.abs(r.x),Math.abs(r.y))>400||Math.abs(r.x)+Math.abs(r.y)>640)&&Math.hypot(r.x-i.x,r.y-i.y)<150&&(t=Math.max(t,.4)))}return t}var GR=()=>({thrown:0,landed:0,damage:0,knockdowns:0,body:0}),KR=()=>({jabs:[],window:[],evasions:[],run:0,runTick:-1e3,unanswered:0,stunnedAt:-1e3,knockedDownAt:-1e5,lowSince:null,tiredRound:0,takeoverRound:0,payoffRound:0,cutMarks:[0,0],eyeShut:[!1,!1],eyeSwelling:[!1,!1],rounds:0}),qR=class{hooks;queue=[];showing=null;lastEnd=-1/0;lastChoice=new Map;cooldowns=new Map;notes=new Map;tallies=new Map;players={};fighters=null;tickRate=30;introduced=!1;lastPhase=null;round=0;roundLength=null;fightRemaining=0;struggleCalled=-1;lastKnockdown=null;refereeDead=!1;final=null;verdictGiven=!1;resultCalled=!1;deaths=new Map;caption={line:null,opacity:0,entering:0};constructor(e={}){this.hooks=e}observe(e,t,n,r,i){this.players=n,this.fighters=e.fighters,this.refereeDead=e.referee?.alive===!1,this.tickRate=r,this.trackClock(e),this.introduced||(this.introduced=!0,e.phase===`countdown`&&e.round_number===1&&this.introduce(e,i));let a=t.find(e=>e.kind===`result`)??null;for(let n of t)this.consider(n,e,a,i);this.inspect(e,i),this.lastPhase=e.phase,this.dropOutOfPhase(e.phase,i)}dropOutOfPhase(e,t){for(let t=this.queue.length-1;t>=0;--t){let n=this.queue[t].phases;n!==null&&!n.has(e)&&this.queue.splice(t,1)}let n=this.showing;n!==null&&n.phases!==null&&!n.phases.has(e)&&(n.end=Math.min(n.end,t+ZL))}finish(e,t,n,r){this.players=t,this.final=e,n&&this.deaths.size<2&&(this.enqueue(this.announcement(`Ladies and gentlemen, we go to the scorecards.`,{kicker:`LADIES AND GENTLEMEN`,title:`WE GO TO THE SCORECARDS`,detail:``,corner:null},iR,99),r,null,30),this.hooks.speak?.([`Ladies and gentlemen, we go to the scorecards.`])),e.method===`forfeit`&&!this.resultCalled&&e.winner_id!==null&&(this.resultCalled=!0,this.say(`forfeit`,e.round,r,{a:this.nameOf(e.winner_id),b:this.nameOf(this.otherId(e.winner_id))},`result`,0))}verdict(e){let t=this.final;if(t===null||this.verdictGiven)return;this.verdictGiven=!0;let n=dr(t);if(t.winner_id===null&&this.deaths.size>=2){let n=`Ladies and gentlemen, both fighters are dead. There is no winner.`;this.enqueue(this.announcement(n,{kicker:`ROUND ${t.round}`,title:`DOUBLE DEATH`,detail:`NO SURVIVORS`,corner:null},rR,100),e,`verdict`,30),this.hooks.speak?.([n]);return}if(t.winner_id===null){let r=`After ${MR(t.round)} rounds, this bout is scored a ${n.toLowerCase()}.`;this.enqueue(this.announcement(r,{kicker:`AFTER ${MR(t.round).toUpperCase()} ROUNDS`,title:n,detail:``,corner:null},rR,100),e,`verdict`,30),this.hooks.speak?.([r]);return}let r=this.nameOf(t.winner_id),i=n.toLowerCase();this.enqueue(this.announcement(`The winner, by ${i}: ${r}!`,{kicker:`THE WINNER, BY ${n}`,title:r.toUpperCase(),detail:``,corner:this.seatOf(t.winner_id)},rR,100),e,`verdict`,30),this.hooks.speak?.([`And the winner, by ${i}... ${r}!`])}resultShown(e){let t=this.final;if(t===null||this.verdictGiven)return;if(t.method===`decision`||t.method===`draw`){this.verdict(e);return}if(this.verdictGiven=!0,t.winner_id===null)return;let n=this.nameOf(t.winner_id),r=this.otherId(t.winner_id),i=t.method===`death`,a=i&&r!==null?this.deaths.get(r)??null:null,o=i?a!==null&&ke(a)!==null?`fatality`:`death`:{ko:`knockout`,flash_ko:`knockout`,tko:`technical knockout`,disqualification:`disqualification`,forfeit:`forfeit`}[t.method]??t.method.replaceAll(`_`,` `),s=this.stoppageClock(t.round),c=t.method===`ko`||t.method===`flash_ko`||t.method===`tko`||i,l=c&&s!==null?`${i?`DEAD`:`STOPPED`} AT ${s} OF ROUND ${t.round}`:`ROUND ${t.round}`,u=c&&s!==null?`${n} wins by ${o} at ${s} of round ${t.round}.`:`${n} wins by ${o} in round ${t.round}.`,d=`WINS BY ${o.toUpperCase()}${a===null?``:` · ${Ae(a)}`}`;this.enqueue(this.announcement(u,{kicker:l,title:n.toUpperCase(),detail:d,corner:this.seatOf(t.winner_id)},rR,100),e,`verdict`,30);let f=i?`${this.nameOf(r)} is dead`:this.refereeDead?`With the referee dead on the canvas, it is over`:`The referee stops the contest`,p=c&&s!==null?`${f} at ${s} of round ${MR(t.round)}. `:``;this.hooks.speak?.([`${p}Your winner, by ${o}... ${n}!`])}replay(e,t=null){let n=t?.kind===`referee_down`?{actor:t.actor_id,target:null,tick:t.tick}:this.lastKnockdown;this.say(`replay`,n?.tick??0,e,{a:this.nameOf(n?.actor??null),b:this.nameOf(n?.target??null)},`replay`,.6,6)}current(e){for(let t=this.queue.length-1;t>=0;--t)this.queue[t].expires<=e&&this.queue.splice(t,1);this.showing!==null&&e>=this.showing.end&&(this.lastEnd=this.showing.end,this.showing=null);let t=null;for(let n of this.queue)n.at>e||(t===null||n.line.priority>t.line.priority||n.line.priority===t.line.priority&&n.at=this.lastEnd+XL:t.line.urgent&&t.line.priority>n.line.priority&&e-n.start>=tR)&&(this.queue.splice(this.queue.indexOf(t),1),this.showing={line:t.line,start:e,end:e+t.line.hold,moment:t.moment,phases:t.phases},t.spoken!==null&&this.hooks.speak?.([t.spoken]))}let n=this.showing;return n===null?null:(this.caption.line=n.line,this.caption.opacity=Math.max(0,Math.min(1,(e-n.start)/ZL,(n.end-e)/ZL)),this.caption.entering=Math.max(0,1-(e-n.start)/ZL),this.caption)}trackClock(e){e.phase===`fight`&&((this.lastPhase===`countdown`||this.lastPhase===`rest`)&&(this.roundLength={round:e.round_number,ticks:e.phase_ticks_remaining+1}),this.fightRemaining=e.phase_ticks_remaining),e.round_number!==this.round&&(this.round=e.round_number,this.tallies.clear())}stoppageClock(e){let t=this.roundLength;if(t===null||t.round!==e)return null;let n=Math.max(0,Math.floor((t.ticks-this.fightRemaining)/this.tickRate));return`${Math.floor(n/60)}:${String(n%60).padStart(2,`0`)}`}introduce(e,t){let n=e.phase_ticks_remaining/this.tickRate;if(n<1.2)return;let r=e.fighters.map(e=>this.nameOf(e.player_id)),i=e.fighters.map((e,t)=>({name:r[t],record:this.players[e.player_id]?.record,style:e.style})),a=zR([i[0],i[1]],n),o=Math.max(1.4,a.length===2?LR(a[0]):n/2),s=[o,Math.max(1.4,n-o)];for(let n of[0,1]){let i=n===0?`blue`:`red`,c=this.players[e.fighters[n].player_id],l=Bt(e.fighters[n].style),u=c===void 0?``:`${l===null?``:`${l} · `}${c.record===void 0?``:`${Ve(c.record)} · `}${c.cpu===!0?`COMPUTER`:`RATED ${c.rating}`}`;this.enqueue(this.announcement(`In the ${i} corner, ${r[n]}.`,{kicker:`IN THE ${i.toUpperCase()} CORNER`,title:r[n].toUpperCase(),detail:u,corner:n},s[n],97),t+n*o,null,30,wR,a[n]??null)}}consider(e,t,n,r){let i=e.actor_id,a=e.target_id,o=`${e.tick}:${a??i??``}`,s={a:this.nameOf(i),b:this.nameOf(a)};switch(e.kind){case`punch_start`:i!==null&&(this.tally(i).thrown+=1);return;case`hit`:case`counter_hit`:i!==null&&a!==null&&!lr(e,t.events)&&this.landed(e,i,a,t,r);return;case`stun`:{if(a===null)return;this.notesFor(a).stunnedAt=e.tick;let t=this.fighter(a),n=t!==void 0&&(t.poise=A-6);this.say(n?`hurtBadly`:`hurt`,e.event_id,r,s,o);return}case`guard_break`:this.say(`guardBreak`,e.event_id,r,s,o);return;case`knockdown`:{if(a===null||(this.lastKnockdown={actor:i,target:a,tick:e.tick},this.notesFor(a).knockedDownAt=e.tick,i!==null&&(this.tally(i).knockdowns+=1),n!==null))return;let c=t.events.some(t=>t.kind===`counter_hit`&&t.tick===e.tick&&t.target_id===a);this.say(e.amount>=2?`knockdownAgain`:e.detail===`body`?`knockdownBody`:c?`knockdownCounter`:`knockdown`,e.event_id,r,s,o);return}case`body_collapse`:this.say(`bodyCollapse`,e.event_id,r,s,o);return;case`parry`:this.say(`parried`,e.event_id,r,s,o,YL,void 0,i);return;case`eye_shut`:if(a===null||e.detail!==`left`&&e.detail!==`right`)return;this.notesFor(a).eyeShut[e.detail===`left`?0:1]=!0,this.say(`eyeShut`,e.event_id,r,{...s,side:e.detail},o);return;case`blind_side`:if(e.detail!==`left`&&e.detail!==`right`)return;this.say(`blindSide`,e.event_id,r,{...s,side:e.detail},null,YL,void 0,i);return;case`corner`:{let t=e.detail===`cut`?`cornerCut`:e.detail===`swelling`?`cornerSwelling`:e.detail===`breath`?`cornerBreath`:null;t!==null&&this.say(t,e.event_id,r,s,null,YL,void 0,i);return}case`count`:e.amount>=6&&this.struggleCalled!==this.lastKnockdown?.tick&&this.fighter(a)?.is_downed===!0&&(this.struggleCalled=this.lastKnockdown?.tick??e.tick,this.say(`struggle`,e.event_id,r,{a:this.nameOf(this.otherId(a)),b:this.nameOf(a)},CR));return;case`get_up`:{for(let e=this.queue.length-1;e>=0;--e)this.queue[e].moment===CR&&this.queue.splice(e,1);this.showing?.moment===CR&&(this.showing.end=Math.min(this.showing.end,r+ZL));let t={a:this.nameOf(this.otherId(i)),b:this.nameOf(i),n:MR(e.amount)};this.say(e.amount>=8?`upLate`:`upEarly`,e.event_id,r,t,o),this.say(`finishCall`,e.event_id,r,t,null,3.4,4);return}case`perfect_block`:this.say(`parry`,e.event_id,r,s,o,YL,void 0,i);return;case`evade`:{if(i===null)return;let t=this.notesFor(i);t.evasions=t.evasions.filter(t=>t>e.tick-cR*this.tickRate),t.evasions.push(e.tick),(this.fighter(a)?.action_power===`power`||t.evasions.length>=3)&&this.say(`evade`,e.event_id,r,s,o,YL,void 0,i)&&(t.evasions.length=0);return}case`whiff`:{let t=this.fighter(i);if(t?.action_power!==`power`||t.action===null)return;this.say(`whiff`,e.event_id,r,{...s,punch:UR(`${t.action}:${t.action_target??`head`}`,t)},o,YL,void 0,i);return}case`clinch`:{if(i===null)return;let t=this.fighter(i),n=e.tick-this.notesFor(i).stunnedAt<=3*this.tickRate||t!==void 0&&t.poise<150;this.say(n?`holdingOn`:`clinch`,e.event_id,r,s,o,YL,void 0,i);return}case`referee_break`:this.say(`refBreak`,e.event_id,r,s,null,YL,void 0,`referee`);return;case`referee_hit`:this.say(`refHit`,e.event_id,r,s,o,YL,void 0,i);return;case`referee_down`:this.say(e.action_id===null?`refBledOut`:`refDown`,e.event_id,r,s,o);return;case`clinch_break`:this.say(`noRef`,e.event_id,r,s,null,YL);return;case`taunt`:this.say(`taunt`,e.event_id,r,{a:s.a,b:this.nameOf(this.otherId(i))},o,YL,void 0,i);return;case`foul`:this.say(e.detail===`headbutt`?`headbutt`:`lowBlow`,e.event_id,r,s,o),this.fighter(i)?.warnings===1&&this.say(`warning`,e.event_id,r,s,null,3.6,4);return;case`point_deduction`:this.say(`deduction`,e.event_id,r,s,`deduction:${e.tick}`);return;case`resume`:this.say(`resume`,e.event_id,r,s,null);return;case`box`:this.say(`box`,e.event_id,r,{a:this.nameOf(this.otherId(a)),b:this.nameOf(a)},o);return;case`stance`:this.say(e.detail===`southpaw`?`southpaw`:`orthodox`,e.event_id,r,s,null,YL,void 0,i);return;case`exhausted`:i!==null&&this.tired(i,e.event_id,r);return;case`bell`:e.detail===`round_start`?(this.tallies.clear(),t.round_number>=2&&this.say(`roundStart`,e.event_id,r,{r:t.round_number},null,YL,TR)):e.detail===`round_end`&&this.roundEnded(e,t,n,r);return;case`injury`:{let n=me.find(t=>t===e.detail);if(a===null||n===void 0)return;let i=gR[N(n)],c={...s,side:we(n)??``};!yR.has(i)&&t.events.some(t=>t.kind===`knockdown`&&t.tick===e.tick&&t.target_id===a)?this.sayAt(i,e.event_id,r+xR,c,8):this.say(i,e.event_id,r,c,o),yR.has(i)&&this.say(`ghastly`,e.event_id,r,s,null,3.8,4);return}case`injury_healed`:{let t=me.find(t=>t===e.detail);if(t===void 0||N(t)!==`shoulder_dislocated`)return;this.sayAt(`shoulderBack`,e.event_id,r+SR,{b:this.nameOf(a??i),side:we(t)??``},9);return}case`armless`:this.say(`armless`,e.event_id,r,s,null,YL,void 0,i);return;case`vomit`:this.say(`vomit`,e.event_id,r,{a:this.nameOf(i??a)},o,YL,void 0,i??a);return;case`finish_him`:this.say(`finishHim`,e.event_id,r,s,o,0);return;case`fatality`:{let t=ge.find(t=>t===e.detail);t!==void 0&&this.say(_R[t],e.event_id,r,s,o,0);return}case`death`:{let t=Oe(e.detail);if(t===null||a===null)return;this.deaths.set(a,t);let n={a:this.nameOf(i??this.otherId(a)),b:s.b};this.deaths.size>=2?this.say(`doubleDeath`,e.event_id,r,n,null,.6):t===`bled_out`||t===`brain`||t===`gutted`?this.say(vR[t],e.event_id,r,n,o,0):this.say(`deathFatality`,e.event_id,r,n,null,3.6);return}case`result`:this.resulted(e,r);return;default:return}}landed(e,t,n,r,i){let[a,o]=HR(e.detail),s=this.tally(t);s.landed+=1,s.damage+=e.amount,o===`body`&&(s.body+=1);let c=this.notesFor(t),l=this.notesFor(n);l.run=0,l.unanswered=0,c.run=e.tick-c.runTick<=aR?c.run+1:1,c.runTick=e.tick,c.unanswered+=1,c.window=c.window.filter(t=>t>e.tick-sR*this.tickRate),c.window.push(e.tick);let u=`${e.tick}:${n}`,d=r.fighters.find(e=>e.player_id===t),f={a:this.nameOf(t),b:this.nameOf(n),punch:UR(e.detail,d)},p=d?.action_power===`power`&&d.action===a;if(e.kind===`counter_hit`&&e.amount>=40?this.say(`counter`,e.event_id,i,f,u,YL,void 0,t):(e.amount>=85||p&&o===`head`&&e.amount>=60)&&this.say(`bigShot`,e.event_id,i,f,u,YL,void 0,t),c.unanswered===5?this.say(`unanswered`,e.event_id,i,f,u,YL,void 0,t):c.run===3&&this.say(`combo`,e.event_id,i,f,u,YL,void 0,t),a===`jab`&&(c.jabs=c.jabs.filter(t=>t>e.tick-oR*this.tickRate),c.jabs.push(e.tick),c.jabs.length>=3&&this.say(`jab`,e.event_id,i,f,null,YL,void 0,t)&&(c.jabs.length=0)),o===`body`){let a=this.fighter(n);a!==void 0&&s.body>=5&&a.staminat>e.tick-sR*this.tickRate).length;c.window.length>=7&&m<=2&&c.takeoverRound!==r.round_number&&(c.takeoverRound=r.round_number,this.say(`takeover`,e.event_id,i,f,null,YL,void 0,t)&&this.hooks.cue?.(`chant`))}roundEnded(e,t,n,r){let i=t.round_number;if(n!==null){(n.detail===`decision`||n.detail===`draw`)&&this.say(`finalBell`,e.event_id,r,{},`bell`,YL,TR);return}let a=t.fighters.find(t=>{let n=this.notesFor(t.player_id);return t.stunned_ticks>0||t.poise({id:e.player_id,tally:this.tally(e.player_id)})),[c,l]=o.tally.landed>=s.tally.landed?[o,s]:[s,o];c.tally.thrown+l.tally.thrown>0&&this.sayAt(`summary`,e.event_id,r+2.4,{r:i,a:this.nameOf(c.id),x:c.tally.landed,y:c.tally.thrown,b:this.nameOf(l.id),z:l.tally.landed,w:l.tally.thrown},5);let u=(o.tally.knockdowns-s.tally.knockdowns)*1e3+(o.tally.damage-s.tally.damage)+6*(o.tally.landed-s.tally.landed),d=Math.abs(u)0?o:s;d!==null&&(this.notesFor(d.id).rounds+=1);let f=d===null?null:d===o?s:o,p=d===null||f===null?0:this.notesFor(d.id).rounds-this.notesFor(f.id).rounds,m=d===null?`roundClose`:o.tally.knockdowns===s.tally.knockdowns?i>=2&&p>=2?`pullingAway`:`roundFor`:`roundBig`;this.sayAt(m,e.event_id,r+6.4,{a:this.nameOf(d?.id??null),b:this.nameOf(f?.id??null)},5)}resulted(e,t){let n=hR[e.detail];if(n===void 0||this.resultCalled)return;this.resultCalled=!0;let r=e.actor_id;this.say(n,e.event_id,t,{a:this.nameOf(r),b:this.nameOf(this.otherId(r))},`result`,0)}inspect(e,t){if(e.phase===`fight`)for(let n of e.fighters){let r=this.notesFor(n.player_id),i={a:this.nameOf(this.otherId(n.player_id)),b:this.nameOf(n.player_id)};for(let[a,o]of[[0,`left`],[1,`right`]]){let s=a===0?n.trauma.left_cut:n.trauma.right_cut,c=r.cutMarks[a];c=lR[c]&&(r.cutMarks[a]=lR.filter(e=>s>=e).length,this.say(c===0?`cut`:c===1?`cutWorse`:`cutGushing`,e.tick+a,t,{...i,side:o},null));let l=a===0?n.trauma.left_eye:n.trauma.right_eye;!r.eyeSwelling[a]&&!r.eyeShut[a]&&l>=uR&&(r.eyeSwelling[a]=!0,this.say(`eyeSwelling`,e.tick+a,t,{...i,side:o},null))}let a=n.stamina/Math.max(1,n.maximum_stamina);a=2*this.tickRate&&this.tired(n.player_id,e.tick,t)):a>=fR&&(r.lowSince=null)}}tired(e,t,n){let r=this.notesFor(e);r.tiredRound!==this.round&&(r.tiredRound=this.round,this.say(`tiring`,t,n,{a:this.nameOf(this.otherId(e)),b:this.nameOf(e)},null))}say(e,t,n,r,i,a=YL,o,s){let c=AR[e],l=`${e}:${s??``}`;if(c!==void 0){if(n<(this.cooldowns.get(l)??-1/0))return!1;this.cooldowns.set(l,n+c)}let u=BR(this.choose(e,t),r),d={speaker:kR[e]??`play`,text:u,priority:OR[e],urgent:ER.has(e),hold:JR(u),card:null},f=yR.has(e);return this.enqueue(d,n+a,i,o??(f?eR:void 0),bR[e]??null,null,f)}sayAt(e,t,n,r,i){let a=BR(this.choose(e,t),r);this.enqueue({speaker:kR[e]??`play`,text:a,priority:OR[e],urgent:ER.has(e),hold:JR(a),card:null},n,null,i)}announcement(e,t,n,r){return{speaker:`announcer`,text:e,priority:r,urgent:!0,hold:n,card:t}}choose(e,t){let n=mR[e],r=this.refereeDead&&DR.has(e)?n.filter(e=>!/referee/iu.test(e)):n,i=VR(t,e.length*31+e.charCodeAt(0))%r.length;return r.length>1&&this.lastChoice.get(e)===i&&(i=(i+1)%r.length),this.lastChoice.set(e,i),r[i]}enqueue(e,t,n,r,i=null,a=null,o=!1){if(n!==null){if(!o&&this.queue.some(t=>t.moment===n&&t.line.priority>=e.priority)||!o&&this.showing?.moment===n&&this.showing.line.priority>=e.priority)return!1;for(let t=this.queue.length-1;t>=0;--t){let r=this.queue[t];r.moment===n&&!r.big&&r.line.prioritynR){let e=0;for(let t=1;tt.player_id===e)}otherId(e){let t=this.fighters;return t===null||e===null?null:t[0].player_id===e?t[1].player_id:t[1].player_id===e?t[0].player_id:null}seatOf(e){let t=this.fighters?.findIndex(t=>t.player_id===e)??-1;return t===0||t===1?t:null}nameOf(e){if(e===null)return`the fighter`;let t=this.players[e]?.name;if(t!==void 0&&t.trim().length>0)return t.trim();let n=this.seatOf(e);return n===0?`the blue corner`:n===1?`the red corner`:`the fighter`}};function JR(e){return Math.min(5.2,Math.max(2.2,1.4+e.length*.05))}var YR={name:`CopyShader`,uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:` + + varying vec2 vUv; + + void main() { + + vUv = uv; + gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); + + }`,fragmentShader:` + + uniform float opacity; + + uniform sampler2D tDiffuse; + + varying vec2 vUv; + + void main() { + + vec4 texel = texture2D( tDiffuse, vUv ); + gl_FragColor = opacity * texel; + + + }`},XR=class{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error(`THREE.Pass: .render() must be implemented in derived pass.`)}dispose(){}},ZR=new Yd(-1,1,1,-1,0,1),QR=new class extends yc{constructor(){super(),this.setAttribute(`position`,new sc([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute(`uv`,new sc([0,2,0,0,2,0],2))}},$R=class{constructor(e){this._mesh=new V(QR,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,ZR)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}},ez=class extends XR{constructor(e,t=`tDiffuse`){super(),this.textureID=t,this.uniforms=null,this.material=null,e instanceof Wu?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=Vu.clone(e.uniforms),this.material=new Wu({name:e.name===void 0?`unspecified`:e.name,defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this._fsQuad=new $R(this.material)}render(e,t,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this._fsQuad.material=this.material,this.renderToScreen?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this._fsQuad.render(e))}dispose(){this.material.dispose(),this._fsQuad.dispose()}},tz=class extends XR{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,n){let r=e.getContext(),i=e.state;i.buffers.color.setMask(!1),i.buffers.depth.setMask(!1),i.buffers.color.setLocked(!0),i.buffers.depth.setLocked(!0);let a,o;this.inverse?(a=0,o=1):(a=1,o=0),i.buffers.stencil.setTest(!0),i.buffers.stencil.setOp(r.REPLACE,r.REPLACE,r.REPLACE),i.buffers.stencil.setFunc(r.ALWAYS,a,4294967295),i.buffers.stencil.setClear(o),i.buffers.stencil.setLocked(!0),e.setRenderTarget(n),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),i.buffers.color.setLocked(!1),i.buffers.depth.setLocked(!1),i.buffers.color.setMask(!0),i.buffers.depth.setMask(!0),i.buffers.stencil.setLocked(!1),i.buffers.stencil.setFunc(r.EQUAL,1,4294967295),i.buffers.stencil.setOp(r.KEEP,r.KEEP,r.KEEP),i.buffers.stencil.setLocked(!0)}},nz=class extends XR{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}},rz=class{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){let n=e.getSize(new R);this._width=n.width,this._height=n.height,t=new zo(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:_i}),t.texture.name=`EffectComposer.rt1`}else this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name=`EffectComposer.rt2`,this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new ez(YR),this.copyPass.material.blending=0,this.timer=new of}swapBuffers(){let e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){let t=this.passes.indexOf(e);t!==-1&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t + + varying vec2 vUv; + + uniform sampler2D colorTexture; + uniform vec2 invSize; + uniform vec2 direction; + uniform float centerWeight; + uniform float gaussianOffsets[KERNEL_PAIRS]; + uniform float gaussianWeights[KERNEL_PAIRS]; + + void main() { + + vec3 diffuseSum = texture2D( colorTexture, vUv ).rgb * centerWeight; + + for ( int i = 0; i < KERNEL_PAIRS; i ++ ) { + + vec2 uvOffset = direction * invSize * gaussianOffsets[ i ]; + vec3 sample1 = texture2D( colorTexture, vUv + uvOffset ).rgb; + vec3 sample2 = texture2D( colorTexture, vUv - uvOffset ).rgb; + diffuseSum += ( sample1 + sample2 ) * gaussianWeights[ i ]; + + } + + gl_FragColor = vec4( diffuseSum, 1.0 ); + + }`})}_getCompositeMaterial(e){return new Wu({defines:{NUM_MIPS:e},uniforms:{blurTexture1:{value:null},blurTexture2:{value:null},blurTexture3:{value:null},blurTexture4:{value:null},blurTexture5:{value:null},bloomStrength:{value:1},bloomFactors:{value:null},bloomTintColors:{value:null},bloomRadius:{value:0}},vertexShader:` + + varying vec2 vUv; + + void main() { + + vUv = uv; + gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); + + }`,fragmentShader:` + + varying vec2 vUv; + + uniform sampler2D blurTexture1; + uniform sampler2D blurTexture2; + uniform sampler2D blurTexture3; + uniform sampler2D blurTexture4; + uniform sampler2D blurTexture5; + uniform float bloomStrength; + uniform float bloomRadius; + uniform float bloomFactors[NUM_MIPS]; + uniform vec3 bloomTintColors[NUM_MIPS]; + + float lerpBloomFactor( const in float factor ) { + + float mirrorFactor = 1.2 - factor; + return mix( factor, mirrorFactor, bloomRadius ); + + } + + void main() { + + // 3.0 for backwards compatibility with previous alpha-based intensity + vec3 bloom = 3.0 * bloomStrength * ( + lerpBloomFactor( bloomFactors[ 0 ] ) * bloomTintColors[ 0 ] * texture2D( blurTexture1, vUv ).rgb + + lerpBloomFactor( bloomFactors[ 1 ] ) * bloomTintColors[ 1 ] * texture2D( blurTexture2, vUv ).rgb + + lerpBloomFactor( bloomFactors[ 2 ] ) * bloomTintColors[ 2 ] * texture2D( blurTexture3, vUv ).rgb + + lerpBloomFactor( bloomFactors[ 3 ] ) * bloomTintColors[ 3 ] * texture2D( blurTexture4, vUv ).rgb + + lerpBloomFactor( bloomFactors[ 4 ] ) * bloomTintColors[ 4 ] * texture2D( blurTexture5, vUv ).rgb + ); + + float bloomAlpha = max( bloom.r, max( bloom.g, bloom.b ) ); + gl_FragColor = vec4( bloom, bloomAlpha ); + + }`})}};oz.BlurDirectionX=new R(1,0),oz.BlurDirectionY=new R(0,1);var sz={name:`OutputShader`,uniforms:{tDiffuse:{value:null},toneMappingExposure:{value:1}},vertexShader:` + precision highp float; + + uniform mat4 modelViewMatrix; + uniform mat4 projectionMatrix; + + attribute vec3 position; + attribute vec2 uv; + + varying vec2 vUv; + + void main() { + + vUv = uv; + gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); + + }`,fragmentShader:` + + precision highp float; + + uniform sampler2D tDiffuse; + + #include + #include + + varying vec2 vUv; + + void main() { + + gl_FragColor = texture2D( tDiffuse, vUv ); + + // tone mapping + + #ifdef LINEAR_TONE_MAPPING + + gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb ); + + #elif defined( REINHARD_TONE_MAPPING ) + + gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb ); + + #elif defined( CINEON_TONE_MAPPING ) + + gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb ); + + #elif defined( ACES_FILMIC_TONE_MAPPING ) + + gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb ); + + #elif defined( AGX_TONE_MAPPING ) + + gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb ); + + #elif defined( NEUTRAL_TONE_MAPPING ) + + gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb ); + + #elif defined( CUSTOM_TONE_MAPPING ) + + gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb ); + + #endif + + // color space + + #ifdef SRGB_TRANSFER + + gl_FragColor = sRGBTransferOETF( gl_FragColor ); + + #endif + + }`},cz=class extends XR{constructor(){super(),this.isOutputPass=!0,this.uniforms=Vu.clone(sz.uniforms),this.material=new Gu({name:sz.name,uniforms:this.uniforms,vertexShader:sz.vertexShader,fragmentShader:sz.fragmentShader}),this._fsQuad=new $R(this.material),this._outputColorSpace=null,this._toneMapping=null}render(e,t,n){this.uniforms.tDiffuse.value=n.texture,this.uniforms.toneMappingExposure.value=e.toneMappingExposure,(this._outputColorSpace!==e.outputColorSpace||this._toneMapping!==e.toneMapping)&&(this._outputColorSpace=e.outputColorSpace,this._toneMapping=e.toneMapping,this.material.defines={},Eo.getTransfer(this._outputColorSpace)===`srgb`&&(this.material.defines.SRGB_TRANSFER=``),this._toneMapping===1?this.material.defines.LINEAR_TONE_MAPPING=``:this._toneMapping===2?this.material.defines.REINHARD_TONE_MAPPING=``:this._toneMapping===3?this.material.defines.CINEON_TONE_MAPPING=``:this._toneMapping===4?this.material.defines.ACES_FILMIC_TONE_MAPPING=``:this._toneMapping===6?this.material.defines.AGX_TONE_MAPPING=``:this._toneMapping===7?this.material.defines.NEUTRAL_TONE_MAPPING=``:this._toneMapping===5&&(this.material.defines.CUSTOM_TONE_MAPPING=``),this.material.needsUpdate=!0),this.renderToScreen===!0?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this._fsQuad.render(e))}dispose(){this.material.dispose(),this._fsQuad.dispose()}},lz=70,uz=1e3,dz=f*2;function fz(e,t){return Math.max(65,100-Math.floor((uz-e)/30)-Math.floor(t/50))}function pz(e,t,n){if(e.action===null||!T(e.action,t.class))return!1;let r=e.action_startup_ticks+e.action_active_ticks+e.action_recovery_ticks;return n-e.action_start_tick0||e.clinch_startup_ticks>0||e.taunt_ticks>0||e.is_foul_recovery_target}function _z(e,t,n={x:0,y:0,speed:0},r=0){let i=Math.max(2,Math.floor(g*fz(e.conditioning,e.trauma.body)/100)),a=e.stunned_ticks-r,o=i;a>1?o=Math.max(2,Math.floor(i*ie/100)):a<=0&&(t.defense===`guard_high`||t.defense===`guard_low`)&&!Pe(e.injuries)&&(o=Math.max(2,Math.floor(i*lz/100))),o=Le(o*10*de(e.style).moveSpeedPercent,e.injuries)/1e3;let s=Math.hypot(t.moveX,t.moveY),c=s>1e3?1e3/s:1;return n.x=t.moveX*c*o/1e3,n.y=t.moveY*c*o/1e3,n.speed=o,n}function vz(e,t,n){return e.kind===`parry`&&e.target_id===t?Math.max(n,e.tick+e.amount):n}function yz(e,t,n){return e.kind===`defense`&&e.actor_id===t&&Mz(e.detail)?Math.max(n??e.tick,e.tick):n}function bz(e,t){if(e.stunned_ticks>0||e.action_id!==null&&e.action_id===t.cutActionId)return!0;let n=t.evasionFrom;if(n===void 0||e.action===null)return!1;let r=e.action_start_tick+e.action_startup_ticks+e.action_active_ticks;return n>=r&&n=n&&t0?Math.min((n.rootedUntil??0)-t,e.stunned_ticks)-1:0;return Math.max(r,i)}function Cz(e,t,n){if(!Mz(e.defense))return 0;let r=n.evasionFrom;return t===void 0||r===void 0||r>t?null:Math.max(0,r+y+de(e.style).evasionTicks-t-1)}function wz(e,t,n){if(e.queued_actions===0)return 1/0;if(t===void 0)return 0;if(e.action!==null&&!bz(e,n)){let n=e.action_start_tick+e.action_startup_ticks+e.action_active_ticks+e.action_recovery_ticks-t-1;if(n>0)return n}return Math.max(0,e.stunned_ticks)}function Tz(e,t,n,r,i={}){let a=Cz(e,r,i);if(n<=0||gz(e)||a===null)return{dx:0,dy:0};let o=Math.max(a,r===void 0?e.action===null?0:1/0:Sz(e,r,i)),s=wz(e,r,i),c=bz(e,i),l=(t,n)=>Math.min(n.share??1,r!==void 0&&!c&&xz(e,r+1+t)?v/100:1),u=e.velocity_x,d=e.velocity_y,f=0,p=0,m=Math.floor(n),h=n-m;for(let e=0;e=o&&er.speed*i&&(u=u/a*r.speed*i,d=d/a*r.speed*i),f+=u,p+=d}if(h>0){let e=m>=o&&m(e*(100-_)+t*_)/100,Dz=1e3,Oz=2.5,kz=class{history=[];offset={dx:0,dy:0};mean={x:0,y:0,speed:0,share:1};sample={x:0,y:0,speed:0};horizon=null;holds={rootedUntil:0,cutActionId:null,evasionFrom:void 0};observe(e,t){this.holds.rootedUntil=vz(e,t,this.holds.rootedUntil),this.holds.evasionFrom=yz(e,t,this.holds.evasionFrom)}update(e,t,n,r,i,a,o,s){for(this.history.push({at:r,held:n<=0?{...t,moveX:0,moveY:0}:t,share:n<=0?1:n});this.history.length>2&&this.history[1].at0&&e.action_id!==null&&(this.holds.cutActionId=e.action_id),e!==null){let t=1e3/s,n=this.horizon;c=Tz(e,i=>this.meanIntent(e,i,r-(n-1-i)*t,t),n,a,this.holds)}let l=Oz*g*s*o,u=c.dx-this.offset.dx,d=c.dy-this.offset.dy,f=Math.hypot(u,d),p=f>l?l/f:1;return this.offset.dx+=u*p,this.offset.dy+=d*p,{dx:this.offset.dx,dy:this.offset.dy}}meanIntent(e,t,n,r){let i=n-r/2,a=n+r/2,o=this.mean;o.x=0,o.y=0,o.speed=0,o.share=0;for(let n=0;nr?{x:i*(S-r),y:a*r}:m>n?{x:i*n,y:a*(S-n)}:{x:i*m,y:a*h}}function jz(e,t,n){let r=e.x+t.dx,i=e.y+t.dy;if(n!==null){let t=Math.min(dz,Math.hypot(e.x-n.x,e.y-n.y)),a=r-n.x,o=i-n.y,s=Math.hypot(a,o);s1e-9?(r=n.x+a/s*t,i=n.y+o/s*t):(r=e.x,i=e.y))}let a=Az(r,i);return{dx:a.x-e.x,dy:a.y-e.y}}function Mz(e){return e===`slip_left`||e===`slip_right`||e===`weave`||e===`pull`}function Nz(e,t,n,r=!1){return e.stunned_ticks>0||e.taunt_ticks>0||e.clinch_ticks>0?e.defense:n===null?Mz(e.defense)&&!r?e.defense:Pe(e.injuries)?`none`:t.defense:n}var Pz=class{kind=null;id=``;startsAt=0;endsAt=0;until=0;sequence=null;started=!1;press(e,t,n,r,i,a=y,o=n){this.kind=e,this.id=t,this.startsAt=o,this.endsAt=o+a*1e3/i,this.until=this.endsAt+Math.max(0,r)*1e3/i,this.sequence=null,this.started=!1}acknowledge(e,t,n){if(this.kind===null)return!1;this.sequence??=n?.(this.id)??null,e.defense===this.kind&&(this.started=!0);let r=!t||e.stunned_ticks>0||e.clinch_ticks>0,i=!this.started&&this.sequence!==null&&e.last_input_sequence>=this.sequence&&e.queued_actions===0;return(r||i)&&(this.kind=null),i}pose(e){return this.kind!==null&&e>=this.until&&(this.kind=null),this.kind!==null&&e>=this.startsAt&&e=this.startsAt&&e=this.startsAt&&e=this.startsAt?!1:(this.kind=null,!0)}},Fz=[{radius:8.2,y:-.55,count:120,scale:1},{radius:10.6,y:.35,count:150,scale:1.04},{radius:13.2,y:1.35,count:180,scale:1.08},{radius:16,y:2.45,count:210,scale:1.12}],Iz=.95,Lz=.42,Rz=[3819104,5915960,3493980,6963002,4612159,5524835,7233348,9076852,4678266,7620714,10107450,11843778,3104688,11573822,2303534,2303534],zz=[13081462,9067067,7225640,14726287,5517341,11105359],Bz=[1380364,2759442,4862496,7035464,9341572,11569742],Vz=.9,Hz=.235,Uz=-.35,Wz=.32,Gz=.26,Kz=6.2;function qz(e,t,n=Kz){return t>0&&Math.hypot(e,t)>n&&Math.abs(Math.atan2(e,t))<.3}var Jz=` +#ifdef USE_INSTANCING + vec4 crowdWorld = modelMatrix * instanceMatrix * vec4(transformed, 1.0); +#else + vec4 crowdWorld = modelMatrix * vec4(transformed, 1.0); +#endif +vCrowdLight = vec3(-crowdWorld.x, ${7.5.toFixed(1)} - crowdWorld.y, -crowdWorld.z); +`,Yz=` +#ifdef USE_COLOR + totalEmissiveRadiance *= vColor.rgb * (0.22 + 0.78 * max(0.0, dot(inverseTransformDirection(normal, viewMatrix), normalize(vCrowdLight)))); +#endif +`,Xz=(e,t,n)=>{let r=Math.min(1,Math.max(0,(n-e)/(t-e)));return r*r*(3-2*r)};function Zz(e,t){let n=[];for(let[r,i]of e.entries())for(let e=0;e0&&Math.abs(Math.atan2(s,c))<.3})}return n}function Qz(e,t,n,r={rise:0,armLeft:0,armRight:0,sway:0}){let i=.2+.7*(1-e.keen),a=Xz(i-.12,i+.12,n),o=Math.abs(Math.sin(t*(2.3+n*3.2)+e.phase*1.7))*(.02+.1*a),s=Math.sin(t*6.2+e.phase)*.32*a,c=Uz+-2.35*a;return r.rise=a*Wz+o,r.armLeft=c+s,r.armRight=c-s*.8,r.sway=Math.sin(t*1.6+e.phase)*(.04+n*.05),r}function $z(e){let t=Jh(e,!1);for(let t of e)t.dispose();if(t===null)throw Error(`crowd geometry could not be merged`);return t}function eB(){let e=new Yl(.16,.28,2,8);e.scale(1.35,1,.8),e.translate(0,.64,0);let t=new Yl(.078,.3,1,5);t.rotateZ(Math.PI/2),t.translate(0,.89,0);let n=new Yl(.11,.26,1,5);return n.rotateX(Math.PI/2),n.scale(1.7,1,1),n.translate(0,.4,.17),$z([e,t,n])}function tB(){let e=new Mu(.105,10,6);e.rotateY(-Math.PI/2),e.scale(.92,1.12,1),e.translate(0,1.12,.01);let t=new Zl(.048,.056,.1,5,1,!0);t.translate(0,.99,0);let n=t.getAttribute(`uv`);for(let e=0;e{e.vertexShader=e.vertexShader.replace(`#include `,`#include +varying vec3 vCrowdLight;`).replace(`#include `,`#include \n${Jz}`),e.fragmentShader=e.fragmentShader.replace(`#include `,`#include +varying vec3 vCrowdLight;`).replace(`#include `,`#include \n${Yz}`)},e.customProgramCacheKey=()=>`hands-crowd`;let u=new Ku({color:724501,roughness:.96,metalness:0,side:2}),d=new _l(o[0],s,i),f=new _l(o[1],c,i),p=new _l(o[2],l,i),m=new _l(o[3],s,i),h=new _l(o[3],s,i),g=[d,f,p,m,h],_=[d,f,p];for(let e of g)e.instanceMatrix.setUsage(Aa),e.frustumCulled=!1;let v=new B;for(let t=0;t.12&&v.setHex(Bz[Math.floor(e()*Bz.length)]).multiplyScalar((.8+e()*.4)*n),p.setColorAt(t,v)}for(let e of g)e.instanceColor.needsUpdate=!0;let y=new V(o[4],u);y.name=`stands`,y.receiveShadow=!1,n.add(y,...g);let b=new z(0,1,0),x=new z,S=new vo,C=new z,w=new Ho,T=new Ho,E=new Ho,D=new Ho,O={rise:0,armLeft:0,armRight:0,sway:0},k=(e,t,n,r)=>{E.makeTranslation(n*Hz,Vz,0),D.makeRotationX(r),T.multiplyMatrices(w,E).multiply(D),e.setMatrixAt(t,T)},A=0,j=!1,ee=!1,M=!1,te=0,ne=0,re=r.flatMap((e,t)=>e.platform?[t]:[]),ie=new Ho().makeScale(0,0,0),ae=(e,t)=>{let n=r[e];if(M&&n.platform)for(let n of t?g:_)n.setMatrixAt(e,ie);else Qz(n,te,ne,O),S.setFromAxisAngle(b,n.yaw+O.sway),w.compose(x.set(n.x,n.y+O.rise*n.scale,n.z),S,C.setScalar(n.scale)),d.setMatrixAt(e,w),f.setMatrixAt(e,w),p.setMatrixAt(e,w),t&&(k(m,e,1,O.armLeft),k(h,e,-1,O.armRight))},oe=(e,t,n=!1)=>{let r=n||ee;ee=!1;let a=r?1:j?4:2,o=Math.ceil(i/a),s=A%a*o,c=Math.min(i,s+o);A+=1,te=e,ne=t;let l=!j||r;for(let e=s;e{e!==j&&(j=e,m.visible=!e,h.visible=!e,e||(ee=!0))},makeRoomForCamera:e=>{let t=qz(e.x,e.z,M?5.9:Kz);if(t!==M){M=t;for(let e of re)ae(e,!0);for(let e of g)e.instanceMatrix.clearUpdateRanges(),e.instanceMatrix.needsUpdate=!0}},dispose:()=>{for(let e of o)e.dispose();for(let e of[s,c,l,u])e.dispose();a.dispose();for(let e of g)e.dispose()}}}var sB=.3,cB=.012,lB=e=>()=>(e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296);function uB(){let e=new gs;e.name=`arena`;let t=[],n=[],r=[],i=new Ku({color:`#05070c`,roughness:.95});n.push(i);let a=new Xl(30,40);t.push(a);let o=new V(a,i);o.rotation.x=-Math.PI/2,o.position.y=-1,o.receiveShadow=!0,e.add(o);let s=lB(20260727),c=Fz,l=oB(s);e.add(l.group);let u=document.createElement(`canvas`);u.width=1024,u.height=64;let d=u.getContext(`2d`);d!==null&&(d.fillStyle=`#070c1a`,d.fillRect(0,0,1024,64),d.fillStyle=`#13203f`,d.fillRect(0,0,1024,5),d.fillRect(0,59,1024,5),d.textBaseline=`middle`,d.font=`800 38px Inter, system-ui, sans-serif`,d.fillStyle=`#e9c46a`,d.fillText(`H A N D S`,28,33),d.fillStyle=`#c9d6f2`,d.font=`600 26px Inter, system-ui, sans-serif`,d.fillText(`CHAMPIONSHIP BOXING`,300,34),d.fillStyle=`#e9c46a`,d.font=`800 30px Inter, system-ui, sans-serif`,d.fillText(`FIGHT NIGHT`,700,34),d.fillStyle=`#b91c1c`,d.fillRect(948,22,22,22),d.fillStyle=`#1d4ed8`,d.fillRect(978,22,22,22));let f=new Wl(u);f.colorSpace=wa,f.wrapS=ti,f.repeat.set(-6,1),r.push(f);let p=new Pc({map:f,side:1});n.push(p);let m=c[0].y+Lz,h=new Zl(c[0].radius-Iz-.03,c[0].radius-Iz-.03,m- -1-.04,72,1,!0);t.push(h);let g=new V(h,p);g.name=`boards`,g.position.y=(m+-1)/2+.02,e.add(g);let _=new Float32Array(270);for(let e=0;e<90;e+=1){let t=c[Math.floor(s()*c.length)],n=s()*Math.PI*2;_[e*3]=Math.sin(n)*t.radius,_[e*3+1]=t.y+.9+s()*.5,_[e*3+2]=Math.cos(n)*t.radius}let v=new yc;v.setAttribute(`position`,new ic(_,3)),t.push(v);let y=new Il({color:13623551,size:.09,transparent:!0,opacity:0,blending:2,depthWrite:!1});n.push(y);let b=new Vl(v,y);e.add(b);let x=new Ku({color:`#11151d`,roughness:.6,metalness:.4});n.push(x);let S=new Ku({color:`#1a2230`,emissive:`#dfe9ff`,emissiveIntensity:1.1,roughness:.4});n.push(S);let C=new Pc({color:`#a8c4ff`,transparent:!0,opacity:.006,blending:2,depthWrite:!1,side:2});n.push(C);let w=new Jl(9,.18,.18);t.push(w);let T=new Zl(.09,.14,.22,10);t.push(T);let E=new Ql(1.7,6.6,20,1,!0);t.push(E);for(let t=0;t<2;t+=1){let n=new V(w,x);n.position.set(0,7.6,t===0?-1.6:1.6),e.add(n);for(let t=0;t<5;t+=1){let r=-3.6+t*1.8,i=new V(T,S);i.position.set(r,7.45,n.position.z),e.add(i);let a=new V(E,C);a.position.set(r,4.1,n.position.z*.4),e.add(a)}}let D=new Ku({color:`#070a12`,roughness:1});n.push(D);let O=new Zl(24,24,14,32,1,!0);t.push(O);let k=new V(O,D);k.position.y=5,k.material.side=1,e.add(k);let A=document.createElement(`canvas`);A.width=512,A.height=256;let j=A.getContext(`2d`);j!==null&&(j.fillStyle=`#04060c`,j.fillRect(0,0,512,256),j.strokeStyle=`#f1cc72`,j.lineWidth=6,j.strokeRect(14,14,484,228),j.fillStyle=`#f1cc72`,j.font=`800 84px Inter, system-ui, sans-serif`,j.textAlign=`center`,j.textBaseline=`middle`,j.fillText(`H A N D S`,256,104),j.fillStyle=`#8fa3c8`,j.font=`600 30px Inter, system-ui, sans-serif`,j.fillText(`CHAMPIONSHIP BOXING`,256,186));let ee=new Wl(A);ee.colorSpace=wa;let M=new Pc({map:ee});n.push(M);let te=new Jl(4.6,2.3,.3);t.push(te);let ne=new V(te,M);ne.position.set(0,6.4,-14.5),e.add(ne);let re=new V(te,x);re.position.set(0,6.4,-14.65),e.add(re),r.push(ee);let ie=0,ae=0,oe=0,se=!1;return{group:e,update:(e,t,n)=>{oe=Math.max(0,oe-t*sB),n&&!se&&l.update(0,0,!0),se=n,n||(l.update(e,oe),f.offset.x=e*cB%1,ie-=t,ie<=0&&(ae=.09+Math.random()*.08,ie=(.25+Math.random()*1.6)/(1+oe*4)),ae=Math.max(0,ae-t),y.opacity=ae>0?.85:0)},excite:e=>{oe=Math.min(1,oe+Math.max(0,e))},excitement:()=>oe,setLowTier:l.setLowTier,makeRoomForCamera:l.makeRoomForCamera,dispose:()=>{for(let e of t)e.dispose();for(let e of n)e.dispose();for(let e of r)e.dispose();l.dispose()}}}var dB=2.05,fB=5.5,pB=1.05,mB=1.78,hB=3.75,gB=.85,_B=.45,vB=1.18,yB=2.5,bB=5.5;function xB(e,t,n){return e<2.5||t<3?null:(n+Math.floor((e-yB)/bB))%2}function SB(e){return Math.max(0,e-yB)%bB}var CB=.95,wB=2.6,TB=-25;function EB(e,t,n,r,i){let a=e===0?-1:1,o=r*Math.PI/180,s=-a*Math.SQRT1_2,c=a*Math.SQRT1_2,l=s*Math.cos(o)+c*Math.sin(o),u=-s*Math.sin(o)+c*Math.cos(o);return i.set(a*t+l*n,0,-a*t+u*n)}function DB(e,t,n,r,i){EB(e,t,wB,TB+Math.min(1,n/bB)*5,r).setY(1.45),EB(e,t,.62,27,i).setY(1.05)}var OB={top:2.42,bottom:.95,width:2.4};function kB(e,t,n,r=.09){let i=Math.max(.2,1-n-r),a=Math.max((OB.top-OB.bottom)/i,OB.width/Math.max(.1,e)),o=(OB.top+OB.bottom)/2;return{distance:a/(2*Math.tan(L.degToRad(t)/2)),height:o-(.5-(r+i/2))*a}}var AB=class{current=new z(0,dB,fB);look=new z(0,pB,0);swayPhase=0;update(e,t,n,r,i,a,o,s,c=!1,l=null){this.swayPhase+=e;let u=a&&l!==null?gB:0,d=(n.x+r.x)/2+((l?.x??0)-(n.x+r.x)/2)*u,f=(n.z+r.z)/2+((l?.z??0)-(n.z+r.z)/2)*u,p=L.clamp(d,-1.4,1.4),m=L.clamp(f,-1.1,1.1),h=c?L.clamp(hB+i*.45-(a?.6:0),3.3,5.6):L.clamp(fB+i*.6-(a?.9:0),4.6,8.4),g=(c?mB:dB)+i*.08-(a?.45:0),_=s?0:Math.sin(this.swayPhase*.21)*.35,v=s?0:Math.sin(this.swayPhase*.13)*.3,y=p*.32+_,b=h+m*.2,x=g+v*.2;if(this.current.x+=(y-this.current.x)*(1-Math.exp(-2.6*e)),this.current.y+=(x-this.current.y)*(1-Math.exp(-2.6*e)),this.current.z+=(b-this.current.z)*(1-Math.exp(-2.6*e)),this.look.x+=(p-this.look.x)*(1-Math.exp(-3.2*e)),this.look.y+=((a?u>0?_B:.7:c?vB:pB)-this.look.y)*(1-Math.exp(-3.2*e)),this.look.z+=(m*.6-this.look.z)*(1-Math.exp(-3.2*e)),!s&&o>5e-4){let e=t*61;this.current.x+=Math.sin(e*1.31)*o,this.current.y+=Math.cos(e*1.97)*o*.6,this.look.x+=Math.sin(e*1.53)*o*.5,this.look.y+=Math.cos(e*2.11)*o*.35}return{position:this.current,lookAt:this.look}}},jB=2.45,MB=2.25,NB=1.35,PB=3.5,FB=1.25,IB=.45;function LB(e,t,n,r,i,a,o=31){let s=L.degToRad(o),c=Math.cos(s)*jB,l=Math.sin(s)*jB,u=-r,d=n,f=-n*c+u*l,p=-r*c+d*l,m=(e,t)=>Math.abs(t)<1e-9?1:L.clamp((Math.sign(t)*PB-e)/t,0,1),h=Math.min(m(e.x,f),m(e.z,p));i.set(L.clamp(e.x+f*h,-3.5,PB),MB,L.clamp(e.z+p*h,-3.5,PB)),a.set(t.x,NB,t.z)}var RB=class{angle=Math.PI;closeness=0;initialised=!1;target=new z;position=new z;look=new z;aim=new z;get forwardX(){return Math.sin(this.angle)}get forwardZ(){return Math.cos(this.angle)}reset(){this.initialised=!1}update(e,t,n,r,i,a,o=16/9){let s=r.x-n.x,c=r.z-n.z,l=Math.hypot(s,c),u=l>.05?Math.atan2(s,c):this.angle,d=L.clamp((1.3-l)/.8,0,1);if(!this.initialised)this.angle=u,this.closeness=d;else{let t=Math.atan2(Math.sin(u-this.angle),Math.cos(u-this.angle));this.angle+=t*(1-Math.exp(-4.5*e)),this.closeness+=(d-this.closeness)*(1-Math.exp(-3*e))}let f=L.clamp(o,IB,1);if(LB(n,r,this.forwardX,this.forwardZ,this.target,this.aim,L.lerp(31,60,this.closeness)*f),!this.initialised)this.position.copy(this.target),this.look.copy(this.aim),this.initialised=!0;else{let t=1-Math.exp(-10*e);this.position.lerp(this.target,t),this.look.lerp(this.aim,t)}let p={position:this.position,lookAt:this.look,tight:!0};if(a||i<=5e-4)return p;let m=t*61;return this.target.set(this.position.x+Math.sin(m*1.31)*i,this.position.y+Math.cos(m*1.97)*i*.6,this.position.z),this.aim.set(this.look.x+Math.sin(m*1.53)*i*.5,this.look.y+Math.cos(m*2.11)*i*.35,this.look.z),{position:this.target,lookAt:this.aim,tight:!0}}},zB=54,BB=136,VB=110,HB=168,UB=400,WB=74,GB=72,KB={right:220,wideTop:64,compactTop:120,height:34},qB=200,JB={reach:192,bottom:80},YB=`rgba(3,6,12,0.86)`,XB=`rgb(4,7,13)`,ZB={play:`#f6d57a`,colour:`#9ec7ff`,announcer:`#f6d57a`},QB=[`#4f86d9`,`#d9483c`],$B=`Inter, system-ui, sans-serif`;function eV(e){let{width:t,height:n}=e,r=t<640,i=n<480,a=i?.78:r?.85:1,o=Math.min(680,t-24),s=e.resultTop,c=s===null&&e.touch&&e.phase!==`complete`,l=nr(t,n,c);if(c&&e.paused===!0&&e.phase===`countdown`)return null;if(s===null&&e.phase===`countdown`){let e=l.x+l.width/2,r=t-(c&&t>n?er(t,n,l.y+l.height):12);return{x:e,y:l.y,maxWidth:Math.min(o,2*Math.min(e-12,r-e)),anchor:`top`,scale:a,cover:{width:l.width,height:l.height}}}let u=t-384;if(s===null&&!e.touch&&!i&&u>=UB){let r=n-(e.hint?HB:VB),i=e.cornerPanelTop===void 0||e.cornerPanelTop===null?r:Math.min(r,e.cornerPanelTop-8);if(i-WB*a>=n*.45)return{x:t/2,y:i,maxWidth:Math.min(o,u),anchor:`bottom`,scale:a,cover:null}}if(s===null&&e.viewerDown)return null;let d=s===null&&r?BB:zB;s===null&&(e.phase===`rest`||e.phase===`foul_recovery`||c&&e.paused===!0?d=Math.max(d,l.y+l.height+8):e.phase===`knockdown`?d=Math.max(d,gr(n,r)+GB):e.phase===`finish`&&(d=Math.max(d,Er(t,n,c).bottom+8+(c?0:59))),e.replay&&t/2-o/2f)return null;let p=c&&e.lag===!0&&!r&&!e.replay&&dMath.round(8*e)+Math.round(10*e)+Math.round(4*e)+2*Math.round(Math.round(17*e)*1.3)+Math.round(5*e);function nV(e,t,n,r){let i=r?1:t.opacity;if(i<=.01)return;let a=r||n.cover!==null?0:t.entering*8*(n.anchor===`bottom`?1:-1);e.save(),e.globalAlpha=i,e.textBaseline=`alphabetic`;let o=i*i;t.line.card===null?aV(e,t.line,n,a,o):sV(e,t.line.card,n,a,o),e.restore()}function rV(e,t,n){if(e.measureText(t).width<=n)return t;let r=t;for(;r.length>1&&e.measureText(`${r}…`).width>n;)r=r.slice(0,-1);return`${r}…`}function iV(e,t){let n=e.length/2,r=null,i=1/0;for(let a=e.indexOf(` `);a>=0;a=e.indexOf(` `,a+1)){let o=e.slice(0,a),s=e.slice(a+1),c=Math.abs(a-n);t(o)&&t(s)&&c0?[e.slice(0,a),e.slice(a+1)]:[e,``]}function aV(e,t,n,r,i){let a=n.scale,o=Math.round(14*a),s=Math.round(10*a),c=n.maxWidth-o*2-4,l=(t,n)=>(e.font=`700 ${n}px ${$B}`,e.measureText(t).width),u=dn(e=>l(t.text,e),c,Math.round(17*a),Math.round(13*a)),d=l(t.text,u)<=c?[t.text]:iV(t.text,e=>l(e,u)<=c).filter(e=>e.length>0),f=Math.max(...d.map(e=>Math.min(c,l(e,u)))),p=JL[t.speaker];e.font=`800 ${s}px ${$B}`;let m=e.measureText(p).width,h=Math.min(n.maxWidth,Math.max(f,m)+o*2+4),g=Math.round(u*1.3),_=Math.round(8*a)+s,v=_+Math.round(4*a)+d.length*g+Math.round(5*a),y=(n.anchor===`bottom`?n.y-v:n.y)+r,b=n.x-h/2,x=ZB[t.speaker];e.fillStyle=YB,e.fillRect(b,y,h,v),e.fillStyle=x,e.fillRect(b,y,4,v),e.globalAlpha=i,e.textAlign=`left`,e.font=`800 ${s}px ${$B}`,e.fillText(p,b+4+o,y+_),e.fillStyle=`#f6f7fb`,e.font=`700 ${u}px ${$B}`,d.forEach((t,n)=>e.fillText(rV(e,t,c),b+4+o,y+_+Math.round(4*a)+g*(n+1)-Math.round(u*.28)))}function oV(e,t,n){let r=Math.round(11*e),i=Math.round(28*e),a=Math.round(6*e),o={pad:Math.round(10*e),gap:Math.round(7*e)},s={pad:Math.max(4,Math.round(6*e)),gap:Math.max(3,Math.round(4*e))},c=t?Math.round(10*e):0,l=[{...o,detail:c},{...s,detail:c},{...s,detail:0}],u=(e,t)=>e.pad*2+r+e.gap+t+(e.detail===0?0:a+e.detail);for(let e of l)if(n===null||u(e,i)<=n)return{kicker:r,title:i,...e,height:u(e,i)};let d=l[2],f=Math.max(12,Math.min(i,(n??1/0)-u(d,0)));return{kicker:r,title:f,...d,height:u(d,f)}}function sV(e,t,n,r,i){let a=n.scale,o=Math.round(18*a),s=n.maxWidth-o*2,c=oV(a,t.detail.length>0,n.cover?.height??null),l=c.kicker,u=c.detail,d=(t,n,r)=>(e.font=`${n} ${r}px ${$B}`,e.measureText(t).width),f=dn(e=>d(t.title,900,e),s,c.title,Math.min(c.title,Math.round(15*a))),p=Math.max(d(t.kicker,800,l),Math.min(s,d(t.title,900,f)),u===0?0:d(t.detail,700,u)),m=Math.min(n.maxWidth,Math.max(240*a,p+o*2,n.cover?.width??0)),h=c.pad+l+c.gap+f+(u===0?0:Math.round(6*a)+u)+c.pad,g=Math.max(h,n.cover?.height??0),_=(n.anchor===`bottom`?n.y-g:n.y)+r,v=n.x-m/2,y=t.corner===null?ZB.announcer:QB[t.corner];e.fillStyle=n.cover===null?YB:XB,e.fillRect(v,_,m,g),e.fillStyle=y,e.fillRect(v,_,m,3),e.globalAlpha=i,e.textAlign=`center`;let b=_+(g-h)/2+c.pad+l;e.font=`800 ${l}px ${$B}`,e.fillText(rV(e,t.kicker,s),n.x,b),b+=c.gap+f,e.fillStyle=`#ffffff`,e.font=`900 ${f}px ${$B}`,e.fillText(rV(e,t.title,s),n.x,b-Math.round(f*.12)),u>0&&(b+=Math.round(6*a)+u,e.fillStyle=`#93a3bd`,e.font=`700 ${u}px ${$B}`,e.fillText(rV(e,t.detail,s),n.x,b))}var cV={broken_nose:[`nose`,.3],broken_jaw:[`mouth`,.25],jaw_torn:[`mouth`,.75],eye_left_out:[`eye_left`,.3],eye_right_out:[`eye_right`,.3],ear_left_torn:[`ear_left`,.3],ear_right_torn:[`ear_right`,.3],skull_fractured:[`skull`,.4],arm_left_broken:[`elbow_left`,.3],arm_right_broken:[`elbow_right`,.3],forearm_left_severed:[`elbow_left`,1],forearm_right_severed:[`elbow_right`,1],arm_left_torn:[`shoulder_left`,1],arm_right_torn:[`shoulder_right`,1],ribs_left_broken:[`ribs_left`,.15],ribs_right_broken:[`ribs_right`,.15],disemboweled:[`belly`,.6],knee_left_blown:[`knee_left`,.2],knee_right_blown:[`knee_right`,.2]},lV=new Map(_e.map(e=>[e,[]]));for(let[e,[t,n]]of Object.entries(cV))lV.get(t).push([e,n]);var uV=new Set([`nose`,`mouth`,`eye_left`,`eye_right`,`ear_left`,`ear_right`,`skull`]),dV=new Set([`waist`,`crotch`,`knee_left`,`knee_right`]),fV=1.5,pV=8,mV=.9,hV=18,gV=36,_V=.45,vV=.25,yV=.3,bV=.08,xV=.012,SV=[`ankleL`,`ankleR`],CV=[`toeL`,`toeR`],wV=.35,TV=.05,EV=.5,DV=.3,OV=.4,kV=2.2,AV=.12,jV=4e-4,MV=.4,NV=.6,PV=4,FV=1.1,IV=1/500,LV=.18,RV=.55,zV=.45,BV=.5,VV=.08,HV=[`gloveL`,`gloveR`],UV={bottom:80,top:108,half:17},WV=70,GV=2,KV=7,qV=.5,JV=.28,YV=[`left`,`right`],XV={left:`eye_left_out`,right:`eye_right_out`},ZV={left:`eye_left`,right:`eye_right`},QV={left:[`forearm_left_severed`,`arm_left_torn`],right:[`forearm_right_severed`,`arm_right_torn`]},$V=[`head`,`arm_left`,`arm_right`,`leg_left`,`leg_right`,`torso`],eH={head:[`neck`,`neck`],jaw:[`mouth`,`head`],forearm_left:[`elbow_left`,`elbowL`],forearm_right:[`elbow_right`,`elbowR`],arm_left:[`shoulder_left`,`shoulderL`],arm_right:[`shoulder_right`,`shoulderR`],leg_left:[`knee_left`,`kneeL`],leg_right:[`knee_right`,`kneeR`],upper_body:[`waist`,`hips`],torso:[`chest`,`upperChest`]},tH=Object.keys(eH),nH={head:[`head`],jaw:[`head`],forearm_left:[`body`,`glove_left`],forearm_right:[`body`,`glove_right`],arm_left:[`body`,`glove_left`],arm_right:[`body`,`glove_right`],leg_left:[`body`,`shoes`],leg_right:[`body`,`shoes`],upper_body:[`head`,`body`,`glove_left`,`glove_right`],torso:[`body`,`pants`]},rH=new z(0,1,0),iH=new z(0,.12,.02),aH=class{effects;bake;bodies=[null,null];position=new z;axis=new z;scratch=new z;turn=new vo;matrix=new Ho;skullOffset=new z;injuries=new Set;time=0;settings={blood:`full`,reducedMotion:!1};xray=new lk;constructor(e,t){this.effects=e,this.bake=t,e.scene.add(this.xray.root)}attach(e,t){this.bodies[e]?.mutilation.dispose(),this.xray.prepare(t.boxer);let n={graph:t,mutilation:new xO(t.boxer),shown:new Set,early:new Map,awaited:new Map,inflicted:new Set,fatalWounds:new Map,forced:new Set,fatalParts:[],burst:new Set,fatality:null,dead:null,gutsDropAt:null,gibbed:!1,vomitUntil:0,printed:[new z,new z],dragged:new z,sliding:!1,broke:null,spatter:0,lost:0,dripIn:0,dripped:0,diedAt:0,voided:!1};return this.bodies[e]=n,n.mutilation}get graphic(){return this.settings.blood===`full`&&!this.settings.reducedMotion}expect(e,t){let n=this.bodies[e];n!=null&&!n.inflicted.has(t)&&n.awaited.set(t,this.time+pV)}sync(e,t,n,r,i,a=!1){this.time=i,this.settings=n;let o=this.bodies[e];if(o==null)return;let s=this.graphic;!s&&(o.gibbed||o.fatalParts.length>0||o.fatalWounds.size>0||o.forced.size>0)&&this.unmaim(o,e);let c=this.injuries;c.clear();let l=!1;for(let e of t.injuries){let t=o.awaited.get(e);if(t!==void 0){if(i<=t){l=!0;continue}o.awaited.delete(e)}c.add(e),o.early.delete(e),o.inflicted.add(e)}for(let[e,t]of o.early)i>t?o.early.delete(e):c.add(e);for(let e of o.forced)c.add(e);if(l)for(let e of o.shown)c.add(e);o.shown.clear();for(let e of c)o.shown.add(e);for(let e of o.inflicted)o.shown.has(e)||o.inflicted.delete(e);let u=o.graph.boxer,d=L.clamp(1-t.blood_volume/be,0,1);if(o.mutilation.apply(o.shown,s?`full`:n.blood===`off`?`off`:`reduced`),o.mutilation.setPallor(n.blood===`off`?0:d),o.graph.setInjuries(o.shown,s),o.graph.setFaint(o.dead===null?L.clamp((.6-t.blood_volume/be)/.6,0,1):0),o.dead!==null&&!o.graph.isDead&&o.graph.die(o.dead),o.mutilation.update(r,i),this.xray.owner===e&&(s&&!o.gibbed?this.xray.update(r):this.xray.stop()),u.root.visible=!o.gibbed,o.gibbed)return;this.wear(o,e,d,r);let f=o.mutilation.isPartGone(`upper_body`),p=f||u.isDecapitated,m=p||u.isHeadBurst,h=1-.65*d,g=0;for(let t of _e){let n=o.fatalWounds.get(t)??0,r=`blood`,c=lV.get(t);for(let e=0;e0&&o.mutilation.anchor(t,this.position,this.axis)&&this.effects.anchorWound(e,t,this.position,this.axis)}for(let t=0;t=o.gutsDropAt&&(o.gutsDropAt=null,this.effects.dropGuts(e)),this.effects.anchorGuts(e,this.position,this.axis)):this.effects.gutsOut(e)&&this.effects.clearGuts(e),i=vV&&this.track(o,Math.min(1,g)),o.dead===null||!o.mutilation.anchor(`waist`,this.position,this.axis))return;this.effects.setCorpse(e,s?this.position:null);let v=s&&this.position.yEV?o.dragged.copy(this.position):y>TV&&(this.effects.smear(o.dragged.x,o.dragged.z,this.position.x,this.position.z,DV),o.dragged.copy(this.position)),o.sliding=v}gibbed(e){return this.bodies[e]?.gibbed===!0}hasGlove(e,t){let n=this.bodies[e]?.shown;return n===void 0||!this.graphic||!(n.has(QV[t][0])||n.has(QV[t][1]))}wear(e,t,n,r){let i=e.graph.boxer,a=this.graphic,o=this.bodies[1-t]??null;e.lost=n;let s=o===null?0:o.lost*kV+o.shown.size*AV,c=a?Math.min(1,Math.max(e.spatter,s)):0;i.headInjury.setSpatter(c*.8),i.bodyInjury.setSpatter(c),i.setGloveBlood(Math.max(i.gloveBloodLevel,c)),i.setTrunksBlood(Math.max(i.trunksBloodLevel,c*.7));let l=this.settings.blood===`off`?1:NV+Math.min(FV,n*PV);if(i.headInjury.setRun(l),i.bodyInjury.setRun(l),this.settings.blood===`off`&&(i.headInjury.clearMarks(),i.bodyInjury.clearMarks()),!a||e.dead!==null||i.gloveBloodLevel0))return;e.dripIn=BV/i.gloveBloodLevel,e.dripped+=1;let u=e.dripped%2;this.hasGlove(t,YV[u])&&(i.rig.bones[HV[u]].getWorldPosition(this.position),this.position.y-=VV,this.effects.shed(this.position,t*4099+e.dripped))}land(e,t,n,r,i,a,o,s=0,c=1){let l=this.bodies[t]??null,u=this.bodies[e]??null;if(l!==null&&n!==null&&this.hasGlove(t,n)?l.graph.boxer.rig.bones[HV[n===`left`?0:1]].getWorldPosition(this.scratch):this.scratch.copy(o),this.bruise(e,this.scratch,r,i),this.graphic&&(a>0&&l!==null&&(l.spatter=Math.min(1,l.spatter+a*jV)),a>0&&u!==null&&(u.spatter=Math.min(1,u.spatter+a*jV*MV)),!(u===null||u.gibbed))){for(let t=0;t<_e.length;t+=1){let n=_e[t],i=this.effects.woundStrength(e,n);i<=0||(r===`head`?!uV.has(n):uV.has(n)||dV.has(n))||u.mutilation.anchor(n,this.position,this.axis)&&this.effects.sprayFluid(`blood`,this.position,c,Math.round(WV*i),s+t+1,.8)}r===`head`&&u.shown.has(`broken_jaw`)&&u.mutilation.anchor(`mouth`,this.position,this.axis)&&this.effects.spawnTeeth(this.position,c,GV,s)}}bruise(e,t,n,r){let i=this.bodies[e];if(i==null||i.gibbed||this.settings.blood===`off`)return;let a=i.graph.boxer,o=n===`head`?a.headMesh:wD(a,`body`);if(o===null||!i.mutilation.skinMatrix(n,n===`head`?`head`:`chest`,this.matrix))return;let s=this.position.copy(t).applyMatrix4(this.matrix.invert()),c=o.geometry.getAttribute(`position`),l=1/0,u=-1;for(let e=0;eUV.top||Math.abs(t)>UV.half))continue;let i=(t-s.x)**2+(r-s.y)**2+(c.getZ(e)-s.z)**2;ia.mutilation.anchor(e,c,l);switch(t){case`broken_nose`:d(`nose`)&&s.sprayFluid(`blood`,c,r,140,n,1.1);break;case`broken_jaw`:d(`mouth`)&&(s.spawnTeeth(c,r,5,n),s.sprayFluid(`blood`,c,r,180,n));break;case`jaw_torn`:d(`mouth`)&&(this.fling(a,e,`jaw`,n,r,{radius:.05,speed:1.2,lift:.8}),s.spawnDebris(`jawbone`,c,r,1,n,1.2),s.spawnTeeth(c,r,9,n),s.sprayFluid(`blood`,c,r,420,n,1.2));break;case`eye_left_out`:case`eye_right_out`:d(`eye_${u}`)&&(s.gougeEye(e,c,l,r,n,u),s.sprayFluid(`blood`,c,r,120,n));break;case`ear_left_torn`:case`ear_right_torn`:d(`ear_${u}`)&&(s.spawnDebris(`ear`,c,r,1,n),s.sprayFluid(`blood`,c,r,130,n));break;case`face_left_flayed`:case`face_right_flayed`:d(`eye_${u}`)&&(s.spawnDebris(`skin`,c,r,3,n),s.sprayFluid(`blood`,c,r,260,n));break;case`skull_fractured`:d(`skull`)&&(s.spawnDebris(`shard`,c,r,7,n,1.2),s.spawnDebris(`brain`,c,r,8,n),s.sprayFluid(`blood`,c,r,300,n,1.3),s.sprayFluid(`brain`,c,r,90,n));break;case`shoulder_left_dislocated`:case`shoulder_right_dislocated`:break;case`arm_left_broken`:case`arm_right_broken`:d(`elbow_${u}`)&&(s.spawnDebris(`bone`,c,r,3,n),s.sprayFluid(`blood`,c,r,200,n));break;case`forearm_left_severed`:case`forearm_right_severed`:this.fling(a,e,`forearm_${u}`,n,r,{radius:.07,speed:1.1}),d(`elbow_${u}`)&&(s.spawnDebris(`bone`,c,r,2,n),s.spawnDebris(`flesh`,c,r,8,n),s.sprayFluid(`blood`,c,r,600,n,1.3));break;case`arm_left_torn`:case`arm_right_torn`:this.fling(a,e,`arm_${u}`,n,r,{radius:.08,speed:1,spin:.7}),d(`shoulder_${u}`)&&(s.spawnDebris(`flesh`,c,r,14,n),s.spawnDebris(`bone`,c,r,2,n),s.sprayFluid(`blood`,c,r,800,n,1.4));break;case`ribs_left_broken`:case`ribs_right_broken`:d(`ribs_${u}`)&&(s.spawnDebris(`bone`,c,r,2,n,.8),s.sprayFluid(`blood`,c,r,140,n));break;case`liver_ruptured`:this.vomit(e,n,1.6);break;case`disemboweled`:d(`belly`)&&(s.spillGuts(e,c,n,hV),s.spawnDebris(`organ`,c,r,3,n),s.spawnDebris(`gut`,c,r,4,n),s.spawnDebris(`fat`,c,r,4,n),s.sprayFluid(`blood`,c,r,650,n,1.2),s.sprayFluid(`bile`,c,r,110,n));break;case`knee_left_blown`:case`knee_right_blown`:d(`knee_${u}`)&&(s.spawnDebris(`bone`,c,r,2,n,.7),s.sprayFluid(`blood`,c,r,110,n))}return!0}rebreak(e,t){let n=this.bodies[e],r=n?.broke??null;return n==null||r===null||r.tick!==t||!this.graphic||n.gibbed?!1:(this.xray.start(e,n.graph.boxer,n.mutilation,r.site,r.x,r.z),!0)}drawBreak(e,t,n,r){if(this.xray.owner<0)return;let i=this.effects.mistPoints,a=i.visible,o=r.visible;i.visible=!1,r.visible=!1,this.xray.drawInset(e,t,n),i.visible=a,r.visible=o}holdXray(e,t){let n=this.bodies[e];n!=null&&this.xray.start(e,n.graph.boxer,n.mutilation,t,1,0,!0)}vomit(e,t,n=1.3){let r=this.bodies[e];r==null||r.gibbed||this.settings.reducedMotion||(r.graph.retch(n),this.settings.blood===`full`&&r.mutilation.anchor(`mouth`,this.position,this.axis)&&(r.vomitUntil=this.time+n,this.effects.gush(e,this.position,this.axis.addScaledVector(rH,-.4).normalize(),n,520,t,`bile`),this.effects.sprayFluid(`blood`,this.position,0,90,t,.6),this.effects.puddle(this.position.x+this.axis.x*OV,this.position.z+this.axis.z*OV,.22,`bile`,t)))}fatality(e,t,n,r){let i=this.bodies[e];if(i==null||i.fatality!==null||!this.graphic)return!1;i.fatality=t;let a=this.effects,o=this.position,s=this.axis,c=(t,i,s=1)=>a.spawnDebris(t,o,r,i,n,s,e),l=(e,t,i=1)=>a.sprayFluid(e,o,r,t,n,i);if(t===`eyes_out`){for(let t=0;ta||Math.hypot(this.position.x-s.x,this.position.z-s.z)t!==n&&e.mutilation.isPartGone(t)),d=[],f=new z;for(let e of nH[n]){let t=wD(c,e);if(t===null||!t.visible)continue;let r=t=>xD(n,e,t)&&!u.some(n=>xD(n,e,t)),i=t.geometry.getAttribute(`position`),a=t.geometry.getIndex(),o=0,s=0,p=new Uint8Array(i.count);if(a===null)p.fill(1);else for(let e=0;e0&&d.push(this.bake(c,e,t,l,this.turn,o===s?void 0:r))}return d.length>0&&this.effects.flingPart(oH(t,n),d,l,this.turn,i,r,{...a,part:n})}};function oH(e,t){return`${e}:${t}`}var sH=96,cH=4,lH=2.5,uH=.45,dH=.032,fH=e=>()=>(e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296);function pH(e){let t=document.createElement(`canvas`);t.width=sH,t.height=sH;let n=t.getContext(`2d`);if(n===null)return t;let r=fH(e),i=sH/2,a=4+Math.floor(r()*3);for(let e=0;e.05)||!Number.isFinite(e)||!Number.isFinite(t))return;let i=fH((Number.isSafeInteger(r)?r:0)*40503+11),a=Math.min(24,Math.max(1,Math.round(n*12))),o=.7+.3*Math.min(3,n);for(let r=0;r=1.5?1.8:1),l=lH+i()*2.5;this.drops.push({x:Math.min(1,Math.max(0,a?i():e+(i()+i()-1)*s*1.6)),y:Math.min(1,Math.max(0,a?i():t+(i()+i()-1)*s)),radius:c,alpha:.6+i()*.35,life:l,maxLife:l,run:c>=dH?.02+i()*.04:0,ran:0,sprite:Math.floor(i()*cH),turn:i()*Math.PI*2})}this.drops.length>96&&this.drops.splice(0,this.drops.length-96)}update(e){let t=Number.isFinite(e)?Math.max(0,e):0;for(let e=this.drops.length-1;e>=0;--e){let n=this.drops[e];n.life-=t,n.life<=0?this.drops.splice(e,1):n.ran+=n.run*t*(n.life/n.maxLife)}}draw(e,t,n){if(this.drops.length!==0){this.sprites??=Array.from({length:cH},(e,t)=>pH(1374496523+t*7919)),e.save();for(let r of this.drops){let i=Math.min(1,r.life/(r.maxLife*uH)),a=r.radius*n,o=r.x*t,s=(r.y+r.ran)*n;if(e.globalAlpha=r.alpha*i,r.ran>0){let t=r.y*n,i=e.createLinearGradient(0,t,0,s);i.addColorStop(0,`rgba(88,0,6,0)`),i.addColorStop(1,`rgba(88,0,6,0.6)`),e.fillStyle=i,e.beginPath(),e.moveTo(o-a*.06,t),e.lineTo(o+a*.06,t),e.lineTo(o+a*.28,s),e.lineTo(o-a*.28,s),e.closePath(),e.fill()}e.save(),e.translate(o,s),e.rotate(r.turn),e.drawImage(this.sprites[r.sprite],-a,-a,a*2,a*2),e.restore()}e.restore()}}clear(){this.drops.length=0}},hH=.026,gH=.038,_H=22,vH=[[.55,.85],[.55,.1],[.4,-.12],[-.4,-.12],[-.55,.05],[-.55,.6],[-.32,.62],[-.3,.16],[.3,.16],[.32,.85]],yH=.03;function bH(){let e=[],t=[],n=vH.length,r=new z,i=new z,a=new z;for(let t=0;t<=_H;t+=1){let n=t/_H*2-1;r.set(n*hH,0,gH*(1-n*n)-gH*.5),i.set(hH,0,-2*gH*n).normalize(),a.set(i.z,0,-i.x),a.dot(r.clone().setY(0).add(new z(0,0,gH*.5)))<0&&a.negate();for(let[t,n]of vH)e.push(r.x+a.x*t*.01,n*.01,r.z+a.z*t*.01)}for(let e=0;e<_H;e+=1)for(let r=0;r=50:e===`hit`&&t>=65:!1}var SH=9.81,CH=.32,wH=4.5,TH=.04,EH=3;function DH(){return{out:!1,moving:!1,sliding:!1,x:0,y:-50,z:0,vx:0,vy:0,vz:0,wx:0,wy:0,wz:0,bounces:0,age:0,restYaw:0}}function OH(e,t,n,r){if(!e.out||!e.moving)return!1;e.age+=n;let i=r+.006;if(!e.sliding)e.vy-=SH*n,e.x+=e.vx*n,e.y+=e.vy*n,e.z+=e.vz*n,NH(t,e.wx*n,e.wy*n,e.wz*n),e.y<=i&&(e.y=i,e.bounces.6?(e.bounces+=1,e.vy=-e.vy*CH,e.vx*=.72,e.vz*=.72,e.wx*=.55,e.wy*=.7,e.wz*=.55):(e.vy=0,e.sliding=!0));else{let r=Math.hypot(e.vx,e.vz),a=Math.max(0,r-wH*n);a<=TH?(e.vx=0,e.vz=0):(e.vx*=a/r,e.vz*=a/r),e.x+=e.vx*n,e.z+=e.vz*n,e.y=i,e.wy*=Math.exp(-4*n),e.restYaw+=e.wy*n,AH.setFromAxisAngle(kH,e.restYaw),t.slerp(AH,1-Math.exp(-12*n)),e.vx===0&&e.vz===0&&t.angleTo(AH)<.02&&(t.copy(AH),e.moving=!1)}return e.moving}var kH=new z(0,1,0),AH=new vo,jH=new vo,MH=new Qo;function NH(e,t,n,r){jH.setFromEuler(MH.set(t,n,r)),e.multiply(jH).normalize()}var PH=[.84,.78,.62],FH=[.4,.04,.04],IH=[.3,.012,.018],LH=[.5,.045,.05],RH=[.86,.64,.16],zH=[.42,.19,.09],BH=[.92,.88,.74],VH=[.72,.36,.34],HH=[.82,.52,.46],UH=(e,t,n)=>{let r=Math.min(1,Math.max(0,n));return[e[0]+(t[0]-e[0])*r,e[1]+(t[1]-e[1])*r,e[2]+(t[2]-e[2])*r]},WH=e=>{let t=Math.min(1,Math.max(0,e));return t*t*(3-2*t)},GH=(e,t,n=0)=>.5+.25*Math.sin(e.x*t*1.31+n)*Math.sin(e.y*t*1.93+n*1.7)+.25*Math.sin(e.z*t*1.57+n*.6)*Math.sin(e.x*t*.83-n),KH=e=>()=>(e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296),qH=new z;function JH(e,t){e.deleteAttribute(`normal`),e.deleteAttribute(`uv`);let n=Xh(e,1e-5);e.dispose();let r=n.getAttribute(`position`);for(let e=0;enew Ho().compose(new z(e,t,n),new vo().setFromEuler(new Qo(r,i,a)),new z(o,s,c));function QH(e,t,n){return YH(new Fu(new lu(e.map(e=>new z(...e))),Math.max(4,e.length*3),t,7,!1),n)}var $H=new Map;function eU(e){let t=$H.get(e);return t===void 0&&(t=e(),$H.set(e,t)),t.clone()}function tU(){return XH([YH(JH(new Du(1,3),e=>{e.normalize();let t=.45+.55*WH((e.x+1)/2),n=1-.34*Math.exp(-(((e.x+.2)/.14)**2))*WH(e.z+.6),r=1+.07*Math.sin(e.x*5.1+.7)*Math.sin(e.z*4.3+1.9);e.set(e.x*.1*r,(e.y>0?e.y:e.y*.4)*.04*t*r,e.z*.062*n*(.7+.3*t))}),e=>UH(UH([.2,.035,.022],[.34,.07,.04],GH(e,70)),IH,e.y<-.006?.5:0)),YH(JH(new Du(1,2),e=>e.set(e.x*.03,e.y*.012,e.z*.014)),[.16,.24,.04],ZH(.03,-.012,.03,0,.5,0)),QH([[.01,.004,-.03],[0,.012,-.055],[-.012,.014,-.075]],.007,e=>UH([.16,.05,.2],IH,WH((-e.z-.06)*60)))])}function nU(){return XH([YH(JH(new Du(1,3),e=>{e.normalize();let t=1-.42*Math.exp(-((e.x/.4)**2))*WH(e.z);e.set(e.x*.058,e.y*.024,e.z*.033*t-e.x*e.x*.012)}),e=>UH([.3,.05,.075],[.19,.025,.05],GH(e,120,1.3))),QH([[0,0,.014],[.004,.002,.034],[.018,0,.058],[.02,-.002,.082]],.0048,e=>UH([.86,.72,.56],IH,WH((e.z-.066)*70))),QH([[-.006,.002,.014],[-.012,.004,.034],[-.03,.002,.046]],.0042,IH),YH(JH(new Du(1,1),e=>e.set(e.x*.014,e.y*.009,e.z*.01)),RH,ZH(0,.002,.02))])}function rU(){return XH([YH(JH(new Du(1,3),e=>{e.normalize();let t=.55+.45*WH((1-e.z)/2+.1),n=1-.3*Math.exp(-(((e.z-.1-e.x*.3)/.1)**2)),r=1+.035*Math.sin(e.x*23)*Math.sin(e.y*19)*Math.sin(e.z*21);e.set(e.x*.062*t*n*r,(e.y>0?e.y:e.y*.55)*.036*t*n*r,e.z*.09*r)}),e=>UH(UH([.66,.34,.34],[.34,.16,.2],WH(GH(e,160,.4)*1.7-.5)),IH,WH((e.z-.05)*22)*.7)),YH(new Zl(.011,.012,.045,9,5,!0),e=>Math.abs((e.y+.5)*110%2)<1?[.84,.74,.62]:[.6,.26,.24],ZH(0,.006,.105,Math.PI/2-.2,0,0))])}function iU(){let e=new lu([[-.085,0,.012],[-.045,.004,-.02],[0,0,.018],[.04,.003,-.016],[.082,0,.014]].map(e=>new z(...e))),t=[],n=[],r=[],i=e.computeFrenetFrames(30,!1);for(let r=0;r<=30;r+=1){let a=r/30,o=e.getPointAt(a),s=Math.min(1,Math.sin(a*Math.PI)*5),c=.0175*(.82+.18*Math.abs(Math.sin(a*Math.PI*5.5)))*(.25+.75*s);for(let e=0;e<9;e+=1){let l=e/9*Math.PI*2,u=qH.copy(i.normals[r]).multiplyScalar(Math.cos(l)).addScaledVector(i.binormals[r],Math.sin(l));t.push(o.x+u.x*c,o.y+u.y*c,o.z+u.z*c);let d=1-.3*(1-Math.abs(Math.sin(a*Math.PI*5.5))),f=e===0?IH:UH(UH(VH,HH,.5+.5*Math.sin(a*23+e)),IH,s<1?.8:0);n.push(f[0]*d,f[1]*d,f[2]*d)}}for(let e=0;e<30;e+=1)for(let t=0;t<9;t+=1){let n=e*9+t,i=e*9+(t+1)%9;r.push(n,i,n+9,i,i+9,n+9)}let a=new yc;a.setAttribute(`position`,new sc(t,3)),a.setAttribute(`color`,new sc(n,3)),a.setIndex(r),a.computeVertexNormals();let o=a.toNonIndexed();return a.dispose(),XH([o,...[[-.03,-.004,-.03],[.012,-.004,.03],[.05,-.004,-.028]].map(([e,t,n])=>YH(JH(new Du(1,1),e=>e.set(e.x*.016,e.y*.007,e.z*.011)),RH,ZH(e,t,n,0,e*20,0)))])}function aU(){let e=[[.012,.008],[.004,.0105],[-.01,.0075],[-.013,-.004],[-.002,-.0095],[.01,-.0065]],t=[-1,-.72,-.3,.2,.62,1],n=[.02,.62,1,.9,.5,.02],r=[.004,-.002,0,.001,-.003,.005],i=[],a=[],o=(i,a)=>{let[o,s]=e[a%e.length];return[t[i]*.062,s*n[i],o*n[i]+r[i]]},s=(n,r)=>{let i=Math.abs(t[n]);return UH(r%e.length===3||r%e.length===4?UH(PH,FH,.75):PH,IH,WH((i-.6)*3.2))};for(let n=0;nUH(zH,LH,WH((-e.x-.006)*90));return XH([YH(JH(new Du(1,3),e=>{e.normalize();let t=e.y>0?1-.75*Math.exp(-(((e.x-.1)/.5)**2+((e.z+.1)/.55)**2)):1;e.set(e.x*.019,e.y*.0055*t,e.z*.031*(1-.18*e.x))}),t=>UH(e(t),[.24,.08,.05],t.y<.003&&t.y>-.001?.5:0)),YH(new Pu(.024,.0048,7,18,Math.PI*1.25),zH,ZH(-.001,.004,.004,-Math.PI/2,0,-Math.PI*.72,.78,1.18,1)),YH(JH(new Du(1,2),e=>e.set(e.x*.0095,e.y*.0055,e.z*.0105)),e,ZH(.002,.002,.031)),YH(JH(new Du(1,1),e=>e.set(e.x*.005,e.y*.005,e.z*.007)),e,ZH(-.011,.004,.006)),YH(JH(new Du(1,1),e=>e.set(e.x*.006,e.y*.005,e.z*.022)),LH,ZH(-.017,0,.002))])}var sU=12;function cU(){let e=e=>[Math.sin(e)*.046,Math.cos(e)*.056-.02],t=[],n=e=>UH(UH(PH,[.7,.6,.44],GH(e,200)),IH,WH((e.y-.003)*220)*.75),r=Math.PI*.62,i=[];for(let t=0;t<=22;t+=1){let[n,a]=e(-r+t/22*r*2);i.push(new z(n,0,a))}let a=new Fu(new lu(i),44,.0085,8,!1);t.push(YH(JH(a,e=>e.setY(e.y*1.35)),n)),t.push(YH(JH(new Du(1,2),e=>e.set(e.x*.016,e.y*.013,e.z*.011)),n,ZH(0,-.003,.038)));for(let n=0;nUH(BH,[.7,.2,.14],WH((-e.y-5e-4)*400)),ZH(a,.0125+(s?.0045:.003),o,0,-i,0))),t.push(YH(JH(new Du(1,1),e=>e.set(e.x*.0058,e.y*.0045,e.z*.0058)),c?[.05,.004,.006]:[.5,.07,.08],ZH(a,.0105,o)))}for(let n of[-1,1]){let[i,a]=e(n*r),o=JH(new Jl(.008,.05,.026,1,4,2),e=>{let t=e.y/.05+.5;e.z+=-.012*t+(t>.9?Math.sign(e.z)*.004:0),e.x*=1-.3*t});t.push(YH(o,e=>UH(PH,IH,WH((e.y-.012)*60)),ZH(i,.02,a-.006,0,n*.25,n*-.12))),t.push(YH(JH(new Du(1,1),e=>e.set(e.x*.009,e.y*.006,e.z*.014)),LH,ZH(i,.047,a-.016)))}let o=XH(t);return o.translate(0,-.016,0),o.computeBoundingBox(),o.computeBoundingSphere(),o}function lU(){let e=(e,t,n)=>{let r=t/13*Math.PI*2,i=.55+.45*Math.abs(Math.sin(t*2.7+.9))+.12*Math.sin(t*5.3),a=e/3*i,o=Math.cos(r)*a*.062,s=Math.sin(r)*a*.044;return[o,.009*Math.sin(o*60+.4)*Math.cos(s*48)+.3*(o*o+s*s)/.062+n*.0028*(1-e/3*.7),s]},t=[],n=[],r=(e,r,i,a)=>{for(let o of[e,r,i])t.push(...o),n.push(...a(o))},i=()=>zH,a=e=>Math.sin(e[0]*310+1)*Math.sin(e[2]*270)>.45?RH:UH(LH,IH,.5+.5*Math.sin(e[0]*140+e[2]*90));for(let t=0;t<3;t+=1)for(let n=0;n<13;n+=1){let o=(n+1)%13;r(e(t,n,1),e(t+1,o,1),e(t+1,n,1),i),r(e(t,n,0),e(t+1,n,0),e(t+1,o,0),a),t>0&&(r(e(t,n,1),e(t,o,1),e(t+1,o,1),i),r(e(t,n,0),e(t+1,o,0),e(t,o,0),a))}for(let t=0;t<13;t+=1){let n=(t+1)%13;r(e(3,t,1),e(3,n,1),e(3,t,0),()=>LH),r(e(3,n,1),e(3,n,0),e(3,t,0),()=>LH)}let o=new yc;return o.setAttribute(`position`,new sc(t,3)),o.setAttribute(`color`,new sc(n,3)),o.computeVertexNormals(),XH([o])}function uU(){let e=KH(795558343),t=[];for(let n=0;n<9;n+=1){let r=e()*Math.PI*2,i=n===0?0:.012+e()*.02,a=n===0?.021:.009+e()*.009,o=e();t.push(YH(JH(new Du(1,2),e=>e.set(e.x*a,e.y*a*.7,e.z*a)),UH(RH,[.92,.8,.36],o),ZH(Math.cos(r)*i,(e()-.3)*.008,Math.sin(r)*i*.8)))}return t.push(YH(JH(new Du(1,1),e=>e.set(e.x*.02,e.y*.005,e.z*.009)),LH,ZH(.018,-.006,.01,0,.6,0))),XH(t)}function dU(){let e=e=>UH(UH(PH,[.68,.58,.42],GH(e,260)),IH,WH(GH(e,90,2.2)*2.4-1.3)),t=YH(JH(new Zl(.02,.02,.022,14,2),e=>{let t=1-.14*(1-(e.y/.011)**2);e.x*=t,e.z*=t*(e.z<0?.8:1)}),e,ZH(0,0,.008)),n=YH(new Zl(.0175,.0175,.005,12),e=>UH([.78,.5,.46],LH,GH(e,400)),ZH(0,.0125,.008)),r=YH(new Pu(.0115,.0042,6,12),e,ZH(0,0,-.016,Math.PI/2,0,0)),i=YH(JH(new Jl(.007,.011,.03,1,1,3),e=>{let t=.5-e.z/.03;e.x*=1-.55*t,e.y=e.y*(1-.4*t)-.008*t}),e,ZH(0,0,-.04)),a=[-1,1].map(t=>YH(JH(new Jl(.024,.008,.008,3,1,1),e=>{let n=.5+t*e.x/.024;e.y*=1-.5*n,e.z=e.z*(1-.4*n)-.006*n}),e,ZH(t*.027,0,-.012))),o=YH(new Zl(.0048,.0048,.03,7),e=>UH([.88,.8,.6],IH,WH((Math.abs(e.y)-.009)*200)),ZH(0,0,-.016));return XH([t,n,r,i,...a,o])}function fU(){return XH([YH(JH(new Jl(.075,.004,.022,9,1,3),e=>{let t=e.x/.075+.5;e.x+=.0375,e.z=e.z*(1-.75*t)*(1+.5*Math.sin(t*17))+.006*Math.sin(t*9),e.y+=.004*Math.sin(t*13)}),e=>UH(UH(LH,IH,GH(e,240)),RH,Math.sin(e.x*260)>.93?.8:0))])}var pU={position:new z(.012,.089,.004),direction:new z(.47,.88,-.12).normalize()};function mU(){let e=YH(JH(new Du(1,4),e=>{e.normalize();let t=WH((1-e.y)/2),n=1-.62*t**2.4,r=1-.1*Math.exp(-(((e.x+.12)/.14)**2))*(e.z>-.2?1:.4);e.set(e.x*.05*n*r+.012*t,e.y>0?e.y*.038:e.y*.07,e.z*.04*n*r)}),e=>{let t=Math.exp(-(((e.x+.008+e.y*.3)/.006)**2)),n=Math.exp(-(((e.y-.032)/.006)**2));return UH(UH(UH([.42,.03,.035],[.26,.015,.025],GH(e,130)),RH,Math.max(t*.85,n*.7)*WH(GH(e,420,.7)*2)),[.12,.02,.1],t>.6&&Math.sin(e.y*300)>.2?.7:0)}),t=(e,t,n)=>YH(JH(new Du(1,2),e=>{let t=1+.12*Math.sin(e.x*9)*Math.sin(e.z*8);e.set(e.x*n*t,e.y*n*.72,e.z*n*.9*t)}),e=>UH([.3,.02,.05],[.18,.012,.045],GH(e,200)),ZH(e,.04,t)),n=(e,t)=>n=>UH(e,IH,WH((n.y-t)*120)),r=QH([[-.006,.03,.006],[-.004,.058,.008],[.004,.08,.006],[.012,.095,.004]],.0125,n([.82,.56,.44],.082)),i=[-1,0,1].map(e=>QH([[-.003+e*.004,.066,.008],[-.012+e*.012,.086,.012-e*.004],[-.016+e*.018,.1,.014-e*.006]],.0048,n([.78,.5,.4],.09))),a=QH([[.016,.03,.022],[.012,.052,.026],[-.006,.066,.03],[-.026,.07,.03]],.0105,e=>UH([.3,.3,.52],IH,WH((-e.x-.014)*110))),o=QH([[.03,.036,-.016],[.034,.058,-.018],[.036,.08,-.02]],.0095,n([.16,.14,.34],.068)),s=XH([e,t(.027,-.006,.024),t(-.024,-.004,.022),r,...i,a,o]);return s.translate(0,-.006,0),s.computeBoundingBox(),s.computeBoundingSphere(),s}var hU=2;function gU(e){let t=Math.min(14,Math.max(0,e));return hU*t-1.55*t*t/28}function _U(e){return Math.max(0,1-Math.max(0,e)/14)**.8}function vU(e){let t=e-Math.floor(e);return t<.16?WH(t/.16):1-WH((t-.16)/.3)}var yU=9.81,bU=.97,xU=.6,SU=10,CU=1.02,wU=.5,TU=.5,EU=2e-4,DU=.45,OU=.03,kU=.15,AU=class{capacity;radius;selfAvoiding;positions;previous;nodes=0;segment=0;pinned=!1;resting=!0;paidOut=0;payRate=0;still=0;constructor(e,t,n){this.capacity=e,this.radius=t,this.selfAvoiding=n,this.positions=new Float32Array(e*3),this.previous=new Float32Array(e*3)}get held(){return this.pinned?Math.max(0,this.nodes-1-Math.floor(this.paidOut)):-1}spill(e,t,n,r,i){this.nodes=Math.min(this.capacity,Math.max(2,Math.round(e)+1)),this.segment=t,this.pinned=!0,this.resting=!1,this.paidOut=1,this.payRate=r,this.still=0;for(let e=0;e.4)for(let e=0;ethis.segment?this.segment:s=a-1?this.still+e:0,this.still>=TU&&(this.resting=!0,s.set(o)),!0}drape(e,t,n,r=!1){let i=Math.hypot(n.x,n.z);if(i<.3)return;let a=this.positions;for(let o=e;oDU||s<-.05)continue;let c=OU+kU*Math.min(1,Math.max(0,s)/.25),l=((a[e]-t.x)*n.x+(a[e+2]-t.z)*n.z)/i;if(l>=c+(r?1e-4:0))continue;let u=Math.max(0,c-l);if(a[e]=a[e]+n.x/i*u,a[e+2]=a[e+2]+n.z/i*u,!r)continue;let d=((a[e]-this.previous[e])*n.x+(a[e+2]-this.previous[e+2])*n.z)/i;this.previous[e]=this.previous[e]+n.x/i*d,this.previous[e+2]=this.previous[e+2]+n.z/i*d}}keepApart(e){let t=this.positions,n=this.radius*1.7;for(let r=e;r=n*n)continue;let c=Math.sqrt(s),l=Math.hypot(i,o)1e-10&&FU.copy(RU).normalize(),IU.addScaledVector(FU,-IU.dot(FU)),IU.lengthSq()<1e-8&&(IU.set(+(Math.abs(FU.x)<.9),0,Math.abs(FU.x)<.9?0:1),IU.addScaledVector(FU,-IU.dot(FU))),IU.normalize(),LU.crossVectors(FU,IU);let a=Math.min(e,n-1-e),c=this.radii[e]*(a===0?.08:a===1?.62:a===2?.9:1);for(let t=0;t0?t.fromBufferAttribute(n,0):t.set(0,1,0).applyQuaternion(e.mesh.quaternion),t.lengthSq()>1e-8?t.normalize():t.set(0,1,0)}var eG=e=>()=>(e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296),$=(e,t=0)=>Number.isFinite(e)?e:t,tG=()=>({alive:!1,x:0,y:-50,z:0,vx:0,vy:0,vz:0,rx:0,ry:0,rz:0,vrx:0,vry:0,vrz:0,scale:0,stretch:1,bounces:0,stained:!1,kind:`flesh`,resting:!1,born:0,owner:-1,fading:-1}),nG=e=>{for(let t of e)if(!t.alive)return!0;return!1},rG=new B(16054267),iG=.012,aG=.055,oG=90,sG=10,cG=.985,lG=new R(.097,.132),uG=.012,dG={r:.82,g:.86,b:.9},fG=4,pG=(e,t)=>Math.trunc(e)*2+(t===`left`?0:1),mG=new z(1,0,0),hG=[`blood`,`bile`,`brain`,`urine`],gG=2400,_G={liver:{build:tU,share:.06,size:[.8,.5],stretch:[.9,.3],stain:.5},kidney:{build:nU,share:.06,size:[.9,.5],stretch:[.9,.25],stain:.3},lung:{build:rU,share:.06,size:[.75,.45],stretch:[.9,.3],stain:.45},gut:{build:iU,share:.18,size:[.8,.5],stretch:[.8,.5],stain:.4},bone:{build:aU,share:.24,size:[.7,.8],stretch:[.8,.6],stain:.14},vertebra:{build:dU,share:.1,size:[.9,.3],stretch:[1,0],stain:.2},skin:{build:lU,share:.1,size:[.8,.8],stretch:[.7,.7],stain:.3},fat:{build:uU,share:.12,size:[.6,.7],stretch:[.8,.5],stain:.2},ear:{build:oU,share:.03,size:[1.3,.3],stretch:[1,0],stain:.14},jawbone:{build:cU,share:.016,size:[1.1,.15],stretch:[1,0],stain:.34}},vG=Object.keys(_G),yG=[`liver`,`kidney`,`lung`],bG=Object.fromEntries(_e.map((e,t)=>[e,t])),xG=14,SG=3.5,CG=1100,wG=.12,TG=.45,EG=FW*Math.sqrt(Math.PI),DG=e=>L.clamp((e-.3)/.6,0,1),OG=e=>xG+326*e**2.2,kG=e=>OG(e)*(1-DG(e)*.88*(1-EG)),AG=16,jG=8,MG=.4,NG=24,PG=11,FG=.046,IG=[0,0,1,3,6],LG=50,RG=48,zG=.6,BG=1,VG=.06,HG=.075,UG=4,WG=24,GG=1.3,KG=new vo().setFromEuler(new Qo(.95,0,0)),qG=60,JG=4,YG=5,XG=1.2,ZG=1.5,QG=.5;function $G(e){if(typeof e==`number`)return{x:e<0?-1:1,z:0};let t=Math.hypot(e.x,e.z);return Number.isFinite(t)&&t>1e-6?{x:e.x/t,z:e.z/t}:{x:1,z:0}}var eK=new z(0,1,0),tK=new z(0,0,1),nK=e=>Number.isFinite(e)?L.clamp(e,0,TW):0,rK=new Set([`hit`,`counter_hit`,`block`,`perfect_block`,`guard_break`,`knockdown`,`bleed`]);function iK(e,t,n,r){let i=Math.abs(e)-r;if(i<=0)return{position:e,velocity:t};let a=Math.sign(e);return Math.abs(n)<=r?{position:a*r,velocity:t*-.42}:{position:e,velocity:-a*Math.max(-a*t,i*sW)}}function aK(e){if(e.kind===`bleed`)return`ooze`;if(e.kind===`knockdown`)return`impact`;let t=e.detail.split(`:`);if(t.at(-1)===`body`)return`body_burst`;let n=t.find(e=>[`jab`,`straight`,`hook`,`uppercut`].includes(e));return n===`hook`?`fan`:n===`uppercut`?`plume`:`jet`}function oK(e,t){e.set($(t.x),$(t.y),$(t.z),$(t.w,1)),e.lengthSq()<1e-6?e.identity():e.normalize()}function sK(){return new qu({color:9063730,roughness:.58,metalness:.02,clearcoat:.25,clearcoatRoughness:.6})}function cK(e,t){let n=sK();n.map=t;let r=e?new e_(n,$h,{core:Pg,wash:!0,baked:!0}):new e_(n,Qh,{core:Ng,lids:Fg,baked:!0});if(!e)return{material:n,injury:r,look:new Vy(n,!0)};let i=n.onBeforeCompile;return n.onBeforeCompile=(e,t)=>{i.call(n,e,t),e.vertexShader=e.vertexShader.replace(`#include `,`#include +attribute vec3 bindPosition;`)},{material:n,injury:r,look:null}}var lK=0,uK=1,dK=2,fK=3;function pK(e,t,n){return e===void 0||e===`forearm_left`||e===`forearm_right`?lK:e===`head`?dK:e===`upper_body`?t?fK:uK:e===`torso`&&n?dK:uK}function mK(e,t,n,r=0){let i=new Ku({map:e,color:t,roughness:n===void 0?.6:.38,metalness:.02,side:2});return n!==void 0&&(xy(i,!0,n).value=r),i}function hK(e,t,n){n.identity();let r=e.getAttribute(`position`),i=e.getAttribute(`bindPosition`),a=e.getIndex();if(i===void 0||i.count!==r.count)return n;let o=new Uint8Array(r.count);if(a===null)o.fill(1);else for(let e=0;e({active:!1,eventId:null,fluid:`blood`,life:0,seconds:1,rate:0,accumulator:0,position:new z,axis:new z(0,1,0)}));simulationRemainder=0;ambientSeed=1597463007;shake=0;lowTier=!1;bloodLevel=`full`;lens=new mH;camera=null;lensPoint=new z;debrisCursor=new Map;visceraMaterial;viscera=[];visceraByShape={};wounds=[];woundsOpen=0;woundShare=1;woundClock=0;parts=[];partsThrown=0;partBox=new Bs;partMiddle=new z;partVertex=new z;limbMap;limbMaterial;trunkMap;trunkMaterial;fleshSections;spines=[];spineMesh;spineStretch;shredGeometry;shredMesh;spineNeck=new z;guts=[];heartGeometry;heartMesh;heartRest;heartRadius;heart={active:!1,moving:!1,owner:-1,age:0,beats:0,vx:0,vy:0,vz:0,vrx:0,vry:0,vrz:0,bounces:0,settle:-1,settleFrom:new vo,settleTo:new vo,settleFromY:0,pool:0,trail:0};corpses=[];flyGeometry;flyMaterial;flyMesh;flies;constructor(e,t=1024,n=UU){this.scene=e,this.budget=n,this.dropletPositions=new Float32Array(n.droplets*3),this.dropletColors=new Float32Array(n.droplets*3),this.dropletBuffers={position:new ic(this.dropletPositions,3),color:new ic(this.dropletColors,3)},this.dropletGeometry=V_(),this.dropletMaterial=new Ku({color:16777215,roughness:.3,metalness:.02}),this.dropletMesh=new _l(this.dropletGeometry,this.dropletMaterial,n.droplets),this.dropletMesh.instanceMatrix.setUsage(Aa),this.dropletMesh.frustumCulled=!1,this.dropletMesh.castShadow=!1,e.add(this.dropletMesh);for(let e=0;eObject.assign(new V(e.geometry,e.material),{castShadow:e.castShadow}));if(e.push(Object.assign(new V(this.stumpGeometry,this.jawMaterial),{castShadow:this.stumps[0].mesh.castShadow})),this.bakedStandIns===null){let e=new Io,t=[cK(!1,e),cK(!0,e)].flatMap(e=>[e.material,e.injury.variant(!1),e.injury.variant(!0)]),n=new Ku({color:1920728,roughness:.38,metalness:.03,map:e});xy(n,!0);let r=[mK(e,16777215),mK(null,16777215),mK(e,1920728,`gloves`),mK(e,1920728,`trunks`)],i=new _l(this.heartGeometry,this.visceraMaterial,1);i.setColorAt(0,this.gibColor.setHex(16777215)),i.castShadow=!0,this.bakedStandIns={map:e,materials:[...t,n,...r],instanced:[i,new _l(this.flyGeometry,this.flyMaterial,1)]}}for(let t of this.bakedStandIns.materials)e.push(Object.assign(new V(this.headGeometry,t),{castShadow:!0}));return e.push(Object.assign(new V(this.heartGeometry,this.visceraMaterial),{castShadow:!0}),...this.bakedStandIns.instanced),e}setCamera(e){this.camera=e}drawLens(e,t,n){this.lens.draw(e,t,n)}get lensDrops(){return this.lens.count}setBloodLevel(e){if(e===this.bloodLevel)return;let t=this.bloodLevel;this.bloodLevel=e,(e===`off`||t===`full`&&e===`reduced`)&&this.clearArcadeGore()}get shakeAmount(){return this.shake}get liveParticles(){return this.droplets.filter(e=>e.alive).length}get liveBloodParticles(){return this.droplets.filter(e=>e.alive&&e.blood).length}get liveMist(){return this.mists.filter(e=>e.alive).length}get canvasStains(){return this.canvasBlood.stains}useUploader(e){this.canvasBlood.useUploader(e)}setLowTier(e){this.canvasBlood.setLowTier(e),this.lowTier=e}get liveGibs(){return this.gibs.filter(e=>e.alive).length}get liveShards(){return this.shards.filter(e=>e.alive).length}debrisCount(e){let t=0;for(let n of this.gibs)n.alive&&n.kind===e&&(t+=1);for(let n of this.shards)n.alive&&n.kind===e&&(t+=1);for(let n of this.eyeballs)n.alive&&n.kind===e&&(t+=1);for(let n of this.viscera)for(let r of n.pieces)r.alive&&r.kind===e&&(t+=1);return t}get activeHeads(){return this.heads.filter(e=>e.active).length}headBurst(e){let t=this.stumps[Math.trunc(e)];return t!==void 0&&t.active&&t.mesh.material===this.jawMaterial}severedHeadPosition(e,t){let n=this.heads[Math.trunc(e)];return n===void 0||!n.active?!1:(t.copy(n.mesh.position),!0)}severedHeadFacing(e,t){let n=this.heads[Math.trunc(e)];return n===void 0||!n.active?!1:(t.set(0,0,1).applyQuaternion(n.mesh.quaternion),!0)}mouthpieceOut(e){return this.shields[Math.trunc(e)]?.out===!0}mouthpiecePosition(e,t){let n=this.shields[Math.trunc(e)];return n===void 0||!n.out?!1:(t.set(n.x,n.y,n.z),!0)}ejectMouthpiece(e,t,n,r,i,a,o=!1){if(e<0||e>=XU)return!1;let s=Math.trunc(e),c=this.shields[s],l=Number.isSafeInteger(i)?i:0;if(c.out&&!o||this.lastShieldEvent[s]===l)return!1;this.lastShieldEvent[s]=l;let u=eG(l*48271+s*7907+5),d=$G(r),f=.9+u()*.9,p=.9+u()*.9,m=(u()-.5)*1.1;Object.assign(c,DH(),{out:!0,moving:!0,x:$(t.x),y:$(t.y,1.45),z:$(t.z),vx:f*d.x-m*d.z,vy:p,vz:f*d.z+m*d.x,wx:(u()-.5)*26,wy:(u()-.5)*18,wz:(u()-.5)*26,restYaw:u()*Math.PI*2});let h=this.shieldMeshes[s];h.position.set(c.x,c.y,c.z),oK(h.quaternion,n),h.visible=!0,this.shieldMaterials[s].color.setHex(a).lerp(rG,.55);let g=this.bloodLevel===`full`;for(let e=0;e<(g?22:12);e+=1){let t=u()*Math.PI*2,n=g?e%3!=0:this.bloodLevel===`reduced`&&e%3==0;this.spawnDroplet(c.x+(u()-.5)*.03,c.y+(u()-.5)*.03,c.z+(u()-.5)*.03,c.vx*(.5+u()*.6)+Math.sin(t)*.4,c.vy*(.4+u()*.6),c.vz*.5+Math.cos(t)*.4,n?W_(u()):dG,.5+u()*.5,n)}return!0}gougeEye(e,t,n,r,i,a,o=!1){if(this.bloodLevel!==`full`||e<0||e>=XU)return;let s=Math.trunc(e),c=pG(s,a),l=this.eyes[c],u=Number.isSafeInteger(i)?i:0;if(l.active&&(o||l.eventId===u))return;l.active&&this.burstEye(s,a,u),l.active=!0,l.eventId=u,l.socket.set($(t.x),$(t.y,1.6),$(t.z)),l.facing.copy(n),l.hasSkull=!1,l.position.copy(l.socket).addScaledVector(n,iG*1.5),this.eyeDirection.copy(n).multiplyScalar(1.3);let d=$G(r);if(this.eyeDirection.x+=d.x*.5,this.eyeDirection.z+=d.z*.5,l.previous.copy(l.position),o||l.previous.addScaledVector(this.eyeDirection,-.016666666666666666),l.bleeding=o?0:sG,l.accumulator=0,this.eyeMeshes[c].visible=!0,this.nerveMeshes[c].visible=!0,this.writeEye(c),o)return;let f=eG(u*52711+s*3571+(a===`right`?977:0)+13);for(let e=0;e1e-8&&o.facing.copy(n).normalize(),r!==void 0&&i!==void 0&&(o.skull.set($(r.x),$(r.y,1.6),$(r.z)),oK(o.skullTurn,i),o.hasSkull=!0))}eyeOut(e,t){return t===void 0?this.eyes[pG(e,`left`)]?.active===!0||this.eyes[pG(e,`right`)]?.active===!0:this.eyes[pG(e,t)]?.active===!0}eyePosition(e,t,n){let r=this.eyes[pG(e,`left`)],i=this.eyes[pG(e,`right`)],a=n===`left`||n===void 0&&r?.active===!0?r:i;return a===void 0||!a.active?!1:(t.copy(a.position),!0)}updateEyes(e){for(let[t,n]of this.eyes.entries()){if(!n.active)continue;this.eyeDirection.copy(n.position).sub(n.previous).multiplyScalar(cG),n.previous.copy(n.position),n.position.add(this.eyeDirection),n.position.y-=cW*e*e,this.eyeDirection.copy(n.position).sub(n.socket);let r=this.eyeDirection.length();if(r>.055&&n.position.copy(n.socket).addScaledVector(this.eyeDirection,aG/r),n.hasSkull&&this.restOnFace(n)){n.previous.lerp(n.position,.6),this.eyeDirection.copy(n.position).sub(n.socket);let e=this.eyeDirection.length();e>.055&&n.position.copy(n.socket).addScaledVector(this.eyeDirection,aG/e)}if(n.position.y<0+iG&&(n.position.y=0+iG),this.bloodLevel===`full`&&n.bleeding>0)for(n.bleeding=Math.max(0,n.bleeding-e),n.accumulator+=e*this.forDevice(oG);n.accumulator>=1;){--n.accumulator;let e=.15+this.ambientRandom()*.5;this.spawnDroplet(n.socket.x,n.socket.y-.005,n.socket.z,n.facing.x*e+(this.ambientRandom()-.5)*.2,-.15-this.ambientRandom()*.4,n.facing.z*e+(this.ambientRandom()-.5)*.2,W_(this.ambientRandom()),.9,!0)}this.writeEye(t)}}restOnFace(e){this.eyeTurn.copy(e.skullTurn).invert();let t=this.eyeDirection.copy(e.position).sub(e.skull).applyQuaternion(this.eyeTurn),n=this.eyeSocketLocal.copy(e.socket).sub(e.skull).applyQuaternion(this.eyeTurn).z+iG+uG;if(t.z>=n)return!1;let r=Math.hypot(t.x/lG.x,t.y/lG.y);return r>=1?!1:(n-t.z<=(1-r)*Math.min(lG.x,lG.y)||r<1e-6?t.z=n:(t.x/=r,t.y/=r),e.position.copy(e.skull).add(t.applyQuaternion(e.skullTurn)),!0)}writeEye(e){let t=this.eyes[e],n=this.eyeMeshes[e],r=this.nerveMeshes[e];n.position.copy(t.position),this.eyeDirection.copy(t.position).sub(t.socket);let i=this.eyeDirection.length();i>1e-5&&(this.eyeDirection.multiplyScalar(1/i),r.quaternion.setFromUnitVectors(eK,this.eyeDirection),this.eyeDirection.addScaledVector(t.facing,.9).normalize(),n.quaternion.setFromUnitVectors(tK,this.eyeDirection)),r.position.copy(t.socket),r.scale.set(1,Math.max(.001,i-iG*.8),1)}returnMouthpiece(e){let t=Math.trunc(e),n=this.shields[t];n!==void 0&&(Object.assign(n,DH()),this.shieldMeshes[t].visible=!1,this.lastShieldEvent[t]=null)}clearMouthpieces(){for(let[e,t]of this.shields.entries())Object.assign(t,DH()),this.shieldMeshes[e].visible=!1,this.lastShieldEvent[e]=null}updateShields(e){for(let[t,n]of this.shields.entries()){if(!n.out||!n.moving)continue;let r=this.shieldMeshes[t],i=n.age<.3&&!n.sliding,a=n.x,o=n.z;OH(n,r.quaternion,e,0);let s=g_-yH-oW,c=iK(n.x,n.vx,a,s),l=iK(n.z,n.vz,o,s);if(n.x=c.position,n.vx=c.velocity,n.z=l.position,n.vz=l.velocity,r.position.set(n.x,n.y,n.z),i&&this.ambientRandom()e.active).length}get activeStumps(){return[...this.stumps,...this.handStumps].filter(e=>e.active).length}spawnDroplet(e,t,n,r,i,a,o,s,c,l=c?.0035+this.ambientRandom()**3*.0125:.0025+this.ambientRandom()**2*.004,u=`blood`){let d=this.liveDropletsthis.droplets[e].maxLife-this.droplets[e].life;for(let n=0;n0&&t(e[i-1])DW&&e.pop()}}forDevice(e){return Math.round(e*this.budget.droplets*(this.lowTier?.5:1)/UU.droplets)}uploadDroplets(e,t,n){if(this.dropletMesh.count=this.liveDroplets,t<=e)return;this.dropletMesh.instanceMatrix.addUpdateRange(e*16,(t-e)*16),this.dropletMesh.instanceMatrix.needsUpdate=!0;let r=this.dropletMesh.instanceColor;n&&r!==null&&(r.addUpdateRange(e*3,(t-e)*3),r.needsUpdate=!0)}retireDroplet(e){this.oldest.length=0;let t=this.liveDroplets-1,n=this.droplets[e];if(n.alive=!1,this.liveDroplets=t,e!==t){let r=this.droplets[t];this.droplets[e]=r,this.droplets[t]=n,this.dropletPositions.copyWithin(e*3,t*3,t*3+3),this.dropletColors.copyWithin(e*3,t*3,t*3+3),this.dropletMesh.setColorAt(e,this.dropletColor.setRGB(r.r,r.g,r.b)),this.writeDropletMatrix(e,r)}this.dropletPositions[t*3+1]=-50,this.writeDropletMatrix(t,n)}sprayDroplet(e,t,n,r,i,a,o,s,c,l,u,d){this.spawnDroplet(t,n,r,i*e.x-o*e.z,a,i*e.z+o*e.x,s,c,l,u,d)}writeDropletMatrix(e,t){if(!t.alive){this.dropletScale.setScalar(0),this.dropletQuaternion.identity(),this.dropletMatrix.compose(this.dropletVelocity.set(0,-50,0),this.dropletQuaternion,this.dropletScale),this.dropletMesh.setMatrixAt(e,this.dropletMatrix);return}let n=Math.hypot(t.vx,t.vy,t.vz);n>1e-4?(this.dropletVelocity.set(t.vx/n,t.vy/n,t.vz/n),this.dropletQuaternion.setFromUnitVectors(eK,this.dropletVelocity)):this.dropletQuaternion.identity();let r=Math.min(1,t.life/(t.maxLife*.3))*this.dropletCloseness*(t.blood&&this.bloodLevel===`full`?xW:1),i=H_(t.radius*r,n,this.dropletShape);this.dropletScale.set(i.width,i.length,i.width),this.dropletMatrix.compose(this.dropletVelocity.set(t.x,t.y,t.z),this.dropletQuaternion,this.dropletScale),this.dropletMesh.setMatrixAt(e,this.dropletMatrix)}spawnMist(e,t,n,r,i){let a=this.mistIndex%this.budget.mist;this.mistIndex+=1;let o=this.mists[a];o.alive=!0,o.x=$(e),o.y=$(t,1),o.z=$(n),o.maxLife=Math.max(.05,$(i,.5)),o.life=o.maxLife,o.scale=Math.max(.1,$(r,1)),this.mistPositions[a*3]=o.x,this.mistPositions[a*3+1]=o.y,this.mistPositions[a*3+2]=o.z,this.mistColors[a*4+3]=Math.min(1,o.scale),this.mistGeometry.attributes.position.needsUpdate=!0,this.mistGeometry.attributes.color.needsUpdate=!0}placeDecal(e,t,n,r,i,a,o){this.canvasBlood.stain($(e),$(t),Math.max(.01,$(n,.2))*.28,Math.max(.01,$(r,.15))*.28,$(i),L.clamp($(a,.4),0,.95),o)}splashLens(e,t,n,r,i){let a=this.camera;if(a===null||this.bloodLevel===`off`||!(r>0))return;let o=this.lensPoint.set($(e),$(t,1.5),$(n)),s=o.distanceTo(a.position);if(o.project(a),!(o.z<1)||Math.abs(o.x)>1.15||Math.abs(o.y)>1.15)return;let c=L.clamp((OW-s)/8.5,0,1);this.lens.splash((o.x+1)/2,(1-o.y)/2,c*r*(this.bloodLevel===`reduced`?.25:1),i)}ambientRandom(){return this.ambientSeed=Math.imul(this.ambientSeed^this.ambientSeed>>>15,1|this.ambientSeed),this.ambientSeed^=this.ambientSeed+Math.imul(this.ambientSeed^this.ambientSeed>>>7,61|this.ambientSeed),((this.ambientSeed^this.ambientSeed>>>14)>>>0)/4294967296}splatter(e,t,n,r=()=>this.ambientRandom(),i=12,a=gW){if(this.bloodLevel===`off`)return;let o=this.bloodLevel===`reduced`,s=o?Math.ceil(i/4):i,c=o?.35:_W;for(let i=0;i0?$(t.y):e.detail.endsWith(`:body`)?1.05:1.58,z:$(t.z)},f=e.kind===`bleed`,p=n||f?0:Math.round(s?(a?4:6)+Math.min(6,Math.max(0,e.amount)/40):(a?6:16)+Math.min(20,Math.max(0,e.amount)/20)),m={x:0,y:0,z:0,vx:0,vy:0,vz:0,life:0,radius:0,color:W_(0)},h=e.kind===`hit`||e.kind===`counter_hit`,g=h?Math.max(0,e.blood-Math.floor(Math.max(0,e.amount)/3)):0,_=n||e.blood<=0||this.bloodLevel===`off`?0:f?this.bloodLevel===`reduced`?1:Math.min(12,3+Math.floor(Math.max(0,e.amount)/8)):this.bloodLevel===`reduced`?Math.min(24,Math.round(e.blood*(a?.12:.24))):this.forDevice(a?Math.round(I_(e.blood,0)/2):o?I_(e.blood,0)+SW:I_(e.blood,h?e.amount:0));f||(this.shake=Math.min(.14,this.shake+(a?.008:Math.max(.012,e.amount/1500)))),o&&(this.shake=Math.min(.2,this.shake+.09));let v=o?1.2:h?L.clamp((e.amount-40)/60,0,1)*(.6+Math.min(100,e.blood)/150):0;!n&&!f&&e.blood>0&&this.splashLens(d.x,d.y,d.z,v,e.event_id);for(let e=0;e0&&t<=uW){let e=1-dW*t;this.spawnDroplet(m.x,m.y,m.z,m.vx*e,m.vy*e,m.vz*e,m.color,m.life,!0,m.radius*(1-fW*t));continue}let n=t===0,r=(i()-.5)*Math.PI,a=n?2.2+i()*1.8:.9+i()*1.5,o=a,s=.5+i()*1.25,u=(i()-.5)*.5;if(c===`fan`)o=a*(.45+Math.cos(r)*.35),s=.55+i()*1.15,u=Math.sin(r)*a*.9;else if(c===`plume`)o=a*(.25+i()*.25),s=1.8+i()*2.2,u=(i()-.5)*a*.65;else if(c===`body_burst`)o=a*(.55+i()*.45),s=-.15+i()*1.05,u=Math.sin(r)*a*.75;else if(c===`ooze`)o=.08+i()*.22,s=-.3-i()*.55,u=(i()-.5)*.22;else if(c===`impact`)o=a*(.45+i()*.65),s=.9+i()*2.1,u=Math.sin(r)*a;else{let e=n?.12:.34;o=a*(.8+i()*.35),s=n?1.3+i()*1.6:.5+i()*1.25,u=(i()-.5)*a*e}let f=o*l.x-u*l.z,p=o*l.z+u*l.x,h=W_(i()),g=d.x+(i()-.5)*.12,_=d.y+(i()-.5)*.14,v=d.z+(i()-.5)*.12,y=.65+i()*.85;n?(m.x=g,m.y=_,m.z=v,m.vx=f,m.vy=s,m.vz=p,m.color=h,m.life=y,m.radius=.008+i()*.008,this.spawnDroplet(g,_,v,f,s,p,h,y,!0,m.radius)):this.spawnDroplet(g,_,v,f,s,p,h,y,!0)}let y=s?o||e.kind===`counter_hit`||h&&(e.amount>=35||g>=vW):e.kind===`hit`&&e.amount>=70||o||e.kind===`counter_hit`||g>=16;if(!n&&e.blood>0&&this.bloodLevel!==`off`&&y){let t=s?this.forDevice(o?36:12+Math.min(24,Math.floor(g/2)+Math.floor(Math.max(0,e.amount-35)/6))):o?3:2,n=s?1:.35;for(let e=0;e0&&this.bloodLevel!==`off`){let t=o?1+Math.min(2,e.blood/55):.8+Math.min(1.2,g/30);this.splatter(d.x+(i()-.5)*.6,d.z+(i()-.5)*.6,s?t*1.3:t,i,x,o?hW:mW)}let S=e.amount>=70||e.kind===`counter_hit`&&e.amount>=P_,C=h&&(e.amount>=60||S&&g>=vW/4);if(s&&!n&&C&&!e.detail.endsWith(`:body`)){let t=Math.min(20,Math.max(3,Math.round((e.amount-10)/6)));for(let e=0;e0){e.sideLow=1/0,e.sideHigh=-1/0;for(let t=0;t=XU)return;let s=Math.trunc(e),c=Number.isSafeInteger(i)?i:0,l=this.heads[s];if(l.active||this.lastDecapitationEvent[s]===c)return;this.stopGush(s),this.applyBakedPart(l,o,a);let u=eG(c*104729+s*8191+23),d=$G(r);this.lastDecapitationEvent[s]=c,l.active=!0,l.moving=!0,l.eventId=c;let f=1.8+u()*1.1;l.vy=2.3+u()*1.1;let p=(u()-.5)*2.2;l.vx=f*d.x-p*d.z,l.vz=f*d.z+p*d.x,l.vrx=(u()-.5)*12,l.vry=(u()-.5)*12,l.vrz=(u()-.5)*12,l.bounces=0,l.trail=0,l.stained=!1,l.settle=-1,l.mesh.position.set($(t.x),$(t.y,1.55),$(t.z)),oK(l.mesh.quaternion,n),l.mesh.visible=!0;let m=this.stumps[s];m.mesh.material=this.stumpMaterial,m.active=!0,m.fountainLife=14,m.accumulator=0,m.seed=c|1,m.direction=d,m.mesh.position.copy(l.mesh.position),m.mesh.quaternion.copy(l.mesh.quaternion),m.mesh.visible=!0;for(let e=0;e=XU)return;let i=Math.trunc(e),a=Number.isSafeInteger(r)?r:0,o=this.stumps[i];if(o.active||this.lastBurstEvent[i]===a)return;this.lastBurstEvent[i]=a,this.stopGush(i);let s=eG(a*91813+i*6151+41),c=$G(n),l=$(t.x),u=$(t.y,1.6),d=$(t.z),f=(e,t,n,r,a)=>{for(let o=0;o=XU)return;let c=Math.trunc(e)*2+(t===`left`?0:1),l=Number.isSafeInteger(a)?a:0,u=this.hands[c];if(u.active||this.lastDismembermentEvent[c]===l)return;this.applyBakedPart(u,s,o);let d=eG(l*130363+c*12289+37),f=$G(i);this.lastDismembermentEvent[c]=l,u.active=!0,u.moving=!0,u.eventId=l;let p=1.3+d()*1.1;u.vy=1.5+d()*1.2;let m=(d()-.5)*1.8;u.vx=p*f.x-m*f.z,u.vz=p*f.z+m*f.x,u.vrx=(d()-.5)*16,u.vry=(d()-.5)*16,u.vrz=(d()-.5)*16,u.bounces=0,u.trail=0,u.stained=!1,u.mesh.position.set($(n.x),$(n.y,1.25),$(n.z)),oK(u.mesh.quaternion,r),u.mesh.visible=!0;let h=this.handStumps[c];h.active=!0,h.fountainLife=MW,h.accumulator=0,h.seed=l|1,h.direction=f,h.mesh.position.copy(u.mesh.position),h.mesh.quaternion.copy(u.mesh.quaternion),h.mesh.visible=!0;for(let t=0;t<$U;t+=1){let t=d()*Math.PI*2,n=.55+d()*1.8;this.sprayGib(f,u.mesh.position.x+(d()-.5)*.08,u.mesh.position.y+(d()-.5)*.08,u.mesh.position.z+(d()-.5)*.08,.5+d()*1.4+Math.sin(t)*n*.45,.5+d()*1.9,Math.cos(t)*n,d,`flesh`,Math.trunc(e))}for(let e=0;e=XU)return;let o=Math.trunc(e),s=Number.isSafeInteger(i)?i:0,c=eG(s*69061+o*2741+29),l=$G(r),u=this.tornAxis.copy(n);u.lengthSq()>1e-8&&Number.isFinite(u.lengthSq())||u.set(0,1,0),u.normalize();let d=$(t.x),f=$(t.y,1.2),p=$(t.z);for(let e=0;e{for(let n=0;n=XU)return;let i=Math.trunc(e)*2+(t===`left`?0:1),a=this.handStumps[i];a.active&&(a.mesh.position.set($(n.x),$(n.y,1.2),$(n.z)),oK(a.mesh.quaternion,r))}anchorStump(e,t,n,r,i){if(this.bloodLevel!==`full`||e<0||e>=XU)return;let a=this.stumps[Math.trunc(e)];a.active&&(a.mesh.position.set($(t.x),$(t.y,1.5),$(t.z)),r===void 0||r.length<18?(a.mesh.geometry=this.stumpGeometry,oK(a.mesh.quaternion,n)):(nv(a.flesh,r,a.mesh.position,this.stumpOutward.set(0,1,0).applyQuaternion(n),.01,i),a.mesh.geometry=a.flesh,a.mesh.quaternion.identity()))}restoreFighter(e){if(e<0||e>=XU)return;let t=Math.trunc(e),n=this.heads[t];n.active=!1,n.moving=!1,n.mesh.visible=!1,n.mesh.position.y=-50,this.applyBakedPart(n,void 0,9063730);let r=this.stumps[t];r.active=!1,r.fountainLife=0,r.accumulator=0,r.mesh.visible=!1,r.mesh.position.y=-50,r.mesh.material=this.stumpMaterial,this.clearGibs(t),this.stopGush(t);for(let e of[t*2,t*2+1]){let t=this.eyes[e];t.active=!1,t.bleeding=0,this.eyeMeshes[e].visible=!1,this.nerveMeshes[e].visible=!1}this.clearWounds(t),this.clearGuts(t),this.clearSpine(t),this.clearCorpse(t),this.heart.owner===t&&(this.heart.active=!1,this.heartMesh.visible=!1);for(let e of[t*2,t*2+1]){let t=this.hands[e];t.active=!1,t.moving=!1,t.mesh.visible=!1,t.mesh.position.y=-50,this.applyBakedPart(t,void 0,1920728);let n=this.handStumps[e];n.active=!1,n.fountainLife=0,n.accumulator=0,n.mesh.visible=!1,n.mesh.position.y=-50}}drip(e,t,n,r=0){let i=+(r===1);if(this.bloodLevel===`off`||n||t<=.05){this.stopDrip(i);return}let a=this.dripEmitters[i];a.position.set($(e.x),$(e.y,1.5),$(e.z)),a.rate=this.bloodLevel===`reduced`?Math.min(3,t*3):Math.min(60,t*40),a.active=!0}stopDrip(e){let t=this.dripEmitters[+(e===1)];t.active=!1,t.rate=0,t.accumulator=0}gush(e,t,n,r,i,a,o=`blood`){if(this.bloodLevel!==`full`||e<0||e>=this.gushes.length)return;let s=this.gushes[Math.trunc(e)],c=Number.isSafeInteger(a)?a:0;s.active&&s.eventId===c||(s.active=!0,s.eventId=c,s.fluid=o,s.seconds=Math.max(.1,$(r,1)),s.life=s.seconds,s.rate=Math.max(0,$(i)),s.accumulator=0,this.anchorGush(e,t,n))}anchorGush(e,t,n){let r=this.gushes[Math.trunc(e)];r!==void 0&&r.active&&(r.position.set($(t.x),$(t.y,1.4),$(t.z)),n.lengthSq()>1e-8&&Number.isFinite(n.lengthSq())&&r.axis.copy(n).normalize())}gushing(e){return this.gushes[Math.trunc(e)]?.active===!0}stopGush(e){let t=this.gushes[e];t!==void 0&&(t.active=!1,t.eventId=null)}updateGushes(e){for(let t of this.gushes){if(!t.active)continue;if(t.life-=e,t.life<=0||this.bloodLevel!==`full`){t.active=!1;continue}let n=t.life/t.seconds,r=(t.seconds-t.life)*PW%1,i=Math.exp(-(((r-.5)/GW)**2));if(t.accumulator+=e*this.forDevice(t.rate)*n*(KW+.7*i),!(t.accumulator<1))for(XW.set(Math.abs(t.axis.y)<.9?0:1,+(Math.abs(t.axis.y)<.9),0).cross(t.axis).normalize(),ZW.crossVectors(t.axis,XW);t.accumulator>=1;){--t.accumulator;let e=Math.sqrt(this.ambientRandom())*JW,r=this.ambientRandom()*Math.PI*2,a=(qW+this.ambientRandom()*2)*(.5+.5*n)*(.7+.3*i);QW.copy(t.axis).multiplyScalar(Math.cos(e)).addScaledVector(XW,Math.sin(e)*Math.cos(r)).addScaledVector(ZW,Math.sin(e)*Math.sin(r)).multiplyScalar(a),this.spawnDroplet(t.position.x+(this.ambientRandom()-.5)*.03,t.position.y+(this.ambientRandom()-.5)*.02,t.position.z+(this.ambientRandom()-.5)*.03,QW.x,QW.y,QW.z,K_(t.fluid,this.ambientRandom()),1.2,!0,(.004+this.ambientRandom()**2*.01)*G_[t.fluid].drop,t.fluid)}}}updateDripEmitters(e){for(let t of this.dripEmitters)if(t.active)for(t.accumulator+=e*t.rate;t.accumulator>=1;)--t.accumulator,this.spawnDroplet(t.position.x+(this.ambientRandom()-.5)*.14,t.position.y-.04,t.position.z+(this.ambientRandom()-.5)*.1,(this.ambientRandom()-.5)*.08,-.25-this.ambientRandom()*.4,(this.ambientRandom()-.5)*.08,W_(this.ambientRandom()),1.1,!0)}spawnTeeth(e,t,n,r){if(this.bloodLevel===`off`)return;let i=this.bloodLevel===`reduced`?+(n>=3):Math.min(12,Math.max(1,Math.round(n)));if(i<=0)return;let a=eG((Number.isSafeInteger(r)?r:0)*7331+91),o=$G(t);for(let t=0;t>3):f.length>>2)}debrisSlot(e){let t=this.debrisCursor.get(e)??0,n=t%e.length;for(let r=0;r=0?n.scale*Math.max(0,n.fading)/AW:n.scale;this.gibScale.set(e*n.stretch,e,e/Math.sqrt(n.stretch))}this.gibMatrix.compose(this.gibPosition,this.gibQuaternion,this.gibScale),e.setMatrixAt(t,this.gibMatrix)}updateDebris(e,t,n,r){let i=!1;for(let[a,o]of e.entries()){if(!o.alive||o.resting&&o.fading<0)continue;if(i=!0,o.fading>=0){o.fading-=n,o.fading<=0&&(o.alive=!1),this.writeDebrisMatrix(t,a,o);continue}o.vy-=6.4*n,o.x+=o.vx*n,o.y+=o.vy*n,o.z+=o.vz*n,o.rx+=o.vrx*n,o.ry+=o.vry*n,o.rz+=o.vrz*n,this.confineGib(o);let e=0+(r===void 0?o.kind===`eye`?iG*JU:.015:r.low*o.scale);if(o.y<=e){if(o.y=e,!o.stained&&this.bloodLevel===`full`&&o.kind!==`tooth`&&o.kind!==`eye`&&(o.stained=!0,r===void 0?this.placeDecal(o.x,o.z,.24+o.scale*.16,.14+o.scale*.1,o.rz,.55,6425104):this.canvasBlood.stain(o.x,o.z,_G[r.shape].stain*o.scale,_G[r.shape].stain*o.scale*.7,o.ry,.6,6425104)),o.bounces.35)o.bounces+=1,o.vy=Math.abs(o.vy)*.3,o.vx*=.68,o.vz*=.68,o.vrx*=.7,o.vry*=.7,o.vrz*=.7;else{if(o.vx=0,o.vy=0,o.vz=0,o.vrx=o.vry=o.vrz=0,o.kind===`shard`&&(o.rx=Math.round(o.rx/Math.PI)*Math.PI),r!==void 0){let e=Math.round(o.rx/Math.PI),t=Math.round(o.rz/Math.PI);o.rx=e*Math.PI,o.rz=t*Math.PI,o.y=0+((e+t)%2==0?r.low:r.high)*o.scale}o.resting=!0}}this.writeDebrisMatrix(t,a,o)}i?t.instanceMatrix.needsUpdate=!0:r!==void 0&&(r.moving=!1)}confineGib(e){Math.abs(e.x)>3.05&&(e.x=Math.sign(e.x)*f_,e.vx*=-.45),Math.abs(e.z)>3.05&&(e.z=Math.sign(e.z)*f_,e.vz*=-.45)}updateDetachedParts(e,t){for(let n of e){if(n.active&&n.settle>=0&&n.settle<1){n.settle=Math.min(1,n.settle+t/aW);let e=n.settle*n.settle*(3-2*n.settle);n.mesh.quaternion.slerpQuaternions(n.settleFrom,n.settleTo,e),n.mesh.position.y=n.settleFromY+(n.settleToY-n.settleFromY)*e}if(!n.active||!n.moving)continue;let e=n.mesh.position.x,r=n.mesh.position.z;if(n.vy-=5.8*t,n.mesh.position.x+=n.vx*t,n.mesh.position.y+=n.vy*t,n.mesh.position.z+=n.vz*t,n.mesh.rotation.x+=n.vrx*t,n.mesh.rotation.y+=n.vry*t,n.mesh.rotation.z+=n.vrz*t,this.bloodLevel===`full`)for(n.trail+=t*this.forDevice(YU),n.trail>=1&&this.trailPoint.copy(n.cap.position).multiply(n.mesh.scale).applyQuaternion(n.mesh.quaternion).add(n.mesh.position);n.trail>=1;)--n.trail,this.spawnDroplet(this.trailPoint.x+(this.ambientRandom()-.5)*.03,this.trailPoint.y+(this.ambientRandom()-.5)*.03,this.trailPoint.z+(this.ambientRandom()-.5)*.03,n.vx*.35+(this.ambientRandom()-.5)*.9,n.vy*.35+(this.ambientRandom()-.5)*.9,n.vz*.35+(this.ambientRandom()-.5)*.9,W_(this.ambientRandom()),.9,!0);let i=g_-n.radius-oW,a=iK(n.mesh.position.x,n.vx,e,i),o=iK(n.mesh.position.z,n.vz,r,i);if(n.mesh.position.x=a.position,n.mesh.position.z=o.position,n.vx=a.velocity,n.vz=o.velocity,n.mesh.position.y<=0+n.radius){if(n.mesh.position.y=0+n.radius,!n.stained&&this.bloodLevel===`full`){n.stained=!0;let e=n.radius===iW?1:.55;this.placeDecal(n.mesh.position.x,n.mesh.position.z,1.3*e,.9*e,n.mesh.rotation.z,.85,4392199)}n.bounces<2&&Math.abs(n.vy)>.42?(n.bounces+=1,n.vy=Math.abs(n.vy)*.32,n.vx*=.62,n.vz*=.62,n.vrx*=.65,n.vry*=.65,n.vrz*=.65):(n.moving=!1,n.vx=0,n.vy=0,n.vz=0,n.vrx=0,n.vry=0,n.vrz=0,n.look!==null&&this.rollOntoEar(n))}Number.isFinite(n.mesh.position.x)&&Number.isFinite(n.mesh.position.y)&&Number.isFinite(n.mesh.position.z)&&Number.isFinite(n.mesh.quaternion.x)&&Number.isFinite(n.mesh.quaternion.y)&&Number.isFinite(n.mesh.quaternion.z)&&Number.isFinite(n.mesh.quaternion.w)||(n.mesh.position.set(0,0+n.radius,0),n.mesh.quaternion.identity(),n.moving=!1,n.vx=0,n.vy=0,n.vz=0)}}rollOntoEar(e){let t=this.settleAxis.set(1,0,0).applyQuaternion(e.mesh.quaternion),n=t.y>=0?1:-1;e.settleFrom.copy(e.mesh.quaternion),e.settleTo.setFromUnitVectors(t,this.settleUp.set(0,n,0)).multiply(e.mesh.quaternion),e.settleFromY=e.mesh.position.y,e.settleToY=0+(n>0?-e.sideLow:e.sideHigh),e.settle=0}stumpRandom(e){let t=e.seed|0;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),e.seed=t|0,((t^t>>>14)>>>0)/4294967296}updateStumpFountains(e){if(this.bloodLevel===`full`)for(let t of[...this.stumps,...this.handStumps]){if(!t.active||t.fountainLife<=0)continue;t.fountainLife=Math.max(0,t.fountainLife-e);let n=Math.min(1,t.fountainLife/NW),r=t.fountainLife*PW%1,i=Math.exp(-(((r-.5)/FW)**2));if(t.accumulator+=e*this.forDevice(IW)*n*(LW+.88*i),t.accumulator<1)continue;let a=$W(t,YW);for(XW.set(Math.abs(a.y)<.9?0:1,+(Math.abs(a.y)<.9),0).cross(a).normalize(),ZW.crossVectors(a,XW);t.accumulator>=1;){--t.accumulator;let e=this.stumpRandom(t),r=this.stumpRandom(t),o=this.stumpRandom(t),s=Math.sqrt(e)*BW,c=r*Math.PI*2;QW.copy(a).multiplyScalar(Math.cos(s)).addScaledVector(XW,Math.sin(s)*Math.cos(c)).addScaledVector(ZW,Math.sin(s)*Math.sin(c)).multiplyScalar(L.lerp(RW,zW,o)*(.7+.3*i)*(.55+.45*n)),this.spawnDroplet(t.mesh.position.x+a.x*.015+(e-.5)*.03,t.mesh.position.y+a.y*.015,t.mesh.position.z+a.z*.015+(r-.5)*.03,QW.x,QW.y,QW.z,W_(e),1.2+o*.6,!0,.004+o*o*.01)}}}update(e){for(this.canvasBlood.update(nK(e)),this.lens.update(nK(e)),this.simulationRemainder+=nK(e);this.simulationRemainder+1e-9>=EW;)this.simulationRemainder=Math.max(0,this.simulationRemainder-EW),this.simulate(EW);for(let e of this.guts)e.active&&e.sinceDrop<0&&e.rope.hold(e.anchor)&&(e.moved=!0),e.moved&&=(e.tube.write(e.rope),!1)}simulate(e){this.shake*=.02**e,this.updateDripEmitters(e),this.updateGushes(e),this.updateStumpFountains(e),this.updateDetachedParts(this.heads,e),this.updateDetachedParts(this.hands,e),this.updateShields(e),this.updateEyes(e),this.updateDebris(this.gibs,this.gibMesh,e),this.updateDebris(this.shards,this.shardMesh,e),this.updateDebris(this.eyeballs,this.eyeballMesh,e);for(let t of this.viscera)t.moving&&this.updateDebris(t.pieces,t.mesh,e,t);this.updateWounds(e),this.updateParts(e),this.updateSpines(e),this.updateGuts(e),this.updateHeart(e),this.updateCorpses(e);let t=this.liveDroplets,n=!1;for(let t=0;t0&&(this.dropletBuffers.position.needsUpdate=!0,this.dropletBuffers.color.needsUpdate=!0,this.uploadDroplets(0,this.liveDroplets,n));let r=!1;for(let[t,n]of this.mists.entries()){if(!n.alive)continue;if(r=!0,n.life-=e,n.life<=0){n.alive=!1,this.mistPositions[t*3+1]=-50;continue}let i=1-n.life/n.maxLife;this.mistPositions[t*3]=n.x,this.mistPositions[t*3+1]=n.y+i*.14,this.mistPositions[t*3+2]=n.z,this.mistColors[t*4+3]=Math.max(0,1-i)*Math.min(1,n.scale)}r&&(this.mistGeometry.attributes.position.needsUpdate=!0,this.mistGeometry.attributes.color.needsUpdate=!0)}clearDroplets(e){let t=this.liveDroplets;for(let t=0;t0))return;let s=eG((Number.isSafeInteger(i)?i:0)*15485863+e.charCodeAt(0)*131+e.length*977+7),c=$G(n),l=Math.max(.2,$(a,1)),u=$(t.x),d=$(t.y,1.2),f=$(t.z),p=Math.min(Math.round(r),this.debrisPlaces(e));for(let t=0;t0))return;let o=Number.isSafeInteger(i)?i:0,s=eG(o*86243+hG.indexOf(e)*3331+59),c=$G(n),l=G_[e],u=Math.max(.2,$(a,1)),d=$(t.x),f=$(t.y,1.2),p=$(t.z),m=Math.min(gG,r);for(let t=this.forDevice(m);t>0;--t){let t=s()*Math.PI*2,n=(.5+s()*1.9)*u;this.sprayDroplet(c,d+(s()-.5)*.08,f+(s()-.5)*.08,p+(s()-.5)*.08,(.4+s()*1.9)*u+Math.sin(t)*n*.35,(.3+s()*2.3)*Math.sqrt(u),Math.cos(t)*n*.8,K_(e,s()),.7+s(),!0,(.004+s()**2*.013)*l.drop,e)}if(e===`blood`){for(let e=Math.min(48,Math.round(m/25));e>0;--e)this.spawnMist(d+(s()-.5)*.4,f+(s()-.5)*.3,p+(s()-.5)*.4,.9+s()*1.5,.6+s()*.7);this.splatter(d+c.x*.3,p+c.z*.3,1+Math.min(2.4,m/500),s,Math.min(50,Math.round(m/20))),this.splashLens(d,f,p,Math.min(3,m/350),o)}else for(let e=Math.min(10,Math.round(m/30));e>0;--e){let t=.2+s()*.9*u;this.placeDecal(d+c.x*t+(s()-.5)*.5,p+c.z*t+(s()-.5)*.5,.5+s()*.9,.3+s()*.7,s()*Math.PI,.7*l.soak,e%2==0?l.splash:l.stain)}this.shake=Math.min(.22,this.shake+Math.min(.06,m/2e4))}puddle(e,t,n,r,i){if(this.bloodLevel!==`full`)return;let a=G_[r];this.canvasBlood.pool($(e),$(t),Math.max(.02,$(n,.1)),.95*a.soak,i,a.pool)}shed(e,t){if(this.bloodLevel!==`full`)return;let n=eG(t*7919+11);this.spawnDroplet($(e.x)+(n()-.5)*.05,$(e.y,1),$(e.z)+(n()-.5)*.05,(n()-.5)*.2,-.1,(n()-.5)*.2,K_(`blood`,n()),1.6,!0)}smear(e,t,n,r,i){this.bloodLevel===`full`&&this.canvasBlood.smear(e,t,n,r,Math.max(.005,$(i,.05)),.75,G_.blood.splash)}footprint(e,t,n,r,i){this.bloodLevel===`full`&&i>0&&this.canvasBlood.print(e,t,n,r,Math.min(1,i)*.85,G_.blood.splash)}setWound(e,t,n,r=`blood`){let i=this.woundAt(e,t);if(i===null)return;let a=this.bloodLevel===`full`?L.clamp($(n),0,1):0;a>0&&i.strength<=0&&(i.anchored=!1,i.accumulator=0,i.run=0,i.pool=0),i.strength=a,i.fluid=r,this.shareWounds()}anchorWound(e,t,n,r){let i=this.woundAt(e,t);i===null||i.strength<=0||(i.position.set($(n.x),$(n.y,1.2),$(n.z)),r.lengthSq()>1e-8&&Number.isFinite(r.lengthSq())&&i.axis.copy(r).normalize(),i.anchored=!0)}woundStrength(e,t){return this.woundAt(e,t)?.strength??0}clearWounds(e){for(let[t,n]of this.wounds.entries())(e===void 0||Math.floor(t/_e.length)===Math.trunc(e))&&(n.strength=0);this.shareWounds()}get openWounds(){return this.woundsOpen}woundAt(e,t){let n=Math.trunc(e);return n>=0&&nCG?CG/e:1}updateWounds(e){if(this.woundsOpen!==0&&this.bloodLevel===`full`){this.woundClock+=e;for(let t=0;t=wG){n.run-=wG;let e=.12+SG*r*r,i=l.y*e,a=(i+Math.sqrt(i*i+2*cW*Math.max(0,u.y-0)))/cW,o=u.x+l.x*e*a,s=u.z+l.z*e*a;n.pool<=0||Math.hypot(o-n.poolX,s-n.poolZ)>Math.max(.12,n.pool*1.2)?(n.poolX=o,n.poolZ=s,n.pool=.03):n.pool=Math.min(TG*(.25+.75*r),n.pool+.012);let c=G_[n.fluid];this.canvasBlood.pool(n.poolX,n.poolZ,n.pool,.95*c.soak,t*7+Math.round(n.pool*80),c.pool)}if(n.accumulator<1)continue;XW.set(Math.abs(l.y)<.9?0:1,+(Math.abs(l.y)<.9),0).cross(l).normalize(),ZW.crossVectors(l,XW);let d=L.lerp(.8,BW*.8,r),f=G_[n.fluid].drop;for(;n.accumulator>=1;){--n.accumulator;let e=Math.sqrt(this.ambientRandom())*d,t=this.ambientRandom()*Math.PI*2;QW.copy(l).multiplyScalar(Math.cos(e)).addScaledVector(XW,Math.sin(e)*Math.cos(t)).addScaledVector(ZW,Math.sin(e)*Math.sin(t)).multiplyScalar(c*(.75+this.ambientRandom()*.4)),this.spawnDroplet(u.x+l.x*.012+(this.ambientRandom()-.5)*.02,u.y+l.y*.012,u.z+l.z*.012+(this.ambientRandom()-.5)*.02,QW.x,QW.y,QW.z,K_(n.fluid,this.ambientRandom()),1.3+r*.5,!0,(.004+this.ambientRandom()**2*.01)*f,n.fluid)}}}}burstEye(e,t,n){let r=Math.trunc(e),i=pG(r,t),a=this.eyes[i];if(r<0||r>=XU||a===void 0||!a.active)return!1;if(a.active=!1,a.bleeding=0,this.eyeMeshes[i].visible=!1,this.nerveMeshes[i].visible=!1,this.bloodLevel!==`full`)return!0;let o=Number.isSafeInteger(n)?n:0,s=eG(o*39916801+i*211+3),{x:c,y:l,z:u}=a.position;for(let e=this.forDevice(160);e>0;--e){let t=s()*Math.PI*2,n=s()*1.6-.6,r=Math.sqrt(Math.max(0,1-Math.min(1,n*n))),i=.6+s()*2.2,a=e%3!=0;this.spawnDroplet(c,l,u,Math.cos(t)*r*i,n*i+.5,Math.sin(t)*r*i,a?W_(s()):dG,.5+s()*.7,a,.003+s()**2*.008)}for(let e=0;e<4;e+=1)this.spawnGib(c,l,u,(s()-.5)*1.6,.4+s()*1.2,(s()-.5)*1.6,s,`flesh`,r);for(let e=0;e<8;e+=1)this.spawnMist(c+(s()-.5)*.12,l+(s()-.5)*.1,u+(s()-.5)*.12,.5+s()*.6,.4+s()*.4);return this.splashLens(c,l,u,.8,o),!0}skinOf(e,t){let n=cK(t.sites===$h,e.map),r=e.look??Sy;return n.look?.set(r),n.material.color.setHex(e.color),n.injury.copyFrom(t),n.injury.setBindToPart(hK(e.geometry,r,this.bindToPartMatrix)),t.material instanceof qu&&(n.material.clearcoat=t.material.clearcoat),n.material}flingPart(e,t,n,r,i,a,o={}){this.removePart(e);let s=this.partBox.makeEmpty();for(let e of t){let t=e.geometry.getAttribute(`position`),n=e.geometry.getIndex(),r=n===null?t.count:n.count;for(let e=0;ep.reach)&&(p=e),(m===null||e.height>m.height)&&(m=e);for(let{fan:e,opening:t}of f)e.materialIndex=pK(o.part,t===p,t===m);c.cut.set(0,0,0),p!==null&&c.cut.copy(p.centre).sub(l),oK(c.group.quaternion,r),c.group.position.copy(l).applyQuaternion(c.group.quaternion),c.group.position.set(c.group.position.x+$(n.x),c.group.position.y+$(n.y,1.2),c.group.position.z+$(n.z)),c.group.visible=!0,c.key=e,c.born=this.partsThrown++;let h=0;for(let t=0;tt.key===e)}partPosition(e,t){let n=this.parts.find(t=>t.key===e);return n!==void 0&&(t.copy(n.group.position),!0)}removePart(e){for(let t of this.parts)if(t.key===e){t.key=null,t.moving=!1,t.settle=-1,t.group.visible=!1,t.group.clear();for(let e of t.geometries)e.dispose();for(let e of t.materials)e.dispose();t.geometries.length=0,t.materials.length=0}}get activeParts(){let e=0;for(let t of this.parts)t.key!==null&&(e+=1);return e}partResting(e){return this.parts.some(t=>t.key===e&&!t.moving&&(t.settle<0||t.settle>=1))}updateParts(e){let t=this.bloodLevel===`full`;for(let n=0;n=0&&r.settle<1){r.settle=Math.min(1,r.settle+e/aW);let t=r.settle*r.settle*(3-2*r.settle);i.quaternion.slerpQuaternions(r.settleFrom,r.settleTo,t),i.position.y=r.settleFromY+(r.settleToY-r.settleFromY)*t}if(!r.moving){if(!t||r.lain>=jG)continue;let a=Math.floor(r.lain/MG);for(r.lain+=e,this.trailPoint.copy(r.cut).applyQuaternion(i.quaternion).add(i.position),r.trail+=e*this.forDevice(NG);r.trail>=1;)--r.trail,this.spawnDroplet(this.trailPoint.x,Math.max(.02,this.trailPoint.y),this.trailPoint.z,(this.ambientRandom()-.5)*.5,.2+this.ambientRandom()*.5,(this.ambientRandom()-.5)*.5,W_(this.ambientRandom()),.6,!0);if(Math.floor(r.lain/MG)===a)continue;let o=.1+r.radius*1.8;r.pool=Math.min(o,r.pool+o*MG*1.5/jG),this.canvasBlood.pool(this.trailPoint.x,this.trailPoint.z,r.pool,.95,n*13+a);continue}let a=i.position.x,o=i.position.z;if(r.vy-=5.8*e,i.position.x+=r.vx*e,i.position.y+=r.vy*e,i.position.z+=r.vz*e,i.rotation.x+=r.vrx*e,i.rotation.y+=r.vry*e,i.rotation.z+=r.vrz*e,t)for(r.trail+=e*this.forDevice(YU),r.trail>=1&&this.trailPoint.copy(r.cut).applyQuaternion(i.quaternion).add(i.position);r.trail>=1;)--r.trail,this.spawnDroplet(this.trailPoint.x+(this.ambientRandom()-.5)*.03,this.trailPoint.y+(this.ambientRandom()-.5)*.03,this.trailPoint.z+(this.ambientRandom()-.5)*.03,r.vx*.35+(this.ambientRandom()-.5)*.9,r.vy*.35+(this.ambientRandom()-.5)*.9,r.vz*.35+(this.ambientRandom()-.5)*.9,W_(this.ambientRandom()),.9,!0);let s=Math.max(.5,g_-r.reach-oW),c=iK(i.position.x,r.vx,a,s),l=iK(i.position.z,r.vz,o,s);if(i.position.x=c.position,i.position.z=l.position,r.vx=c.velocity,r.vz=l.velocity,i.position.y<=0+r.radius){if(i.position.y=0+r.radius,!r.stained&&t){r.stained=!0;let e=Math.min(2.4,r.radius/iW+.3);this.placeDecal(i.position.x,i.position.z,1.3*e,.9*e,i.rotation.z,.85,4392199)}if(r.bounces<2&&Math.abs(r.vy)>.42)r.bounces+=1,r.vy=Math.abs(r.vy)*.32,r.vx*=.62,r.vz*=.62,r.vrx*=.65,r.vry*=.65,r.vrz*=.65;else{r.moving=!1,r.trail=0;let e=this.settleAxis.copy(r.thin).applyQuaternion(i.quaternion);r.settleFrom.copy(i.quaternion),r.settleTo.setFromUnitVectors(e,this.settleUp.set(0,e.y>=0?1:-1,0)).multiply(i.quaternion),r.settleFromY=i.position.y,r.settleToY=0+r.thickness,r.settle=0}}Number.isFinite(i.position.x+i.position.y+i.position.z+i.quaternion.x+i.quaternion.y+i.quaternion.z+i.quaternion.w)||(i.position.set(0,0+r.thickness,0),i.quaternion.identity(),r.moving=!1,r.settle=-1)}}attachSpine(e){let t=this.spines[Math.trunc(e)];t!==void 0&&this.bloodLevel===`full`&&(t.wanted=!0)}spineOut(e){return this.spines[Math.trunc(e)]?.out===!0}spineTail(e,t){let n=this.spines[Math.trunc(e)];return n===void 0||!n.out?!1:(n.rope.node(PG,t),!0)}updateSpines(e){for(let t=0;t=1;){--n.trail;let e=a.node(Math.floor(this.ambientRandom()*12),this.gibPosition);this.spawnDroplet(e.x,e.y,e.z,(this.ambientRandom()-.5)*.8,(this.ambientRandom()-.5)*.8,(this.ambientRandom()-.5)*.8,W_(this.ambientRandom()),.8,!0)}}}}writeSpine(e){let t=this.spines[e].rope;for(let n=0;n1e-6?i.multiplyScalar(1/a):i.set(0,1,0)),r.add(this.partVertex).multiplyScalar(.5);let o=(.9+.5*Math.min(1,n/6))*(n>=9?.55+.25*(10-n):1);this.gibMatrix.compose(r,this.gibQuaternion,this.gibScale.set(o,this.spineStretch,o)),this.spineMesh.setMatrixAt(e*PG+n,this.gibMatrix)}this.spineMesh.instanceMatrix.needsUpdate=!0;for(let n=0;ne.out);this.spineMesh.visible=n,this.shredMesh.visible=n}spillGuts(e,t,n,r=18){let i=this.guts[Math.trunc(e)];if(i===void 0||e<0||this.bloodLevel!==`full`)return;let a=Number.isSafeInteger(n)?n:0;if(i.active&&i.eventId===a)return;let o=L.clamp(Math.round($(r,18)),2,RG),s=Math.max(2,Math.min(o,this.lowTier?Math.ceil(this.budget.gutLinks/2):this.budget.gutLinks));i.active=!0,i.eventId=a,i.sinceDrop=-1,i.drip=0,i.smeared.fill(NaN),i.anchor.set($(t.x),$(t.y,.9),$(t.z)),i.rope.spill(s,o*MU/s,i.anchor,s/zG,eG(a*28657+Math.trunc(e)*5+1)),i.tube.write(i.rope),i.mesh.visible=!0,i.moved=!1}anchorGuts(e,t,n){let r=this.guts[Math.trunc(e)];r===void 0||!r.active||r.sinceDrop>=0||(r.anchor.set($(t.x),$(t.y,.9),$(t.z)),n.lengthSq()>1e-8&&Number.isFinite(n.lengthSq())&&r.away.copy(n).normalize())}gutsOut(e){return this.guts[Math.trunc(e)]?.active===!0}dropGuts(e){let t=this.guts[Math.trunc(e)];t===void 0||!t.active||t.sinceDrop>=0||(t.sinceDrop=0,t.rope.release())}clearGuts(e){for(let[t,n]of this.guts.entries())(e===void 0||t===Math.trunc(e))&&(n.active=!1,n.eventId=null,n.moved=!1,n.rope.clear(),n.mesh.visible=!1)}gutsLength(e){let t=this.guts[Math.trunc(e)];return t===void 0||!t.active?0:t.rope.length}gutsPoint(e,t,n){let r=this.guts[Math.trunc(e)];return r===void 0||!r.active?!1:(r.rope.node(Math.round(L.clamp(t,0,1)*(r.rope.nodes-1)),n),!0)}updateGuts(e){for(let t=0;t=0&&n.sinceDrop=BG&&i)){let e=r.node(r.nodes>>1,this.gibPosition);this.canvasBlood.pool(e.x,e.z,.26,.95,t+3),this.puddle(e.x+.12,e.z+.05,.11,`bile`,t+5)}if(r.step(e,n.anchor,0,Math.max(2.4383999999999997,Math.abs(n.anchor.x),Math.abs(n.anchor.z)),n.away)&&(n.moved=!0,i)){for(let e=0;e0+.024*1.5){n.smeared[e*2]=NaN;continue}let i=n.smeared[e*2],a=n.smeared[e*2+1],o=Math.hypot(t.x-i,t.z-a);o=0))for(n.drip+=e*this.forDevice(WG);n.drip>=1;){--n.drip;let e=r.node(Math.floor(this.ambientRandom()*r.nodes),this.gibPosition),t=this.ambientRandom()<.8?`blood`:`bile`;this.spawnDroplet(e.x,e.y-jU,e.z,(this.ambientRandom()-.5)*.3,-.1,(this.ambientRandom()-.5)*.3,K_(t,this.ambientRandom()),.9,!0,.004+this.ambientRandom()*.005,t)}}}}ejectHeart(e,t,n,r=-1){if(this.bloodLevel!==`full`)return;let i=this.heart,a=eG((Number.isSafeInteger(n)?n:0)*611953+19),o=$G(t),s=2+a()*1.2,c=(a()-.5)*1.2;i.active=!0,i.moving=!0,i.owner=Math.trunc(r),i.age=0,i.beats=0,i.bounces=0,i.settle=-1,i.pool=0,i.trail=0,i.vx=s*o.x-c*o.z,i.vy=1.8+a()*1.2,i.vz=s*o.z+c*o.x,i.vrx=(a()-.5)*14,i.vry=(a()-.5)*14,i.vrz=(a()-.5)*14,i.settleTo.setFromAxisAngle(eK,a()*Math.PI*2).multiply(KG),this.heartMesh.position.set($(e.x),$(e.y,1.2),$(e.z)),this.heartMesh.quaternion.identity(),this.heartMesh.scale.setScalar(GG),this.heartMesh.visible=!0}get heartOut(){return this.heart.active}get heartBeating(){return this.heart.active&&this.heart.age<14}heartPosition(e){return this.heart.active?(e.copy(this.heartMesh.position),!0):!1}updateHeart(e){let t=this.heart;if(!t.active)return;let n=this.heartMesh,r=this.bloodLevel===`full`;if(t.moving){let i=n.position.x,a=n.position.z;t.vy-=6.4*e,n.position.x+=t.vx*e,n.position.y+=t.vy*e,n.position.z+=t.vz*e,n.rotation.x+=t.vrx*e,n.rotation.y+=t.vry*e,n.rotation.z+=t.vrz*e;let o=g_-this.heartRadius-oW,s=iK(n.position.x,t.vx,i,o),c=iK(n.position.z,t.vz,a,o);if(n.position.x=s.position,n.position.z=c.position,t.vx=s.velocity,t.vz=c.velocity,r)for(t.trail+=e*this.forDevice(YU/2);t.trail>=1;)--t.trail,this.spawnDroplet(n.position.x,n.position.y,n.position.z,t.vx*.3+(this.ambientRandom()-.5)*.8,t.vy*.3+(this.ambientRandom()-.5)*.8,t.vz*.3+(this.ambientRandom()-.5)*.8,W_(this.ambientRandom()),.8,!0);n.position.y<=0+this.heartRadius&&(n.position.y=0+this.heartRadius,t.bounces===0&&r&&this.placeDecal(n.position.x,n.position.z,.9,.7,n.rotation.z,.8,4392199),t.bounces<2&&Math.abs(t.vy)>.4?(t.bounces+=1,t.vy=Math.abs(t.vy)*.3,t.vx*=.6,t.vz*=.6,t.vrx*=.6,t.vry*=.6,t.vrz*=.6):(t.moving=!1,t.settle=0,t.settleFrom.copy(n.quaternion),t.settleFromY=n.position.y)),Number.isFinite(n.position.x+n.position.y+n.position.z)||(n.position.set(0,0+this.heartRest,0),n.quaternion.copy(t.settleTo),t.moving=!1,t.settle=1)}else if(t.settle<1){t.settle=Math.min(1,t.settle+e/aW);let r=t.settle*t.settle*(3-2*t.settle);n.quaternion.slerpQuaternions(t.settleFrom,t.settleTo,r),n.position.y=t.settleFromY+(0+this.heartRest-t.settleFromY)*r}if(t.age>=14)return;t.age+=e;let i=_U(t.age),a=gU(t.age),o=vU(a)*(.35+.65*i);if(n.scale.set(GG*(1-.17*o),GG*(1+.08*o),GG*(1-.17*o)),Math.floor(a)<=t.beats||(t.beats=Math.floor(a),!r))return;let s=this.trailPoint.copy(pU.position).multiply(n.scale).applyQuaternion(n.quaternion).add(n.position),c=YW.copy(pU.direction).applyQuaternion(n.quaternion);XW.set(Math.abs(c.y)<.9?0:1,+(Math.abs(c.y)<.9),0).cross(c).normalize(),ZW.crossVectors(c,XW);for(let e=this.forDevice(Math.round(8+qG*i));e>0;--e){let e=Math.sqrt(this.ambientRandom())*.2,t=this.ambientRandom()*Math.PI*2;QW.copy(c).multiplyScalar(Math.cos(e)).addScaledVector(XW,Math.sin(e)*Math.cos(t)).addScaledVector(ZW,Math.sin(e)*Math.sin(t)).multiplyScalar((.7+2.9*i)*(.5+.55*this.ambientRandom())),this.spawnDroplet(s.x,s.y,s.z,QW.x,QW.y,QW.z,W_(this.ambientRandom()),1.1,!0,.004+this.ambientRandom()**2*.011)}t.moving||(t.pool=Math.min(.3,t.pool+.022),this.canvasBlood.pool(n.position.x,n.position.z,t.pool,.95,t.beats))}setCorpse(e,t){let n=Math.trunc(e),r=this.corpses[n];r!==void 0&&(t===null||this.bloodLevel!==`full`?this.clearCorpse(n):(r.active||(r.active=!0,r.age=0,r.puddle=0),r.position.set($(t.x),Math.max(0,$(t.y,0)),$(t.z))))}fliesOver(e){let t=this.corpses[Math.trunc(e)];return t===void 0||!t.active?0:this.fliesArrived(t.age)}fliesArrived(e){let t=this.lowTier?this.budget.flies>>1:this.budget.flies;return Math.floor(L.clamp((e-JG)/YG,0,1)*t)}updateCorpses(e){for(let t=0;t=n.puddle+.04&&(n.puddle=r,this.puddle(n.position.x,n.position.z,r,`urine`,t*11+Math.round(r*25)));let i=this.fliesArrived(n.age);if(i===0)continue;let a=this.budget.flies,o=YG/(this.lowTier?a>>1:a);for(let e=0;e=i)this.gibMatrix.makeScale(0,0,0).setPosition(0,-50,0);else{let t=Math.min(1,(n.age-JG-e*o)/XG),i=HU(this.flies,r,n.age,this.gibPosition),a=1+(1-t)*2.5;this.gibMatrix.makeTranslation(n.position.x+i.x*a,Math.max(.03,n.position.y+i.y+(1-t)*(1-t)*1.6),n.position.z+i.z*a)}this.flyMesh.setMatrixAt(r,this.gibMatrix)}this.flyMesh.visible=!0,this.flyMesh.instanceMatrix.needsUpdate=!0}}clearCorpse(e){let t=this.corpses[e];if(t.active){t.active=!1,this.gibMatrix.makeScale(0,0,0).setPosition(0,-50,0);for(let t=0;te.active)}}dispose(){this.scene.remove(this.dropletMesh),this.scene.remove(this.mistPoints),this.scene.remove(this.gibMesh),this.scene.remove(this.shardMesh),this.scene.remove(this.eyeballMesh);for(let e of this.viscera)this.scene.remove(e.mesh),e.mesh.dispose(),e.geometry.dispose();this.visceraMaterial.dispose();for(let e of this.parts)e.key!==null&&this.removePart(e.key),this.scene.remove(e.group);this.limbMaterial.dispose(),this.limbMap.dispose(),this.trunkMaterial.dispose(),this.trunkMap.dispose(),this.scene.remove(this.spineMesh,this.shredMesh,this.heartMesh,this.flyMesh),this.spineMesh.dispose(),this.shredMesh.dispose(),this.shredGeometry.dispose();for(let e of this.guts)this.scene.remove(e.mesh),e.tube.dispose();this.heartGeometry.dispose(),this.flyMesh.dispose(),this.flyGeometry.dispose(),this.flyMaterial.dispose(),this.dropletMesh.dispose(),this.dropletGeometry.dispose(),this.dropletMaterial.dispose(),this.canvasBlood.dispose();for(let e of[...this.heads,...this.hands])e.baked?.dispose(),e.bakedFlesh?.dispose();for(let e of[...this.stumps,...this.handStumps])e.flesh.dispose();this.mistGeometry.dispose(),this.mistMaterial.dispose(),this.mistMap.dispose(),this.gibMesh.dispose(),this.gibGeometry.dispose(),this.gibMaterial.dispose(),this.shardMesh.dispose(),this.eyeballMesh.dispose(),this.shardGeometry.dispose(),this.shardMaterial.dispose(),this.jawMaterial.dispose(),this.jawMap.dispose(),this.headGeometry.dispose();for(let e of this.headMaterials)e.dispose();this.handGeometry.dispose();for(let e of this.handMaterials)e.dispose();this.stumpGeometry.dispose(),this.wristStumpGeometry.dispose(),this.shieldGeometry.dispose();for(let e of this.shieldMaterials)e.dispose();for(let e of this.shieldMeshes)this.scene.remove(e);this.eyeGeometry.dispose(),this.eyeMap.dispose(),this.eyeMaterial.dispose(),this.nerveGeometry.dispose(),this.nerveMaterial.dispose();for(let e of[...this.eyeMeshes,...this.nerveMeshes])this.scene.remove(e);if(this.stumpMaterial.dispose(),this.stumpMap.dispose(),this.wristMaterial.dispose(),this.wristMap.dispose(),this.bakedStandIns!==null){this.bakedStandIns.map.dispose();for(let e of this.bakedStandIns.materials)e.dispose();for(let e of this.bakedStandIns.instanced)e.dispose();this.bakedStandIns=null}for(let e of this.heads)this.scene.remove(e.mesh);for(let e of this.hands)this.scene.remove(e.mesh);for(let e of[...this.stumps,...this.handStumps])this.scene.remove(e.mesh)}},vK={maximum:1,minimum:.55,slowMs:24,fastMs:17.5,windowMs:1e3,step:.15},yK=10,bK=10,xK=160,SK=3,CK=3,wK=class{options;scale;elapsed=0;frames=0;fastWindows=0;holdWindows=0;fruitlessAttempts=0;pending=null;raised=null;raiseHoldWindows=0;failedRaises=0;constructor(e=vK){this.options=e,this.scale=e.maximum}record(e){if(!(e>0)||e>1e3||(this.elapsed+=e,this.frames+=1,this.elapsede.before*.9)return this.scale=e.previous,this.holdWindows=Math.min(xK,yK*2**this.fruitlessAttempts),this.fruitlessAttempts+=1,!0;this.fruitlessAttempts=0}if(this.raised!==null){let e=this.raised;if(t>this.options.slowMs)return this.raised=null,this.scale=e.previous,this.fastWindows=0,this.raiseHoldWindows=Math.min(xK,bK*2**this.failedRaises),this.failedRaises+=1,!0;e.windows+=1,e.windows>=CK&&(this.raised=null,this.failedRaises=0)}if(t>this.options.slowMs){if(this.fastWindows=0,this.holdWindows>0)return--this.holdWindows,!1;if(this.scale<=this.options.minimum)return!1;let e=this.scale;return this.scale=Math.max(this.options.minimum,this.scale-this.options.step),this.pending={before:t,previous:e},!0}return t0?(--this.raiseHoldWindows,!1):this.fastWindows>=SK&&this.scale0&&e.poise===0)return 1;if(e.is_downed)return EK;let n=e.stunned_ticksthis.value?7:.9;return this.value+=(e-this.value)*(1-Math.exp(-n*Math.max(0,t))),e===0&&this.value<.003&&(this.value=0),this.value}},kK=.4,AK=.5,jK={before:24,after:24,speed:.5};function MK(e,t,n=30,r=kK,i=42,a=33){let o=t.tick-i,s=t.tick+a,c=e.filter(e=>e.tick>=o-1&&e.tick<=s+1),l=c.at(-1),u=l!==void 0&&l.result!==null&&l.tick({...l,tick:l.tick+t+1,events:[]}))]:c,d=u[0],f=u.at(-1);if(d===void 0||f===void 0||u.length<8||d.tick>t.tick-12||f.tick=1&&this.lastHeat<1&&!r&&(this.flare=1),this.lastHeat=t,this.flare=Math.max(0,this.flare-n/LK);let a=this.mesh.material;if(a.opacity=Math.min(1,t*.8+this.flare*.6),this.mesh.visible=a.opacity>.01,!this.mesh.visible)return;this.mesh.position.copy(e),this.mesh.quaternion.copy(i.quaternion);let o=FK*(.55+.45*t)*(1+this.flare*IK);this.mesh.scale.set(o,o,1)}get active(){return this.mesh.visible}standIn(){return new V(this.mesh.geometry,this.mesh.material)}reset(){this.flare=0,this.lastHeat=0,this.mesh.material.opacity=0,this.mesh.visible=!1}dispose(){this.mesh.geometry.dispose(),this.mesh.material.dispose()}},GK=class{group=new gs;flash;ring;age=1/0;constructor(e){this.flash=UK(e,new B(1,.86,.62)),this.flash.material.depthTest=!1,this.ring=new V(new ju(.42,.5,40),new Pc({color:PK,blending:2,depthWrite:!1,transparent:!0,side:2})),this.flash.renderOrder=6,this.ring.renderOrder=6,this.group.add(this.flash,this.ring),this.group.visible=!1}fire(e){this.age=0,this.group.position.copy(e)}update(e,t){this.age+=e;let n=this.age/RK,r=this.age/BK;if(this.group.visible=r<1,!this.group.visible)return;this.group.quaternion.copy(t.quaternion),this.flash.visible=n<1;let i=zK*(.35+.65*Math.sqrt(Math.min(1,n)));this.flash.scale.set(i,i,1),this.flash.material.opacity=(1-Math.min(1,n))**2;let a=VK*(.15+.85*(1-(1-r)**3));this.ring.scale.set(a,a,a),this.ring.material.opacity=.9*(1-r)}get active(){return this.group.visible}standIns(){return[new V(this.flash.geometry,this.flash.material),new V(this.ring.geometry,this.ring.material)]}reset(){this.age=1/0,this.group.visible=!1}dispose(){this.flash.geometry.dispose(),this.flash.material.dispose(),this.ring.geometry.dispose(),this.ring.material.dispose()}},KK=10,qK=.055,JK=3.2,YK=1.4,XK=class{color;mesh;geometry;positions=new Float32Array(60);colors=new Float32Array(80);history=[];last=new z;hasLast=!1;tangent=new z;side=new z;toCamera=new z;shade=new B;strength=0;heat=0;constructor(e){this.color=e,this.geometry=new yc,this.geometry.setAttribute(`position`,new ic(this.positions,3).setUsage(Aa)),this.geometry.setAttribute(`color`,new ic(this.colors,4).setUsage(Aa));let t=[];for(let e=0;e<9;e+=1){let n=e*2;t.push(n,n+1,n+2,n+1,n+3,n+2)}this.geometry.setIndex(t);let n=new Pc({vertexColors:!0,transparent:!0,blending:2,depthWrite:!1,side:2});this.mesh=new V(this.geometry,n),this.mesh.frustumCulled=!1,this.mesh.visible=!1,this.mesh.renderOrder=4}update(e,t,n,r,i=0){if(t<=0)return;let a=this.hasLast?e.distanceTo(this.last)/t:0;this.last.copy(e),this.hasLast=!0,this.heat=i>this.heat?i:this.heat+(i-this.heat)*Math.min(1,t*6);let o=JK*(1-.55*this.heat),s=r&&a>o?Math.min(1,(a-o)/4+this.heat*.4):0;this.strength+=(s-this.strength)*Math.min(1,t*18);let c=this.history.length>=KK?this.history.shift():new z;if(c.copy(e),this.history.push(c),this.strength<.02||this.history.length<3){this.mesh.visible=!1;return}let l=this.history.length,u=this.shade.copy(this.color).lerp(PK,this.heat),d=qK*(1+YK*this.heat);for(let e=0;e3*t}function eq(e,t,n){let r=e.detail.endsWith(`:head`)||e.detail.endsWith(`:body`);return t===void 0||![`hit`,`counter_hit`].includes(e.kind)||!r||n===null||n.winner_id===null||n.winner_id!==e.actor_id?!1:n.finish_method===`flash_ko`||(n.finish_method===`ko`||n.finish_method===`tko`)&&t.is_downed}function tq(e){for(let t of e.passes)t.dispose?.();e.dispose()}function nq(e,t,n,r,i){e.setRenderTarget(t.readBuffer);let a=e.compileAsync(n,r,i);return e.setRenderTarget(null),a}var rq=-4e-4,iq=10,aq=16;function oq(e,t,n){let r=t?aq:n;e.autoUpdate=!t,e.intensity=+!t,e.bias=t?iq:rq,e.mapSize.x!==r&&(e.mapSize.set(r,r),e.map?.dispose(),e.map=null,e.needsUpdate=!0)}function sq(e,t){let n=t.fighters.findIndex(t=>t.player_id===e.target_id),r=t.fighters.findIndex(t=>t.player_id===e.actor_id),i=e.kind===`block`||e.kind===`perfect_block`;return{recipientIndex:i?r:n,puncherIndex:i?n:r}}function cq(e,t,n){if(e===void 0||t===void 0)return;let r=n.x(t.x)-n.x(e.x),i=n.z(t.y)-n.z(e.y),a=Math.hypot(r,i);return Number.isFinite(a)&&a>.001?{x:r/a,z:i/a}:void 0}var lq=e=>e.kind===`hit`||e.kind===`counter_hit`,uq=e=>e.kind===`block`||e.kind===`perfect_block`,dq=480,fq=.56,pq=1.8,mq=1.7,hq=1.2,gq=1.6,_q=30,vq=6.5,yq=.4,bq=600,xq=2.8,Sq=.6,Cq=[[1,0],[-1,0],[.75,-.66],[-.75,-.66],[.75,.66],[-.75,.66]],wq=.15,Tq=.6,Eq=2.3,Dq=.5,Oq=3.42,kq=2.2,Aq=.9,jq=`body`,Mq=`collapse`,Nq=.55,Pq=.5,Fq=.5,Iq=.28,Lq=104,Rq=260,zq=.05,Bq=2.95,Vq=2.4,Hq=1.6,Uq=.98,Wq=500,Gq={uniforms:{tDiffuse:{value:null},uTime:{value:0},uVignette:{value:.32},uGrain:{value:.035},uRocked:{value:0}},vertexShader:` varying vec2 vUv; void main() { vUv = uv; @@ -5387,8 +5535,8 @@ void main() { float grain = (hash(floor(vUv * vec2(960.0, 540.0))) - 0.5) * uGrain; color.rgb += grain * (0.15 + color.rgb); gl_FragColor = color; -}`},FG=[{x:-102,y:-16},{x:102,y:-16}],IG=[0,1],LG=.5,RG={x:0,z:-.2},zG=0,BG=200,VG=1.3,HG=.7,UG=4.5;function WG(e,t,n,r){let i=n.x-e,a=n.y-t,o=Math.hypot(i,a);return o<=Math.max(r,1e-6)?{x:n.x,y:n.y,arrived:!0}:{x:e+i/o*r,y:t+a/o*r,arrived:!1}}var GG=16,KG=.6,qG={hit:.18,counter_hit:.3,guard_break:.25,knockdown:1,block:.04,perfect_block:.1,parry:.22,body_collapse:.45},JG=new Set([`hit`,`counter_hit`,`block`,`perfect_block`,`guard_break`,`knockdown`,`parry`,`body_collapse`,`eye_shut`]),YG=new Set([`parry`,`body_collapse`,`eye_shut`]),XG=new Set([`hit`,`counter_hit`,`block`,`perfect_block`]),ZG=1.2,QG=.8,$G=2.4,eK=2.5,tK=new Set([`referee_hit`,`referee_down`]),nK=.05,rK=.08,iK={parry:{text:`PARRIED`,seconds:1},eye_shut:{text:`EYE SWOLLEN SHUT`,seconds:1.6}},aK=new Set([`injury`,`vomit`,`finish_him`,`fatality`,`death`]),oK=1.8,sK=3,cK=.6;function lK(e,t){let n=Ae(e,t);return n!==`severed`&&n!==`torn`}function uK(e){return e.kind===`death`?e.detail===`brain`?`head_burst`:null:e.kind===`fatality`?e.detail===`head_burst`?`head_burst`:e.detail===`decapitation`||e.detail===`spine_rip`?`decapitation`:null:null}var dK=e=>e.kind===`knockdown`&&e.detail===`body`;function fK(e,t){if($W(e)&&e.action_id!==null)return t.find(t=>eG(t)&&t.action_id===e.action_id&&t.actor_id===e.target_id&&t.target_id===e.actor_id)}function pK(e,t){if(eG(e)&&e.action_id!==null)return t.find(t=>$W(t)&&t.action_id===e.action_id&&t.actor_id===e.target_id&&t.target_id===e.actor_id)}function mK(e,t){return e.map((n,r)=>{if(YG.has(n.kind)||n.kind===`knockdown`&&n.detail===SG)return{event:n,presentationEvent:n,presentImpact:!1,reactAmount:null};let{puncherIndex:i}=ZW(n,t),a=t.fighters[i],o=a?.action_key?.split(`:`)??[],s=o.length>=3?`${o[0]}:${o[2]}`:n.detail,c=pK(n,e);if(eG(n))return{event:n,presentationEvent:{...n,detail:c?.detail||s,direction:c?.direction??a?.facing??n.direction,blood:c?.blood??n.blood},presentImpact:!0,reactAmount:n.amount};if(fK(n,e)!==void 0)return{event:n,presentationEvent:n,presentImpact:!1,reactAmount:n.amount};if(n.kind===`knockdown`){let t=e.slice(0,r).reverse().find(e=>$W(e)&&e.tick===n.tick&&e.actor_id===n.actor_id&&e.target_id===n.target_id);if(t!==void 0)return{event:n,presentationEvent:{...n,detail:t.detail,direction:t.direction,blood:t.blood,action_id:t.action_id},presentImpact:!0,reactAmount:fK(t,e)===void 0?null:t.amount}}return{event:n,presentationEvent:n,presentImpact:!0,reactAmount:n.amount}})}function hK(e){let t=e?.trauma;if(t===void 0)return{side:1,lift:.08,lateral:.035,prop:`enswell`};switch(e?.corner_choice){case`cut`:return{side:t.right_cut>t.left_cut?-1:1,lift:.11,lateral:.04,prop:`enswell`};case`swelling`:return{side:t.right_eye>t.left_eye?-1:1,lift:.08,lateral:.035,prop:`enswell`};case`breath`:return{side:1,lift:-.015,lateral:0,prop:`bottle`};default:return{side:t.right_eye+t.right_cut>t.left_eye+t.left_cut?-1:1,lift:.08,lateral:.035,prop:`enswell`}}}function gK(e){return e?.split(`:`)[1]===`right`?1:-1}function _K(e){return e.result===null?e.tick-1:e.tick}var vK=50,yK=40,bK=40,xK=50,SK=[`jab`,`straight`,`hook`,`uppercut`];function CK(e,t,n,r){if(!WW(e,t,n))return null;let i=r?.action_key?.split(`:`),a=e.detail.split(`:`).find(e=>SK.includes(e))??i?.[0],o=i?.[1]===`right`?`left`:`right`,s=e.amount;return e.detail.endsWith(`:head`)?n?.finish_method===`flash_ko`||e.kind===`counter_hit`&&s>=70?`head_burst`:a===`uppercut`&&s>=yK||a===`straight`&&s>=vK?`decapitation`:(a===`hook`||a===`jab`)&&s>=bK?`eye_${o}`:`jaw_dislocation`:a===`hook`?s>=xK?`dismember_${o}`:`shoulder_${o}`:`ribs_${o}`}function wK(){let e=document.createElement(`canvas`);e.width=128,e.height=128;let t=e.getContext(`2d`);if(t!==null){let e=t.createRadialGradient(64,64,8,64,64,62);e.addColorStop(0,`rgba(0,0,0,0.68)`),e.addColorStop(.6,`rgba(0,0,0,0.34)`),e.addColorStop(1,`rgba(0,0,0,0)`),t.fillStyle=e,t.fillRect(0,0,128,128)}return new ky(e)}var TK=new q(0,.12,.02),EK=new q(0,1,0),DK=new WeakMap;function OK(e){let t=DK.get(e);return t===void 0&&(t=AO(e,qK),DK.set(e,t)),t}function kK(e){return e.y>cA-1.4}var AK=new WeakMap;function jK(e){let t=AK.get(e);return t===void 0&&(t=AO(e,kK),AK.set(e,t)),t}function MK(e,t,n){let r=e.bone(`head`);if(r===null)return null;e.root.updateMatrixWorld(!0);let i=e.headMesh,a=jK(i.geometry);if(a.length===0)return null;let o=t.length===a.length*3?t:new Float32Array(a.length*3);n.position.set(0,0,0);for(let[t,r]of a.entries())VK(e,r,n.scratch),n.scratch.toArray(o,t*3),n.position.add(n.scratch);return n.position.multiplyScalar(1/a.length),r.getWorldQuaternion(n.quaternion),n.across.set(1,0,0).applyQuaternion(n.quaternion),n.scratch.set(0,1,0).applyQuaternion(n.quaternion),n.quaternion.setFromUnitVectors(EK,n.scratch),o}function NK(e,t,n,r){let i=e?.currentRoot;return r.set(i?.x??n.x(t.x),0,i?.z??n.z(t.y))}function PK(e,t,n,r,i){let a=Math.hypot(e-n,t-r);return a>=i?{x:e,z:t}:a<1e-6?{x:n,z:r-i}:{x:n+(e-n)/a*i,z:r+(t-r)/a*i}}var FK=[0,1.05,-1.05,2.1,-2.1,Math.PI];function IK(e,t,n,r,i,a,o=[]){let s=n===null?0:Math.hypot(n.x,n.z),c=n!==null&&s>=.35?[Math.atan2(n.x,n.z)]:[];for(let e of FK)c.push(a+e);for(let n of c){let a=G.clamp(e+Math.sin(n)*r,-i,i),s=G.clamp(t+Math.cos(n)*r,-i,i),c=Math.hypot(a-e,s-t);if(!(c{let r=G.clamp(((n.x-e)*(a-e)+(n.z-t)*(s-t))/(c*c),.25,1);return Math.hypot(e+(a-e)*r-n.x,t+(s-t)*r-n.z)1e-9&&(s=Math.min(s,(Math.sign(n)*i-e)/n)),Math.abs(r)>1e-9&&(s=Math.min(s,(Math.sign(r)*a-t)/r));for(let i of[-1,1])for(let a of[-1,1]){let c=i*n+a*r;c>1e-9&&(s=Math.min(s,(o-i*e-a*t)/c))}return Math.max(0,s)}function RK(e,t,n,r,i,a,o,s=1/0){let c=Math.hypot(n-e,r-t);if(c>=i)return null;let l=c<1e-6?1:(n-e)/c,u=c<1e-6?0:(r-t)/c,d=i-c,f=LK(e,t,-l,-u,a,o,s),p=LK(n,r,l,u,a,o,s),m=Math.min(d/2,f),h=Math.min(d-m,p);m=Math.min(d-h,f);let g=G.clamp;return{ax:g(e-l*m,-a,a),ay:g(t-u*m,-o,o),bx:g(n+l*h,-a,a),by:g(r+u*h,-o,o)}}var zK=new WeakMap;function BK(e,t,n,r,i,a,o,s=null){let c=zK.get(e);if(c!==void 0&&c.width===t&&c.height===n)return c.top;let l=Hr(t,n,zr(e,r,i,r.map(e=>a.total(e.player_id)),s),!0).y;return zK.set(e,{width:t,height:n,top:l}),l}function VK(e,t,n){let r=e.headMesh;return Dj(n.fromBufferAttribute(r.geometry.getAttribute(`position`),t),e.look,n),r.applyBoneTransform(t,n).applyMatrix4(r.matrixWorld)}var HK=new Sg,UK=new Sg,WK=new Dg;function GK(e,t,n){let r=e.geometry;HK.fromBufferAttribute(r.getAttribute(`skinIndex`),t),UK.fromBufferAttribute(r.getAttribute(`skinWeight`),t),n.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);for(let t=0;t<4;t+=1){let r=UK.getComponent(t);if(r===0)continue;let i=HK.getComponent(t);WK.multiplyMatrices(e.skeleton.bones[i].matrixWorld,e.skeleton.boneInverses[i]);for(let e=0;e<16;e+=1)n.elements[e]+=WK.elements[e]*r}return n.premultiply(e.bindMatrixInverse).multiply(e.bindMatrix)}var KK=new q(-1,0,0);function qK(e){return e.y>oA-sA*(e.z- -4)-.3}var JK={tick_rate:30,ring_half_width:500,ring_half_height:500};function YK(e,t,n,r,i,a,o=!0){let s=e.geometry,c=s.getAttribute(`position`),l=s.getIndex(),u=[],d=l!==null&&r===void 0?[]:null;if(l===null||d===null)for(let e=0;e=i.start+o))return{action:i.punchClass,action_hand:i.hand,action_target:`head`,action_power:`normal`,action_id:`idle-${n}-${r}`,action_key:`${i.punchClass}:${i.hand}:head:normal`,action_start_tick:e-(t-i.start),action_startup_ticks:a.startup,action_active_ticks:a.active,action_recovery_ticks:a.recovery,action_contact_tick:e-(t-i.start)+a.startup}}return{}}var nq=1000003,rq=1.6;function iq(e,t,n,r,i,a){let o=r<0?-1:1,s=o=>Math.hypot(G.clamp(e+n*o*i,-a,a)-e,G.clamp(t+r*o*i,-a,a)-t);return s(o)>=i*.8||s(o)>=s(-o)?o:-o}function aq(e,t,n){return t?e.kind===`knockdown`?1:Math.min(1,.35+e.amount/400):(n===`full`?1:n===`reduced`?.4:0)*(e.kind===`knockdown`?.85:e.amount>=50?Math.min(.75,(e.amount-30)/140):0)}function oq(e){if(e.kind!==`hit`&&e.kind!==`counter_hit`||e.amount<(e.detail.endsWith(`:body`)?70:50))return null;let t=Math.min(100,Math.max(0,e.blood));return{seconds:.6+t/50,rate:150+e.amount*1.5+t*2}}function sq(e,t){return t===`full`?e>100?Math.min(.65,e/1800):0:e>350?Math.min(.3,e/4600):0}function cq(e){return!e.is_downed&&e.stunned_ticks===0&&e.clinch_ticks===0&&e.clinch_startup_ticks===0&&e.taunt_ticks===0&&!e.is_foul_recovery_target}function lq(e,t){if(e===null)return null;let n=t.fighters.find(t=>t.player_id===e.target_id),r=t.fighters.find(t=>t.player_id===e.actor_id);return CK(e,n===void 0?void 0:{...n,is_downed:!0},{finish_method:`ko`,winner_id:e.actor_id},r)}var uq=.2,dq=1.1,fq=1.6,pq=2.4,mq=2,hq=new q(0,-.1,.08),gq=new q(0,-.07,.1),_q=new q(0,-.35,1),vq=3,yq=320,bq=8,xq=1.6,Sq=.08,Cq=.12,wq=e=>e===`shoulder_left`||e===`shoulder_right`||e===`ribs_left`||e===`ribs_right`?e:`mouth`;function Tq(e,t,n=dq){return Math.min(n,.06+.08*Math.sqrt(Math.max(0,e))*Math.min(1.6,Math.max(0,t)))}function Eq(e,t,n){return e.is_downed||t?.isDown===!0||n!==void 0&&e.player_id===n}var Dq=6,Oq=11,kq=.13;function Aq(e,t){let n=t===`left`?`leftRibs`:`rightRibs`;e.impact(n,[t===`left`?-6:Dq,-6*.15,-1.5],Oq),e.set(n,{bruise:1.2,swell:0,blood:1.4})}function jq(e,t){e.set(`mouth`,{cut:1,blood:1.4}),e.set(`chin`,{bruise:1.2}),t.set(`neckSmear`,{blood:1.4})}function Mq(e,t){e.set(t===`left`?`leftShoulderSmear`:`rightShoulderSmear`,{blood:1.4}),e.set(t===`left`?`leftPec`:`rightPec`,{bruise:1.1})}var Nq=new WeakMap;function Pq(e,t){let n=Nq.get(e);if(n===void 0){let t=e.getAttribute(`position`),r=new q,i=new q,a=VA.map(e=>{let n=0,a=1/0;i.set(e[0],e[1],e[2]);for(let e=0;ethis.onAnnouncement?.(e),cue:e=>this.onCrowdCue?.(e)});touchControls=Md();resultAnnounced=!1;captionText=``;rocked=new vW;tmpA=new q;tmpB=new q;contactPoint=new q;cornerPanelTop=null;mouthPoint=new q;tmpHead=new q;tmpHeadQuaternion=new rg;tmpStump=new q;tmpStumpOffset=new q;tmpStumpQuaternion=new rg;tmpStumpAcross=new q;tmpPart=new q;tmpPartQuaternion=new rg;woundPoint=new q;woundAxis=new q;constructor(e,t=JK,n,r={}){this.canvas=e,this.simulation=t,this.settings=n,this.manualClock=r.manualClock===!0,this.localInput=r.localInput??null,this.powerHeld=r.powerHeld??null,this.inputSequenceOf=r.inputSequenceOf??null,this.buffer=new Ef(8,t.tick_rate),this.mapping=DE(t),this.renderer=new AT({canvas:e,antialias:!0,powerPreference:`high-performance`,preserveDrawingBuffer:r.manualClock===!0}),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=1,this.renderer.toneMapping=4,this.renderer.toneMappingExposure=1,this.renderer.setPixelRatio(this.basePixelRatio),this.scene.background=new J(`#04060b`),this.scene.fog=new l_(`#04060b`,.042),this.camera=new Ox(36,1,.1,80),this.camera.position.set(0,2.05,5.9),this.camera.lookAt(0,1.05,0),this.setupLights(),this.ring=rF(),this.scene.add(this.ring.group),this.arena=iD(),this.scene.add(this.arena.group),this.effects=new sW(this.scene,Md()?1024:2048,Md()?PV:NV),this.effects.useUploader(this.renderer),this.effects.setCamera(this.camera),this.carnage=new Yz(this.effects,ZK),this.blobTexture=wK();let i=new hb(1,1);for(let e=0;e<3;e+=1){let t=new Y(i,new yv({map:this.blobTexture,transparent:!0,depthWrite:!1}));t.rotation.x=-Math.PI/2,t.position.y=.006+e*4e-4,t.renderOrder=1,this.blobShadows.push(t),this.scene.add(t)}this.composer=new zT(this.renderer),this.composer.addPass(new BT(this.scene,this.camera));let a=new HT(new K(1280,720),.2,.45,1.08);this.bloomPass=a,this.composer.addPass(a),this.finishPass=new IT(PG),this.composer.addPass(this.finishPass),this.composer.addPass(new WT),this.hudCanvas=document.createElement(`canvas`),this.hudCanvas.className=`fight-hud`,this.hudCanvas.style.cssText=`position:absolute;inset:0;width:100%;height:100%;pointer-events:none`,e.insertAdjacentElement(`afterend`,this.hudCanvas),this.bloodLevel=n().blood,this.effects.setBloodLevel(this.bloodLevel),this.ensureGraphs(),this.manualClock||(this.raf=requestAnimationFrame(e=>this.draw(e)))}ensureGraphs(){this.glbLoading||this.graphs!==null||(this.glbLoading=!0,this.graphsReady=mF().then(async e=>{if(this.destroyed)return;let t=new DF(e,{skin:11563071,gear:1920728}),n=new DF(e,{skin:7225640,gear:12131356});this.graphs=[new aI(t,this.mapping),new aI(n,this.mapping)];let r=[this.carnage.attach(0,this.graphs[0]),this.carnage.attach(1,this.graphs[1])];this.lookIds.fill(null),this.syncInjuryPresentation(0),this.syncInjuryPresentation(1);let i=new DF(e,{skin:13081462,gear:3889080,look:hj.referee,outfit:Pj,wounds:!0});this.referee=new aI(i,this.mapping,{referee:!0,knockout:!0});let a=new DF(e,{skin:9067067,gear:1778224,look:hj.blueCorner,outfit:Fj}),o=new DF(e,{skin:14264188,gear:1778224,look:hj.redCorner,outfit:Ij});this.cornermen=[new aI(a,this.mapping,{referee:!0}),new aI(o,this.mapping,{referee:!0})];let s=new DF(e,{skin:12160102,gear:1778224,look:hj.blueCutman,outfit:Lj}),c=new DF(e,{skin:5913126,gear:1778224,look:hj.redCutman,outfit:Lj});this.cutmen=[new aI(s,this.mapping,{referee:!0}),new aI(c,this.mapping,{referee:!0})],s.root.visible=!1,c.root.visible=!1,this.trails=[1920728,12131356].flatMap(e=>[0,1].map(()=>new BW(new J(e).lerp(new J(16777215),.55))));let l=MW();this.glowMap=l,this.glows=[0,1,2,3].map(()=>new PW(l)),this.impactFlashes=[0,1].map(()=>new FW(l));let u=new t_;u.add(t.root,n.root,i.root,a.root,o.root,s.root,c.root,...this.trails.map(e=>e.mesh),...this.effects.compileStandIns(),...r.flatMap(e=>e.compileStandIns()),this.glows[0].standIn(),...this.impactFlashes[0].standIns());let d=t.headInjury.open;t.headInjury.setOpen(!0);try{await KW(this.renderer,this.composer,u,this.camera,this.scene)}catch{}if(!this.destroyed){this.scene.add(t.root,n.root,i.root,a.root,o.root,s.root,c.root);for(let e of this.trails)this.scene.add(e.mesh);for(let e of this.glows)this.scene.add(e.mesh);for(let e of this.impactFlashes)this.scene.add(e.group);this.compileShadowsOf(u),t.headInjury.setOpen(d)}}).catch(e=>{this.glbLoading=!1,console.error(`boxer_glb_load_failed`,e)}))}compileShadowsOf(e){let t=this.keyLight;if(t!==null&&e.children.length!==0){for(let t of e.children)t.frustumCulled=!1,t.onBeforeShadow=(e,t,n,r,i,a)=>{a.needsUpdate=!0};this.scene.add(e),t.shadow.needsUpdate=!0,this.renderer.setRenderTarget(this.composer.readBuffer);try{this.renderer.render(this.scene,this.camera)}catch{}finally{this.renderer.setRenderTarget(null),this.scene.remove(e)}}}get ready(){return this.graphsReady}get labRigs(){let e=this.graphs;return e===null?[]:[e[0].boxer.root,e[1].boxer.root]}get labScene(){return this.scene}get labEffects(){return this.effects}labSetCameraOverride(e,t){this.cameraOverride={position:new q(...e),lookAt:new q(...t)}}labFrame(e,t=!0){this.draw(e*1e3,!0,t)}setCornerPanelTop(e){this.cornerPanelTop=e}viewForward(){return this.ownViewActive?(this.ownForward.x=this.fighterCam.forwardX,this.ownForward.z=this.fighterCam.forwardZ,this.ownForward):null}setPlayers(e,t,n=Object.keys(e)){this.players=e,this.viewerId=t,this.playerOrder=n}updateIdleFighters(e,t,n){let r=this.graphs;if(r===null)return;let i=this.playerOrder.filter(e=>this.players[e]!==void 0).length<2;for(let[a,o]of r.entries()){let r=this.playerOrder[a]??`seat-${a}`,s=!i||r===this.viewerId||this.viewerId===null&&a===0;if(o.boxer.root.visible=s,!s)continue;this.wearLook(a===0?0:1,r);let c=a===0?-1:1,l=Math.floor(t*this.simulation.tick_rate),u={...QK(r),x:i?0:c*180,y:i?-70:0,facing:i?1:-c,facing_x:i?0:-c*1e3,facing_y:i?-1e3:0,...i?tq(l):{}},d={...QK(this.playerOrder[1-a]??`opponent`),x:i?0:-c*180,y:i?-150:0};o.setResting(!1),o.update(u,d,e,t,this.settings().reducedMotion,this.bloodLevel,i?l:n)}}setFinal(e){if(e!==null&&e.match_id===this.final?.match_id)return;this.final=e,this.stoppageWinner=-1,this.stoppageRaiseAt=1/0,this.stoppageSpot=null,this.raiseFramed=!1,this.ceremony=this.ceremonyFor(e);let t=e?.method===`draw`&&this.deaths.every(e=>e!==null);if(this.finalRevealAt=this.frameSeconds+(this.ceremony===null?t?fr:mr(e):UG),this.ovationUntil=e===null?0:this.frameSeconds+GG,e!==null&&this.commentary.finish(e,this.players,this.ceremony!==null,this.frameSeconds),this.ceremony===null&&this.endCeremony(),this.pendingFinish=null,e===null||!dr.has(e.method))return;let n=this.lastKnockdown===null?null:SW(this.history,this.lastKnockdown.hit??this.lastKnockdown.knockdown,this.simulation.tick_rate),r=this.finishingInjury(e);if(n!==null&&this.graphs!==null&&!this.settings().reducedMotion){r!==null&&(this.replayInjuries[r.index]={injury:r.injury,event:r.event}),this.startReplay(n);return}if(r!==null){let e=this.pendingContacts.find(e=>e.event.event_id===r.event.event_id);e===void 0?this.applyArcadeInjury(r.index,r.injury,r.event):e.injury??=r.injury}let i=this.buffer.latest()?.result?.tick;i===void 0?this.presentFinish(e):this.pendingFinish={final:e,tick:i,latestAt:this.frameSeconds+_G}}presentFinishWhenShown(e){let t=this.pendingFinish;t===null||ee.player_id===t.hit.target_id)??-1;return r<0||this.arcadeInjuries[r]!==null?null:{index:r,injury:t.finisher,event:t.hit}}ceremonyFor(e){let t=this.buffer.latest()?.fighters;if(e===null||t===void 0||e.method!==`decision`&&e.method!==`draw`||t.some(e=>e.is_downed)||this.deaths.some(e=>e!==null))return null;let n=t.findIndex(t=>t.player_id===e.winner_id);return{winnerSeat:n===0||n===1?n:null,positions:null,refereeArrived:!1,arrivedAt:null,announced:!1}}endCeremony(){for(let e of this.graphs??[])e.awaitVerdict(null);this.referee?.raise(null,null)}ceremonyFighters(e,t,n,r,i=null){e.positions===null&&(e.positions=[{x:t[0].x+(i?.[0].x??0),y:t[0].y+(i?.[0].y??0)},{x:t[1].x+(i?.[1].x??0),y:t[1].y+(i?.[1].y??0)}],e.marks=e.positions[0].x<=e.positions[1].x?[0,1]:[1,0]);let a=e.marks??IG,o=e.refereeArrived;for(let r of[0,1]){let i=e.positions[r],s=a[r],c=WG(i.x,i.y,FG[s],BG*n),l=Math.hypot(c.x-i.x,c.y-i.y),u=n>0?1/(n*this.simulation.tick_rate):0,d=!c.arrived&&l>1e-6;Object.assign(this.drawnFighters[r],t[r],{x:c.x,y:c.y,velocity_x:(c.x-i.x)*u,velocity_y:(c.y-i.y)*u,facing_x:d?Math.round((c.x-i.x)/l*1e3):0,facing_y:d?Math.round((c.y-i.y)/l*1e3):-1e3,facing:d&&c.x=HG){e.announced=!0,this.commentary.verdict(this.frameSeconds);for(let t of[0,1])this.graphs?.[t]?.announce(e.winnerSeat===null?`level`:e.winnerSeat===t?`winner`:`loser`);this.finalRevealAt=Math.min(this.finalRevealAt,this.frameSeconds+.35),this.arena.excite(1)}if(e.announced){let n=n=>{let r=a[0]===n?0:1,i=e.winnerSeat===null||e.winnerSeat===r,o=Ae(t[r].injuries,n===0?`left`:`right`)===`whole`,s=this.graphs?.[r]?.boxer.rig.bones[n===0?`gloveL`:`gloveR`];return i&&o&&s!==void 0?s.getWorldPosition(this.ceremonyWrists[n]):null};this.referee?.isDown!==!0&&this.referee?.raise(n(1),n(0))}return this.drawnFighters}ceremonyFrame(e){let t=this.ceremony,n=this.buffer.latest();if(t===null||t.arrivedAt===null||this.replay!==null||this.final===null||n===null)return null;let{width:r,height:i}=this.hudViewport,a=BK(this.final,r,i,n.fighters,this.players,this.roundStats,this.viewerId),o=CD(this.camera.aspect,this.camera.fov,(i-a)/Math.max(1,i)),s=this.settings().reducedMotion?0:Math.sin((e-t.arrivedAt)*.35)*.06*o.distance;return this.cornerPosition.set(s,o.height+.05*o.distance,o.distance),this.cornerLookAt.set(0,o.height,0),{position:this.cornerPosition,lookAt:this.cornerLookAt,framed:!0}}raiseFrame(e,t,n){let r=this.buffer.latest();if(this.stoppageWinner<0||this.final===null||this.replay!==null||this.ceremony!==null||r===null||e0?-1:1)*fG,o=this.stoppageSpot?.z??0;this.raiseFramed||this.raiseCentre.set(i.x+a/2,0,i.z+o/2),this.raiseCentre.lerp(this.tmpCamera.set(i.x+a/2,0,i.z+o/2),1-Math.exp(-3*t)),this.raiseFramed=!0;let{width:s,height:c}=this.hudViewport,l=BK(this.final,s,c,r.fighters,this.players,this.roundStats,this.viewerId,this.deaths[0]??this.deaths[1]),u=CD(this.camera.aspect,this.baseFov,(c-l)/Math.max(1,c)),d=e-(this.stoppageRaiseAt-dG),f=n?0:Math.sin(d*.35)*.06*u.distance;return this.cornerPosition.set(G.clamp(this.raiseCentre.x,-1.4,1.4)+f,u.height+.05*u.distance,this.raiseCentre.z+u.distance),this.cornerLookAt.set(this.raiseCentre.x,u.height,this.raiseCentre.z),{position:this.cornerPosition,lookAt:this.cornerLookAt,framed:!0}}presentFinish(e){let t=this.buffer.latest()?.referee.alive===!1;t||this.referee?.waveOff();let n=this.buffer.latest()?.fighters,r=n?.findIndex(t=>t.player_id!==e.winner_id&&t.player_id!==null)??-1;if(r>=0&&this.headCacheValid[r]&&!this.settings().reducedMotion&&!this.carnage.gibbed(r)&&(this.finishCloseUpIndex=r,this.finishCloseUpUntil=this.frameSeconds+iG,this.finishCloseUpBearing=null,this.finishCloseUpAt=this.frameSeconds),e.winner_id===null)return;let i=n?.findIndex(t=>t.player_id===e.winner_id)??-1;if(i<0)return;this.graphs?.[i]?.celebrate(uG);let a=n?.[i]?.injuries??[];!t&&(lK(a,`left`)||lK(a,`right`))&&(this.stoppageWinner=i,this.stoppageRaiseAt=this.frameSeconds+dG)}cornerShotFrame(e,t,n){if(t===null||t.phase!==`rest`||n||this.graphs===null)return null;let r=t.fighters.findIndex(e=>e.player_id===this.viewerId),i=e-this.restStartedAt,a=hD(i,t.phase_ticks_remaining/this.simulation.tick_rate,+(r===1));return a===null||!this.graphs[a].stoolVisible||this.cutmen!==null&&this.cutmanProgress[a]e.player_id===this.viewerId)===1),n=this.mapping.x(l);return bD(t,n,-3.5,sG,this.cornerPosition).setY(cG),bD(t,n,0,0,this.cornerLookAt),this.cornerLookAt.lerp(bD(+(t===0),n,0,0,this.tmpCamera),lG).setY(.9),{position:this.cornerPosition,lookAt:this.cornerLookAt,framed:!0}}closeUpFrame(e){if(e>=this.finishCloseUpUntil||this.finishCloseUpIndex<0||!this.headCacheValid[this.finishCloseUpIndex])return null;let t=this.arcadeInjuries[this.finishCloseUpIndex],n=t===`decapitation`&&this.effects.severedHeadPosition(this.finishCloseUpIndex,this.closeUpTarget),r=!n&&this.effects.partPosition(Xz(this.finishCloseUpIndex,`upper_body`),this.closeUpTarget),i=n||r?null:this.graphs?.[this.finishCloseUpIndex]?.fallBody??null;if(this.finishCloseUpBearing===null&&i!==null&&!i.body.asleep&&e-this.finishCloseUpAt.4?u:.9,a)}let d=this.finishCloseUpBearing+l;return this.closeUpPosition.set(G.clamp(s.x+Math.sin(d)*c,-2.2,yG),s.y+(n?.42:o?.5:.75),G.clamp(s.z+Math.cos(d)*c,-2.2,yG)),this.replayLookAt.copy(s),{position:this.closeUpPosition,lookAt:this.replayLookAt,tight:!0}}raiseSpot(e,t){let n=e.x>0?-1:1,r={x:n*fG,z:0},i=-1/0;for(let[a,o]of pG){let s=e.x+n*a*fG,c=e.z+o*fG,l=Math.min(gG-Math.abs(s),gG-Math.abs(c),Math.hypot(s-t.x,c-t.z)-hG);for(let e of this.graphs??[]){let t=e.fallBody;if(t!==null)for(let e of[0,1,2,3,4])t.bodyPoint(e,this.bodyPoint),l=Math.min(l,Math.hypot(s-this.bodyPoint.x,c-this.bodyPoint.z)-CG-.05)}for(let e of[0,1])this.effects.severedHeadPosition(e,this.closeUpTarget)&&(l=Math.min(l,Math.hypot(s-this.closeUpTarget.x,c-this.closeUpTarget.z)-bG-.05));if(l>=0)return{x:s-e.x,z:c-e.z};l>i&&(i=l,r={x:s-e.x,z:c-e.z})}return r}nearerGlove(e,t){e.getWorldPosition(this.stoppageWrist),t.getWorldPosition(this.stoppageOtherWrist);let n=e=>Math.hypot(e.x-this.refereePosition.x,e.z-this.refereePosition.z);return n(this.stoppageOtherWrist)-.5*n.length()}startReplay(e){let t=new Ef(e.snapshots.length+2,this.simulation.tick_rate);for(let n of e.snapshots)t.push(n);if(this.replay={plan:e,buffer:t,startedAt:this.frameSeconds,impactFired:!1,side:null},this.drawnOffsetsLive=!1,this.commentary.replay(this.frameSeconds,e.impact),this.replayFollow=0,this.replayFollowAt=0,e.impact.kind===`referee_down`){this.referee?.resetTransient(!1),this.referee?.primeReplayFall(),this.effects.stopGush(2);return}for(let e=this.pendingGore.length-1;e>=0;--e)this.pendingGore[e].event.kind!==`injury`&&this.pendingGore.splice(e,1);for(let e of[0,1]){this.effects.stopGush(e),this.deaths[e]!==null&&this.carnage.undoDeath(e);let t=this.arcadeInjuries[e],n=this.arcadeInjuryEvents[e];t!==null&&n!==null&&(this.replayInjuries[e]={injury:t,event:n},this.restoreInjury(e))}for(let t of this.pendingContacts.splice(0)){let n=t.recipientIndex;t.injury!==null&&(n===0||n===1)&&this.replayInjuries[n]===null&&this.arcadeInjuries[n]===null&&(this.replayInjuries[n]={injury:t.injury,event:t.event}),t.event.event_id!==e.impact.event_id&&(t.injury=null,t.contactTick=1/0,this.pendingContacts.push(t))}let n=e.snapshots[0]?.fighters.findIndex(t=>t.player_id===e.impact.target_id)??-1;n>=0&&e.impact.detail.endsWith(`:head`)&&this.effects.returnMouthpiece(n);let r=this.lastKnockdown?.knockdown.detail===xG;for(let[t,i]of(this.graphs??[]).entries()){let a=this.liveFallTicks[t]??null;i.resetTransient(!1),a!==null&&a>=e.impact.tick-1&&i.primeReplayFall(),t===n&&r&&i.fallToKnee(!0)}this.finalRevealAt=this.frameSeconds+e.durationSeconds+mr(this.final)}endReplay(){let e=this.replay?.plan.impact.kind===`referee_down`;if(this.replay=null,e){this.drawnOffsetsLive=!1;let e=this.buffer.latest();for(let[t,n]of(this.graphs??[]).entries())n.resetTransient(e?.fighters[t]?.is_downed===!0);return}this.drawnOffsetsLive=!1,this.reapplyReplayInjuries();let t=this.buffer.latest();for(let[e,n]of(this.graphs??[]).entries()){let r=t?.fighters[e],i=r!==void 0&&r.player_id===this.flashKnockout?.loserId;n.resetTransient(r?.is_downed===!0||i),i&&n.knockOut()}for(let e of[0,1])this.showDeath(e,0,!0);this.final!==null&&this.presentFinish(this.final)}fireRefereeEvents(e){for(let t=0;te){t+=1;continue}this.pendingRefereeEvents.splice(t,1);let r=this.buffer.latest();n.kind===`referee_down`?(r!==null&&this.fireRefereeFall(n,r),this.eventCallout={text:`THE REFEREE IS DEAD!`,until:this.frameSeconds+$G},this.refereeReplayAt={at:this.frameSeconds+QG,impact:n}):n.kind===`referee_hit`?r!==null&&this.punchReferee(n,r,!1):this.referee!==null&&(this.referee.boxer.rig.bones.head.getWorldPosition(this.refereeHead),this.effects.addEvent(n,this.refereeHead,this.settings().reducedMotion))}}punchReferee(e,t,n){let r=this.referee;if(r===null)return;let[i,a]=e.detail.split(`:`),o=t.fighters.findIndex(t=>t.player_id===e.actor_id),s=t.fighters[o],c=s?.action_key?.split(`:`)[1]??null;r.react(`hit`,a===`body`?`body`:`head`,e.direction,i,c,n?Math.max(e.amount,140):e.amount),r.boxer.rig.bones.head.getWorldPosition(this.refereeHead);let l=s===void 0?void 0:QW(s,{...s,x:t.referee.x,y:t.referee.y},this.mapping),u=this.settings().reducedMotion;this.effects.addEvent({...e,kind:n?`knockdown`:`hit`},this.refereeHead,u,l);let d=n||u?null:oq({...e,kind:`hit`}),f=d===null?null:this.refereeMouth();d!==null&&f!==null&&this.effects.gush(2,f.position,f.axis,d.seconds,d.rate,e.event_id);let p=this.refereePunchPower(e);o>=0&&this.graphs?.[o]?.landedHit(e.action_id,!1,p),this.onContact?.(e,p)}fireRefereeFall(e,t,n=!1){let r=this.referee;if(r===null)return;let i=n?this.refereeBlow(e):null;i===null?(r.boxer.rig.bones.head.getWorldPosition(this.refereeHead),this.effects.addEvent({...e,kind:`knockdown`,amount:160,blood:80},this.refereeHead,this.settings().reducedMotion)):this.punchReferee(i,t,!0);let a=this.settings().reducedMotion?null:this.refereeMouth();a!==null&&this.effects.gush(2,a.position,a.axis,vq,yq,e.event_id),r.knockOut(),this.onContact?.(e,!1)}refereePunchPower(e){for(let t=this.history.length-1;t>=0;--t){let n=this.history[t];if(n.tickt.player_id===e.actor_id);return r!==void 0&&r.action_id===e.action_id&&r.action_power===`power`}return!1}refereeBlow(e){if(e.action_id===null)return null;for(let t=this.history.length-1;t>=0;--t){let n=this.history[t],r=n.events.find(t=>t.kind===`referee_hit`&&t.action_id===e.action_id&&t.tick===e.tick);if(r!==void 0)return r;if(n.tick=0?e.fighters[a]:void 0,l=c?.action_key?.split(`:`)??[],u=l[0]??null,d=l[1]??null,f=l[3]===`power`;this.graphs?.[i]?.react(`hit`,r.detail.endsWith(`:body`)?`body`:`head`,r.direction,u,d,r.amount),n.knockdown.detail===`body`&&n.knockdown.tick>r.tick&&this.graphs?.[i]?.windedFor((n.knockdown.tick-r.tick)/this.simulation.tick_rate+.15,gK(c?.action_key??null)),o.player_id===this.flashKnockout?.loserId&&this.graphs?.[i]?.knockOut(),a>=0&&this.graphs?.[a]?.landedHit(r.action_id,n.blocked,f),r.detail.endsWith(`:head`)&&!this.settings().reducedMotion&&this.knockOutMouthpiece(i,s??r.direction,r.event_id+nq,!0),f&&!n.blocked&&!this.settings().reducedMotion&&this.presentPowerHit(i,r),this.onContact?.(r,f),this.reapplyReplayInjuries(s),this.deaths[i]!=null&&(this.showDeath(i,s??r.direction,!0),this.announceDeath(i));for(let e of this.pendingGore.splice(0))this.presentGore(e.event);for(let t of this.pendingContacts)t.contactTick===1/0&&(t.contactTick=this.replay?.plan.impact.tick??e.tick)}replayFrame(e,t){let[n,r]=e.fighters,i=this.mapping.x(n.x),a=this.mapping.z(n.y),o=this.mapping.x(r.x),s=this.mapping.z(r.y),c=this.replay?.plan.impact.kind===`referee_down`,l=e.fighters.findIndex(e=>e.player_id===this.replay?.plan.impact.target_id),u=this.replay?.impactFired===!0&&l>=0&&this.headCacheValid[l]===!0;if(c&&this.referee!==null)return this.refereeReplayFrame(e,t);let d=1-Math.exp(-3*Math.max(0,t-this.replayFollowAt));this.replayFollowAt=t,this.replayFollow+=(+!!u-this.replayFollow)*d;let f=l<0?0:Math.max(this.portraitPull>1.3?.7:0,this.replayFollow*.8),p=u?this.headCache[l].x:l===1?o:i,m=u?this.headCache[l].z:l===1?s:a,h=(i+o)/2+(p-(i+o)/2)*f,g=(a+s)/2+(m-(a+s)/2)*f,_=-(s-a),v=o-i,y=Math.hypot(_,v)||1;_/=y,v/=y;let b=2.5,x=this.replay;x!==null&&x.side===null&&(x.side=iq(h,g,_,v,b,yG));let S=x?.side??(v<0?-1:1);_*=S,v*=S;let C=.35*Math.sin(t*.7),w=_*Math.cos(C)-v*Math.sin(C),T=_*Math.sin(C)+v*Math.cos(C);this.replayCameraPosition.set(G.clamp(h+w*b,-2.2,yG),1.38-Math.min(.25,t*.05),G.clamp(g+T*b,-2.2,yG));let E=Math.hypot(this.replayCameraPosition.x-h,this.replayCameraPosition.z-g),D=Math.hypot(h,g);if(E.01){let e=rq-E;this.replayCameraPosition.x=G.clamp(this.replayCameraPosition.x-h/D*e,-2.2,yG),this.replayCameraPosition.z=G.clamp(this.replayCameraPosition.z-g/D*e,-2.2,yG)}let O=u?G.clamp(this.headCache[l].y,.45,1.28):1.28;this.replayLookAt.set(h,1.28+(O-1.28)*this.replayFollow,g);let k=this.settings().reducedMotion?0:this.powerShake;if(k>5e-4){let e=t*61;this.replayCameraPosition.x=G.clamp(this.replayCameraPosition.x+Math.sin(e*1.31)*k,-2.2,yG),this.replayCameraPosition.y+=Math.cos(e*1.97)*k*.6,this.replayLookAt.x+=Math.sin(e*1.53)*k*.5,this.replayLookAt.y+=Math.cos(e*2.11)*k*.35}return{position:this.replayCameraPosition,lookAt:this.replayLookAt,tight:!0}}setInputLatency(e){this.inputLatencyMs=e,this.lagWarned=gr(e,this.lagWarned)}resyncClock(){this.buffer.resync()}setReconnect(e){this.reconnectMs=e}setBloodLevel(e){e!==`full`&&this.bloodLevel===`full`&&this.restoreAllInjuries(),this.bloodLevel=e,e===`off`&&this.downedPoolAccumulators.fill(0),this.effects.setBloodLevel(e)}setReducedMotion(e){e&&(this.restoreAllInjuries(),this.effects.clearDynamic())}syncInjuryPresentation(e){let t=this.arcadeInjuries[e],n=this.graphs;if(n!==null){let r=n[e];t===`head_burst`?r.boxer.setHeadBurst(!0):r.boxer.setDecapitated(t===`decapitation`),r.boxer.headInjury.setEyeOut(t===`eye_left`||t===`eye_right`?`both`:null),r.boxer.setHandDismembered(`left`,t===`dismember_left`),r.boxer.setHandDismembered(`right`,t===`dismember_right`);let i=t===`jaw_dislocation`?`jaw`:t===`shoulder_left`||t===`shoulder_right`?t:null;r.setArcadeDislocation(i)}}applyArcadeInjury(e,t,n,r){t===`dismember_left`&&!this.carnage.hasGlove(e,`left`)?t=`ribs_left`:t===`dismember_right`&&!this.carnage.hasGlove(e,`right`)?t=`ribs_right`:(t===`eye_left`&&this.carnage.eyeBurst(e,`left`)||t===`eye_right`&&this.carnage.eyeBurst(e,`right`))&&(t=`jaw_dislocation`);let i=!1;if(t===`decapitation`){let t=this.headWorldPose(e);if(t!==null){let a=this.graphs?.[e],o=a===void 0?void 0:XK(a.boxer,t.position,t.quaternion);this.effects.decapitate(e,t.position,t.quaternion,r??n.direction,n.event_id,this.skinColor(e),o);let s=this.stumpWorldPose(e);s!==null&&this.effects.anchorStump(e,s.position,s.quaternion,s.rim,s.across),i=!0}}else if(t===`head_burst`){let t=this.headWorldPose(e);if(t!==null){this.effects.burstHead(e,t.position,r??n.direction,n.event_id);let a=this.burstStumpPose(e);a!==null&&this.effects.anchorStump(e,a.position,a.quaternion,a.rim,a.across),i=!0}}else if(t===`eye_left`||t===`eye_right`){let a=this.graphs?.[e]?.boxer,o=t===`eye_left`?`left`:`right`;if(a!==void 0&&Fq(a,o,this.tmpPart,this.tmpStumpOffset,this.tmpPartQuaternion)){let t=r??n.direction;this.effects.gougeEye(e,this.tmpPart,this.tmpStumpOffset,t,n.event_id,o);let s=o===`left`?`right`:`left`;!this.effects.eyeOut(e,s)&&!this.carnage.eyeBurst(e,s)&&Fq(a,s,this.tmpPart,this.tmpStumpOffset,this.tmpPartQuaternion)&&this.effects.spawnDebris(`eye`,this.tmpPart,t,1,n.event_id,xq,e),i=!0}}else if(t===`dismember_left`||t===`dismember_right`){let a=t===`dismember_left`?`left`:`right`,o=this.handWorldPose(e,a);if(o!==null){let t=this.graphs?.[e],s=t===void 0?void 0:{...YK(t.boxer.gloveMesh(a),o.position,o.quaternion),gloveBlood:t.boxer.gloveBloodLevel};this.effects.dismemberHand(e,a,o.position,o.quaternion,r??n.direction,n.event_id,this.gearColor(e),s),this.effects.anchorHandStump(e,a,o.position,o.quaternion),i=!0}}else if(t===`jaw_dislocation`||t===`shoulder_left`||t===`shoulder_right`||t===`ribs_left`||t===`ribs_right`){let a=this.tornWound(e,wq(t));a!==null&&(this.effects.tearOpen(e,a.position,a.axis,r??n.direction,n.event_id,t===`jaw_dislocation`?bq:0),i=!0)}return i?(this.arcadeInjuries[e]=t,this.arcadeInjuryEvents[e]=n,this.observedInjuryDown[e]=!1,this.syncInjuryPresentation(e),this.onArcadeInjury?.(t,n),!0):!1}reapplyReplayInjuries(e){for(let t of[0,1]){let n=this.replayInjuries[t];if(n===null)continue;this.replayInjuries[t]=null;let r=this.settings();r.blood!==`full`||r.reducedMotion||this.applyArcadeInjury(t,n.injury,{...n.event,event_id:n.event.event_id+nq},e)}}restoreInjury(e){this.arcadeInjuries[e]!==null&&(this.arcadeInjuries[e]=null,this.arcadeInjuryEvents[e]=null,this.observedInjuryDown[e]=!1,this.syncInjuryPresentation(e),this.effects.restoreFighter(e))}restoreAllInjuries(){this.restoreInjury(0),this.restoreInjury(1),this.effects.clearArcadeGore()}headWorldPose(e){let t=this.graphs,n=t===null?null:t[e].boxer.bone(`head`);return n===null||t===null?null:(t[e].boxer.root.updateMatrixWorld(!0),n.getWorldPosition(this.tmpHead),n.getWorldQuaternion(this.tmpHeadQuaternion),this.tmpStumpOffset.copy(TK).applyQuaternion(this.tmpHeadQuaternion),this.tmpHead.add(this.tmpStumpOffset),{position:this.tmpHead,quaternion:this.tmpHeadQuaternion})}handWorldPose(e,t){let n=this.graphs,r=n===null?null:n[e].boxer.bone(t===`left`?`gloveL`:`gloveR`);return r===null||n===null?null:(n[e].boxer.root.updateMatrixWorld(!0),r.getWorldPosition(this.tmpPart),r.getWorldQuaternion(this.tmpPartQuaternion),{position:this.tmpPart,quaternion:this.tmpPartQuaternion})}gearColor(e){return this.graphs?.[e]?.boxer.gearBaseColor.getHex()??1920728}skinColor(e){return this.graphs?.[e]?.boxer.skinBaseColor.getHex()??11563071}stumpWorldPose(e){let t=this.graphs?.[e]?.boxer,n=t?.bone(`head`);if(t===void 0||n==null)return null;t.root.updateMatrixWorld(!0);let r=t.headMesh,i=OK(r.geometry);if(i.length===0)return null;this.stumpRim.length!==i.length*3&&(this.stumpRim=new Float32Array(i.length*3)),this.tmpStump.set(0,0,0);for(let[e,n]of i.entries())VK(t,n,this.tmpStumpOffset),this.tmpStumpOffset.toArray(this.stumpRim,e*3),this.tmpStump.add(this.tmpStumpOffset);return this.tmpStump.multiplyScalar(1/i.length),n.getWorldPosition(this.tmpStumpOffset).sub(this.tmpStump).normalize(),this.tmpStumpAcross.set(1,0,0).applyQuaternion(n.getWorldQuaternion(this.tmpStumpQuaternion)),this.tmpStumpQuaternion.setFromUnitVectors(EK,this.tmpStumpOffset),{position:this.tmpStump,quaternion:this.tmpStumpQuaternion,rim:this.stumpRim,across:this.tmpStumpAcross}}burstStumpPose(e){let t=this.graphs?.[e]?.boxer;if(t===void 0)return null;let n=MK(t,this.stumpRim,this.burstStump);return n===null?null:(this.stumpRim=n,{position:this.burstStump.position,quaternion:this.burstStump.quaternion,rim:n,across:this.burstStump.across})}predictAction(e){let t=this.buffer.latest();if(t===null||this.viewerId===null||this.replay!==null)return;let n=t.fighters.findIndex(e=>e.player_id===this.viewerId);if(n<0)return;let r=t.fighters[n];if(t.phase!==`fight`&&t.phase!==`finish`||!cq(r))return;let i=(this.inputLatencyMs??60)/1e3*this.simulation.tick_rate,a=i+this.buffer.interpolationDelayTicks,o=this.manualClock?this.lastManualTime:performance.now(),s=this.graphs?.[n];if(mE(e.kind)){let n=s?.ownPunchActive===!0;if(e.id===void 0||r.stamina0||!n&&ZT(r,t.tick)>0)return;let i=n?s.ownTicksToRecovery:0;n&&s.cutOwnRecovery(),this.evasion.press(e.kind,e.id,o,a,this.simulation.tick_rate,y+P(r.style).evasionTicks,o+i*1e3/this.simulation.tick_rate);return}if(e.kind!==`punch`)return;this.evasion.drop(o)&&s?.keepOwnRecovery();let c=Me(r.injuries,e.hand);c!==null&&s?.predict(c===e.hand?e:{...e,hand:c},performance.now()/1e3,this.simulation.tick_rate,a,XT(r,e,t.tick+1),i)}acknowledgeActions(e,t){for(let[n,r]of e.fighters.entries()){let i=r.player_id===this.viewerId,a=e.phase===`fight`||e.phase===`finish`;i&&this.evasion.acknowledge(r,a,this.inputSequenceOf)&&this.graphs?.[n]?.keepOwnRecovery();let o=t.filter(t=>ZW(t,e).puncherIndex===n);this.graphs?.[n]?.acknowledge(r,a,o,i?this.inputSequenceOf:null)}}push(e){if(!this.buffer.push(e,this.manualClock?this.lastManualTime:performance.now()))return;let t=this.dedupe.accept(e.events);this.acknowledgeActions(e,t),this.history.push(e),this.history.length>tG&&this.history.shift();for(let n of t){if(this.roundStats.record(n,t),n.kind===`knockdown`){let r=t.find(e=>$W(e)&&e.target_id===n.target_id&&e.tick===n.tick)??(n.detail===`body`?this.recordedHit(n):null),i=r!==null&&cr(r,e.events);this.lastKnockdown={knockdown:n,hit:r,blocked:i,finisher:i?null:lq(r,e)};let a=e.fighters.findIndex(e=>e.player_id===n.target_id);this.graphs?.[a]?.fallToKnee(n.detail===xG),n.detail===SG&&(this.lastKnockdown=null)}if(n.kind===`result`&&n.detail===`flash_ko`){let e=t.findLast(e=>(e.kind===`hit`||e.kind===`counter_hit`)&&e.actor_id===n.actor_id)??null;e!==null&&e.target_id!==null&&(this.flashKnockout={hitEventId:e.event_id,loserId:e.target_id},this.lastKnockdown={knockdown:{...e,kind:`knockdown`},hit:e,blocked:!1,finisher:null})}n.kind===`referee_break`&&this.referee?.breakClinch(),(tK.has(n.kind)||n.kind===`bleed`&&n.actor_id===`referee`)&&this.pendingRefereeEvents.push(n),n.kind===`box`&&(this.eventCallout={text:`BOX!`,until:this.frameSeconds+ZG}),n.kind===`body_collapse`&&n.target_id===this.viewerId&&(this.ownCollapseUntil=n.tick+n.amount),n.kind===`finish_him`&&(this.finishTargetId=n.target_id),(n.kind===`fatality`||n.kind===`death`)&&this.noteDeath(n,t,e),this.movement.observe(n,this.viewerId)}this.commentary.observe(e,t,this.players,this.simulation.tick_rate,this.frameSeconds);let n=e.fighters.findIndex(e=>e.player_id===this.viewerId),r=e.result===null&&!t.some(e=>e.kind===`knockdown`);for(let{event:i,presentationEvent:a,presentImpact:o,reactAmount:s}of mK(t,e)){let t=e.fighters.findIndex(e=>e.player_id===i.target_id),c=e.fighters.findIndex(e=>e.player_id===i.actor_id),{recipientIndex:l,puncherIndex:u}=ZW(i,e),d=e.fighters[l]??e.fighters[t]??e.fighters[c]??e.fighters[0];if(NK(this.graphs?.[e.fighters.indexOf(d)],d,this.mapping,this.contactPoint),JG.has(i.kind)){let t=u>=0?e.fighters[u]:null;this.pendingContacts.push({event:i,presentationEvent:a,presentImpact:o,reactAmount:s,contactTick:r&&u===n&&XG.has(i.kind)&&this.graphs?.[u]?.pressLanded(i.action_id)===!0?-1/0:t?.action_contact_tick??i.tick,recipientIndex:l,puncherIndex:u,injury:CK(i,e.fighters[l],e.result,t??void 0),power:t!==null&&t.action_id===i.action_id&&t.action_power===`power`})}else i.kind===`bleed`&&i.actor_id!==`referee`&&this.effects.addEvent(i,this.contactPoint,this.settings().reducedMotion)}for(let n of t){if(!aK.has(n.kind))continue;let t=n.action_id===null?void 0:this.pendingContacts.find(e=>e.event.tick===n.tick&&e.event.action_id===n.action_id&&($W(e.event)||eG(e.event)));t!==void 0&&(t.injury??=uK(n)),n.kind!==`fatality`&&(this.pendingGore.push({event:n,at:t?.contactTick??n.tick}),n.kind===`injury`&&pe(n.detail)&&this.carnage.expect(e.fighters.findIndex(e=>e.player_id===n.target_id),n.detail))}}fireContacts(e){for(let t=0;te){t+=1;continue}this.pendingContacts.splice(t,1);let{event:r,presentationEvent:i,reactAmount:a,recipientIndex:o,puncherIndex:s,injury:c}=n,l=n.presentImpact&&!dK(i),u=this.buffer.latest()?.fighters[o],d=QW(this.buffer.latest()?.fighters[s],u,this.mapping);this.presentFightEvent(r,o,s),l&&u!==void 0&&(this.contactOn(o,u,i.detail.endsWith(`:body`),d,i.direction),this.effects.addEvent(i,this.contactPoint,this.settings().reducedMotion,d));let f=this.settings();if(n.power&&l&&$W(r)&&u!==void 0&&!f.reducedMotion&&this.presentPowerHit(o,i),(n.presentImpact||YG.has(r.kind))&&this.arena.excite(qG[r.kind]??0),l&&o>=0&&[`hit`,`counter_hit`,`knockdown`].includes(r.kind)){let e=this.viewerId!==null&&this.buffer.latest()?.fighters[o]?.player_id===this.viewerId;this.viewerHitFlash=Math.max(this.viewerHitFlash,aq(r,e,f.blood))}c!==null&&o>=0&&this.arcadeInjuries[o]===null&&f.blood===`full`&&!f.reducedMotion&&this.applyArcadeInjury(o,c,r,d);let p=this.graphs;l&&o>=0&&!f.reducedMotion&&dB(r.kind,r.amount,i.detail.endsWith(`:head`))&&this.knockOutMouthpiece(o,d??i.direction,r.event_id,!1);let m=l&&!f.reducedMotion?oq(r):null;m!==null&&o>=0&&this.gushFromMouth(o,r.event_id,m.seconds,m.rate),n.presentImpact&&o>=0&&r.kind===`knockdown`&&!f.reducedMotion&&this.gushFromMouth(o,r.event_id,vq,yq);let h=l&&o>=0?_O(r.kind,r.amount,i.detail.endsWith(`:head`)):0;if(h>0&&!f.reducedMotion&&f.blood!==`off`){let e=this.headWorldPose(o);e!==null&&(this.mouthPoint.set(0,-.07,.1).applyQuaternion(e.quaternion).add(e.position),this.effects.spawnTeeth(this.mouthPoint,d??i.direction,h,r.event_id))}if(l&&o>=0&&a!==null&&[`hit`,`counter_hit`,`block`,`perfect_block`,`knockdown`].includes(r.kind)){let e=r.kind===`block`||r.kind===`perfect_block`,t=i.detail.endsWith(`:body`)?`body`:`head`;if(p!==null){let n=(s>=0?this.buffer.latest()?.fighters[s]:void 0)?.action_key?.split(`:`)??[],c=n[0]??i.detail.split(`:`)[0]??null,l=n[1]??null;p[o].react(e?`block`:`hit`,t,i.direction,c,l,a),$W(r)&&t===`head`&&l!==null&&this.carnage.punched(o,l===`left`?`right`:`left`,r.event_id),this.flashKnockout?.hitEventId===r.event_id&&p[o].knockOut()}}l&&s>=0&&[`hit`,`counter_hit`,`block`,`perfect_block`,`guard_break`].includes(r.kind)&&p?.[s]?.landedHit(r.action_id,r.kind===`block`||r.kind===`perfect_block`,n.power),(n.presentImpact||!$W(r))&&this.onContact?.(r,n.power===!0)}this.replay===null&&this.fireRefereeEvents(e);let t=this.refereeReplayAt;if(t!==null&&this.replay===null&&this.frameSeconds>=t.at){this.refereeReplayAt=null;let e=SW(this.history,t.impact,this.simulation.tick_rate,xW.speed,xW.before,xW.after),n=this.buffer.latest(),r=e!==null&&n!==null&&n.phase===`referee_down`&&n.phase_ticks_remaining/this.simulation.tick_rate>=e.durationSeconds-.5;e!==null&&r&&!this.settings().reducedMotion&&this.startReplay(e)}}fireGore(e){for(let t=0;te?t+=1:(this.pendingGore.splice(t,1),this.presentGore(n.event))}}presentGore(e){let t=this.buffer.latest()?.fighters,n=t?.findIndex(t=>t.player_id===(e.kind===`vomit`?e.actor_id:e.target_id))??-1;if(t===void 0||n<0)return;let r=QW(e.actor_id===e.target_id?void 0:t.find(t=>t.player_id===e.actor_id),t[n],this.mapping)??e.direction;if(e.kind===`vomit`)this.carnage.vomit(n,e.event_id),this.onGore?.({kind:`vomit`});else if(e.kind===`finish_him`)this.arena.excite(1),this.onGore?.({kind:`finish_him`});else if(e.kind===`death`)this.showDeath(n,r,!1),this.announceDeath(n);else if(e.kind===`injury`&&pe(e.detail)){let i=e.detail;if(!this.carnage.inflict(n,i,e.event_id,r))return;this.eventCallout={text:`${we(i)}!`,until:this.frameSeconds+oK},this.arena.excite(cK);let a=this.viewerId!==null&&t[n].player_id===this.viewerId;this.settings().blood!==`off`&&(this.viewerHitFlash=Math.max(this.viewerHitFlash,a?1:.5)),this.settings().reducedMotion||(this.powerShake=Math.min(rK,this.powerShake+nK)),this.onGore?.({kind:`injury`,injury:i})}}showDeath(e,t,n){let r=this.deaths[e]??null;if(r===null)return;let i=this.fatal?.index===e?this.fatal:null,a=(i?.hit.event_id??e)+(n?nq:0);i===null?r===`gutted`&&this.carnage.fatality(e,`gutting`,a,t):this.carnage.fatality(e,i.fatality,a,t),this.carnage.die(e,r)}announceDeath(e){let t=this.deaths[e]??null;if(t===null)return;let n=Oe(t);this.eventCallout={text:`${ke(t)}!`,until:this.frameSeconds+sK},this.arena.excite(1),this.settings().reducedMotion||(this.powerShake=rK),n!==null&&this.onGore?.({kind:`fatality`,fatality:n}),this.onGore?.({kind:`death`,cause:t})}noteDeath(e,t,n){let r=n.fighters.findIndex(t=>t.player_id===e.target_id);if(r!==0&&r!==1)return;let i=e.action_id===null?null:t.find(t=>$W(t)&&t.tick===e.tick&&t.action_id===e.action_id&&t.target_id===e.target_id)??null;if(e.kind===`fatality`){i!==null&&me.includes(e.detail)&&(this.fatal={index:r,fatality:e.detail,hit:i});return}let a=De(e.detail);a!==null&&(this.deaths[r]=a,i===null?this.lastKnockdown=null:(this.flashKnockout={hitEventId:i.event_id,loserId:n.fighters[r].player_id},this.lastKnockdown={knockdown:{...i,kind:`knockdown`},hit:i,blocked:!1,finisher:null}))}presentFightEvent(e,t,n){let r=iK[e.kind];r!==void 0&&(this.eventCallout={text:r.text,until:this.frameSeconds+r.seconds});let i=this.graphs;if(!(i===null||t<0)&&(e.kind===`parry`&&i[t]?.stagger(),e.kind===`body_collapse`)){let r=n>=0?this.buffer.latest()?.fighters[n]:void 0;i[t]?.windedFor(e.amount/this.simulation.tick_rate+.15,gK(r?.action_key??null))}}recordedHit(e){if(e.action_id===null)return null;for(let t=this.history.length-1;t>=0;--t){let n=this.history[t].events.find(t=>(t.kind===`hit`||t.kind===`counter_hit`)&&t.action_id===e.action_id&&t.target_id===e.target_id);if(n!==void 0)return n}return null}enterRest(e){this.restStartedAt=e,this.effects.clearMouthpieces()}contactOn(e,t,n,r,i){let a=n?null:this.headWorldPose(e),o=n?this.graphs?.[e]?.boxer.rig.bones.upperChest:void 0,s=a?.position??o?.getWorldPosition(this.contactPoint)??null;if(s===null)return NK(this.graphs?.[e],t,this.mapping,this.contactPoint);let c=r??{x:i<0?-1:1,z:0},l=n?Cq:Sq;return this.contactPoint.set(s.x-c.x*l,s.y,s.z-c.z*l)}gushFromMouth(e,t,n,r){let i=this.tornWound(e,`mouth`);i!==null&&this.effects.gush(e,i.position,i.axis,n,r,t)}anchorGush(e){if(!this.effects.gushing(e)||this.carnage.vomiting(e))return;let t=this.tornWound(e,wq(this.arcadeInjuries[e]??null));t!==null&&this.effects.anchorGush(e,t.position,t.axis)}tornWound(e,t){if(t===`mouth`){let t=this.headWorldPose(e);return t===null?null:{position:this.woundPoint.copy(gq).applyQuaternion(t.quaternion).add(t.position),axis:this.woundAxis.copy(_q).applyQuaternion(t.quaternion)}}let n=this.graphs?.[e]?.boxer;if(n===void 0)return null;n.root.updateMatrixWorld(!0);let r=n.rig.bones,i=t===`shoulder_left`||t===`ribs_left`,a=r.shoulderL.getWorldPosition(this.woundAxis).sub(r.shoulderR.getWorldPosition(this.tmpStumpOffset)).normalize().multiplyScalar(i?1:-1),o=r.upperChest.getWorldPosition(this.tmpStump),s=this.tmpStumpOffset.copy(o).sub(r.hips.getWorldPosition(this.tmpStumpAcross)).normalize();return t===`ribs_left`||t===`ribs_right`?{position:this.woundPoint.copy(o).addScaledVector(a,kq).addScaledVector(s,-.06),axis:a}:((i?r.shoulderL:r.shoulderR).getWorldPosition(this.woundPoint),{position:this.woundPoint,axis:a.addScaledVector(s,.5).normalize()})}refereeMouth(){let e=this.referee?.boxer.rig.bones.head;return e===void 0?null:(e.getWorldPosition(this.tmpHead),e.getWorldQuaternion(this.tmpHeadQuaternion),this.tmpHead.add(this.tmpStumpOffset.copy(TK).applyQuaternion(this.tmpHeadQuaternion)),{position:this.woundPoint.copy(gq).applyQuaternion(this.tmpHeadQuaternion).add(this.tmpHead),axis:this.woundAxis.copy(_q).applyQuaternion(this.tmpHeadQuaternion)})}knockOutMouthpiece(e,t,n,r){let i=this.headWorldPose(e);i!==null&&(this.mouthPoint.set(0,-.075,.1).applyQuaternion(i.quaternion).add(i.position),this.effects.ejectMouthpiece(e,this.mouthPoint,i.quaternion,t,n,this.gearColor(e),r))}get resultVisible(){return this.final!==null&&this.frameSeconds>=this.finalRevealAt}get resolutionScale(){return this.scaler.scale}get diagnostics(){let e=this.renderer.getContext(),t=e.getExtension(`WEBGL_debug_renderer_info`),n=t===null?e.getParameter(e.RENDERER):e.getParameter(t.UNMASKED_RENDERER_WEBGL);return{frameMs:this.frameMsAverage,resolutionScale:this.scaler.scale,gpu:this.memoryInfo,graphics:String(n)}}get memoryInfo(){return{geometries:this.renderer.info.memory.geometries,textures:this.renderer.info.memory.textures,programs:this.renderer.info.programs?.length??0}}applyResolutionScale(){let e=this.basePixelRatio*this.scaler.scale;this.renderer.setPixelRatio(e),this.composer.setPixelRatio(e);let t=this.scaler.scale<=nG;this.bloomPass.enabled=!t,this.keyLight!==null&&XW(this.keyLight.shadow,t,this.scaler.scale<.8?1024:2048),this.arena.setLowTier(t),this.effects.setLowTier(t)}setupLights(){let e=new gx(`#3c4a72`,`#07080c`,.55);this.scene.add(e),this.lights.push(e);let t=new Ax(`#fff1dc`,150,24,.56,.55,1.7);t.position.set(.6,7.4,1.2),t.target.position.set(0,.6,0),t.castShadow=!0,t.shadow.mapSize.set(2048,2048),t.shadow.bias=qW,t.shadow.camera.near=3,t.shadow.camera.far=14,this.keyLight=t,this.scene.add(t,t.target),this.lights.push(t);let n=new Ax(`#ffe6c8`,95,24,.6,.6,1.7);n.position.set(-2.6,7,-2.2),n.target.position.set(0,.8,0),this.scene.add(n,n.target),this.lights.push(n);for(let[e,t,n,r]of[[`#8fa8ff`,-5.5,3.8,-5.4],[`#7f95e8`,5.6,3.6,-5.6]]){let i=new Ax(e,34,30,.72,.9,1.8);i.position.set(t,n,r),i.target.position.set(0,1.2,0),this.scene.add(i,i.target),this.lights.push(i)}let r=new Ax(`#ffe8d0`,48,22,.32,.8,1.5);r.position.set(0,5.8,5.4),r.target.position.set(0,1,0),this.scene.add(r,r.target),this.lights.push(r),this.followSpot=r}draw(e,t=!1,n=!0){if(this.destroyed)return;let r=e-this.previous,i=t?1/60:Math.min(.05,Math.max(.001,r/1e3));this.previous=e,!t&&this.scaler.record(r)&&this.applyResolutionScale(),!t&&r>0&&r<1e3&&(this.frameMsAverage+=(r-this.frameMsAverage)*.05);let a=Math.min(this.pixelRatioCap,window.devicePixelRatio||1);a!==this.basePixelRatio&&(this.basePixelRatio=a,this.applyResolutionScale());let o=this.canvas.clientWidth,s=this.canvas.clientHeight;o>0&&s>0&&(this.renderer.getSize(this.sizeCheck),(this.sizeCheck.x!==o||this.sizeCheck.y!==s)&&(this.renderer.setSize(o,s,!1),this.composer.setSize(o,s),this.camera.aspect=o/s,this.portraitPull=G.clamp(1.2/this.camera.aspect,1,2.2),this.baseFov=36*Math.min(1.3,Math.sqrt(this.portraitPull)),this.camera.fov=this.baseFov,this.camera.updateProjectionMatrix()));let c=e/1e3;this.frameSeconds=c,this.finishPass.uniforms.uTime.value=c%1e3,t&&(this.lastManualTime=e);let l=this.settings();this.setBloodLevel(l.blood);let u=this.buffer.latest(),d=i,f=u?.result!==null&&u?.result!==void 0&&dr.has(u.result.finish_method);if(this.cheer(c,i),f&&!this.finishSeen&&(this.finishSeen=!0,this.finishSlowMotion=2.2,this.arena.excite(1)),this.finishSlowMotion>0&&!l.reducedMotion){this.finishSlowMotion=Math.max(0,this.finishSlowMotion-i);let e=Math.min(1,this.finishSlowMotion/.5);i*=.3+.7*(1-e)}this.viewerHitFlash=Math.max(0,this.viewerHitFlash-i*3.2);let p=u===null?0:t?_K(u):this.buffer.renderTick(e),m=this.updateRocked(u===null?null:this.shownAt(p),d,l.reducedMotion);m!==null&&u!==null&&this.onRocked?.(m,u.tick);let h=u===null?null:this.applyLocalPrediction(this.buffer.sample(p),i,e),g=this.replay;if(g!==null){let e=c-g.startedAt;e>=g.plan.durationSeconds||g.plan.impact.kind===`referee_down`&&u?.phase!==`referee_down`?this.endReplay():(p=CW(g.plan,e,this.simulation.tick_rate),h=g.buffer.sample(p)??h,!g.impactFired&&p>=g.plan.impact.tick&&h!==null&&(g.impactFired=!0,this.fireReplayImpact(h)))}let _=this.replay===null?i:i*this.replay.plan.speed,v=1.8,y=!1,b=null;if(h!==null){let e=this.replay===null?this.ceremony:null,[t,n]=e===null?this.standApart(h.fighters,_):this.ceremonyFighters(e,h.fighters,_,c,this.drawnOffsets);for(let[e,t]of h.fighters.entries())this.arcadeInjuries[e]!==null&&this.replay===null&&(t.is_downed?this.observedInjuryDown[e]=!0:this.observedInjuryDown[e]&&h.result===null&&this.restoreInjury(e));let r=this.graphs;if(r!==null){this.wearLook(0,t.player_id),this.wearLook(1,n.player_id);let e=this.headCacheValid[0]?this.headCache[0]:void 0,i=this.headCacheValid[1]?this.headCache[1]:void 0;r[0].boxer.root.visible=!0,r[1].boxer.root.visible=!0;let a=UW(h,this.simulation.tick_rate);r[0].setResting(a),r[1].setResting(a);let o=h.phase===`countdown`?h.phase_ticks_remaining:null;r[0].setCountdown(o),r[1].setCountdown(o);let s=this.replay!==null||h.phase===`complete`;r[0].stayDown(s),r[1].stayDown(s),h.phase===`fight`&&this.lastPhase===`rest`&&this.replay===null&&(this.roundCalloutUntil=c+rG,this.roundCalloutRound=h.round_number),h.phase===`rest`&&this.lastPhase!==`rest`&&this.enterRest(c),this.lastPhase=h.phase,this.anticipatePunches(u,p),r[0].setObstacle(r[1].boxer.root.position.x,r[1].boxer.root.position.z),r[1].setObstacle(r[0].boxer.root.position.x,r[0].boxer.root.position.z);let d=this.referee?.boxer.rig.bones.head.getWorldPosition(this.refereeHead)??null;r[0].setRefereeHead(d),r[1].setRefereeHead(d),r[0].update(t,n,_,c,l.reducedMotion,l.blood,p,i),r[1].update(n,t,_,c,l.reducedMotion,l.blood,p,e);let f=h.phase===`finish`?Er(h.fighters,this.finishTargetId):null;for(let[e,t]of h.fighters.entries()){let n=f!==null&&t.player_id===f.player_id;r[e].setDazed(n),this.carnage.sync(e,(this.replay===null?void 0:u?.fighters[e])??t,l,_,c,n)}let m=r[h.fighters.findIndex(e=>e.player_id===this.viewerId)],g=m?.ownPressId??null;if(m!==void 0&&g!==null&&g!==this.soundedPress){this.soundedPress=g;let{punchClass:e,power:t}=m.punchKind;this.onOwnPunch?.(e,t,g)}for(let[e,t]of r.entries()){let n=t.boxer.bone(`head`);n!==null&&(t.boxer.root.updateMatrixWorld(!0),n.getWorldPosition(this.headCache[e]),this.headCacheValid[e]=!0);let r=t.fallBody!==null;r&&!this.fallingLive[e]&&this.replay===null&&(this.liveFallTicks[e]=p),this.fallingLive[e]=r}}for(let e=0;ee.player_id===this.viewerId),C=l.camera===`fighter`&&S>=0&&HW(h)?this.fighterCam.update(i,c,S===0?this.tmpA:this.tmpB,S===0?this.tmpB:this.tmpA,this.effects.shakeAmount+this.powerShake,l.reducedMotion,this.camera.aspect):null;C===null&&this.fighterCam.reset();let w=this.replay,T=this.cameraOverride??(w!==null&&h!==null?this.replayFrame(h,c-w.startedAt):this.closeUpFrame(c)??this.raiseFrame(c,i,l.reducedMotion)??this.cornerShotFrame(c,h,l.reducedMotion)??this.restWideFrame(h)??this.ceremonyFrame(c)??C??x);this.ownViewActive=C!==null&&T===C;let E=this.ownViewActive?this.baseFov*kD:this.baseFov;if(this.camera.fov!==E&&(this.camera.fov=E,this.camera.updateProjectionMatrix()),this.cameraOverride===null&&this.portraitPull>1&&T.framed!==!0&&!this.ownViewActive){let e=T.tight===!0,t=this.portraitPull/Math.min(1.3,Math.sqrt(this.portraitPull)),n=e?Math.min(t,1.25):t;this.tmpCamera.subVectors(T.position,T.lookAt).multiplyScalar(n),this.camera.position.copy(T.lookAt).add(this.tmpCamera),e&&(this.camera.position.x=G.clamp(this.camera.position.x,-2.2,yG),this.camera.position.z=G.clamp(this.camera.position.z,-2.2,yG)),this.camera.lookAt(T.lookAt.x,T.lookAt.y-(this.portraitPull-1)*(e?.08:.45),T.lookAt.z)}else this.camera.position.copy(T.position),this.camera.lookAt(T.lookAt);this.effects.setViewDistance(this.camera.position.distanceTo(T.lookAt)),this.arena.makeRoomForCamera(this.camera.position);let D=T===x?BP(Math.max(this.tmpA.z,this.tmpB.z)):T.framed===!0?zG:1;this.ring.setNearRopeOpacity(this.ring.nearRopeOpacity()+(D-this.ring.nearRopeOpacity())*(1-Math.exp(-6*i))),n&&(this.composer.render(),this.drawHudOverlay(h)),!this.destroyed&&!this.manualClock&&(this.raf=requestAnimationFrame(e=>this.draw(e)))}applyLocalPrediction(e,t,n){if(e===null||this.localInput===null||this.viewerId===null)return e;let r=e.fighters.findIndex(e=>e.player_id===this.viewerId),i=this.localInput()??{moveX:0,moveY:0,defense:`none`},a=(this.inputLatencyMs??60)/1e3*this.simulation.tick_rate+this.buffer.interpolationDelayTicks,o=this.ownCollapseUntil>e.tick,s=e.phase===`fight`||e.phase===`finish`&&r>=0&&Er(e.fighters,this.finishTargetId)!==e.fighters[r],c=r>=0&&s&&!o?e.fighters[r]:null,l=this.evasion.holdsFeet(n)?0:this.graphs?.[r]?.ownFootwork??1,u=this.movement.update(c,i,l,n,a,e.tick,t,this.simulation.tick_rate),d=this.evasion.pose(n);if(r<0)return e;let f=e.fighters[r],p=c===null?f.defense:hE(c,i,d,this.evasion.hidesServerEvasion(n));if(Math.abs(u.dx)<.01&&Math.abs(u.dy)<.01&&p===f.defense)return e;let m=pE(f,u,e.fighters[+(r===0)]??null),h={...f,x:f.x+m.dx,y:f.y+m.dy,defense:p},g=r===0?[h,e.fighters[1]]:[e.fighters[0],h];return{...e,fighters:g}}anticipatePunches(e,t){if(!(this.replay!==null||e===null||e.phase!==`fight`&&e.phase!==`finish`))for(let[n,r]of(this.graphs??[]).entries()){let i=e.fighters[n];i!==void 0&&!i.is_downed&&r.anticipate(i,i.action_start_tick-t)}}cheer(e,t){ee.clinch_ticks>0||e.clinch_startup_ticks>0||e.is_downed)?null:RK(n.x,n.y,r.x,r.y,DG,u-f,d-f,S),[a,o]=this.drawnTargets;a.x=i===null?0:i.ax-n.x,a.y=i===null?0:i.ay-n.y,o.x=i===null?0:i.bx-r.x,o.y=i===null?0:i.by-r.y,this.clearOfTheFallen(e);let s=1-Math.exp(-14*t);for(let e of[0,1]){let n=this.drawnOffsets[e],r=this.drawnTargets[e],i=r.x-n.x,a=r.y-n.y;if(this.drawnOffsetsLive){i*=s,a*=s;let e=Math.hypot(i,a);e>OG*t&&(i*=OG*t/e,a*=OG*t/e)}n.x+=i,n.y+=a}return this.drawnOffsetsLive=!0,[this.drawnAt(0,n),this.drawnAt(1,r)]}drawnAt(e,t){let n=this.drawnOffsets[e];if(Math.abs(n.x)<.01&&Math.abs(n.y)<.01)return t;let r=fE(t.x+n.x,t.y+n.y);return Object.assign(this.drawnFighters[e],t,{x:r.x,y:r.y})}clearOfTheFallen(e){for(let t of[0,1]){let n=this.graphs?.[t]?.fallBody??null,r=+(t===0),i=e[r];if(n===null||i.is_downed||(this.graphs?.[r]?.fallBody??null)!==null)continue;let a=this.drawnTargets[r],o=this.mapping.x(i.x+a.x),s=this.mapping.z(i.y+a.y),c=this.clearOf(n,o,s);a.x+=(c.x-o)/this.mapping.x(1),a.y+=(c.z-s)/this.mapping.z(1);return}}clearOf(e,t,n){let r={x:t,z:n};for(let t of[0,1,2,3,4])e.bodyPoint(t,this.bodyPoint),r=PK(r.x,r.z,this.bodyPoint.x,this.bodyPoint.z,wG);let i=this.insideRopes(r.x,r.z);if(Math.hypot(i.x-r.x,i.z-r.z)<1e-6)return r;let a=t=>[0,1,2,3,4].every(n=>(e.bodyPoint(n,this.bodyPoint),Math.hypot(t.x-this.bodyPoint.x,t.z-this.bodyPoint.z)>=.499999));for(let e=kG;e<=2.000000001;e+=kG)for(let[t,n]of[[1,0],[-1,0],[0,1],[0,-1]]){let r=this.insideRopes(i.x+t*e,i.z+n*e);if(a(r))return r}return i}insideRopes(e,t){let n=fE(e/this.mapping.x(1),t/this.mapping.z(1));return{x:this.mapping.x(n.x),z:this.mapping.z(n.y)}}headHeightOf(e){return(this.graphs?.[e]?.boxer.metrics.headRestY??1.52)+.04}bleed(e,t,n){for(let[r,i]of e.entries()){let e=Eq(i,this.graphs?.[r],this.flashKnockout?.loserId),a=this.arcadeInjuries[r]??null,o=a!==null,s=(i.trauma.bleeding+i.trauma.left_cut+i.trauma.right_cut)/380,c=o?Math.max(s,fq):s;if(c>.05&&!e)this.downedPoolAccumulators[r]=0,this.downedPoolCounts[r]=0,this.effects.drip(this.dripPoint(r),c,n.reducedMotion,r);else if(c>uq&&e&&n.blood!==`off`){this.effects.stopDrip(r),this.downedPoolAccumulators[r]+=t*5*(o?pq:1);let e=this.poolSource(r,a);for(;this.downedPoolAccumulators[r]>=1;){--this.downedPoolAccumulators[r];let t=this.downedPoolCounts[r];this.downedPoolCounts[r]=t+1;let n=Tq(t,c,o?mq:dq),i=t*2.399963+r*Math.PI;this.effects.pool(e.x+Math.sin(i)*n*.25,e.z+Math.cos(i)*n*.25,n,t+r*7)}}else this.effects.stopDrip(r),this.downedPoolAccumulators[r]=0,e||(this.downedPoolCounts[r]=0)}}dripPoint(e){let t=this.headWorldPose(e);if(t!==null)return t.position.add(this.tmpStumpOffset.copy(hq).applyQuaternion(t.quaternion));if(this.headCacheValid[e])return this.tmpHead.copy(this.headCache[e]);let n=e===0?this.tmpA:this.tmpB;return this.tmpHead.set(n.x,this.headHeightOf(e),n.z)}poolSource(e,t){if(t===`dismember_left`||t===`dismember_right`){let n=this.handWorldPose(e,t===`dismember_left`?`left`:`right`);if(n!==null)return n.position}let n=wq(t);if(n!==`mouth`){let t=this.tornWound(e,n);if(t!==null)return t.position}return this.headCacheValid[e]?this.headCache[e]:e===0?this.tmpA:this.tmpB}updateBlobShadows(){let e=[this.tmpA,this.tmpB,this.refereePosition];for(let[t,n]of this.blobShadows.entries()){n.visible=t>=2||!this.carnage.gibbed(t);let r=t<2?this.graphs?.[t]:this.referee??void 0,i=r?.fallBody?.centre(this.bodyPoint)??null??(r?.boxer.root.visible===!0?r.currentRoot:e[t]);n.position.x=i.x,n.position.z=i.z;let a=t<2?this.buffer.latest()?.fighters[t]:void 0,o=t<2?a!==void 0&&Eq(a,r,this.flashKnockout?.loserId):r?.isDown===!0;n.scale.set(o?2.1:1.25,o?.9:.85,1)}}updateReferee(e,t,n,r){let i=this.referee;if(i===null)return;let a=this.replay===null||this.replay.plan.impact.kind===`referee_down`;i.boxer.root.visible=a;let o=this.blobShadows[2];o!==void 0&&(o.visible=a);let s=n?.referee??null,c=this.replay!==null&&this.replay.plan.impact.kind===`referee_down`?this.replay:null;!this.refereePlaced&&s!==null&&(this.refereePlaced=!0,this.refereePosition.set(this.mapping.x(s.x),0,this.mapping.z(s.y)));let l=this.refereeReplayAt!==null||this.pendingRefereeEvents.some(e=>e.kind===`referee_down`);s?.alive===!0&&i.isDown&&this.replay===null&&n?.phase!==`referee_down`&&!l&&i.resetTransient(!1),s===null||s.alive||i.isDown||this.replay!==null||l||(this.refereePosition.set(this.mapping.x(s.x),0,this.mapping.z(s.y)),i.knockOut(),this.refereeFallUnseen=!0);let u=s!==null&&(n?.phase===`fight`&&s.alive||c!==null&&!c.impactFired)?s:null,d=s?.alive===!1&&(c===null||c.impactFired),f=n?.fighters.find(e=>e.is_downed)??(n?.phase===`knockdown`?n.fighters.find(e=>e.player_id===this.lastKnockdown?.knockdown.target_id):void 0)??null,p=n?.fighters.some(e=>e.clinch_ticks>0||e.clinch_startup_ticks>0)??!1,m=f===null&&i.breaking,h=f===null?void 0:this.graphs?.[n?.fighters.indexOf(f)??-1],g=h?.fallBody?.centre(this.bodyPoint)??null,_=f!==null&&!f.is_downed?h?.currentRoot??null:null,v=f===null?(this.tmpA.x+this.tmpB.x)/2:g?.x??_?.x??this.mapping.x(f.x),y=f===null?(this.tmpA.z+this.tmpB.z)/2:g?.z??_?.z??this.mapping.z(f.y),b=this.refereeAway.set(this.refereePosition.x-v,0,this.refereePosition.z-y);if(b.lengthSq()<.01&&b.set(0,0,-1),b.normalize(),m){let e=this.tmpB.z-this.tmpA.z,t=this.tmpA.x-this.tmpB.x,n=Math.hypot(e,t),r=e*b.x+t*b.z>=0?1:-1;n>.01&&b.set(e/n*r,0,t/n*r)}let{standoff:x,clearance:S}=Iq(f!==null,p,m),C=G.clamp(v+b.x*x,-2.4,2.4),w=G.clamp(y+b.z*x,-2.4,2.4),T=this.refereePosition.x,E=this.refereePosition.z,D=this.replay===null&&this.ceremony?.positions!==null?this.ceremony:null,O=!d&&D===null&&this.replay===null&&this.stoppageWinner>=0&&this.frameSeconds>=this.stoppageRaiseAt?this.stoppageWinner===0?this.tmpA:this.tmpB:null,k=O===null?null:this.stoppageSpot??=this.raiseSpot(O,this.stoppageWinner===0?this.tmpB:this.tmpA),A=k!==null&&k.x<0?-1:1;if(d)D!==null&&(D.refereeArrived=!0);else if(O!==null&&k!==null){let t=WG(this.refereePosition.x,this.refereePosition.z,{x:O.x+k.x,y:O.z+k.z},VG*e);this.refereePosition.x=t.x,this.refereePosition.z=t.y}else if(D!==null){let t=WG(this.refereePosition.x,this.refereePosition.z,{x:RG.x,y:RG.z},VG*e);this.refereePosition.x=t.x,this.refereePosition.z=t.y,D.refereeArrived=t.arrived}else if(u!==null){let t=c===null?1-Math.exp(-20*e):1;this.refereePosition.x+=(this.mapping.x(u.x)-this.refereePosition.x)*t,this.refereePosition.z+=(this.mapping.z(u.y)-this.refereePosition.z)*t}else{let t=1-Math.exp(-(m?8:1.6)*e),n=m?Math.min(1,jG*e/Math.max(1e-6,Math.hypot(C-this.refereePosition.x,w-this.refereePosition.z)*t)):1;this.refereePosition.x+=(C-this.refereePosition.x)*t*n,this.refereePosition.z+=(w-this.refereePosition.z)*t*n}let j=O===null?D===null?u!==null||d?0:S:D.refereeArrived?0:LG:fG*.85;for(let e of j>0?[this.tmpA,this.tmpB]:[]){let t=this.refereePosition.x-e.x,n=this.refereePosition.z-e.z,r=Math.hypot(t,n);r.001&&(this.refereePosition.x=e.x+t/r*j,this.refereePosition.z=e.z+n/r*j)}for(let e of D!==null||d?[]:this.graphs??[]){let t=e.fallBody;if(t!==null)for(let e of[0,1,2,3,4]){t.bodyPoint(e,this.bodyPoint);let n=PK(this.refereePosition.x,this.refereePosition.z,this.bodyPoint.x,this.bodyPoint.z,CG);this.refereePosition.x=n.x,this.refereePosition.z=n.z}}for(let e of d?[]:[0,1]){if(!this.effects.severedHeadPosition(e,this.closeUpTarget))continue;let t=PK(this.refereePosition.x,this.refereePosition.z,this.closeUpTarget.x,this.closeUpTarget.z,bG);this.refereePosition.x=t.x,this.refereePosition.z=t.z}if(c===null&&!d){let t=this.refereePosition.x-T,n=this.refereePosition.z-E,r=Math.hypot(t,n),i=eK*e;r>i&&(this.refereePosition.x=T+t/r*i,this.refereePosition.z=E+n/r*i)}e>0&&this.refereeVelocity.set((this.refereePosition.x-T)/e,0,(this.refereePosition.z-E)/e);let ee=O!==null&&k!==null&&Math.hypot(this.refereePosition.x-O.x-k.x,this.refereePosition.z-O.z-k.z)<=mG,M=D!==null&&!D.refereeArrived,te=O===null?D===null?u===null?Math.atan2(v-this.refereePosition.x,y-this.refereePosition.z):Math.atan2(u.facing_x,-u.facing_y):M?Math.atan2(RG.x-this.refereePosition.x,RG.z-this.refereePosition.z):0:ee?0:Math.atan2(O.x-this.refereePosition.x,O.z-this.refereePosition.z);if(O!==null){let e=this.graphs?.[this.stoppageWinner]?.boxer.rig.bones,t=n?.fighters[this.stoppageWinner]?.injuries??[],r=lK(t,`left`),a=!ee||e===void 0?null:r&&lK(t,`right`)?this.nearerGlove(e.gloveL,e.gloveR):(r?e.gloveL:e.gloveR).getWorldPosition(this.stoppageWrist);i.raise(A<0?a:null,A>0?a:null)}let ne=((te-this.refereeYaw+Math.PI)%(Math.PI*2)+Math.PI*2)%(Math.PI*2)-Math.PI;this.refereeYaw+=ne*(1-Math.exp(-(m?8:3)*e));let re=Lq(this.refereePosition,this.refereeYaw,this.refereeVelocity,this.mapping,s);i.setRefereeCount(f!==null,f?.get_up_count??0),i.aimBreak(this.tmpA,this.tmpB);let ie=this.settings();if(i.update(re.self,re.focus,e,t,ie.reducedMotion,ie.blood,r),this.refereeFallUnseen&&(this.refereeFallUnseen=!1,i.fallBody?.settle()),this.effects.gushing(2)){let e=this.refereeMouth();e!==null&&this.effects.anchorGush(2,e.position,e.axis)}this.poolUnderReferee(s?.alive===!1,d,e,ie.blood)}poolUnderReferee(e,t,n,r){if(!e&&this.replay===null&&(this.refereePoolAccumulator=0,this.refereePoolCount=0),!t||r===`off`||this.referee===null)return;this.refereePoolAccumulator+=n*5*pq;let i=this.referee.boxer.rig.bones.head.getWorldPosition(this.refereeHead);for(;this.refereePoolAccumulator>=1;){--this.refereePoolAccumulator;let e=this.refereePoolCount,t=Tq(e,fq,mq);if(t>=mq)return;this.refereePoolCount=e+1;let n=e*2.399963;this.effects.pool(i.x+Math.sin(n)*t*.25,i.z+Math.cos(n)*t*.25,t,e+14)}}updateTrails(e,t){let n=this.graphs;if(!(n===null||this.trails.length<4)){for(let[r,i]of n.entries())for(let[n,a]of[`gloveL`,`gloveR`].entries()){let o=this.trails[r*2+n],s=this.glows[r*2+n];if(!i.boxer.root.visible||!this.carnage.hasGlove(r,n===0?`left`:`right`)){o.reset(),s?.reset();continue}i.boxer.rig.bones[a].getWorldPosition(this.trailGlove);let c=i.powerHeat(n===0?`left`:`right`);o.update(this.trailGlove,e,this.camera.position,!t&&this.replay===null&&!i.isDown,c),s?.update(this.trailGlove,c,e,t,this.camera)}for(let t of this.impactFlashes)t.update(e,this.camera);this.powerShake*=.02**e}}presentPowerHit(e,t){let n=!t.detail.endsWith(`:body`)&&this.headCacheValid[e]===!0?this.headCache[e]:void 0;n===void 0?this.powerHitPoint.set(this.contactPoint.x,t.detail.endsWith(`:body`)?1.05:1.55,this.contactPoint.z):this.powerHitPoint.copy(n),this.impactFlashes[e]?.fire(this.powerHitPoint),this.powerShake=Math.min(rK,this.powerShake+nK)}updateCornermen(e,t,n,r){let i=this.cornermen;if(i===null)return;let a=UW(n,this.simulation.tick_rate);for(let[n,o]of i.entries()){let i=n===0?-1:1,s=a?AG:vG;this.cornermanPosition.set(i*s,0,-i*s);let c=n===0?3*Math.PI/4:-Math.PI/4;o.attend(a);let l=Lq(this.cornermanPosition,c,this.cornermanVelocity,this.mapping);o.update(l.self,l.focus,e,t,!1,`off`,r)}}updateCutmen(e,t,n,r){let i=this.cutmen,a=this.graphs;if(i===null||a===null)return;let o=n?.phase===`rest`,s=this.mapping.x(l);for(let[c,l]of i.entries()){let i=c===0?-1:1,u=o&&a[c].stoolVisible?1:0,d=this.cutmanProgress[c],f=d+Math.sign(u-d)*Math.min(Math.abs(u-d),e/MG);this.cutmanProgress[c]=f;let p=l.boxer.root.visible;if(l.boxer.root.visible=f>.005,!l.boxer.root.visible)continue;this.cutmanFrom.set(i*vG,0,-i*2.42),bD(c===0?0:1,s,_D,32,this.cutmanTo);let m=f*f*(3-2*f);this.cornermanPosition.copy(this.cutmanFrom).lerp(this.cutmanTo,m);let h=this.cutmanLast[c];p||h.copy(this.cornermanPosition),this.cornermanVelocity.copy(this.cornermanPosition).sub(h).divideScalar(Math.max(e,.001)),h.copy(this.cornermanPosition);let g=f>.02&&f=NG?_===null?Math.atan2(i,-i):Math.atan2(_.x-this.cutmanTo.x,_.z-this.cutmanTo.z):Math.atan2(-this.cutmanFrom.x,-this.cutmanFrom.z),y=hK(n?.fighters[c]);if(f>=NG&&_!==null){let e=a[c].boxer.root.rotation.y;this.cutmanFacing.set(Math.sin(e),0,Math.cos(e)),this.cutmanEye.copy(_).addScaledVector(this.cutmanFacing,.09),this.cutmanEye.x+=Math.cos(e)*y.side*y.lateral,this.cutmanEye.z-=Math.sin(e)*y.side*y.lateral,this.cutmanEye.y+=y.lift,l.treat(this.cutmanEye,this.cutmanFacing,y.side,y.prop)}else l.treat(null);let b=Lq(this.cornermanPosition,v,this.cornermanVelocity,this.mapping);l.update(b.self,b.focus,e,t,!1,`off`,r)}}drawHudOverlay(e){let t=VW(this.hudCanvas);if(t===null)return;let{context:n,viewport:r}=t;if(this.hudViewport.width=r.width,this.hudViewport.height=r.height,n.clearRect(0,0,r.width,r.height),e===null)return;let i=this.settings();if(this.viewerHitFlash>.01&&!i.reducedMotion){let e=n.createRadialGradient(r.width/2,r.height/2,r.width*.12,r.width/2,r.height/2,r.width*.7);e.addColorStop(0,`rgba(255,235,225,${(this.viewerHitFlash*.18).toFixed(3)})`),e.addColorStop(1,`rgba(140,0,10,${(this.viewerHitFlash*.55).toFixed(3)})`),n.fillStyle=e,n.fillRect(0,0,r.width,r.height)}let a=sq(Math.max(...e.fighters.map(e=>e.trauma.head+e.trauma.body)),i.blood);if(a>0){let e=n.createRadialGradient(r.width/2,r.height/2,r.width*.2,r.width/2,r.height/2,r.width*.72);e.addColorStop(0,`rgba(90,0,8,0)`),e.addColorStop(1,`rgba(75,0,8,${a.toFixed(3)})`),n.fillStyle=e,n.fillRect(0,0,r.width,r.height)}i.reducedMotion||this.effects.drawLens(n,r.width,r.height);let o=this.deaths[0]??this.deaths[1],s=this.replay===null?null:this.replay.plan.impact.kind===`referee_down`?`REFEREE DOWN`:o===null?`KNOCKOUT REPLAY`:Oe(o)===null?`DEATH REPLAY`:`FATALITY REPLAY`;Fr(n,r.width,r.height,e,this.players,this.viewerId,this.frameSeconds>=this.finalRevealAt?this.final:null,this.reconnectMs,this.simulation.tick_rate,this.roundStats,s,this.lagWarned?this.inputLatencyMs:null,this.frameSecondsthis.avatars.get(e),this.lastKnockdown?.knockdown.target_id??null,this.touchControls&&e.fighters.some(e=>e.player_id===this.viewerId),this.powerHeld?.()===!0,o,this.finishTargetId,!i.reducedMotion),this.drawCaption(n,r.width,r.height,e)}updateRocked(e,t,n){let r=e?.fighters.find(e=>e.player_id===this.viewerId),i=e===null||this.replay!==null||this.final!==null?0:_W(r,e.phase),a=this.rocked.update(n?0:i,t);return this.finishPass.uniforms.uRocked.value=n?0:a,r===void 0?null:i}shownAt(e){for(let t=this.history.length-1;t>=0;--t)if(this.history[t].tick<=e)return this.history[t];return null}drawCaption(e,t,n,r){let i=this.final!==null&&this.frameSeconds>=this.finalRevealAt?this.final:null;i!==null&&!this.resultAnnounced&&(this.resultAnnounced=!0,this.commentary.resultShown(this.frameSeconds));let a=this.commentary.current(this.frameSeconds),o=this.settings(),s=a===null||!o.commentary?``:a.line.text;if(s!==this.captionText&&(this.captionText=s,this.hudCanvas.dataset.caption=s),a===null||!o.commentary)return;let c=r.fighters.find(e=>e.player_id===this.viewerId),l=Vn(t,n),u=i===null?null:BK(i,t,n,r.fighters,this.players,this.roundStats,this.viewerId,this.deaths[0]??this.deaths[1])/l,d=this.frameSeconds0});p!==null&&(e.save(),e.scale(l,l),XD(e,a,p,o.reducedMotion),e.restore())}destroy(){if(!this.destroyed){if(this.destroyed=!0,cancelAnimationFrame(this.raf),this.raf=0,this.buffer.clear(),this.dedupe.reset(),this.pendingContacts.length=0,this.pendingGore.length=0,this.carnage.dispose(),this.effects.dispose(),this.avatars.dispose(),this.arena.dispose(),iF(this.ring),this.graphs!==null){for(let e of this.graphs)this.scene.remove(e.boxer.root),e.dispose();this.graphs=null}this.referee!==null&&(this.scene.remove(this.referee.boxer.root),this.referee.dispose(),this.referee=null);for(let e of this.trails)this.scene.remove(e.mesh),e.dispose();this.trails=[];for(let e of this.glows)this.scene.remove(e.mesh),e.dispose();this.glows=[];for(let e of this.impactFlashes)this.scene.remove(e.group),e.dispose();if(this.impactFlashes=[],this.glowMap?.dispose(),this.glowMap=null,this.cornermen!==null){for(let e of this.cornermen)this.scene.remove(e.boxer.root),e.dispose();this.cornermen=null}if(this.cutmen!==null){for(let e of this.cutmen)this.scene.remove(e.boxer.root),e.dispose();this.cutmen=null}for(let e of this.lights)this.scene.remove(e);this.keyLight?.shadow.map?.dispose(),this.keyLight?.shadow.dispose(),this.blobTexture.dispose();for(let e of this.blobShadows)this.scene.remove(e),e.geometry.dispose(),e.material.dispose();this.renderer.renderLists.dispose(),GW(this.composer),this.bloomPass.materialHighPassFilter.dispose(),hF(),this.renderer.dispose(),this.hudCanvas.remove()}}},zq=[`broadcast`,`close`,`fighter`],Bq=`hands.preferences.v1`,Vq={length:0,clear:()=>void 0,getItem:()=>null,key:()=>null,removeItem:()=>void 0,setItem:()=>void 0},Hq=()=>{try{return window.localStorage}catch{return Vq}},Uq=()=>({volume:.7,haptics:!0,reducedMotion:window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1,blood:`full`,commentary:!0,announcer:!0,camera:`broadcast`});function Wq(e=Hq()){let t=Uq();try{let n=JSON.parse(e.getItem(Bq)??`null`);if(typeof n!=`object`||!n||Array.isArray(n))return t;let r=n;return{volume:typeof r.volume==`number`&&Number.isFinite(r.volume)?Math.max(0,Math.min(1,r.volume)):t.volume,haptics:typeof r.haptics==`boolean`?r.haptics:t.haptics,reducedMotion:typeof r.reducedMotion==`boolean`?r.reducedMotion:t.reducedMotion,blood:r.blood===`reduced`||r.blood===`off`||r.blood===`full`?r.blood:t.blood,commentary:typeof r.commentary==`boolean`?r.commentary:t.commentary,announcer:typeof r.announcer==`boolean`?r.announcer:t.announcer,camera:zq.includes(r.camera)?r.camera:t.camera}}catch{return t}}function Gq(e,t=Hq()){try{t.setItem(Bq,JSON.stringify({volume:Math.max(0,Math.min(1,e.volume)),haptics:e.haptics,reducedMotion:e.reducedMotion,blood:e.blood,commentary:e.commentary,announcer:e.announcer,camera:e.camera}))}catch{}}var Kq=class{value;listeners=new Set;constructor(e=Hq()){this.storage=e,this.value=Wq(e)}storage;get current(){return this.value}update(e){this.value={...this.value,...e},Gq(this.value,this.storage);for(let e of this.listeners)e(this.value)}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}destroy(){this.listeners.clear()}},qq={stage:`bootstrapping`,player:null,playerId:null,role:null,players:{},playerOrder:[],simulation:null,snapshot:null,final:null,select:null,serverTick:0,nextSequence:0,reconnectMs:0,safeError:null},Jq=e=>Object.fromEntries(e.map(e=>[e.id,e]));function Yq(e,t){if(t.type===`bootstrap`)return{...e,stage:`authorizing`,simulation:t.simulation,safeError:null};if(t.type===`authorized`)return{...e,stage:`connecting`,player:t.player,safeError:null};if(t.type===`connecting`)return{...e,stage:`connecting`};if(t.type===`reconnect-tick`)return{...e,stage:`paused`,reconnectMs:Math.max(0,t.remainingMs)};if(t.type===`fatal`)return{...e,stage:`fatal`,safeError:t.code,reconnectMs:0};let n=t.message;switch(n.type){case`welcome`:return{...e,playerId:n.role===`fighter`?n.player_id:null,role:n.role,players:Jq(n.players),playerOrder:n.players.map(e=>e.id),serverTick:n.server_tick,nextSequence:n.role===`fighter`?n.next_sequence:0,safeError:null};case`ticket`:return e;case`waiting`:return{...e,stage:`waiting`,select:null};case`select`:return{...e,stage:`select`,select:n,players:Jq(n.players),playerOrder:n.players.map(e=>e.id)};case`ready`:return{...e,stage:e.snapshot?.phase??`countdown`,select:null,players:Jq(n.players),playerOrder:n.players.map(e=>e.id)};case`paused`:return{...e,stage:`paused`,reconnectMs:n.grace_ms};case`resumed`:return{...e,stage:e.snapshot?.phase??`countdown`,reconnectMs:0};case`snapshot`:return{...e,stage:n.payload.phase,snapshot:n.payload,serverTick:Math.max(e.serverTick,n.payload.tick)};case`final`:return{...e,stage:`complete`,final:n,reconnectMs:0};case`error`:return{...e,stage:`fatal`,safeError:n.code,reconnectMs:0}}}var Xq=new Set([`hit`,`counter_hit`,`block`,`perfect_block`,`guard_break`,`knockdown`,`parry`,`body_collapse`,`eye_shut`,`referee_hit`,`referee_down`]),Zq=11e3,Qq=1500,$q=4e3,eJ=3e3,tJ=6,nJ=5e3,rJ=[{level:`rookie`,label:`Rookie`,detail:`Slow hands, leaves openings`},{level:`contender`,label:`Contender`,detail:`Works the body, punishes mistakes`},{level:`champion`,label:`Champion`,detail:`Slips, counters, finishes`}],iJ=e=>Mt.includes(e),aJ=class{root;reloadPage;authorizer;state=qq;settings=new Kq;input=new pf;audio=new _i(()=>this.settings.current);haptics=new Rd(()=>this.settings.current);voice=new Zr(()=>this.settings.current);feedbackEvents=new Df;soundedPunches=[];renderer=null;network=null;session=null;abort=new AbortController;destroyed=!1;generation=0;reloadOnRetry=!1;reloading=!1;canvas;status;overlay;roleIndicator;controlsButton;controlsPanel;retry;rematchButton;hint;cpuPicker;cpuPrompt;cpuLevel=null;rematchOpponent=null;lastPhase=null;cpuRematchLevel=null;cpuRematch=null;cpuRematchTimer=null;diagnosticsTimer=null;finalReceivedAt=0;lastFinalMatchId=null;rematchAttempts=0;rematchTimer=null;rematchCountdownTimer=null;resultRevealTimer=null;resultWaitTimer=null;completeSince=null;summaryClock=new or;fightSummary;liveFightStatus;finalSummary;corner;stylePicker;constructor(e,t=()=>window.location.reload(),n=new _d){this.root=e,this.reloadPage=t,this.authorizer=n,e.innerHTML=`
HANDStwo-player boxing

`,this.canvas=e.querySelector(`canvas`),this.status=e.querySelector(`[data-status]`),this.overlay=e.querySelector(`[data-overlay]`),this.roleIndicator=e.querySelector(`[data-role]`),this.controlsButton=e.querySelector(`[data-controls]`),this.controlsPanel=e.querySelector(`[data-controls-panel]`),this.retry=e.querySelector(`[data-retry]`),this.rematchButton=e.querySelector(`[data-rematch]`),this.hint=e.querySelector(`[data-hint]`),this.cpuPicker=e.querySelector(`[data-cpu]`),this.cpuPrompt=e.querySelector(`[data-cpu-prompt]`),this.cpuPicker.addEventListener(`click`,this.onCpuPick),this.rematchButton.addEventListener(`click`,this.onRematch),this.fightSummary=e.querySelector(`[data-fight-summary]`),this.liveFightStatus=e.querySelector(`[data-fight-status]`),this.finalSummary=e.querySelector(`[data-final]`),this.retry.addEventListener(`click`,this.onRetry),this.bindPanels(),this.syncSettings(),this.input.attachTouch(e.querySelector(`.activity`)),this.corner=new kd(e.querySelector(`.activity`),e=>this.network?.sendCornerChoice(e)??!1),this.stylePicker=new Xt(e.querySelector(`.activity`),(e,t)=>this.network?.chooseStyle(e,t)??!1),this.input.setViewForward(()=>this.renderer?.viewForward()??null),window.addEventListener(`keydown`,this.onCameraKey)}onCameraKey=e=>{if(e.code!==`KeyK`||e.repeat||e.ctrlKey||e.metaKey||e.altKey)return;let t=e.target;if(t instanceof HTMLInputElement||t instanceof HTMLSelectElement||t instanceof HTMLTextAreaElement)return;e.preventDefault();let n=zq[(zq.indexOf(this.settings.current.camera)+1)%zq.length];this.settings.update({camera:n}),this.root.querySelector(`[data-camera]`).value=n};start(){this.authorize()}resetForAuthorization(){this.reloadOnRetry=!1,this.network?.dispose(),this.network=null,this.session?.destroy(),this.session=null,this.renderer?.destroy(),this.renderer=null,this.voice.cancel(),this.audio.reset(),this.abort.abort(),this.abort=new AbortController,this.state=qq,this.feedbackEvents.reset(),this.input.setActive(!1),this.input.reset(),this.finalSummary.textContent=``,this.fightSummary.textContent=``,this.liveFightStatus.textContent=``,this.clearRematchTimers(),this.rematchButton.hidden=!0,this.cpuLevel=null,this.lastPhase=null}onCpuPick=e=>{let t=e.target?.closest(`[data-cpu-level]`)?.dataset.cpuLevel;iJ(t)&&this.state.stage===`waiting`&&this.state.role===`fighter`&&this.cpuLevel===null&&this.callCpu(t)};callCpu(e){this.network?.requestCpu(e)===!0&&(this.cpuLevel=e,this.renderState())}get cpuBout(){return Object.values(this.state.players).some(e=>e.cpu===!0)}onRematch=()=>{this.rematchButton.disabled||this.state.stage!==`complete`||(this.rematchAttempts=1,this.rematchOpponent=this.cpuBout||this.state.role!==`fighter`?null:Object.values(this.state.players).find(e=>e.id!==this.state.playerId)?.name??null,this.authorize())};clearRematchTimers(){this.rematchTimer!==null&&window.clearTimeout(this.rematchTimer),this.rematchCountdownTimer!==null&&window.clearInterval(this.rematchCountdownTimer),this.rematchTimer=null,this.rematchCountdownTimer=null,this.clearCpuRematch()}scheduleCpuRematch(e){this.clearCpuRematch(),this.cpuRematch={level:e,at:Date.now()+nJ},this.cpuRematchTimer=window.setInterval(()=>{let e=this.cpuRematch;e===null||this.state.stage!==`waiting`||this.state.role!==`fighter`||this.cpuLevel!==null?this.clearCpuRematch():Date.now()>=e.at&&(this.clearCpuRematch(),this.callCpu(e.level)),this.renderState()},250)}clearCpuRematch(){this.cpuRematchTimer!==null&&window.clearInterval(this.cpuRematchTimer),this.cpuRematchTimer=null,this.cpuRematch=null}awaitResultReveal(){this.resultRevealTimer!==null&&window.clearInterval(this.resultRevealTimer);let e=()=>{let e=this.renderer?.resultVisible??!0;this.overlay.hidden=this.state.stage===`complete`&&!e,(e||this.state.stage!==`complete`)&&this.resultRevealTimer!==null&&(window.clearInterval(this.resultRevealTimer),this.resultRevealTimer=null)};this.resultRevealTimer=window.setInterval(e,200),e()}startRematchCountdown(){this.clearRematchTimers();let e=this.state.role===`fighter`?`Rematch`:`Next bout`,t=()=>{let t=Math.ceil((this.finalReceivedAt+Zq-Date.now())/1e3);this.rematchButton.hidden=this.state.stage!==`complete`,this.rematchButton.disabled=t>0,this.setText(this.rematchButton,t>0?`${e} in ${t}s`:e),t<=0&&this.rematchCountdownTimer!==null&&(window.clearInterval(this.rematchCountdownTimer),this.rematchCountdownTimer=null)};t(),this.rematchCountdownTimer=window.setInterval(t,1e3)}scheduleRematchRetry(){this.rematchTimer===null&&(this.rematchAttempts>=tJ?this.fail(`rematch_unavailable`):(this.rematchAttempts+=1,this.setText(this.status,`The ring is still being cleared… trying again.`),this.rematchTimer=window.setTimeout(()=>{this.rematchTimer=null,this.authorize()},eJ)))}async authorize(){let e=++this.generation;this.resetForAuthorization(),this.dispatch({type:`connecting`}),this.setText(this.status,`Securing Discord Activity session…`),this.retry.hidden=!0;try{let t=await this.authorizer.authorize(this.abort.signal);if(this.destroyed||e!==this.generation){t.destroy();return}this.session=t,this.dispatch({type:`bootstrap`,simulation:t.bootstrap.simulation}),this.dispatch({type:`authorized`,player:t.player}),this.input.onAction(e=>{this.renderer?.predictAction?.(e),this.network?.notifyAction()}),this.input.onHeldChange(()=>this.network?.notifyHeld());let n=t.takeTicket();if(n===null)throw Error(`ticket_unavailable`);let r=new Rf(n,()=>this.input.frame(),{onMessage:e=>this.receive(e),onReconnect:e=>{this.dispatch({type:`reconnect-tick`,remainingMs:e}),this.renderer?.setReconnect(e),this.renderState()},onFatal:e=>this.fail(e),onFreshAuth:()=>{e===this.generation&&this.authorize()}});this.network=r,r.start(),this.setText(this.status,`Connecting to the ring…`)}catch(t){!this.abort.signal.aborted&&e===this.generation&&(this.reloadOnRetry=t instanceof vi&&t.reloadRequired,this.fail(wi(t)))}}ensureRenderer(){if(this.renderer!==null||this.session===null||this.destroyed)return;let e=new Rq(this.canvas,this.session.bootstrap.simulation,()=>this.settings.current,{localInput:()=>this.input.held(),inputSequenceOf:e=>this.network?.sequenceOf(e)??null,powerHeld:()=>this.input.powerHeld});e.onContact=(e,t)=>{this.audio.event(e,t),this.haptics.event(e,t)},e.onOwnPunch=(e,t,n)=>{this.audio.whoosh(e,t),this.soundedPunches.push(n),this.soundedPunches.length>8&&this.soundedPunches.shift()},e.onArcadeInjury=e=>this.audio.injury(e),e.onGore=e=>{this.audio.gore(e),this.haptics.gore(e),e.kind===`finish_him`?this.voice.shout(`Finish him!`):e.kind===`fatality`&&this.voice.shout(`Fatality.`)},e.onAnnouncement=e=>this.voice.speak(e),e.onCrowdCue=()=>this.audio.chant(),e.onRocked=(e,t)=>this.audio.rocked(e,t),this.renderer=e}receive(e){if(e.type===`error`){this.fail(e.code);return}e.type===`welcome`&&this.ensureRenderer(),(e.type===`welcome`||e.type===`resumed`)&&this.renderer?.resyncClock();let t=this.rematchAttempts>0;(e.type===`waiting`||e.type===`ready`)&&(this.rematchAttempts=0),e.type===`ready`&&(this.rematchOpponent=null),e.type===`ready`&&this.rememberStyle(e.players),e.type===`final`&&this.rematchAttempts>0&&e.match_id===this.lastFinalMatchId?this.scheduleRematchRetry():(this.dispatch({type:`message`,message:e}),e.type===`snapshot`&&this.receiveSnapshot(e.payload),e.type!==`select`&&e.type!==`ready`||e.players.some(e=>e.cpu===!0)||(this.cpuLevel=null),e.type===`waiting`&&(this.cpuLevel===null?t&&this.cpuRematchLevel!==null&&this.scheduleCpuRematch(this.cpuRematchLevel):this.callCpu(this.cpuLevel)),e.type===`final`&&(this.cpuRematchLevel=this.cpuBout?this.cpuLevel:null,this.rematchAttempts=0,this.lastFinalMatchId=e.match_id,this.finalReceivedAt=Date.now(),this.renderer?.setFinal(e),this.audio.result(e),this.startRematchCountdown(),this.awaitResultReveal()),this.renderer?.setPlayers(this.state.players,this.state.playerId,this.state.playerOrder),this.renderer?.setReconnect(this.state.reconnectMs),this.renderState())}get networkStats(){return{inputLatencyMs:this.network?.inputLatencyMs??null,resolutionScale:this.renderer?.resolutionScale??null,gpu:this.renderer?.memoryInfo??null}}receiveSnapshot(e){this.lastPhase===`countdown`&&e.phase!==`countdown`&&this.voice.finishLine(Qq),this.lastPhase=e.phase,this.renderer?.setInputLatency(this.network?.inputLatencyMs??null),this.renderer?.push(e);let t=e.fighters.find(e=>e.player_id===this.state.playerId);this.input.setKnockdown(t?.is_downed===!0),t!==void 0&&this.audio.snapshot(e.tick,t.stamina,t.maximum_stamina,t.trauma.head+t.trauma.body),this.audio.roundClock(e.phase,e.round_number,e.phase_ticks_remaining,this.state.simulation?.tick_rate??30),this.audio.tension(Fp(e));for(let t of this.feedbackEvents.accept(e.events)){if(Xq.has(t.kind)||t.kind===`punch_start`&&t.action_id!==null&&this.soundedPunches.includes(t.action_id))continue;let n=t.kind===`punch_start`?e.fighters.find(e=>e.player_id===t.actor_id&&e.action_id===t.action_id):void 0;this.audio.event(t,n?.action_power===`power`),this.haptics.event(t)}}rememberStyle(e){let t=e.find(e=>e.id===this.state.playerId)?.style;this.state.role===`fighter`&&t!==void 0&&Ut(t)}dispatch(e){this.state=Yq(this.state,e)}setText(e,t){e.textContent!==t&&(e.textContent=t)}renderState(){let e={bootstrapping:`Loading…`,authorizing:`Authorizing with Discord…`,connecting:`Connecting securely…`,waiting:this.state.role===`spectator`?`Waiting for the fighters…`:this.cpuLevel===null?this.cpuRematch===null?this.rematchOpponent===null?`Waiting for an opponent. Anyone in this channel can join with Play now.`:`Waiting for ${this.rematchOpponent} to take the rematch…`:`Rematch with the ${rJ.find(e=>e.level===this.cpuRematch?.level)?.label??`computer`} in ${Math.max(1,Math.ceil((this.cpuRematch.at-Date.now())/1e3))}s, unless someone joins first.`:`Calling in the computer…`,select:`Pick how your fighter boxes.`,countdown:`Bout countdown.`,fight:`Round ${this.state.snapshot?.round_number??1} in progress.`,knockdown:`Knockdown count ${this.state.snapshot?.fighters.find(e=>e.player_id===this.state.playerId)?.get_up_count??0}.`,foul_recovery:`Foul recovery in progress.`,referee_down:`The referee is down. The bout goes on without him.`,finish:this.state.snapshot!==null&&Er(this.state.snapshot.fighters)?.player_id===this.state.playerId?`You are out on your feet: one more punch kills you.`:`Finish him: one more punch kills.`,rest:`Between-round rest.`,paused:`Connection paused. ${Math.ceil(this.state.reconnectMs/1e3)} seconds remain.`,complete:this.cpuBout?`Bout complete. Scorecards are displayed. Bouts against the computer are unrated.`:`Bout complete. Scorecards and rating changes are displayed.`,fatal:jd(this.state.safeError??`safe_error`)},t=this.state.role===`spectator`;this.setText(this.status,t?`Spectating — ${e[this.state.stage]}`:e[this.state.stage]);let n=this.state.stage===`complete`&&this.state.final!==null;if(this.status.hidden=n||[`select`,`countdown`,`fight`,`knockdown`,`foul_recovery`,`referee_down`,`finish`,`rest`].includes(this.state.stage),this.overlay.toggleAttribute(`data-raised`,this.state.snapshot!==null),this.overlay.toggleAttribute(`data-result`,n),this.state.stage!==`complete`)this.overlay.hidden=!1,this.completeSince=null;else if(this.state.final===null){this.completeSince??=Date.now();let e=Date.now()-this.completeSince;this.overlay.hidden=e<$q,this.overlay.hidden&&this.resultWaitTimer===null&&(this.resultWaitTimer=window.setTimeout(()=>{this.resultWaitTimer=null,this.renderState()},$q-e+50))}this.roleIndicator.hidden=!t,this.controlsButton.hidden=t,t&&(this.controlsPanel.hidden=!0,this.controlsButton.setAttribute(`aria-expanded`,`false`));let r=this.state.snapshot?.fighters.find(e=>e.player_id===this.state.playerId),i=t?`Spectating. ${e[this.state.stage]}`:this.state.stage===`knockdown`&&r?.is_downed===!0?`Knockdown. Count ${r.get_up_count}. ${r.get_up_prompt===null?`Wait for your private rhythm instruction.`:`Press ${r.get_up_prompt===`get_up_left`?`left`:`right`} now.`}`:this.state.stage===`paused`?`Connection paused.`:e[this.state.stage];this.setText(this.liveFightStatus,i),this.corner.update(this.state.snapshot,this.state.playerId,this.state.role===`fighter`&&this.state.stage===`rest`),this.renderer?.setCornerPanelTop(this.corner.top()),this.stylePicker.update(this.state.stage===`select`?this.state.select:null,this.state.playerId,this.state.role),this.retry.hidden=this.state.stage!==`fatal`,this.setText(this.retry,this.reloadOnRetry?`Reload`:`Retry securely`),this.state.stage!==`complete`&&(this.rematchButton.hidden=!0),this.cpuPicker.hidden=t||this.state.stage!==`waiting`||this.cpuLevel!==null,this.setText(this.cpuPrompt,this.cpuRematch===null?this.rematchOpponent===null?`No one here yet? Fight the computer.`:`Or fight the computer instead:`:`Or start now:`);let a=!t&&(this.state.stage===`waiting`||this.state.stage===`countdown`);this.hint.hidden=!a,a&&this.setText(this.hint,Kd(Md(),window.innerWidth)),this.overlay.toggleAttribute(`data-touch-hint`,a&&this.state.stage===`countdown`&&Md());let o=!t&&[`countdown`,`fight`,`knockdown`,`foul_recovery`,`referee_down`,`finish`].includes(this.state.stage),s=!t&&this.state.snapshot!==null&&(this.state.stage===`rest`||this.state.stage===`paused`);if(this.input.setActive(o,o||s),this.network?.setActive(o),this.renderFightSummary(),this.state.final!==null){let e=this.state.final;this.setText(this.finalSummary,`${e.method.replaceAll(`_`,` `)}. ${e.winner_id===null?`Draw`:`${this.state.players[e.winner_id]?.name??`Winner`} wins`}. Scorecards: ${e.scorecards.map(e=>`${e.judge}: ${e.player_one.reduce((e,t)=>e+t,0)} to ${e.player_two.reduce((e,t)=>e+t,0)}`).join(`; `)}. ${this.cpuBout?`Unrated bout against the computer.`:`Ratings: ${Object.entries(e.ratings).map(([e,t])=>`${this.state.players[e]?.name??`fighter`} ${t.before} to ${t.after}`).join(`; `)}.`}`)}}renderFightSummary(){let e=this.state.snapshot;if(e===null)return;let t=this.state.simulation?.tick_rate??30,n=Math.floor(this.summaryClock.ticks(e)/t),r=`${Math.floor(n/60)}:${String(n%60).padStart(2,`0`)}`,i=e.fighters.map(e=>{let t=this.state.players[e.player_id],n=e.injuries.length===0?`no injuries`:`injuries: ${e.injuries.map(e=>we(e).toLowerCase()).join(`, `)}`;return`${t?.name??`Fighter`}, ${t?.cpu===!0?`computer opponent`:`ELO ${t?.rating??`unknown`}`}, stamina ${Math.round(e.stamina)} of ${Math.round(e.maximum_stamina)}, guard ${Math.round(e.guard)}, poise ${Math.round(e.poise)}, conditioning ${Math.round(e.conditioning)}, blood ${Math.round(e.blood_volume/ve*100)} percent, ${n}, ${e.warnings} warnings, ${e.knockdowns} knockdowns`}),a=e.fighters.find(e=>e.player_id===this.state.playerId),o=a?.is_downed===!0?a.get_up_prompt===null?`You are down. Count ${a.get_up_count}. Wait for your private rhythm instruction.`:`You are down. Count ${a.get_up_count}. Press ${a.get_up_prompt===`get_up_left`?`left`:`right`} now. Get-up progress ${a.get_up_meter} of ${a.get_up_required}.`:``;this.setText(this.fightSummary,`Round ${e.round_number}. ${e.phase.replace(`_`,` `)}. Clock ${r}. ${i.join(`. `)}. ${o}`.trim())}onRetry=()=>{this.reloadOnRetry?(this.reloading=!0,this.reloadPage()):this.authorize()};bindPanels(){let e=(e,t)=>{let n=this.root.querySelector(e),r=this.root.querySelector(t);n.addEventListener(`click`,()=>{r.hidden=!r.hidden,n.setAttribute(`aria-expanded`,String(!r.hidden))})};e(`[data-controls]`,`[data-controls-panel]`),e(`[data-settings]`,`[data-settings-panel]`);let t=this.root.querySelector(`[data-settings-panel]`);this.root.querySelector(`[data-settings]`).addEventListener(`click`,()=>{this.diagnosticsTimer!==null&&window.clearInterval(this.diagnosticsTimer),this.diagnosticsTimer=null,t.hidden||(this.refreshDiagnostics(),this.diagnosticsTimer=window.setInterval(()=>this.refreshDiagnostics(),1e3))});let n=this.root.querySelector(`[data-copy-diagnostics]`);n.addEventListener(`click`,()=>{let e=this.diagnosticsText(),t=()=>{this.setText(n,`Copied`),window.setTimeout(()=>this.setText(n,`Copy diagnostics`),1500)},r=()=>{let e=this.root.querySelector(`[data-diagnostics]`),t=window.getSelection();if(t===null)return;let r=document.createRange();r.selectNodeContents(e),t.removeAllRanges(),t.addRange(r),this.setText(n,`Selected. Copy manually`),window.setTimeout(()=>this.setText(n,`Copy diagnostics`),2500)},i=navigator.clipboard;i===void 0||typeof i.writeText!=`function`?r():i.writeText(e).then(t).catch(r)}),this.root.querySelector(`[data-volume]`).addEventListener(`input`,e=>{this.settings.update({volume:Number(e.target.value)}),this.audio.setVolume(),this.voice.settingsChanged()}),this.root.querySelector(`[data-haptics]`).addEventListener(`change`,e=>{this.settings.update({haptics:e.target.checked})}),this.root.querySelector(`[data-motion]`).addEventListener(`change`,e=>{let t=e.target.checked;this.settings.update({reducedMotion:t}),this.renderer?.setReducedMotion(t)}),this.root.querySelector(`[data-commentary]`).addEventListener(`change`,e=>{this.settings.update({commentary:e.target.checked})}),this.root.querySelector(`[data-announcer]`).addEventListener(`change`,e=>{let t=e.target.checked;this.settings.update({announcer:t}),t||this.voice.cancel()}),this.root.querySelector(`[data-blood]`).addEventListener(`change`,e=>{let t=e.target.value;this.settings.update({blood:t}),this.renderer?.setBloodLevel(t)}),this.root.querySelector(`[data-camera]`).addEventListener(`change`,e=>{let t=zq.find(t=>t===e.target.value);t!==void 0&&this.settings.update({camera:t})})}diagnosticsText(){let e=this.networkStats,t=this.renderer?.diagnostics,n=t===void 0||t.frameMs<=0?`-`:(1e3/t.frameMs).toFixed(0);return[`stage: ${this.state.stage} · role: ${this.state.role??`-`}`,`input latency: ${e.inputLatencyMs===null?`-`:`${Math.round(e.inputLatencyMs)} ms`}`,`frame: ${t===void 0?`-`:`${t.frameMs.toFixed(1)} ms (${n} fps)`} · render scale: ${t?.resolutionScale??`-`}`,`gpu objects: ${t===void 0?`-`:`${t.gpu.geometries} geometries, ${t.gpu.textures} textures, ${t.gpu.programs} programs`}`,`graphics: ${t?.graphics??`-`}`,`browser: ${navigator.userAgent}`,`pointer: ${Md()?`coarse`:`fine`} · viewport: ${window.innerWidth}x${window.innerHeight} @${window.devicePixelRatio}`,`last error: ${this.state.safeError??`none`}`,`match: ${this.state.final?.match_id??`-`}`].join(` -`)}refreshDiagnostics(){this.setText(this.root.querySelector(`[data-diagnostics]`),this.diagnosticsText())}syncSettings(){let e=this.settings.current;this.root.querySelector(`[data-volume]`).value=String(e.volume),this.root.querySelector(`[data-haptics]`).checked=e.haptics,this.root.querySelector(`[data-motion]`).checked=e.reducedMotion,this.root.querySelector(`[data-blood]`).value=e.blood,this.root.querySelector(`[data-commentary]`).checked=e.commentary,this.syncAnnouncerSetting(),this.voice.onVoicesChanged=()=>this.syncAnnouncerSetting(),this.root.querySelector(`[data-camera]`).value=e.camera}syncAnnouncerSetting(){let e=this.root.querySelector(`[data-announcer]`),t=this.voice.hasVoice;e.checked=this.settings.current.announcer&&t,e.disabled=!t;let n=this.voice.supported?t?null:`This device has no English voice of its own`:`This browser cannot speak`;n===null?e.parentElement.removeAttribute(`title`):e.parentElement.title=n}fail(e){e===`room_closed`&&this.rematchAttempts>0?this.scheduleRematchRetry():(e===`client_outdated`&&(this.reloadOnRetry=!0),this.dispatch({type:`fatal`,code:e}),this.rematchOpponent=null,this.voice.cancel(),this.network?.dispose(),this.network=null,this.session?.destroy(),this.session=null,this.renderer?.destroy(),this.renderer=null,this.input.setActive(!1),this.input.reset(),this.renderState())}destroy(){this.destroyed||(this.destroyed=!0,this.generation+=1,this.abort.abort(),this.network?.dispose(),this.session?.destroy(),this.reloading||this.authorizer.close(),this.renderer?.destroy(),window.removeEventListener(`keydown`,this.onCameraKey),this.input.destroy(),this.corner.destroy(),this.stylePicker.destroy(),this.audio.destroy(),this.voice.destroy(),this.settings.destroy(),this.retry.removeEventListener(`click`,this.onRetry),this.rematchButton.removeEventListener(`click`,this.onRematch),this.cpuPicker.removeEventListener(`click`,this.onCpuPick),this.clearRematchTimers(),this.diagnosticsTimer!==null&&window.clearInterval(this.diagnosticsTimer),this.resultRevealTimer!==null&&window.clearInterval(this.resultRevealTimer),this.resultWaitTimer!==null&&window.clearTimeout(this.resultWaitTimer),this.diagnosticsTimer=null,this.root.replaceChildren())}};(new URLSearchParams(window.location.search).get(`styles`)??``).split(`,`);var oJ={broadcast:{position:[0,1.88,7.15],lookAt:[0,1.12,0]},side:{position:[7.4,1.6,0],lookAt:[0,1.1,0]},top:{position:[.01,8.5,.01],lookAt:[0,0,0]},ringside:{position:[1.6,1.5,4.1],lookAt:[.2,1.25,0]}},sJ=[[`hips`,`spine`],[`spine`,`head`],[`chest`,`shoulderL`],[`shoulderL`,`elbowL`],[`elbowL`,`gloveL`],[`chest`,`shoulderR`],[`shoulderR`,`elbowR`],[`elbowR`,`gloveR`],[`hips`,`hipL`],[`hipL`,`kneeL`],[`kneeL`,`ankleL`],[`hips`,`hipR`],[`hipR`,`kneeR`],[`kneeR`,`ankleR`]],cJ=class{root;renderer=null;replay=null;raf=0;playing=!1;speed=1;virtualTick=0;carry=0;latencyMs=0;pendingQueue=[];destroyed=!1;overlays={skeleton:!1,hurtbox:!1,hitbox:!1};skeletonLines=[];hurtboxMeshes=[];hitboxMeshes=[];statusEl;metricsEl;canvas;constructor(e){this.root=e,e.innerHTML=`
+}`},Kq=[{x:-102,y:-16},{x:102,y:-16}],qq=[0,1],Jq=.5,Yq={x:0,z:-.2},Xq=0,Zq=200,Qq=1.3,$q=.7,eJ=4.5;function tJ(e,t,n,r){let i=n.x-e,a=n.y-t,o=Math.hypot(i,a);return o<=Math.max(r,1e-6)?{x:n.x,y:n.y,arrived:!0}:{x:e+i/o*r,y:t+a/o*r,arrived:!1}}var nJ=16,rJ=.6,iJ={hit:.18,counter_hit:.3,guard_break:.25,knockdown:1,block:.04,perfect_block:.1,parry:.22,body_collapse:.45},aJ=new Set([`hit`,`counter_hit`,`block`,`perfect_block`,`guard_break`,`knockdown`,`parry`,`body_collapse`,`eye_shut`]),oJ=new Set([`parry`,`body_collapse`,`eye_shut`]),sJ=new Set([`hit`,`counter_hit`,`block`,`perfect_block`]),cJ=1.2,lJ=.8,uJ=2.4,dJ=2.5,fJ=new Set([`referee_hit`,`referee_down`]),pJ=.05,mJ=.08,hJ={parry:{text:`PARRIED`,seconds:1},eye_shut:{text:`EYE SWOLLEN SHUT`,seconds:1.6}},gJ=new Set([`injury`,`vomit`,`finish_him`,`fatality`,`death`]),_J=1.8,vJ=3,yJ=.6;function bJ(e,t){let n=je(e,t);return n!==`severed`&&n!==`torn`}function xJ(e){return e.kind===`death`?e.detail===`brain`?`head_burst`:null:e.kind===`fatality`?e.detail===`head_burst`?`head_burst`:e.detail===`decapitation`||e.detail===`spine_rip`?`decapitation`:null:null}var SJ=e=>e.kind===`knockdown`&&e.detail===`body`;function CJ(e,t){if(lq(e)&&e.action_id!==null)return t.find(t=>uq(t)&&t.action_id===e.action_id&&t.actor_id===e.target_id&&t.target_id===e.actor_id)}function wJ(e,t){if(uq(e)&&e.action_id!==null)return t.find(t=>lq(t)&&t.action_id===e.action_id&&t.actor_id===e.target_id&&t.target_id===e.actor_id)}function TJ(e,t){return e.map((n,r)=>{if(oJ.has(n.kind)||n.kind===`knockdown`&&n.detail===Mq)return{event:n,presentationEvent:n,presentImpact:!1,reactAmount:null};let{puncherIndex:i}=sq(n,t),a=t.fighters[i],o=a?.action_key?.split(`:`)??[],s=o.length>=3?`${o[0]}:${o[2]}`:n.detail,c=wJ(n,e);if(uq(n))return{event:n,presentationEvent:{...n,detail:c?.detail||s,direction:c?.direction??a?.facing??n.direction,blood:c?.blood??n.blood},presentImpact:!0,reactAmount:n.amount};if(CJ(n,e)!==void 0)return{event:n,presentationEvent:n,presentImpact:!1,reactAmount:n.amount};if(n.kind===`knockdown`){let t=e.slice(0,r).reverse().find(e=>lq(e)&&e.tick===n.tick&&e.actor_id===n.actor_id&&e.target_id===n.target_id);if(t!==void 0)return{event:n,presentationEvent:{...n,detail:t.detail,direction:t.direction,blood:t.blood,action_id:t.action_id},presentImpact:!0,reactAmount:CJ(t,e)===void 0?null:t.amount}}return{event:n,presentationEvent:n,presentImpact:!0,reactAmount:n.amount}})}function EJ(e){let t=e?.trauma;if(t===void 0)return{side:1,lift:.08,lateral:.035,prop:`enswell`};switch(e?.corner_choice){case`cut`:return{side:t.right_cut>t.left_cut?-1:1,lift:.11,lateral:.04,prop:`enswell`};case`swelling`:return{side:t.right_eye>t.left_eye?-1:1,lift:.08,lateral:.035,prop:`enswell`};case`breath`:return{side:1,lift:-.015,lateral:0,prop:`bottle`};default:return{side:t.right_eye+t.right_cut>t.left_eye+t.left_cut?-1:1,lift:.08,lateral:.035,prop:`enswell`}}}function DJ(e){return e?.split(`:`)[1]===`right`?1:-1}function OJ(e){return e.result===null?e.tick-1:e.tick}var kJ=50,AJ=40,jJ=40,MJ=50,NJ=[`jab`,`straight`,`hook`,`uppercut`];function PJ(e,t,n,r){if(!eq(e,t,n))return null;let i=r?.action_key?.split(`:`),a=e.detail.split(`:`).find(e=>NJ.includes(e))??i?.[0],o=i?.[1]===`right`?`left`:`right`,s=e.amount;return e.detail.endsWith(`:head`)?n?.finish_method===`flash_ko`||e.kind===`counter_hit`&&s>=70?`head_burst`:a===`uppercut`&&s>=AJ||a===`straight`&&s>=kJ?`decapitation`:(a===`hook`||a===`jab`)&&s>=jJ?`eye_${o}`:`jaw_dislocation`:a===`hook`?s>=MJ?`dismember_${o}`:`shoulder_${o}`:`ribs_${o}`}function FJ(){let e=document.createElement(`canvas`);e.width=128,e.height=128;let t=e.getContext(`2d`);if(t!==null){let e=t.createRadialGradient(64,64,8,64,64,62);e.addColorStop(0,`rgba(0,0,0,0.68)`),e.addColorStop(.6,`rgba(0,0,0,0.34)`),e.addColorStop(1,`rgba(0,0,0,0)`),t.fillStyle=e,t.fillRect(0,0,128,128)}return new Wl(e)}var IJ=.42,LJ=.16;function RJ(e){return .9*L.clamp(1-e/LJ,0,1)}var zJ=new z(0,.12,.02),BJ=new z(0,1,0),VJ=new WeakMap;function HJ(e){let t=VJ.get(e);return t===void 0&&(t=J_(e,sY),VJ.set(e,t)),t}function UJ(e){return e.y>ng-1.4}var WJ=new WeakMap;function GJ(e){let t=WJ.get(e);return t===void 0&&(t=J_(e,UJ),WJ.set(e,t)),t}function KJ(e,t,n){let r=e.bone(`head`);if(r===null)return null;e.root.updateMatrixWorld(!0);let i=e.headMesh,a=GJ(i.geometry);if(a.length===0)return null;let o=t.length===a.length*3?t:new Float32Array(a.length*3);n.position.set(0,0,0);for(let[t,r]of a.entries())tY(e,r,n.scratch),n.scratch.toArray(o,t*3),n.position.add(n.scratch);return n.position.multiplyScalar(1/a.length),r.getWorldQuaternion(n.quaternion),n.across.set(1,0,0).applyQuaternion(n.quaternion),n.scratch.set(0,1,0).applyQuaternion(n.quaternion),n.quaternion.setFromUnitVectors(BJ,n.scratch),o}function qJ(e,t,n,r){let i=e?.currentRoot;return r.set(i?.x??n.x(t.x),0,i?.z??n.z(t.y))}function JJ(e,t,n,r,i){let a=Math.hypot(e-n,t-r);return a>=i?{x:e,z:t}:a<1e-6?{x:n,z:r-i}:{x:n+(e-n)/a*i,z:r+(t-r)/a*i}}var YJ=[0,1.05,-1.05,2.1,-2.1,Math.PI];function XJ(e,t,n,r,i,a,o=[]){let s=n===null?0:Math.hypot(n.x,n.z),c=n!==null&&s>=.35?[Math.atan2(n.x,n.z)]:[];for(let e of YJ)c.push(a+e);for(let n of c){let a=L.clamp(e+Math.sin(n)*r,-i,i),s=L.clamp(t+Math.cos(n)*r,-i,i),c=Math.hypot(a-e,s-t);if(!(c{let r=L.clamp(((n.x-e)*(a-e)+(n.z-t)*(s-t))/(c*c),.25,1);return Math.hypot(e+(a-e)*r-n.x,t+(s-t)*r-n.z)1e-9&&(s=Math.min(s,(Math.sign(n)*i-e)/n)),Math.abs(r)>1e-9&&(s=Math.min(s,(Math.sign(r)*a-t)/r));for(let i of[-1,1])for(let a of[-1,1]){let c=i*n+a*r;c>1e-9&&(s=Math.min(s,(o-i*e-a*t)/c))}return Math.max(0,s)}function QJ(e,t,n,r,i,a,o,s=1/0){let c=Math.hypot(n-e,r-t);if(c>=i)return null;let l=c<1e-6?1:(n-e)/c,u=c<1e-6?0:(r-t)/c,d=i-c,f=ZJ(e,t,-l,-u,a,o,s),p=ZJ(n,r,l,u,a,o,s),m=Math.min(d/2,f),h=Math.min(d-m,p);m=Math.min(d-h,f);let g=L.clamp;return{ax:g(e-l*m,-a,a),ay:g(t-u*m,-o,o),bx:g(n+l*h,-a,a),by:g(r+u*h,-o,o)}}var $J=new WeakMap;function eY(e,t,n,r,i,a,o,s=null){let c=$J.get(e);if(c!==void 0&&c.width===t&&c.height===n)return c.top;let l=Ur(t,n,Br(e,r,i,r.map(e=>a.total(e.player_id)),s),!0).y;return $J.set(e,{width:t,height:n,top:l}),l}function tY(e,t,n){let r=e.headMesh;return Fy(n.fromBufferAttribute(r.geometry.getAttribute(`position`),t),e.look,n),r.applyBoneTransform(t,n).applyMatrix4(r.matrixWorld)}var nY=new Lo,rY=new Lo,iY=new Ho;function aY(e,t,n){let r=e.geometry;nY.fromBufferAttribute(r.getAttribute(`skinIndex`),t),rY.fromBufferAttribute(r.getAttribute(`skinWeight`),t),n.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);for(let t=0;t<4;t+=1){let r=rY.getComponent(t);if(r===0)continue;let i=nY.getComponent(t);iY.multiplyMatrices(e.skeleton.bones[i].matrixWorld,e.skeleton.boneInverses[i]);for(let e=0;e<16;e+=1)n.elements[e]+=iY.elements[e]*r}return n.premultiply(e.bindMatrixInverse).multiply(e.bindMatrix)}var oY=new z(-1,0,0);function sY(e){return e.y>eg-tg*(e.z- -4)-.3}var cY={tick_rate:30,ring_half_width:500,ring_half_height:500};function lY(e,t,n,r,i,a,o=!0){let s=e.geometry,c=s.getAttribute(`position`),l=s.getIndex(),u=[],d=l!==null&&r===void 0?[]:null;if(l===null||d===null)for(let e=0;e=i.start+o))return{action:i.punchClass,action_hand:i.hand,action_target:`head`,action_power:`normal`,action_id:`idle-${n}-${r}`,action_key:`${i.punchClass}:${i.hand}:head:normal`,action_start_tick:e-(t-i.start),action_startup_ticks:a.startup,action_active_ticks:a.active,action_recovery_ticks:a.recovery,action_contact_tick:e-(t-i.start)+a.startup}}return{}}var gY=1000003,_Y=1.6;function vY(e,t,n,r,i,a){let o=r<0?-1:1,s=o=>Math.hypot(L.clamp(e+n*o*i,-a,a)-e,L.clamp(t+r*o*i,-a,a)-t);return s(o)>=i*.8||s(o)>=s(-o)?o:-o}function yY(e,t,n){return t?e.kind===`knockdown`?1:Math.min(1,.35+e.amount/400):(n===`full`?1:n===`reduced`?.4:0)*(e.kind===`knockdown`?.85:e.amount>=50?Math.min(.75,(e.amount-30)/140):0)}function bY(e){if(e.kind!==`hit`&&e.kind!==`counter_hit`||e.amount<(e.detail.endsWith(`:body`)?70:50))return null;let t=Math.min(100,Math.max(0,e.blood));return{seconds:.6+t/50,rate:150+e.amount*1.5+t*2}}function xY(e,t){return t===`full`?e>100?Math.min(.65,e/1800):0:e>350?Math.min(.3,e/4600):0}function SY(e){return!e.is_downed&&e.stunned_ticks===0&&e.clinch_ticks===0&&e.clinch_startup_ticks===0&&e.taunt_ticks===0&&!e.is_foul_recovery_target}function CY(e,t){if(e===null)return null;let n=t.fighters.find(t=>t.player_id===e.target_id),r=t.fighters.find(t=>t.player_id===e.actor_id);return PJ(e,n===void 0?void 0:{...n,is_downed:!0},{finish_method:`ko`,winner_id:e.actor_id},r)}var wY=.2,TY=1.1,EY=1.6,DY=2.4,OY=2,kY=new z(0,-.1,.08),AY=new z(0,-.07,.1),jY=new z(0,-.35,1),MY=3,NY=320,PY=8,FY=1.6,IY=.08,LY=.12,RY=e=>e===`shoulder_left`||e===`shoulder_right`||e===`ribs_left`||e===`ribs_right`?e:`mouth`;function zY(e,t,n=TY){return Math.min(n,.06+.08*Math.sqrt(Math.max(0,e))*Math.min(1.6,Math.max(0,t)))}function BY(e,t,n){return e.is_downed||t?.isDown===!0||n!==void 0&&e.player_id===n}var VY=6,HY=11,UY=.13;function WY(e,t){let n=t===`left`?`leftRibs`:`rightRibs`;e.impact(n,[t===`left`?-6:VY,-6*.15,-1.5],HY),e.set(n,{bruise:1.2,swell:0,blood:1.4})}function GY(e,t){e.set(`mouth`,{cut:1,blood:1.4}),e.set(`chin`,{bruise:1.2}),t.set(`neckSmear`,{blood:1.4})}function KY(e,t){e.set(t===`left`?`leftShoulderSmear`:`rightShoulderSmear`,{blood:1.4}),e.set(t===`left`?`leftPec`:`rightPec`,{bruise:1.1})}var qY=new WeakMap;function JY(e,t){let n=qY.get(e);if(n===void 0){let t=e.getAttribute(`position`),r=new z,i=new z,a=Fg.map(e=>{let n=0,a=1/0;i.set(e[0],e[1],e[2]);for(let e=0;ethis.onAnnouncement?.(e),cue:e=>this.onCrowdCue?.(e)});touchControls=VI();resultAnnounced=!1;captionText=``;rocked=new OK;tmpA=new z;tmpB=new z;contactPoint=new z;cornerPanelTop=null;mouthPoint=new z;tmpHead=new z;tmpHeadQuaternion=new vo;tmpStump=new z;tmpStumpOffset=new z;tmpStumpQuaternion=new vo;tmpStumpAcross=new z;tmpPart=new z;tmpPartQuaternion=new vo;woundPoint=new z;woundAxis=new z;constructor(e,t=cY,n,r={}){this.canvas=e,this.simulation=t,this.settings=n,this.manualClock=r.manualClock===!0,this.localInput=r.localInput??null,this.powerHeld=r.powerHeld??null,this.inputSequenceOf=r.inputSequenceOf??null,this.buffer=new FL(8,t.tick_rate),this.mapping=v_(t),this.renderer=new qh({canvas:e,antialias:!0,powerPreference:`high-performance`,preserveDrawingBuffer:r.manualClock===!0}),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=1,this.renderer.toneMapping=4,this.renderer.toneMappingExposure=1,this.renderer.setPixelRatio(this.basePixelRatio),this.scene.background=new B(`#04060b`),this.scene.fog=new ws(`#04060b`,.042),this.camera=new Wd(36,1,.1,80),this.camera.position.set(0,2.05,5.9),this.camera.lookAt(0,1.05,0),this.setupLights(),this.ring=IC(),this.scene.add(this.ring.group),this.arena=uB(),this.scene.add(this.arena.group),this.effects=new _K(this.scene,VI()?1024:2048,VI()?WU:UU),this.effects.useUploader(this.renderer),this.effects.setCamera(this.camera),this.carnage=new aH(this.effects,dY),this.blobTexture=FJ();let i=new Au(1,1);for(let e=0;e<3;e+=1){let t=new V(i,new Pc({map:this.blobTexture,transparent:!0,depthWrite:!1}));t.rotation.x=-Math.PI/2,t.position.y=.006+e*4e-4,t.renderOrder=1,this.blobShadows.push(t),this.scene.add(t)}for(let e=0;e<4;e+=1){let t=new V(i,new Pc({map:this.blobTexture,transparent:!0,depthWrite:!1}));t.rotation.x=-Math.PI/2,t.position.y=.0075+e*4e-4,t.scale.set(IJ,IJ,1),t.renderOrder=1,t.visible=!1,this.footShadows.push(t),this.scene.add(t)}this.composer=new rz(this.renderer),this.composer.addPass(new iz(this.scene,this.camera));let a=new oz(new R(1280,720),.22,.35,1.5);this.bloomPass=a,this.composer.addPass(a),this.finishPass=new ez(Gq),this.composer.addPass(this.finishPass),this.composer.addPass(new cz),this.hudCanvas=document.createElement(`canvas`),this.hudCanvas.className=`fight-hud`,this.hudCanvas.style.cssText=`position:absolute;inset:0;width:100%;height:100%;pointer-events:none`,e.insertAdjacentElement(`afterend`,this.hudCanvas),this.bloodLevel=n().blood,this.effects.setBloodLevel(this.bloodLevel),this.ensureGraphs(),this.manualClock||(this.raf=requestAnimationFrame(e=>this.draw(e)))}ensureGraphs(){this.glbLoading||this.graphs!==null||(this.glbLoading=!0,this.graphsReady=YC().then(async e=>{if(this.destroyed)return;let t=new cw(e,{skin:11563071,gear:1920728}),n=new cw(e,{skin:7225640,gear:12131356});this.graphs=[new Bw(t,this.mapping),new Bw(n,this.mapping)];let r=[this.carnage.attach(0,this.graphs[0]),this.carnage.attach(1,this.graphs[1])];this.lookIds.fill(null),this.syncInjuryPresentation(0),this.syncInjuryPresentation(1);let i=new cw(e,{skin:13081462,gear:3889080,look:Cy.referee,outfit:Gy,wounds:!0});this.referee=new Bw(i,this.mapping,{referee:!0,knockout:!0});let a=new cw(e,{skin:9067067,gear:1778224,look:Cy.blueCorner,outfit:Ky}),o=new cw(e,{skin:14264188,gear:1778224,look:Cy.redCorner,outfit:qy});this.cornermen=[new Bw(a,this.mapping,{referee:!0}),new Bw(o,this.mapping,{referee:!0})];let s=new cw(e,{skin:12160102,gear:1778224,look:Cy.blueCutman,outfit:Jy}),c=new cw(e,{skin:5913126,gear:1778224,look:Cy.redCutman,outfit:Jy});this.cutmen=[new Bw(s,this.mapping,{referee:!0}),new Bw(c,this.mapping,{referee:!0})],s.root.visible=!1,c.root.visible=!1,this.trails=[1920728,12131356].flatMap(e=>[0,1].map(()=>new XK(new B(e).lerp(new B(16777215),.55))));let l=HK();this.glowMap=l,this.glows=[0,1,2,3].map(()=>new WK(l)),this.impactFlashes=[0,1].map(()=>new GK(l));let u=new gs;u.add(t.root,n.root,i.root,a.root,o.root,s.root,c.root,...this.trails.map(e=>e.mesh),...this.effects.compileStandIns(),...r.flatMap(e=>e.compileStandIns()),this.glows[0].standIn(),...this.impactFlashes[0].standIns()),u.add(this.carnage.xray.standIn());let d=t.headInjury.open;t.headInjury.setOpen(!0);try{await nq(this.renderer,this.composer,u,this.camera,this.scene)}catch{}if(!this.destroyed){this.scene.add(t.root,n.root,i.root,a.root,o.root,s.root,c.root);for(let e of this.trails)this.scene.add(e.mesh);for(let e of this.glows)this.scene.add(e.mesh);for(let e of this.impactFlashes)this.scene.add(e.group);this.compileShadowsOf(u),t.headInjury.setOpen(d)}}).catch(e=>{this.glbLoading=!1,console.error(`boxer_glb_load_failed`,e)}))}compileShadowsOf(e){let t=this.keyLight;if(t!==null&&e.children.length!==0){for(let t of e.children)t.frustumCulled=!1,t.onBeforeShadow=(e,t,n,r,i,a)=>{a.needsUpdate=!0};this.scene.add(e),t.shadow.needsUpdate=!0,this.renderer.setRenderTarget(this.composer.readBuffer);try{this.renderer.render(this.scene,this.camera)}catch{}finally{this.renderer.setRenderTarget(null),this.scene.remove(e)}}}get ready(){return this.graphsReady}get labRigs(){let e=this.graphs;return e===null?[]:[e[0].boxer.root,e[1].boxer.root]}get labScene(){return this.scene}get labEffects(){return this.effects}labSetCameraOverride(e,t){this.cameraOverride={position:new z(...e),lookAt:new z(...t)}}labFrame(e,t=!0){this.draw(e*1e3,!0,t)}setCornerPanelTop(e){this.cornerPanelTop=e}viewForward(){return this.ownViewActive?(this.ownForward.x=this.fighterCam.forwardX,this.ownForward.z=this.fighterCam.forwardZ,this.ownForward):null}setPlayers(e,t,n=Object.keys(e)){this.players=e,this.viewerId=t,this.playerOrder=n}updateIdleFighters(e,t,n){let r=this.graphs;if(r===null)return;let i=this.playerOrder.filter(e=>this.players[e]!==void 0).length<2;for(let[a,o]of r.entries()){let r=this.playerOrder[a]??`seat-${a}`,s=!i||r===this.viewerId||this.viewerId===null&&a===0;if(o.boxer.root.visible=s,!s)continue;this.wearLook(a===0?0:1,r);let c=a===0?-1:1,l=Math.floor(t*this.simulation.tick_rate),u={...fY(r),x:i?0:c*180,y:i?-70:0,facing:i?1:-c,facing_x:i?0:-c*1e3,facing_y:i?-1e3:0,...i?hY(l):{}},d={...fY(this.playerOrder[1-a]??`opponent`),x:i?0:-c*180,y:i?-150:0};o.setResting(!1),o.update(u,d,e,t,this.settings().reducedMotion,this.bloodLevel,i?l:n)}}setFinal(e){if(e!==null&&e.match_id===this.final?.match_id)return;this.final=e,this.stoppageWinner=-1,this.stoppageRaiseAt=1/0,this.stoppageSpot=null,this.raiseFramed=!1,this.ceremony=this.ceremonyFor(e);let t=e?.method===`draw`&&this.deaths.every(e=>e!==null);if(this.finalRevealAt=this.frameSeconds+(this.ceremony===null?t?pr:hr(e):eJ),this.ovationUntil=e===null?0:this.frameSeconds+nJ,e!==null&&this.commentary.finish(e,this.players,this.ceremony!==null,this.frameSeconds),this.ceremony===null&&this.endCeremony(),this.pendingFinish=null,e===null||!fr.has(e.method))return;let n=this.lastKnockdown===null?null:MK(this.history,this.lastKnockdown.hit??this.lastKnockdown.knockdown,this.simulation.tick_rate),r=this.finishingInjury(e);if(n!==null&&this.graphs!==null&&!this.settings().reducedMotion){r!==null&&(this.replayInjuries[r.index]={injury:r.injury,event:r.event}),this.startReplay(n);return}if(r!==null){let e=this.pendingContacts.find(e=>e.event.event_id===r.event.event_id);e===void 0?this.applyArcadeInjury(r.index,r.injury,r.event):e.injury??=r.injury}let i=this.buffer.latest()?.result?.tick;i===void 0?this.presentFinish(e):this.pendingFinish={final:e,tick:i,latestAt:this.frameSeconds+Dq}}presentFinishWhenShown(e){let t=this.pendingFinish;t===null||ee.player_id===t.hit.target_id)??-1;return r<0||this.arcadeInjuries[r]!==null?null:{index:r,injury:t.finisher,event:t.hit}}ceremonyFor(e){let t=this.buffer.latest()?.fighters;if(e===null||t===void 0||e.method!==`decision`&&e.method!==`draw`||t.some(e=>e.is_downed)||this.deaths.some(e=>e!==null))return null;let n=t.findIndex(t=>t.player_id===e.winner_id);return{winnerSeat:n===0||n===1?n:null,positions:null,refereeArrived:!1,arrivedAt:null,announced:!1}}endCeremony(){for(let e of this.graphs??[])e.awaitVerdict(null);this.referee?.raise(null,null)}ceremonyFighters(e,t,n,r,i=null){e.positions===null&&(e.positions=[{x:t[0].x+(i?.[0].x??0),y:t[0].y+(i?.[0].y??0)},{x:t[1].x+(i?.[1].x??0),y:t[1].y+(i?.[1].y??0)}],e.marks=e.positions[0].x<=e.positions[1].x?[0,1]:[1,0]);let a=e.marks??qq,o=e.refereeArrived;for(let r of[0,1]){let i=e.positions[r],s=a[r],c=tJ(i.x,i.y,Kq[s],Zq*n),l=Math.hypot(c.x-i.x,c.y-i.y),u=n>0?1/(n*this.simulation.tick_rate):0,d=!c.arrived&&l>1e-6;Object.assign(this.drawnFighters[r],t[r],{x:c.x,y:c.y,velocity_x:(c.x-i.x)*u,velocity_y:(c.y-i.y)*u,facing_x:d?Math.round((c.x-i.x)/l*1e3):0,facing_y:d?Math.round((c.y-i.y)/l*1e3):-1e3,facing:d&&c.x=$q){e.announced=!0,this.commentary.verdict(this.frameSeconds);for(let t of[0,1])this.graphs?.[t]?.announce(e.winnerSeat===null?`level`:e.winnerSeat===t?`winner`:`loser`);this.finalRevealAt=Math.min(this.finalRevealAt,this.frameSeconds+.35),this.arena.excite(1)}if(e.announced){let n=n=>{let r=a[0]===n?0:1,i=e.winnerSeat===null||e.winnerSeat===r,o=je(t[r].injuries,n===0?`left`:`right`)===`whole`,s=this.graphs?.[r]?.boxer.rig.bones[n===0?`gloveL`:`gloveR`];return i&&o&&s!==void 0?s.getWorldPosition(this.ceremonyWrists[n]):null};this.referee?.isDown!==!0&&this.referee?.raise(n(1),n(0))}return this.drawnFighters}ceremonyFrame(e){let t=this.ceremony,n=this.buffer.latest();if(t===null||t.arrivedAt===null||this.replay!==null||this.final===null||n===null)return null;let{width:r,height:i}=this.hudViewport,a=eY(this.final,r,i,n.fighters,this.players,this.roundStats,this.viewerId),o=kB(this.camera.aspect,this.camera.fov,(i-a)/Math.max(1,i)),s=this.settings().reducedMotion?0:Math.sin((e-t.arrivedAt)*.35)*.06*o.distance;return this.cornerPosition.set(s,o.height+.05*o.distance,o.distance),this.cornerLookAt.set(0,o.height,0),{position:this.cornerPosition,lookAt:this.cornerLookAt,framed:!0}}raiseFrame(e,t,n){let r=this.buffer.latest();if(this.stoppageWinner<0||this.final===null||this.replay!==null||this.ceremony!==null||r===null||e0?-1:1)*Sq,o=this.stoppageSpot?.z??0;this.raiseFramed||this.raiseCentre.set(i.x+a/2,0,i.z+o/2),this.raiseCentre.lerp(this.tmpCamera.set(i.x+a/2,0,i.z+o/2),1-Math.exp(-3*t)),this.raiseFramed=!0;let{width:s,height:c}=this.hudViewport,l=eY(this.final,s,c,r.fighters,this.players,this.roundStats,this.viewerId,this.deaths[0]??this.deaths[1]),u=kB(this.camera.aspect,this.baseFov,(c-l)/Math.max(1,c)),d=e-(this.stoppageRaiseAt-xq),f=n?0:Math.sin(d*.35)*.06*u.distance;return this.cornerPosition.set(L.clamp(this.raiseCentre.x,-1.4,1.4)+f,u.height+.05*u.distance,this.raiseCentre.z+u.distance),this.cornerLookAt.set(this.raiseCentre.x,u.height,this.raiseCentre.z),{position:this.cornerPosition,lookAt:this.cornerLookAt,framed:!0}}presentFinish(e){let t=this.buffer.latest()?.referee.alive===!1;t||this.referee?.waveOff(void 0,e.method===`death`);let n=this.buffer.latest()?.fighters,r=n?.findIndex(t=>t.player_id!==e.winner_id&&t.player_id!==null)??-1;if(r>=0&&this.headCacheValid[r]&&!this.settings().reducedMotion&&!this.carnage.gibbed(r)&&(this.finishCloseUpIndex=r,this.finishCloseUpUntil=this.frameSeconds+mq,this.finishCloseUpBearing=null,this.finishCloseUpAt=this.frameSeconds),e.winner_id===null)return;let i=n?.findIndex(t=>t.player_id===e.winner_id)??-1;if(i<0)return;this.graphs?.[i]?.celebrate(bq);let a=n?.[i]?.injuries??[];!t&&(bJ(a,`left`)||bJ(a,`right`))&&(this.stoppageWinner=i,this.stoppageRaiseAt=this.frameSeconds+xq)}cornerShotFrame(e,t,n){if(t===null||t.phase!==`rest`||n||this.graphs===null)return null;let r=t.fighters.findIndex(e=>e.player_id===this.viewerId),i=e-this.restStartedAt,a=xB(i,t.phase_ticks_remaining/this.simulation.tick_rate,+(r===1));return a===null||!this.graphs[a].stoolVisible||this.cutmen!==null&&this.cutmanProgress[a]e.player_id===this.viewerId)===1),n=this.mapping.x(l);return EB(t,n,-3.5,_q,this.cornerPosition).setY(vq),EB(t,n,0,0,this.cornerLookAt),this.cornerLookAt.lerp(EB(+(t===0),n,0,0,this.tmpCamera),yq).setY(.9),{position:this.cornerPosition,lookAt:this.cornerLookAt,framed:!0}}closeUpFrame(e){if(e>=this.finishCloseUpUntil||this.finishCloseUpIndex<0||!this.headCacheValid[this.finishCloseUpIndex])return null;let t=this.arcadeInjuries[this.finishCloseUpIndex],n=t===`decapitation`&&this.effects.severedHeadPosition(this.finishCloseUpIndex,this.closeUpTarget),r=!n&&this.effects.partPosition(oH(this.finishCloseUpIndex,`upper_body`),this.closeUpTarget),i=n||r?null:this.graphs?.[this.finishCloseUpIndex]?.fallBody??null;if(this.finishCloseUpBearing===null&&i!==null&&!i.body.asleep&&e-this.finishCloseUpAt.4?u:.9,a)}let d=this.finishCloseUpBearing+l;return this.closeUpPosition.set(L.clamp(s.x+Math.sin(d)*c,-2.2,kq),s.y+(n?.42:o?.5:.75),L.clamp(s.z+Math.cos(d)*c,-2.2,kq)),this.replayLookAt.copy(s),{position:this.closeUpPosition,lookAt:this.replayLookAt,tight:!0}}raiseSpot(e,t){let n=e.x>0?-1:1,r={x:n*Sq,z:0},i=-1/0;for(let[a,o]of Cq){let s=e.x+n*a*Sq,c=e.z+o*Sq,l=Math.min(Eq-Math.abs(s),Eq-Math.abs(c),Math.hypot(s-t.x,c-t.z)-Tq);for(let e of this.graphs??[]){let t=e.fallBody;if(t!==null)for(let e of[0,1,2,3,4])t.bodyPoint(e,this.bodyPoint),l=Math.min(l,Math.hypot(s-this.bodyPoint.x,c-this.bodyPoint.z)-Nq-.05)}for(let e of[0,1])this.effects.severedHeadPosition(e,this.closeUpTarget)&&(l=Math.min(l,Math.hypot(s-this.closeUpTarget.x,c-this.closeUpTarget.z)-Aq-.05));if(l>=0)return{x:s-e.x,z:c-e.z};l>i&&(i=l,r={x:s-e.x,z:c-e.z})}return r}nearerGlove(e,t){e.getWorldPosition(this.stoppageWrist),t.getWorldPosition(this.stoppageOtherWrist);let n=e=>Math.hypot(e.x-this.refereePosition.x,e.z-this.refereePosition.z);return n(this.stoppageOtherWrist)-.5*n.length()}startReplay(e){let t=new FL(e.snapshots.length+2,this.simulation.tick_rate);for(let n of e.snapshots)t.push(n);if(this.replay={plan:e,buffer:t,startedAt:this.frameSeconds,impactFired:!1,side:null},this.drawnOffsetsLive=!1,this.commentary.replay(this.frameSeconds,e.impact),this.replayFollow=0,this.replayFollowAt=0,e.impact.kind===`referee_down`){this.referee?.resetTransient(!1),this.referee?.primeReplayFall(),this.effects.stopGush(2);return}for(let e=this.pendingGore.length-1;e>=0;--e)this.pendingGore[e].event.kind!==`injury`&&this.pendingGore.splice(e,1);for(let e of[0,1]){this.effects.stopGush(e),this.deaths[e]!==null&&this.carnage.undoDeath(e);let t=this.arcadeInjuries[e],n=this.arcadeInjuryEvents[e];t!==null&&n!==null&&(this.replayInjuries[e]={injury:t,event:n},this.restoreInjury(e))}for(let t of this.pendingContacts.splice(0)){let n=t.recipientIndex;t.injury!==null&&(n===0||n===1)&&this.replayInjuries[n]===null&&this.arcadeInjuries[n]===null&&(this.replayInjuries[n]={injury:t.injury,event:t.event}),t.event.event_id!==e.impact.event_id&&(t.injury=null,t.contactTick=1/0,this.pendingContacts.push(t))}let n=e.snapshots[0]?.fighters.findIndex(t=>t.player_id===e.impact.target_id)??-1;n>=0&&e.impact.detail.endsWith(`:head`)&&this.effects.returnMouthpiece(n);let r=this.lastKnockdown?.knockdown.detail===jq;for(let[t,i]of(this.graphs??[]).entries()){let a=this.liveFallTicks[t]??null;i.resetTransient(!1),a!==null&&a>=e.impact.tick-1&&i.primeReplayFall(),t===n&&r&&i.fallToKnee(!0)}this.finalRevealAt=this.frameSeconds+e.durationSeconds+hr(this.final)}endReplay(){let e=this.replay?.plan.impact.kind===`referee_down`;if(this.replay=null,e){this.drawnOffsetsLive=!1;let e=this.buffer.latest();for(let[t,n]of(this.graphs??[]).entries())n.resetTransient(e?.fighters[t]?.is_downed===!0);return}this.drawnOffsetsLive=!1,this.reapplyReplayInjuries();let t=this.buffer.latest();for(let[e,n]of(this.graphs??[]).entries()){let r=t?.fighters[e],i=r!==void 0&&r.player_id===this.flashKnockout?.loserId;n.resetTransient(r?.is_downed===!0||i),i&&n.knockOut()}for(let e of[0,1])this.showDeath(e,0,!0);this.final!==null&&this.presentFinish(this.final)}fireRefereeEvents(e){for(let t=0;te){t+=1;continue}this.pendingRefereeEvents.splice(t,1);let r=this.buffer.latest();n.kind===`referee_down`?(r!==null&&this.fireRefereeFall(n,r),this.eventCallout={text:`THE REFEREE IS DEAD!`,until:this.frameSeconds+uJ},this.refereeReplayAt={at:this.frameSeconds+lJ,impact:n}):n.kind===`referee_hit`?r!==null&&this.punchReferee(n,r,!1):this.referee!==null&&(this.referee.boxer.rig.bones.head.getWorldPosition(this.refereeHead),this.effects.addEvent(n,this.refereeHead,this.settings().reducedMotion))}}punchReferee(e,t,n){let r=this.referee;if(r===null)return;let[i,a]=e.detail.split(`:`),o=t.fighters.findIndex(t=>t.player_id===e.actor_id),s=t.fighters[o],c=s?.action_key?.split(`:`)[1]??null;r.react(`hit`,a===`body`?`body`:`head`,e.direction,i,c,n?Math.max(e.amount,140):e.amount),r.boxer.rig.bones.head.getWorldPosition(this.refereeHead);let l=s===void 0?void 0:cq(s,{...s,x:t.referee.x,y:t.referee.y},this.mapping),u=this.settings().reducedMotion;this.effects.addEvent({...e,kind:n?`knockdown`:`hit`},this.refereeHead,u,l);let d=n||u?null:bY({...e,kind:`hit`}),f=d===null?null:this.refereeMouth();d!==null&&f!==null&&this.effects.gush(2,f.position,f.axis,d.seconds,d.rate,e.event_id);let p=this.refereePunchPower(e);o>=0&&this.graphs?.[o]?.landedHit(e.action_id,!1,p),this.onContact?.(e,p)}fireRefereeFall(e,t,n=!1){let r=this.referee;if(r===null)return;let i=n?this.refereeBlow(e):null;i===null?(r.boxer.rig.bones.head.getWorldPosition(this.refereeHead),this.effects.addEvent({...e,kind:`knockdown`,amount:160,blood:80},this.refereeHead,this.settings().reducedMotion)):this.punchReferee(i,t,!0);let a=this.settings().reducedMotion?null:this.refereeMouth();a!==null&&this.effects.gush(2,a.position,a.axis,MY,NY,e.event_id),r.knockOut(),this.onContact?.(e,!1)}refereePunchPower(e){for(let t=this.history.length-1;t>=0;--t){let n=this.history[t];if(n.tickt.player_id===e.actor_id);return r!==void 0&&r.action_id===e.action_id&&r.action_power===`power`}return!1}refereeBlow(e){if(e.action_id===null)return null;for(let t=this.history.length-1;t>=0;--t){let n=this.history[t],r=n.events.find(t=>t.kind===`referee_hit`&&t.action_id===e.action_id&&t.tick===e.tick);if(r!==void 0)return r;if(n.tick=0?e.fighters[a]:void 0,l=c?.action_key?.split(`:`)??[],u=l[0]??null,d=l[1]??null,f=l[3]===`power`;this.graphs?.[i]?.react(`hit`,r.detail.endsWith(`:body`)?`body`:`head`,r.direction,u,d,r.amount),n.knockdown.detail===`body`&&n.knockdown.tick>r.tick&&this.graphs?.[i]?.windedFor((n.knockdown.tick-r.tick)/this.simulation.tick_rate+.15,DJ(c?.action_key??null)),o.player_id===this.flashKnockout?.loserId&&this.graphs?.[i]?.knockOut(),a>=0&&this.graphs?.[a]?.landedHit(r.action_id,n.blocked,f),r.detail.endsWith(`:head`)&&!this.settings().reducedMotion&&this.knockOutMouthpiece(i,s??r.direction,r.event_id+gY,!0),f&&!n.blocked&&!this.settings().reducedMotion&&this.presentPowerHit(i,r),this.onContact?.(r,f),this.reapplyReplayInjuries(s),this.deaths[i]!=null&&(this.showDeath(i,s??r.direction,!0),this.announceDeath(i));for(let e of this.pendingGore.splice(0))this.presentGore(e.event);for(let t of this.pendingContacts)t.contactTick===1/0&&(t.contactTick=this.replay?.plan.impact.tick??e.tick)}replayFrame(e,t){let[n,r]=e.fighters,i=this.mapping.x(n.x),a=this.mapping.z(n.y),o=this.mapping.x(r.x),s=this.mapping.z(r.y),c=this.replay?.plan.impact.kind===`referee_down`,l=e.fighters.findIndex(e=>e.player_id===this.replay?.plan.impact.target_id),u=this.replay?.impactFired===!0&&l>=0&&this.headCacheValid[l]===!0;if(c&&this.referee!==null)return this.refereeReplayFrame(e,t);let d=1-Math.exp(-3*Math.max(0,t-this.replayFollowAt));this.replayFollowAt=t,this.replayFollow+=(+!!u-this.replayFollow)*d;let f=l<0?0:Math.max(this.portraitPull>1.3?.7:0,this.replayFollow*.8),p=u?this.headCache[l].x:l===1?o:i,m=u?this.headCache[l].z:l===1?s:a,h=(i+o)/2+(p-(i+o)/2)*f,g=(a+s)/2+(m-(a+s)/2)*f,_=-(s-a),v=o-i,y=Math.hypot(_,v)||1;_/=y,v/=y;let b=2.5,x=this.replay;x!==null&&x.side===null&&(x.side=vY(h,g,_,v,b,kq));let S=x?.side??(v<0?-1:1);_*=S,v*=S;let C=.35*Math.sin(t*.7),w=_*Math.cos(C)-v*Math.sin(C),T=_*Math.sin(C)+v*Math.cos(C);this.replayCameraPosition.set(L.clamp(h+w*b,-2.2,kq),1.38-Math.min(.25,t*.05),L.clamp(g+T*b,-2.2,kq));let E=Math.hypot(this.replayCameraPosition.x-h,this.replayCameraPosition.z-g),D=Math.hypot(h,g);if(E<_Y&&D>.01){let e=_Y-E;this.replayCameraPosition.x=L.clamp(this.replayCameraPosition.x-h/D*e,-2.2,kq),this.replayCameraPosition.z=L.clamp(this.replayCameraPosition.z-g/D*e,-2.2,kq)}let O=u?L.clamp(this.headCache[l].y,.45,1.28):1.28;this.replayLookAt.set(h,1.28+(O-1.28)*this.replayFollow,g);let k=this.settings().reducedMotion?0:this.powerShake;if(k>5e-4){let e=t*61;this.replayCameraPosition.x=L.clamp(this.replayCameraPosition.x+Math.sin(e*1.31)*k,-2.2,kq),this.replayCameraPosition.y+=Math.cos(e*1.97)*k*.6,this.replayLookAt.x+=Math.sin(e*1.53)*k*.5,this.replayLookAt.y+=Math.cos(e*2.11)*k*.35}return{position:this.replayCameraPosition,lookAt:this.replayLookAt,tight:!0}}setInputLatency(e){this.inputLatencyMs=e,this.lagWarned=_r(e,this.lagWarned)}resyncClock(){this.buffer.resync()}setReconnect(e){this.reconnectMs=e}setBloodLevel(e){e!==`full`&&this.bloodLevel===`full`&&this.restoreAllInjuries(),this.bloodLevel=e,e===`off`&&this.downedPoolAccumulators.fill(0),this.effects.setBloodLevel(e)}setReducedMotion(e){e&&(this.restoreAllInjuries(),this.effects.clearDynamic())}syncInjuryPresentation(e){let t=this.arcadeInjuries[e],n=this.graphs;if(n!==null){let r=n[e];t===`head_burst`?r.boxer.setHeadBurst(!0):r.boxer.setDecapitated(t===`decapitation`),r.boxer.headInjury.setEyeOut(t===`eye_left`||t===`eye_right`?`both`:null),r.boxer.setHandDismembered(`left`,t===`dismember_left`),r.boxer.setHandDismembered(`right`,t===`dismember_right`);let i=t===`jaw_dislocation`?`jaw`:t===`shoulder_left`||t===`shoulder_right`?t:null;r.setArcadeDislocation(i)}}applyArcadeInjury(e,t,n,r){t===`dismember_left`&&!this.carnage.hasGlove(e,`left`)?t=`ribs_left`:t===`dismember_right`&&!this.carnage.hasGlove(e,`right`)?t=`ribs_right`:(t===`eye_left`&&this.carnage.eyeBurst(e,`left`)||t===`eye_right`&&this.carnage.eyeBurst(e,`right`))&&(t=`jaw_dislocation`);let i=!1;if(t===`decapitation`){let t=this.headWorldPose(e);if(t!==null){let a=this.graphs?.[e],o=a===void 0?void 0:uY(a.boxer,t.position,t.quaternion);this.effects.decapitate(e,t.position,t.quaternion,r??n.direction,n.event_id,this.skinColor(e),o);let s=this.stumpWorldPose(e);s!==null&&this.effects.anchorStump(e,s.position,s.quaternion,s.rim,s.across),i=!0}}else if(t===`head_burst`){let t=this.headWorldPose(e);if(t!==null){this.effects.burstHead(e,t.position,r??n.direction,n.event_id);let a=this.burstStumpPose(e);a!==null&&this.effects.anchorStump(e,a.position,a.quaternion,a.rim,a.across),i=!0}}else if(t===`eye_left`||t===`eye_right`){let a=this.graphs?.[e]?.boxer,o=t===`eye_left`?`left`:`right`;if(a!==void 0&&YY(a,o,this.tmpPart,this.tmpStumpOffset,this.tmpPartQuaternion)){let t=r??n.direction;this.effects.gougeEye(e,this.tmpPart,this.tmpStumpOffset,t,n.event_id,o);let s=o===`left`?`right`:`left`;!this.effects.eyeOut(e,s)&&!this.carnage.eyeBurst(e,s)&&YY(a,s,this.tmpPart,this.tmpStumpOffset,this.tmpPartQuaternion)&&this.effects.spawnDebris(`eye`,this.tmpPart,t,1,n.event_id,FY,e),i=!0}}else if(t===`dismember_left`||t===`dismember_right`){let a=t===`dismember_left`?`left`:`right`,o=this.handWorldPose(e,a);if(o!==null){let t=this.graphs?.[e],s=t===void 0?void 0:{...lY(t.boxer.gloveMesh(a),o.position,o.quaternion),gloveBlood:t.boxer.gloveBloodLevel};this.effects.dismemberHand(e,a,o.position,o.quaternion,r??n.direction,n.event_id,this.gearColor(e),s),this.effects.anchorHandStump(e,a,o.position,o.quaternion),i=!0}}else if(t===`jaw_dislocation`||t===`shoulder_left`||t===`shoulder_right`||t===`ribs_left`||t===`ribs_right`){let a=this.tornWound(e,RY(t));a!==null&&(this.effects.tearOpen(e,a.position,a.axis,r??n.direction,n.event_id,t===`jaw_dislocation`?PY:0),i=!0)}return i?(this.arcadeInjuries[e]=t,this.arcadeInjuryEvents[e]=n,this.observedInjuryDown[e]=!1,this.syncInjuryPresentation(e),this.onArcadeInjury?.(t,n),!0):!1}reapplyReplayInjuries(e){for(let t of[0,1]){let n=this.replayInjuries[t];if(n===null)continue;this.replayInjuries[t]=null;let r=this.settings();r.blood!==`full`||r.reducedMotion||this.applyArcadeInjury(t,n.injury,{...n.event,event_id:n.event.event_id+gY},e)}}restoreInjury(e){this.arcadeInjuries[e]!==null&&(this.arcadeInjuries[e]=null,this.arcadeInjuryEvents[e]=null,this.observedInjuryDown[e]=!1,this.syncInjuryPresentation(e),this.effects.restoreFighter(e))}restoreAllInjuries(){this.restoreInjury(0),this.restoreInjury(1),this.effects.clearArcadeGore()}headWorldPose(e){let t=this.graphs,n=t===null?null:t[e].boxer.bone(`head`);return n===null||t===null?null:(t[e].boxer.root.updateMatrixWorld(!0),n.getWorldPosition(this.tmpHead),n.getWorldQuaternion(this.tmpHeadQuaternion),this.tmpStumpOffset.copy(zJ).applyQuaternion(this.tmpHeadQuaternion),this.tmpHead.add(this.tmpStumpOffset),{position:this.tmpHead,quaternion:this.tmpHeadQuaternion})}handWorldPose(e,t){let n=this.graphs,r=n===null?null:n[e].boxer.bone(t===`left`?`gloveL`:`gloveR`);return r===null||n===null?null:(n[e].boxer.root.updateMatrixWorld(!0),r.getWorldPosition(this.tmpPart),r.getWorldQuaternion(this.tmpPartQuaternion),{position:this.tmpPart,quaternion:this.tmpPartQuaternion})}gearColor(e){return this.graphs?.[e]?.boxer.gearBaseColor.getHex()??1920728}skinColor(e){return this.graphs?.[e]?.boxer.skinBaseColor.getHex()??11563071}stumpWorldPose(e){let t=this.graphs?.[e]?.boxer,n=t?.bone(`head`);if(t===void 0||n==null)return null;t.root.updateMatrixWorld(!0);let r=t.headMesh,i=HJ(r.geometry);if(i.length===0)return null;this.stumpRim.length!==i.length*3&&(this.stumpRim=new Float32Array(i.length*3)),this.tmpStump.set(0,0,0);for(let[e,n]of i.entries())tY(t,n,this.tmpStumpOffset),this.tmpStumpOffset.toArray(this.stumpRim,e*3),this.tmpStump.add(this.tmpStumpOffset);return this.tmpStump.multiplyScalar(1/i.length),n.getWorldPosition(this.tmpStumpOffset).sub(this.tmpStump).normalize(),this.tmpStumpAcross.set(1,0,0).applyQuaternion(n.getWorldQuaternion(this.tmpStumpQuaternion)),this.tmpStumpQuaternion.setFromUnitVectors(BJ,this.tmpStumpOffset),{position:this.tmpStump,quaternion:this.tmpStumpQuaternion,rim:this.stumpRim,across:this.tmpStumpAcross}}burstStumpPose(e){let t=this.graphs?.[e]?.boxer;if(t===void 0)return null;let n=KJ(t,this.stumpRim,this.burstStump);return n===null?null:(this.stumpRim=n,{position:this.burstStump.position,quaternion:this.burstStump.quaternion,rim:n,across:this.burstStump.across})}predictAction(e){let t=this.buffer.latest();if(t===null||this.viewerId===null||this.replay!==null)return;let n=t.fighters.findIndex(e=>e.player_id===this.viewerId);if(n<0)return;let r=t.fighters[n];if(t.phase!==`fight`&&t.phase!==`finish`||!SY(r))return;let i=(this.inputLatencyMs??60)/1e3*this.simulation.tick_rate,a=i+this.buffer.interpolationDelayTicks,o=this.manualClock?this.lastManualTime:performance.now(),s=this.graphs?.[n];if(Mz(e.kind)){let n=s?.ownPunchActive===!0;if(e.id===void 0||r.stamina0||!n&&hz(r,t.tick)>0)return;let i=n?s.ownTicksToRecovery:0;n&&s.cutOwnRecovery(),this.evasion.press(e.kind,e.id,o,a,this.simulation.tick_rate,y+de(r.style).evasionTicks,o+i*1e3/this.simulation.tick_rate);return}if(e.kind!==`punch`)return;this.evasion.drop(o)&&s?.keepOwnRecovery();let c=Ne(r.injuries,e.hand);c!==null&&s?.predict(c===e.hand?e:{...e,hand:c},performance.now()/1e3,this.simulation.tick_rate,a,mz(r,e,t.tick+1),i)}acknowledgeActions(e,t){for(let[n,r]of e.fighters.entries()){let i=r.player_id===this.viewerId,a=e.phase===`fight`||e.phase===`finish`;i&&this.evasion.acknowledge(r,a,this.inputSequenceOf)&&this.graphs?.[n]?.keepOwnRecovery();let o=t.filter(t=>sq(t,e).puncherIndex===n);this.graphs?.[n]?.acknowledge(r,a,o,i?this.inputSequenceOf:null)}}push(e){if(!this.buffer.push(e,this.manualClock?this.lastManualTime:performance.now()))return;let t=this.dedupe.accept(e.events);this.acknowledgeActions(e,t),this.history.push(e),this.history.length>dq&&this.history.shift();for(let n of t){if(this.roundStats.record(n,t),n.kind===`knockdown`){let r=t.find(e=>lq(e)&&e.target_id===n.target_id&&e.tick===n.tick)??(n.detail===`body`?this.recordedHit(n):null),i=r!==null&&lr(r,e.events);this.lastKnockdown={knockdown:n,hit:r,blocked:i,finisher:i?null:CY(r,e)};let a=e.fighters.findIndex(e=>e.player_id===n.target_id);this.graphs?.[a]?.fallToKnee(n.detail===jq),n.detail===Mq&&(this.lastKnockdown=null)}if(n.kind===`result`&&n.detail===`flash_ko`){let e=t.findLast(e=>(e.kind===`hit`||e.kind===`counter_hit`)&&e.actor_id===n.actor_id)??null;e!==null&&e.target_id!==null&&(this.flashKnockout={hitEventId:e.event_id,loserId:e.target_id},this.lastKnockdown={knockdown:{...e,kind:`knockdown`},hit:e,blocked:!1,finisher:null})}n.kind===`referee_break`&&this.referee?.breakClinch(),(fJ.has(n.kind)||n.kind===`bleed`&&n.actor_id===`referee`)&&this.pendingRefereeEvents.push(n),n.kind===`box`&&(this.eventCallout={text:`BOX!`,until:this.frameSeconds+cJ}),n.kind===`body_collapse`&&n.target_id===this.viewerId&&(this.ownCollapseUntil=n.tick+n.amount),n.kind===`finish_him`&&(this.finishTargetId=n.target_id),(n.kind===`fatality`||n.kind===`death`)&&this.noteDeath(n,t,e),this.movement.observe(n,this.viewerId)}this.commentary.observe(e,t,this.players,this.simulation.tick_rate,this.frameSeconds);let n=e.fighters.findIndex(e=>e.player_id===this.viewerId),r=e.result===null&&!t.some(e=>e.kind===`knockdown`);for(let{event:i,presentationEvent:a,presentImpact:o,reactAmount:s}of TJ(t,e)){let t=e.fighters.findIndex(e=>e.player_id===i.target_id),c=e.fighters.findIndex(e=>e.player_id===i.actor_id),{recipientIndex:l,puncherIndex:u}=sq(i,e),d=e.fighters[l]??e.fighters[t]??e.fighters[c]??e.fighters[0];if(qJ(this.graphs?.[e.fighters.indexOf(d)],d,this.mapping,this.contactPoint),aJ.has(i.kind)){let t=u>=0?e.fighters[u]:null;this.pendingContacts.push({event:i,presentationEvent:a,presentImpact:o,reactAmount:s,contactTick:r&&u===n&&sJ.has(i.kind)&&this.graphs?.[u]?.pressLanded(i.action_id)===!0?-1/0:t?.action_contact_tick??i.tick,recipientIndex:l,puncherIndex:u,injury:PJ(i,e.fighters[l],e.result,t??void 0),power:t!==null&&t.action_id===i.action_id&&t.action_power===`power`})}else i.kind===`bleed`&&i.actor_id!==`referee`&&this.effects.addEvent(i,this.contactPoint,this.settings().reducedMotion)}for(let n of t){if(!gJ.has(n.kind))continue;let t=n.action_id===null?void 0:this.pendingContacts.find(e=>e.event.tick===n.tick&&e.event.action_id===n.action_id&&(lq(e.event)||uq(e.event)));t!==void 0&&(t.injury??=xJ(n)),n.kind!==`fatality`&&(this.pendingGore.push({event:n,at:t?.contactTick??n.tick}),n.kind===`injury`&&he(n.detail)&&this.carnage.expect(e.fighters.findIndex(e=>e.player_id===n.target_id),n.detail))}}fireContacts(e){for(let t=0;te){t+=1;continue}this.pendingContacts.splice(t,1);let{event:r,presentationEvent:i,reactAmount:a,recipientIndex:o,puncherIndex:s,injury:c}=n,l=n.presentImpact&&!SJ(i),u=this.buffer.latest()?.fighters[o],d=cq(this.buffer.latest()?.fighters[s],u,this.mapping);this.presentFightEvent(r,o,s),l&&u!==void 0&&(this.contactOn(o,u,i.detail.endsWith(`:body`),d,i.direction),this.effects.addEvent(i,this.contactPoint,this.settings().reducedMotion,d));let f=this.settings();if(n.power&&l&&lq(r)&&u!==void 0&&!f.reducedMotion&&this.presentPowerHit(o,i),(n.presentImpact||oJ.has(r.kind))&&this.arena.excite(iJ[r.kind]??0),l&&o>=0&&[`hit`,`counter_hit`,`knockdown`].includes(r.kind)){let e=this.viewerId!==null&&this.buffer.latest()?.fighters[o]?.player_id===this.viewerId;this.viewerHitFlash=Math.max(this.viewerHitFlash,yY(r,e,f.blood))}c!==null&&o>=0&&this.arcadeInjuries[o]===null&&f.blood===`full`&&!f.reducedMotion&&this.applyArcadeInjury(o,c,r,d);let p=this.graphs;l&&o>=0&&!f.reducedMotion&&xH(r.kind,r.amount,i.detail.endsWith(`:head`))&&this.knockOutMouthpiece(o,d??i.direction,r.event_id,!1);let m=l&&!f.reducedMotion?bY(r):null;m!==null&&o>=0&&this.gushFromMouth(o,r.event_id,m.seconds,m.rate),n.presentImpact&&o>=0&&r.kind===`knockdown`&&!f.reducedMotion&&this.gushFromMouth(o,r.event_id,MY,NY);let h=l&&o>=0?F_(r.kind,r.amount,i.detail.endsWith(`:head`)):0;if(h>0&&!f.reducedMotion&&f.blood!==`off`){let e=this.headWorldPose(o);e!==null&&(this.mouthPoint.set(0,-.07,.1).applyQuaternion(e.quaternion).add(e.position),this.effects.spawnTeeth(this.mouthPoint,d??i.direction,h,r.event_id))}if(l&&o>=0&&a!==null&&[`hit`,`counter_hit`,`block`,`perfect_block`,`knockdown`].includes(r.kind)){let e=r.kind===`block`||r.kind===`perfect_block`,t=i.detail.endsWith(`:body`)?`body`:`head`;if(p!==null){let n=(s>=0?this.buffer.latest()?.fighters[s]:void 0)?.action_key?.split(`:`)??[],c=n[0]??i.detail.split(`:`)[0]??null,l=n[1]??null;p[o].react(e?`block`:`hit`,t,i.direction,c,l,a),lq(r)&&t===`head`&&l!==null&&this.carnage.punched(o,l===`left`?`right`:`left`,r.event_id),lq(r)&&l!==null&&this.carnage.land(o,s,l,t,r.amount,r.blood,this.contactPoint,r.event_id,d??i.direction),this.flashKnockout?.hitEventId===r.event_id&&p[o].knockOut()}}l&&s>=0&&[`hit`,`counter_hit`,`block`,`perfect_block`,`guard_break`].includes(r.kind)&&p?.[s]?.landedHit(r.action_id,r.kind===`block`||r.kind===`perfect_block`,n.power),(n.presentImpact||!lq(r))&&this.onContact?.(r,n.power===!0)}this.replay===null&&this.fireRefereeEvents(e);let t=this.refereeReplayAt;if(t!==null&&this.replay===null&&this.frameSeconds>=t.at){this.refereeReplayAt=null;let e=MK(this.history,t.impact,this.simulation.tick_rate,jK.speed,jK.before,jK.after),n=this.buffer.latest(),r=e!==null&&n!==null&&n.phase===`referee_down`&&n.phase_ticks_remaining/this.simulation.tick_rate>=e.durationSeconds-.5;e!==null&&r&&!this.settings().reducedMotion&&this.startReplay(e)}}fireGore(e){for(let t=0;te?t+=1:(this.pendingGore.splice(t,1),this.presentGore(n.event))}}presentGore(e){let t=this.buffer.latest()?.fighters,n=t?.findIndex(t=>t.player_id===(e.kind===`vomit`?e.actor_id:e.target_id))??-1;if(t===void 0||n<0)return;let r=cq(e.actor_id===e.target_id?void 0:t.find(t=>t.player_id===e.actor_id),t[n],this.mapping)??e.direction;if(e.kind===`vomit`)this.carnage.vomit(n,e.event_id),this.onGore?.({kind:`vomit`});else if(e.kind===`finish_him`)this.arena.excite(1),this.onGore?.({kind:`finish_him`});else if(e.kind===`death`)this.showDeath(n,r,!1),this.announceDeath(n);else if(e.kind===`injury`&&he(e.detail)){let i=e.detail;if(!this.carnage.inflict(n,i,e.event_id,r,e.tick))return;this.eventCallout={text:`${Ee(i)}!`,until:this.frameSeconds+_J},this.arena.excite(yJ);let a=this.viewerId!==null&&t[n].player_id===this.viewerId;this.settings().blood!==`off`&&(this.viewerHitFlash=Math.max(this.viewerHitFlash,a?1:.5)),this.settings().reducedMotion||(this.powerShake=Math.min(mJ,this.powerShake+pJ)),this.onGore?.({kind:`injury`,injury:i})}}showDeath(e,t,n){let r=this.deaths[e]??null;if(r===null)return;let i=this.fatal?.index===e?this.fatal:null,a=(i?.hit.event_id??e)+(n?gY:0);i===null?r===`gutted`&&this.carnage.fatality(e,`gutting`,a,t):this.carnage.fatality(e,i.fatality,a,t),this.carnage.die(e,r)}announceDeath(e){let t=this.deaths[e]??null;if(t===null)return;let n=ke(t);this.eventCallout={text:`${Ae(t)}!`,until:this.frameSeconds+vJ},this.arena.excite(1),this.settings().reducedMotion||(this.powerShake=mJ),n!==null&&this.onGore?.({kind:`fatality`,fatality:n}),this.onGore?.({kind:`death`,cause:t})}noteDeath(e,t,n){let r=n.fighters.findIndex(t=>t.player_id===e.target_id);if(r!==0&&r!==1)return;let i=e.action_id===null?null:t.find(t=>lq(t)&&t.tick===e.tick&&t.action_id===e.action_id&&t.target_id===e.target_id)??null;if(e.kind===`fatality`){i!==null&&ge.includes(e.detail)&&(this.fatal={index:r,fatality:e.detail,hit:i});return}let a=Oe(e.detail);a!==null&&(this.deaths[r]=a,i===null?this.lastKnockdown=null:(this.flashKnockout={hitEventId:i.event_id,loserId:n.fighters[r].player_id},this.lastKnockdown={knockdown:{...i,kind:`knockdown`},hit:i,blocked:!1,finisher:null}))}presentFightEvent(e,t,n){let r=hJ[e.kind];r!==void 0&&(this.eventCallout={text:r.text,until:this.frameSeconds+r.seconds});let i=this.graphs;if(!(i===null||t<0)&&(e.kind===`parry`&&i[t]?.stagger(),e.kind===`body_collapse`)){let r=n>=0?this.buffer.latest()?.fighters[n]:void 0;i[t]?.windedFor(e.amount/this.simulation.tick_rate+.15,DJ(r?.action_key??null))}}recordedHit(e){if(e.action_id===null)return null;for(let t=this.history.length-1;t>=0;--t){let n=this.history[t].events.find(t=>(t.kind===`hit`||t.kind===`counter_hit`)&&t.action_id===e.action_id&&t.target_id===e.target_id);if(n!==void 0)return n}return null}enterRest(e){this.restStartedAt=e,this.effects.clearMouthpieces()}contactOn(e,t,n,r,i){let a=n?null:this.headWorldPose(e),o=n?this.graphs?.[e]?.boxer.rig.bones.upperChest:void 0,s=a?.position??o?.getWorldPosition(this.contactPoint)??null;if(s===null)return qJ(this.graphs?.[e],t,this.mapping,this.contactPoint);let c=r??{x:i<0?-1:1,z:0},l=n?LY:IY;return this.contactPoint.set(s.x-c.x*l,s.y,s.z-c.z*l)}gushFromMouth(e,t,n,r){let i=this.tornWound(e,`mouth`);i!==null&&this.effects.gush(e,i.position,i.axis,n,r,t)}anchorGush(e){if(!this.effects.gushing(e)||this.carnage.vomiting(e))return;let t=this.tornWound(e,RY(this.arcadeInjuries[e]??null));t!==null&&this.effects.anchorGush(e,t.position,t.axis)}tornWound(e,t){if(t===`mouth`){let t=this.headWorldPose(e);return t===null?null:{position:this.woundPoint.copy(AY).applyQuaternion(t.quaternion).add(t.position),axis:this.woundAxis.copy(jY).applyQuaternion(t.quaternion)}}let n=this.graphs?.[e]?.boxer;if(n===void 0)return null;n.root.updateMatrixWorld(!0);let r=n.rig.bones,i=t===`shoulder_left`||t===`ribs_left`,a=r.shoulderL.getWorldPosition(this.woundAxis).sub(r.shoulderR.getWorldPosition(this.tmpStumpOffset)).normalize().multiplyScalar(i?1:-1),o=r.upperChest.getWorldPosition(this.tmpStump),s=this.tmpStumpOffset.copy(o).sub(r.hips.getWorldPosition(this.tmpStumpAcross)).normalize();return t===`ribs_left`||t===`ribs_right`?{position:this.woundPoint.copy(o).addScaledVector(a,UY).addScaledVector(s,-.06),axis:a}:((i?r.shoulderL:r.shoulderR).getWorldPosition(this.woundPoint),{position:this.woundPoint,axis:a.addScaledVector(s,.5).normalize()})}refereeMouth(){let e=this.referee?.boxer.rig.bones.head;return e===void 0?null:(e.getWorldPosition(this.tmpHead),e.getWorldQuaternion(this.tmpHeadQuaternion),this.tmpHead.add(this.tmpStumpOffset.copy(zJ).applyQuaternion(this.tmpHeadQuaternion)),{position:this.woundPoint.copy(AY).applyQuaternion(this.tmpHeadQuaternion).add(this.tmpHead),axis:this.woundAxis.copy(jY).applyQuaternion(this.tmpHeadQuaternion)})}knockOutMouthpiece(e,t,n,r){let i=this.headWorldPose(e);i!==null&&(this.mouthPoint.set(0,-.075,.1).applyQuaternion(i.quaternion).add(i.position),this.effects.ejectMouthpiece(e,this.mouthPoint,i.quaternion,t,n,this.gearColor(e),r))}get resultVisible(){return this.final!==null&&this.frameSeconds>=this.finalRevealAt}get resolutionScale(){return this.scaler.scale}get diagnostics(){let e=this.renderer.getContext(),t=e.getExtension(`WEBGL_debug_renderer_info`),n=t===null?e.getParameter(e.RENDERER):e.getParameter(t.UNMASKED_RENDERER_WEBGL);return{frameMs:this.frameMsAverage,resolutionScale:this.scaler.scale,gpu:this.memoryInfo,graphics:String(n)}}get memoryInfo(){return{geometries:this.renderer.info.memory.geometries,textures:this.renderer.info.memory.textures,programs:this.renderer.info.programs?.length??0}}applyResolutionScale(){let e=this.basePixelRatio*this.scaler.scale;this.renderer.setPixelRatio(e),this.composer.setPixelRatio(e);let t=this.scaler.scale<=fq;this.bloomPass.enabled=!t,this.keyLight!==null&&oq(this.keyLight.shadow,t,this.scaler.scale<.8?1024:2048),this.arena.setLowTier(t),this.effects.setLowTier(t)}setupLights(){let e=new Md(`#33416c`,`#3b2c20`,.6);this.scene.add(e),this.lights.push(e);let t=new Kd(`#fff0da`,185,26,.56,.6,1.7);t.position.set(.9,7.2,4.4),t.target.position.set(0,.6,0),t.castShadow=!0,t.shadow.mapSize.set(2048,2048),t.shadow.bias=rq,t.shadow.camera.near=3,t.shadow.camera.far=14,this.keyLight=t,this.scene.add(t,t.target),this.lights.push(t);let n=new Kd(`#cfdcff`,55,24,.6,.7,1.7);n.position.set(-3.6,5.5,2.2),n.target.position.set(0,.8,0),this.scene.add(n,n.target),this.lights.push(n);for(let[e,t,n,r]of[[`#a9c0ff`,-5.2,3.4,-4.6],[`#9db4ff`,5.2,3.4,-4.6]]){let i=new Kd(e,170,30,.6,.9,1.8);i.position.set(t,n,r),i.target.position.set(0,1.2,0),this.scene.add(i,i.target),this.lights.push(i)}let r=new Kd(`#e4ecff`,85,22,.3,.8,1.5);r.position.set(0,6.4,-4.4),r.target.position.set(0,1,0),this.scene.add(r,r.target),this.lights.push(r),this.followSpot=r}draw(e,t=!1,n=!0){if(this.destroyed)return;let r=e-this.previous,i=t?1/60:Math.min(.05,Math.max(.001,r/1e3));this.previous=e,!t&&this.scaler.record(r)&&this.applyResolutionScale(),!t&&r>0&&r<1e3&&(this.frameMsAverage+=(r-this.frameMsAverage)*.05);let a=Math.min(this.pixelRatioCap,window.devicePixelRatio||1);a!==this.basePixelRatio&&(this.basePixelRatio=a,this.applyResolutionScale());let o=this.canvas.clientWidth,s=this.canvas.clientHeight;o>0&&s>0&&(this.renderer.getSize(this.sizeCheck),(this.sizeCheck.x!==o||this.sizeCheck.y!==s)&&(this.renderer.setSize(o,s,!1),this.composer.setSize(o,s),this.camera.aspect=o/s,this.portraitPull=L.clamp(1.2/this.camera.aspect,1,2.2),this.baseFov=36*Math.min(1.3,Math.sqrt(this.portraitPull)),this.camera.fov=this.baseFov,this.camera.updateProjectionMatrix()));let c=e/1e3;this.frameSeconds=c,this.finishPass.uniforms.uTime.value=c%1e3,t&&(this.lastManualTime=e);let l=this.settings();this.setBloodLevel(l.blood);let u=this.buffer.latest(),d=i,f=u?.result!==null&&u?.result!==void 0&&fr.has(u.result.finish_method);if(this.cheer(c,i),f&&!this.finishSeen&&(this.finishSeen=!0,this.finishSlowMotion=2.2,this.arena.excite(1)),this.finishSlowMotion>0&&!l.reducedMotion){this.finishSlowMotion=Math.max(0,this.finishSlowMotion-i);let e=Math.min(1,this.finishSlowMotion/.5);i*=.3+.7*(1-e)}this.viewerHitFlash=Math.max(0,this.viewerHitFlash-i*3.2);let p=u===null?0:t?OJ(u):this.buffer.renderTick(e),m=this.updateRocked(u===null?null:this.shownAt(p),d,l.reducedMotion);m!==null&&u!==null&&this.onRocked?.(m,u.tick);let h=u===null?null:this.applyLocalPrediction(this.buffer.sample(p),i,e),g=this.replay;if(g!==null){let e=c-g.startedAt;e>=g.plan.durationSeconds||g.plan.impact.kind===`referee_down`&&u?.phase!==`referee_down`?this.endReplay():(p=NK(g.plan,e,this.simulation.tick_rate),h=g.buffer.sample(p)??h,!g.impactFired&&p>=g.plan.impact.tick&&h!==null&&(g.impactFired=!0,this.fireReplayImpact(h)))}let _=this.replay===null?i:i*this.replay.plan.speed,v=1.8,y=!1,b=null;if(h!==null){let e=this.replay===null?this.ceremony:null,[t,n]=e===null?this.standApart(h.fighters,_):this.ceremonyFighters(e,h.fighters,_,c,this.drawnOffsets);for(let[e,t]of h.fighters.entries())this.arcadeInjuries[e]!==null&&this.replay===null&&(t.is_downed?this.observedInjuryDown[e]=!0:this.observedInjuryDown[e]&&h.result===null&&this.restoreInjury(e));let r=this.graphs;if(r!==null){this.wearLook(0,t.player_id),this.wearLook(1,n.player_id);let e=this.headCacheValid[0]?this.headCache[0]:void 0,i=this.headCacheValid[1]?this.headCache[1]:void 0;r[0].boxer.root.visible=!0,r[1].boxer.root.visible=!0;let a=$K(h,this.simulation.tick_rate);r[0].setResting(a),r[1].setResting(a);let o=h.phase===`countdown`?h.phase_ticks_remaining:null;r[0].setCountdown(o),r[1].setCountdown(o);let s=this.replay!==null||h.phase===`complete`;r[0].stayDown(s),r[1].stayDown(s),h.phase===`fight`&&this.lastPhase===`rest`&&this.replay===null&&(this.roundCalloutUntil=c+pq,this.roundCalloutRound=h.round_number),h.phase===`rest`&&this.lastPhase!==`rest`&&this.enterRest(c),this.lastPhase=h.phase,this.anticipatePunches(u,p),r[0].setObstacle(r[1].boxer.root.position.x,r[1].boxer.root.position.z),r[1].setObstacle(r[0].boxer.root.position.x,r[0].boxer.root.position.z);let d=this.referee?.boxer.rig.bones.head.getWorldPosition(this.refereeHead)??null;r[0].setRefereeHead(d),r[1].setRefereeHead(d),r[0].update(t,n,_,c,l.reducedMotion,l.blood,p,i),r[1].update(n,t,_,c,l.reducedMotion,l.blood,p,e);let f=h.phase===`finish`?Dr(h.fighters,this.finishTargetId):null;for(let[e,t]of h.fighters.entries()){let n=f!==null&&t.player_id===f.player_id;r[e].setDazed(n),this.carnage.sync(e,(this.replay===null?void 0:u?.fighters[e])??t,l,_,c,n)}let m=r[h.fighters.findIndex(e=>e.player_id===this.viewerId)],g=m?.ownPressId??null;if(m!==void 0&&g!==null&&g!==this.soundedPress){this.soundedPress=g;let{punchClass:e,power:t}=m.punchKind;this.onOwnPunch?.(e,t,g)}for(let[e,t]of r.entries()){let n=t.boxer.bone(`head`);n!==null&&(t.boxer.root.updateMatrixWorld(!0),n.getWorldPosition(this.headCache[e]),this.headCacheValid[e]=!0);let r=t.fallBody!==null;r&&!this.fallingLive[e]&&this.replay===null&&(this.liveFallTicks[e]=p),this.fallingLive[e]=r}}for(let e=0;ee.player_id===this.viewerId),C=l.camera===`fighter`&&S>=0&&QK(h)?this.fighterCam.update(i,c,S===0?this.tmpA:this.tmpB,S===0?this.tmpB:this.tmpA,this.effects.shakeAmount+this.powerShake,l.reducedMotion,this.camera.aspect):null;C===null&&this.fighterCam.reset();let w=this.replay,T=this.cameraOverride??(w!==null&&h!==null?this.replayFrame(h,c-w.startedAt):this.closeUpFrame(c)??this.raiseFrame(c,i,l.reducedMotion)??this.cornerShotFrame(c,h,l.reducedMotion)??this.restWideFrame(h)??this.ceremonyFrame(c)??C??x);this.ownViewActive=C!==null&&T===C;let E=this.ownViewActive?this.baseFov*FB:this.baseFov;if(this.camera.fov!==E&&(this.camera.fov=E,this.camera.updateProjectionMatrix()),this.cameraOverride===null&&this.portraitPull>1&&T.framed!==!0&&!this.ownViewActive){let e=T.tight===!0,t=this.portraitPull/Math.min(1.3,Math.sqrt(this.portraitPull)),n=e?Math.min(t,1.25):t;this.tmpCamera.subVectors(T.position,T.lookAt).multiplyScalar(n),this.camera.position.copy(T.lookAt).add(this.tmpCamera),e&&(this.camera.position.x=L.clamp(this.camera.position.x,-2.2,kq),this.camera.position.z=L.clamp(this.camera.position.z,-2.2,kq)),this.camera.lookAt(T.lookAt.x,T.lookAt.y-(this.portraitPull-1)*(e?.08:.45),T.lookAt.z)}else this.camera.position.copy(T.position),this.camera.lookAt(T.lookAt);this.effects.setViewDistance(this.camera.position.distanceTo(T.lookAt)),this.arena.makeRoomForCamera(this.camera.position);let D=T===x?yC(Math.max(this.tmpA.z,this.tmpB.z)):T.framed===!0?Xq:1;this.ring.setNearRopeOpacity(this.ring.nearRopeOpacity()+(D-this.ring.nearRopeOpacity())*(1-Math.exp(-6*i))),n&&(this.composer.render(),this.bloomPass.enabled&&this.carnage.drawBreak(this.renderer,this.scene,this.camera,this.arena.group),this.drawHudOverlay(h)),!this.destroyed&&!this.manualClock&&(this.raf=requestAnimationFrame(e=>this.draw(e)))}applyLocalPrediction(e,t,n){if(e===null||this.localInput===null||this.viewerId===null)return e;let r=e.fighters.findIndex(e=>e.player_id===this.viewerId),i=this.localInput()??{moveX:0,moveY:0,defense:`none`},a=(this.inputLatencyMs??60)/1e3*this.simulation.tick_rate+this.buffer.interpolationDelayTicks,o=this.ownCollapseUntil>e.tick,s=e.phase===`fight`||e.phase===`finish`&&r>=0&&Dr(e.fighters,this.finishTargetId)!==e.fighters[r],c=r>=0&&s&&!o?e.fighters[r]:null,l=this.evasion.holdsFeet(n)?0:this.graphs?.[r]?.ownFootwork??1,u=this.movement.update(c,i,l,n,a,e.tick,t,this.simulation.tick_rate),d=this.evasion.pose(n);if(r<0)return e;let f=e.fighters[r],p=c===null?f.defense:Nz(c,i,d,this.evasion.hidesServerEvasion(n));if(Math.abs(u.dx)<.01&&Math.abs(u.dy)<.01&&p===f.defense)return e;let m=jz(f,u,e.fighters[+(r===0)]??null),h={...f,x:f.x+m.dx,y:f.y+m.dy,defense:p},g=r===0?[h,e.fighters[1]]:[e.fighters[0],h];return{...e,fighters:g}}anticipatePunches(e,t){if(!(this.replay!==null||e===null||e.phase!==`fight`&&e.phase!==`finish`))for(let[n,r]of(this.graphs??[]).entries()){let i=e.fighters[n];i!==void 0&&!i.is_downed&&r.anticipate(i,i.action_start_tick-t)}}cheer(e,t){ee.clinch_ticks>0||e.clinch_startup_ticks>0||e.is_downed)?null:QJ(n.x,n.y,r.x,r.y,Lq,u-f,d-f,S),[a,o]=this.drawnTargets;a.x=i===null?0:i.ax-n.x,a.y=i===null?0:i.ay-n.y,o.x=i===null?0:i.bx-r.x,o.y=i===null?0:i.by-r.y,this.clearOfTheFallen(e);let s=1-Math.exp(-14*t);for(let e of[0,1]){let n=this.drawnOffsets[e],r=this.drawnTargets[e],i=r.x-n.x,a=r.y-n.y;if(this.drawnOffsetsLive){i*=s,a*=s;let e=Math.hypot(i,a);e>Rq*t&&(i*=Rq*t/e,a*=Rq*t/e)}n.x+=i,n.y+=a}return this.drawnOffsetsLive=!0,[this.drawnAt(0,n),this.drawnAt(1,r)]}drawnAt(e,t){let n=this.drawnOffsets[e];if(Math.abs(n.x)<.01&&Math.abs(n.y)<.01)return t;let r=Az(t.x+n.x,t.y+n.y);return Object.assign(this.drawnFighters[e],t,{x:r.x,y:r.y})}clearOfTheFallen(e){for(let t of[0,1]){let n=this.graphs?.[t]?.fallBody??null,r=+(t===0),i=e[r];if(n===null||i.is_downed||(this.graphs?.[r]?.fallBody??null)!==null)continue;let a=this.drawnTargets[r],o=this.mapping.x(i.x+a.x),s=this.mapping.z(i.y+a.y),c=this.clearOf(n,o,s);a.x+=(c.x-o)/this.mapping.x(1),a.y+=(c.z-s)/this.mapping.z(1);return}}clearOf(e,t,n){let r={x:t,z:n};for(let t of[0,1,2,3,4])e.bodyPoint(t,this.bodyPoint),r=JJ(r.x,r.z,this.bodyPoint.x,this.bodyPoint.z,Pq);let i=this.insideRopes(r.x,r.z);if(Math.hypot(i.x-r.x,i.z-r.z)<1e-6)return r;let a=t=>[0,1,2,3,4].every(n=>(e.bodyPoint(n,this.bodyPoint),Math.hypot(t.x-this.bodyPoint.x,t.z-this.bodyPoint.z)>=.499999));for(let e=zq;e<=2.000000001;e+=zq)for(let[t,n]of[[1,0],[-1,0],[0,1],[0,-1]]){let r=this.insideRopes(i.x+t*e,i.z+n*e);if(a(r))return r}return i}insideRopes(e,t){let n=Az(e/this.mapping.x(1),t/this.mapping.z(1));return{x:this.mapping.x(n.x),z:this.mapping.z(n.y)}}headHeightOf(e){return(this.graphs?.[e]?.boxer.metrics.headRestY??1.52)+.04}bleed(e,t,n){for(let[r,i]of e.entries()){let e=BY(i,this.graphs?.[r],this.flashKnockout?.loserId),a=this.arcadeInjuries[r]??null,o=a!==null,s=(i.trauma.bleeding+i.trauma.left_cut+i.trauma.right_cut)/380,c=o?Math.max(s,EY):s;if(c>.05&&!e)this.downedPoolAccumulators[r]=0,this.downedPoolCounts[r]=0,this.effects.drip(this.dripPoint(r),c,n.reducedMotion,r);else if(c>wY&&e&&n.blood!==`off`){this.effects.stopDrip(r),this.downedPoolAccumulators[r]+=t*5*(o?DY:1);let e=this.poolSource(r,a);for(;this.downedPoolAccumulators[r]>=1;){--this.downedPoolAccumulators[r];let t=this.downedPoolCounts[r];this.downedPoolCounts[r]=t+1;let n=zY(t,c,o?OY:TY),i=t*2.399963+r*Math.PI;this.effects.pool(e.x+Math.sin(i)*n*.25,e.z+Math.cos(i)*n*.25,n,t+r*7)}}else this.effects.stopDrip(r),this.downedPoolAccumulators[r]=0,e||(this.downedPoolCounts[r]=0)}}dripPoint(e){let t=this.headWorldPose(e);if(t!==null)return t.position.add(this.tmpStumpOffset.copy(kY).applyQuaternion(t.quaternion));if(this.headCacheValid[e])return this.tmpHead.copy(this.headCache[e]);let n=e===0?this.tmpA:this.tmpB;return this.tmpHead.set(n.x,this.headHeightOf(e),n.z)}poolSource(e,t){if(t===`dismember_left`||t===`dismember_right`){let n=this.handWorldPose(e,t===`dismember_left`?`left`:`right`);if(n!==null)return n.position}let n=RY(t);if(n!==`mouth`){let t=this.tornWound(e,n);if(t!==null)return t.position}return this.headCacheValid[e]?this.headCache[e]:e===0?this.tmpA:this.tmpB}updateBlobShadows(){let e=[this.tmpA,this.tmpB,this.refereePosition];for(let[t,n]of this.blobShadows.entries()){n.visible=t>=2||!this.carnage.gibbed(t);let r=t<2?this.graphs?.[t]:this.referee??void 0,i=r?.fallBody?.centre(this.bodyPoint)??null??(r?.boxer.root.visible===!0?r.currentRoot:e[t]);n.position.x=i.x,n.position.z=i.z;let a=t<2?this.buffer.latest()?.fighters[t]:void 0,o=t<2?a!==void 0&&BY(a,r,this.flashKnockout?.loserId):r?.isDown===!0;n.scale.set(o?2.1:1.25,o?.9:.85,1)}}updateFootShadows(){for(let[e,t]of this.footShadows.entries()){let n=e>>1,r=this.graphs?.[n]?.boxer;t.visible=r!==void 0&&r.root.visible&&!this.carnage.gibbed(n),r!==void 0&&t.visible&&(r.rig.bones[e%2==0?`ankleL`:`ankleR`].getWorldPosition(this.footPoint),t.position.x=this.footPoint.x,t.position.z=this.footPoint.z,t.material.opacity=RJ(this.footPoint.y-r.metrics.ankleRestY))}}updateReferee(e,t,n,r){let i=this.referee;if(i===null)return;let a=this.replay===null||this.replay.plan.impact.kind===`referee_down`;i.boxer.root.visible=a;let o=this.blobShadows[2];o!==void 0&&(o.visible=a);let s=n?.referee??null,c=this.replay!==null&&this.replay.plan.impact.kind===`referee_down`?this.replay:null;!this.refereePlaced&&s!==null&&(this.refereePlaced=!0,this.refereePosition.set(this.mapping.x(s.x),0,this.mapping.z(s.y)));let l=this.refereeReplayAt!==null||this.pendingRefereeEvents.some(e=>e.kind===`referee_down`);s?.alive===!0&&i.isDown&&this.replay===null&&n?.phase!==`referee_down`&&!l&&i.resetTransient(!1),s===null||s.alive||i.isDown||this.replay!==null||l||(this.refereePosition.set(this.mapping.x(s.x),0,this.mapping.z(s.y)),i.knockOut(),this.refereeFallUnseen=!0);let u=s!==null&&(n?.phase===`fight`&&s.alive||c!==null&&!c.impactFired)?s:null,d=s?.alive===!1&&(c===null||c.impactFired),f=n?.fighters.find(e=>e.is_downed)??(n?.phase===`knockdown`?n.fighters.find(e=>e.player_id===this.lastKnockdown?.knockdown.target_id):void 0)??null,p=n?.fighters.some(e=>e.clinch_ticks>0||e.clinch_startup_ticks>0)??!1,m=f===null&&i.breaking,h=f===null?void 0:this.graphs?.[n?.fighters.indexOf(f)??-1],g=h?.fallBody?.centre(this.bodyPoint)??null,_=f!==null&&!f.is_downed?h?.currentRoot??null:null,v=f===null?(this.tmpA.x+this.tmpB.x)/2:g?.x??_?.x??this.mapping.x(f.x),y=f===null?(this.tmpA.z+this.tmpB.z)/2:g?.z??_?.z??this.mapping.z(f.y),b=this.refereeAway.set(this.refereePosition.x-v,0,this.refereePosition.z-y);if(b.lengthSq()<.01&&b.set(0,0,-1),b.normalize(),m){let e=this.tmpB.z-this.tmpA.z,t=this.tmpA.x-this.tmpB.x,n=Math.hypot(e,t),r=e*b.x+t*b.z>=0?1:-1;n>.01&&b.set(e/n*r,0,t/n*r)}let{standoff:x,clearance:S}=XY(f!==null,p,m),C=L.clamp(v+b.x*x,-2.4,2.4),w=L.clamp(y+b.z*x,-2.4,2.4),T=this.refereePosition.x,E=this.refereePosition.z,D=this.replay===null&&this.ceremony?.positions!==null?this.ceremony:null,O=!d&&D===null&&this.replay===null&&this.stoppageWinner>=0&&this.frameSeconds>=this.stoppageRaiseAt?this.stoppageWinner===0?this.tmpA:this.tmpB:null,k=O===null?null:this.stoppageSpot??=this.raiseSpot(O,this.stoppageWinner===0?this.tmpB:this.tmpA),A=k!==null&&k.x<0?-1:1;if(d)D!==null&&(D.refereeArrived=!0);else if(O!==null&&k!==null){let t=tJ(this.refereePosition.x,this.refereePosition.z,{x:O.x+k.x,y:O.z+k.z},Qq*e);this.refereePosition.x=t.x,this.refereePosition.z=t.y}else if(D!==null){let t=tJ(this.refereePosition.x,this.refereePosition.z,{x:Yq.x,y:Yq.z},Qq*e);this.refereePosition.x=t.x,this.refereePosition.z=t.y,D.refereeArrived=t.arrived}else if(u!==null){let t=c===null?1-Math.exp(-20*e):1;this.refereePosition.x+=(this.mapping.x(u.x)-this.refereePosition.x)*t,this.refereePosition.z+=(this.mapping.z(u.y)-this.refereePosition.z)*t}else{let t=1-Math.exp(-(m?8:1.6)*e),n=m?Math.min(1,Vq*e/Math.max(1e-6,Math.hypot(C-this.refereePosition.x,w-this.refereePosition.z)*t)):1;this.refereePosition.x+=(C-this.refereePosition.x)*t*n,this.refereePosition.z+=(w-this.refereePosition.z)*t*n}let j=O===null?D===null?u!==null||d?0:S:D.refereeArrived?0:Jq:Sq*.85;for(let e of j>0?[this.tmpA,this.tmpB]:[]){let t=this.refereePosition.x-e.x,n=this.refereePosition.z-e.z,r=Math.hypot(t,n);r.001&&(this.refereePosition.x=e.x+t/r*j,this.refereePosition.z=e.z+n/r*j)}for(let e of D!==null||d?[]:this.graphs??[]){let t=e.fallBody;if(t!==null)for(let e of[0,1,2,3,4]){t.bodyPoint(e,this.bodyPoint);let n=JJ(this.refereePosition.x,this.refereePosition.z,this.bodyPoint.x,this.bodyPoint.z,Nq);this.refereePosition.x=n.x,this.refereePosition.z=n.z}}for(let e of d?[]:[0,1]){if(!this.effects.severedHeadPosition(e,this.closeUpTarget))continue;let t=JJ(this.refereePosition.x,this.refereePosition.z,this.closeUpTarget.x,this.closeUpTarget.z,Aq);this.refereePosition.x=t.x,this.refereePosition.z=t.z}if(c===null&&!d){let t=this.refereePosition.x-T,n=this.refereePosition.z-E,r=Math.hypot(t,n),i=dJ*e;r>i&&(this.refereePosition.x=T+t/r*i,this.refereePosition.z=E+n/r*i)}e>0&&this.refereeVelocity.set((this.refereePosition.x-T)/e,0,(this.refereePosition.z-E)/e);let ee=O!==null&&k!==null&&Math.hypot(this.refereePosition.x-O.x-k.x,this.refereePosition.z-O.z-k.z)<=wq,M=D!==null&&!D.refereeArrived,te=O===null?D===null?u===null?Math.atan2(v-this.refereePosition.x,y-this.refereePosition.z):Math.atan2(u.facing_x,-u.facing_y):M?Math.atan2(Yq.x-this.refereePosition.x,Yq.z-this.refereePosition.z):0:ee?0:Math.atan2(O.x-this.refereePosition.x,O.z-this.refereePosition.z);if(O!==null){let e=this.graphs?.[this.stoppageWinner]?.boxer.rig.bones,t=n?.fighters[this.stoppageWinner]?.injuries??[],r=bJ(t,`left`),a=!ee||e===void 0?null:r&&bJ(t,`right`)?this.nearerGlove(e.gloveL,e.gloveR):(r?e.gloveL:e.gloveR).getWorldPosition(this.stoppageWrist);i.raise(A<0?a:null,A>0?a:null)}let ne=((te-this.refereeYaw+Math.PI)%(Math.PI*2)+Math.PI*2)%(Math.PI*2)-Math.PI;this.refereeYaw+=ne*(1-Math.exp(-(m?8:3)*e));let re=ZY(this.refereePosition,this.refereeYaw,this.refereeVelocity,this.mapping,s);i.setRefereeCount(f!==null,f?.get_up_count??0);let ie=f===null?n?.fighters.findIndex(e=>e.stunned_ticks>0)??-1:-1,ae=ie===0?this.tmpA:this.tmpB,oe=f===null?ie>=0?b.set(ae.x,1.5,ae.z):null:b.set(v,f.is_downed?.25:1.5,y);i.aimBreak(this.tmpA,this.tmpB,oe,n?.phase===`finish`?`stand_back`:`watch`);let se=this.settings();if(i.update(re.self,re.focus,e,t,se.reducedMotion,se.blood,r),this.refereeFallUnseen&&(this.refereeFallUnseen=!1,i.fallBody?.settle()),this.effects.gushing(2)){let e=this.refereeMouth();e!==null&&this.effects.anchorGush(2,e.position,e.axis)}this.poolUnderReferee(s?.alive===!1,d,e,se.blood)}poolUnderReferee(e,t,n,r){if(!e&&this.replay===null&&(this.refereePoolAccumulator=0,this.refereePoolCount=0),!t||r===`off`||this.referee===null)return;this.refereePoolAccumulator+=n*5*DY;let i=this.referee.boxer.rig.bones.head.getWorldPosition(this.refereeHead);for(;this.refereePoolAccumulator>=1;){--this.refereePoolAccumulator;let e=this.refereePoolCount,t=zY(e,EY,OY);if(t>=OY)return;this.refereePoolCount=e+1;let n=e*2.399963;this.effects.pool(i.x+Math.sin(n)*t*.25,i.z+Math.cos(n)*t*.25,t,e+14)}}updateTrails(e,t){let n=this.graphs;if(!(n===null||this.trails.length<4)){for(let[r,i]of n.entries())for(let[n,a]of[`gloveL`,`gloveR`].entries()){let o=this.trails[r*2+n],s=this.glows[r*2+n];if(!i.boxer.root.visible||!this.carnage.hasGlove(r,n===0?`left`:`right`)){o.reset(),s?.reset();continue}i.boxer.rig.bones[a].getWorldPosition(this.trailGlove);let c=i.powerHeat(n===0?`left`:`right`);o.update(this.trailGlove,e,this.camera.position,!t&&this.replay===null&&!i.isDown,c),s?.update(this.trailGlove,c,e,t,this.camera)}for(let t of this.impactFlashes)t.update(e,this.camera);this.powerShake*=.02**e}}presentPowerHit(e,t){let n=!t.detail.endsWith(`:body`)&&this.headCacheValid[e]===!0?this.headCache[e]:void 0;n===void 0?this.powerHitPoint.set(this.contactPoint.x,t.detail.endsWith(`:body`)?1.05:1.55,this.contactPoint.z):this.powerHitPoint.copy(n),this.impactFlashes[e]?.fire(this.powerHitPoint),this.powerShake=Math.min(mJ,this.powerShake+pJ)}updateCornermen(e,t,n,r){let i=this.cornermen;if(i===null)return;let a=$K(n,this.simulation.tick_rate),o=n?.phase===`complete`?this.final:null;for(let[s,c]of i.entries()){let i=s===0?-1:1,l=o===null?`work`:this.deaths[s]===null?o.winner_id!==null&&o.winner_id===n?.fighters[s]?.player_id?`cheer`:`work`:`mourn`,u=a||l!==`work`,d=u?Bq:Oq;this.cornermanPosition.set(i*d,0,-i*d);let f=s===0?3*Math.PI/4:-Math.PI/4;c.attend(u,l);let p=ZY(this.cornermanPosition,f,this.cornermanVelocity,this.mapping);c.update(p.self,p.focus,e,t,!1,`off`,r)}}updateCutmen(e,t,n,r){let i=this.cutmen,a=this.graphs;if(i===null||a===null)return;let o=n?.phase===`rest`,s=this.mapping.x(l);for(let[c,l]of i.entries()){let i=c===0?-1:1,u=o&&a[c].stoolVisible?1:0,d=this.cutmanProgress[c],f=d+Math.sign(u-d)*Math.min(Math.abs(u-d),e/Hq);this.cutmanProgress[c]=f;let p=l.boxer.root.visible;if(l.boxer.root.visible=f>.005,!l.boxer.root.visible)continue;this.cutmanFrom.set(i*Oq,0,-i*2.42),EB(c===0?0:1,s,CB,32,this.cutmanTo);let m=f*f*(3-2*f);this.cornermanPosition.copy(this.cutmanFrom).lerp(this.cutmanTo,m);let h=this.cutmanLast[c];p||h.copy(this.cornermanPosition),this.cornermanVelocity.copy(this.cornermanPosition).sub(h).divideScalar(Math.max(e,.001)),h.copy(this.cornermanPosition);let g=f>.02&&f=Uq?_===null?Math.atan2(i,-i):Math.atan2(_.x-this.cutmanTo.x,_.z-this.cutmanTo.z):Math.atan2(-this.cutmanFrom.x,-this.cutmanFrom.z),y=EJ(n?.fighters[c]);if(f>=Uq&&_!==null){let e=a[c].boxer.root.rotation.y;this.cutmanFacing.set(Math.sin(e),0,Math.cos(e)),this.cutmanEye.copy(_).addScaledVector(this.cutmanFacing,.09),this.cutmanEye.x+=Math.cos(e)*y.side*y.lateral,this.cutmanEye.z-=Math.sin(e)*y.side*y.lateral,this.cutmanEye.y+=y.lift;let t=n?.fighters[c]?.trauma,r=t===void 0||y.prop===`bottle`?0:Math.min(1,Math.max(t.left_cut,t.right_cut)/Wq);l.treat(this.cutmanEye,this.cutmanFacing,y.side,y.prop,r)}else l.treat(null);let b=ZY(this.cornermanPosition,v,this.cornermanVelocity,this.mapping);l.update(b.self,b.focus,e,t,!1,`off`,r)}}drawHudOverlay(e){let t=ZK(this.hudCanvas);if(t===null)return;let{context:n,viewport:r}=t;if(this.hudViewport.width=r.width,this.hudViewport.height=r.height,n.clearRect(0,0,r.width,r.height),e===null)return;let i=this.settings();if(this.viewerHitFlash>.01&&!i.reducedMotion){let e=n.createRadialGradient(r.width/2,r.height/2,r.width*.12,r.width/2,r.height/2,r.width*.7);e.addColorStop(0,`rgba(255,235,225,${(this.viewerHitFlash*.18).toFixed(3)})`),e.addColorStop(1,`rgba(140,0,10,${(this.viewerHitFlash*.55).toFixed(3)})`),n.fillStyle=e,n.fillRect(0,0,r.width,r.height)}let a=xY(Math.max(...e.fighters.map(e=>e.trauma.head+e.trauma.body)),i.blood);if(a>0){let e=n.createRadialGradient(r.width/2,r.height/2,r.width*.2,r.width/2,r.height/2,r.width*.72);e.addColorStop(0,`rgba(90,0,8,0)`),e.addColorStop(1,`rgba(75,0,8,${a.toFixed(3)})`),n.fillStyle=e,n.fillRect(0,0,r.width,r.height)}i.reducedMotion||this.effects.drawLens(n,r.width,r.height);let o=this.deaths[0]??this.deaths[1],s=this.replay===null?null:this.replay.plan.impact.kind===`referee_down`?`REFEREE DOWN`:o===null?`KNOCKOUT REPLAY`:ke(o)===null?`DEATH REPLAY`:`FATALITY REPLAY`;Ir(n,r.width,r.height,e,this.players,this.viewerId,this.frameSeconds>=this.finalRevealAt?this.final:null,this.reconnectMs,this.simulation.tick_rate,this.roundStats,s,this.lagWarned?this.inputLatencyMs:null,this.frameSecondsthis.avatars.get(e),this.lastKnockdown?.knockdown.target_id??null,this.touchControls&&e.fighters.some(e=>e.player_id===this.viewerId),this.powerHeld?.()===!0,o,this.finishTargetId,!i.reducedMotion),this.drawCaption(n,r.width,r.height,e)}updateRocked(e,t,n){let r=e?.fighters.find(e=>e.player_id===this.viewerId),i=e===null||this.replay!==null||this.final!==null?0:DK(r,e.phase),a=this.rocked.update(n?0:i,t);return this.finishPass.uniforms.uRocked.value=n?0:a,r===void 0?null:i}shownAt(e){for(let t=this.history.length-1;t>=0;--t)if(this.history[t].tick<=e)return this.history[t];return null}drawCaption(e,t,n,r){let i=this.final!==null&&this.frameSeconds>=this.finalRevealAt?this.final:null;i!==null&&!this.resultAnnounced&&(this.resultAnnounced=!0,this.commentary.resultShown(this.frameSeconds));let a=this.commentary.current(this.frameSeconds),o=this.settings(),s=a===null||!o.commentary?``:a.line.text;if(s!==this.captionText&&(this.captionText=s,this.hudCanvas.dataset.caption=s),a===null||!o.commentary)return;let c=r.fighters.find(e=>e.player_id===this.viewerId),l=Hn(t,n),u=i===null?null:eY(i,t,n,r.fighters,this.players,this.roundStats,this.viewerId,this.deaths[0]??this.deaths[1])/l,d=this.frameSeconds0});p!==null&&(e.save(),e.scale(l,l),nV(e,a,p,o.reducedMotion),e.restore())}destroy(){if(!this.destroyed){if(this.destroyed=!0,cancelAnimationFrame(this.raf),this.raf=0,this.buffer.clear(),this.dedupe.reset(),this.pendingContacts.length=0,this.pendingGore.length=0,this.carnage.dispose(),this.effects.dispose(),this.avatars.dispose(),this.arena.dispose(),LC(this.ring),this.graphs!==null){for(let e of this.graphs)this.scene.remove(e.boxer.root),e.dispose();this.graphs=null}this.referee!==null&&(this.scene.remove(this.referee.boxer.root),this.referee.dispose(),this.referee=null);for(let e of this.trails)this.scene.remove(e.mesh),e.dispose();this.trails=[];for(let e of this.glows)this.scene.remove(e.mesh),e.dispose();this.glows=[];for(let e of this.impactFlashes)this.scene.remove(e.group),e.dispose();if(this.impactFlashes=[],this.glowMap?.dispose(),this.glowMap=null,this.cornermen!==null){for(let e of this.cornermen)this.scene.remove(e.boxer.root),e.dispose();this.cornermen=null}if(this.cutmen!==null){for(let e of this.cutmen)this.scene.remove(e.boxer.root),e.dispose();this.cutmen=null}for(let e of this.lights)this.scene.remove(e);this.keyLight?.shadow.map?.dispose(),this.keyLight?.shadow.dispose(),this.blobTexture.dispose();for(let e of[...this.blobShadows,...this.footShadows])this.scene.remove(e),e.geometry.dispose(),e.material.dispose();this.renderer.renderLists.dispose(),tq(this.composer),this.bloomPass.materialHighPassFilter.dispose(),XC(),this.renderer.dispose(),this.hudCanvas.remove()}}},$Y=[`broadcast`,`close`,`fighter`],eX=`hands.preferences.v1`,tX={length:0,clear:()=>void 0,getItem:()=>null,key:()=>null,removeItem:()=>void 0,setItem:()=>void 0},nX=()=>{try{return window.localStorage}catch{return tX}},rX=()=>({volume:.7,haptics:!0,reducedMotion:window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1,blood:`full`,commentary:!0,announcer:!0,camera:`broadcast`});function iX(e=nX()){let t=rX();try{let n=JSON.parse(e.getItem(eX)??`null`);if(typeof n!=`object`||!n||Array.isArray(n))return t;let r=n;return{volume:typeof r.volume==`number`&&Number.isFinite(r.volume)?Math.max(0,Math.min(1,r.volume)):t.volume,haptics:typeof r.haptics==`boolean`?r.haptics:t.haptics,reducedMotion:typeof r.reducedMotion==`boolean`?r.reducedMotion:t.reducedMotion,blood:r.blood===`reduced`||r.blood===`off`||r.blood===`full`?r.blood:t.blood,commentary:typeof r.commentary==`boolean`?r.commentary:t.commentary,announcer:typeof r.announcer==`boolean`?r.announcer:t.announcer,camera:$Y.includes(r.camera)?r.camera:t.camera}}catch{return t}}function aX(e,t=nX()){try{t.setItem(eX,JSON.stringify({volume:Math.max(0,Math.min(1,e.volume)),haptics:e.haptics,reducedMotion:e.reducedMotion,blood:e.blood,commentary:e.commentary,announcer:e.announcer,camera:e.camera}))}catch{}}var oX=class{value;listeners=new Set;constructor(e=nX()){this.storage=e,this.value=iX(e)}storage;get current(){return this.value}update(e){this.value={...this.value,...e},aX(this.value,this.storage);for(let e of this.listeners)e(this.value)}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}destroy(){this.listeners.clear()}},sX={stage:`bootstrapping`,player:null,playerId:null,role:null,players:{},playerOrder:[],simulation:null,snapshot:null,final:null,select:null,serverTick:0,nextSequence:0,reconnectMs:0,safeError:null},cX=e=>Object.fromEntries(e.map(e=>[e.id,e]));function lX(e,t){if(t.type===`bootstrap`)return{...e,stage:`authorizing`,simulation:t.simulation,safeError:null};if(t.type===`authorized`)return{...e,stage:`connecting`,player:t.player,safeError:null};if(t.type===`connecting`)return{...e,stage:`connecting`};if(t.type===`reconnect-tick`)return{...e,stage:`paused`,reconnectMs:Math.max(0,t.remainingMs)};if(t.type===`fatal`)return{...e,stage:`fatal`,safeError:t.code,reconnectMs:0};let n=t.message;switch(n.type){case`welcome`:return{...e,playerId:n.role===`fighter`?n.player_id:null,role:n.role,players:cX(n.players),playerOrder:n.players.map(e=>e.id),serverTick:n.server_tick,nextSequence:n.role===`fighter`?n.next_sequence:0,safeError:null};case`ticket`:return e;case`waiting`:return{...e,stage:`waiting`,select:null};case`select`:return{...e,stage:`select`,select:n,players:cX(n.players),playerOrder:n.players.map(e=>e.id)};case`ready`:return{...e,stage:e.snapshot?.phase??`countdown`,select:null,players:cX(n.players),playerOrder:n.players.map(e=>e.id)};case`paused`:return{...e,stage:`paused`,reconnectMs:n.grace_ms};case`resumed`:return{...e,stage:e.snapshot?.phase??`countdown`,reconnectMs:0};case`snapshot`:return{...e,stage:n.payload.phase,snapshot:n.payload,serverTick:Math.max(e.serverTick,n.payload.tick)};case`final`:return{...e,stage:`complete`,final:n,reconnectMs:0};case`error`:return{...e,stage:`fatal`,safeError:n.code,reconnectMs:0}}}var uX=new Set([`hit`,`counter_hit`,`block`,`perfect_block`,`guard_break`,`knockdown`,`parry`,`body_collapse`,`eye_shut`,`referee_hit`,`referee_down`]),dX=11e3,fX=1500,pX=4e3,mX=3e3,hX=6,gX=5e3,_X=[{level:`rookie`,label:`Rookie`,detail:`Slow hands, leaves openings`},{level:`contender`,label:`Contender`,detail:`Works the body, punishes mistakes`},{level:`champion`,label:`Champion`,detail:`Slips, counters, finishes`}],vX=e=>Nt.includes(e),yX=class{root;reloadPage;authorizer;state=sX;settings=new oX;input=new SL;audio=new Ok(()=>this.settings.current);haptics=new JI(()=>this.settings.current);voice=new Qr(()=>this.settings.current);feedbackEvents=new IL;soundedPunches=[];renderer=null;network=null;session=null;abort=new AbortController;destroyed=!1;generation=0;reloadOnRetry=!1;reloading=!1;canvas;status;overlay;roleIndicator;controlsButton;controlsPanel;retry;rematchButton;hint;cpuPicker;cpuPrompt;cpuLevel=null;rematchOpponent=null;lastPhase=null;cpuRematchLevel=null;cpuRematch=null;cpuRematchTimer=null;diagnosticsTimer=null;finalReceivedAt=0;lastFinalMatchId=null;rematchAttempts=0;rematchTimer=null;rematchCountdownTimer=null;resultRevealTimer=null;resultWaitTimer=null;completeSince=null;summaryClock=new sr;fightSummary;liveFightStatus;finalSummary;corner;stylePicker;constructor(e,t=()=>window.location.reload(),n=new EI){this.root=e,this.reloadPage=t,this.authorizer=n,e.innerHTML=`
HANDStwo-player boxing

`,this.canvas=e.querySelector(`canvas`),this.status=e.querySelector(`[data-status]`),this.overlay=e.querySelector(`[data-overlay]`),this.roleIndicator=e.querySelector(`[data-role]`),this.controlsButton=e.querySelector(`[data-controls]`),this.controlsPanel=e.querySelector(`[data-controls-panel]`),this.retry=e.querySelector(`[data-retry]`),this.rematchButton=e.querySelector(`[data-rematch]`),this.hint=e.querySelector(`[data-hint]`),this.cpuPicker=e.querySelector(`[data-cpu]`),this.cpuPrompt=e.querySelector(`[data-cpu-prompt]`),this.cpuPicker.addEventListener(`click`,this.onCpuPick),this.rematchButton.addEventListener(`click`,this.onRematch),this.fightSummary=e.querySelector(`[data-fight-summary]`),this.liveFightStatus=e.querySelector(`[data-fight-status]`),this.finalSummary=e.querySelector(`[data-final]`),this.retry.addEventListener(`click`,this.onRetry),this.bindPanels(),this.syncSettings(),this.input.attachTouch(e.querySelector(`.activity`)),this.corner=new RI(e.querySelector(`.activity`),e=>this.network?.sendCornerChoice(e)??!1),this.stylePicker=new Zt(e.querySelector(`.activity`),(e,t)=>this.network?.chooseStyle(e,t)??!1),this.input.setViewForward(()=>this.renderer?.viewForward()??null),window.addEventListener(`keydown`,this.onCameraKey)}onCameraKey=e=>{if(e.code!==`KeyK`||e.repeat||e.ctrlKey||e.metaKey||e.altKey)return;let t=e.target;if(t instanceof HTMLInputElement||t instanceof HTMLSelectElement||t instanceof HTMLTextAreaElement)return;e.preventDefault();let n=$Y[($Y.indexOf(this.settings.current.camera)+1)%$Y.length];this.settings.update({camera:n}),this.root.querySelector(`[data-camera]`).value=n};start(){this.authorize()}resetForAuthorization(){this.reloadOnRetry=!1,this.network?.dispose(),this.network=null,this.session?.destroy(),this.session=null,this.renderer?.destroy(),this.renderer=null,this.voice.cancel(),this.audio.reset(),this.abort.abort(),this.abort=new AbortController,this.state=sX,this.feedbackEvents.reset(),this.input.setActive(!1),this.input.reset(),this.finalSummary.textContent=``,this.fightSummary.textContent=``,this.liveFightStatus.textContent=``,this.clearRematchTimers(),this.rematchButton.hidden=!0,this.cpuLevel=null,this.lastPhase=null}onCpuPick=e=>{let t=e.target?.closest(`[data-cpu-level]`)?.dataset.cpuLevel;vX(t)&&this.state.stage===`waiting`&&this.state.role===`fighter`&&this.cpuLevel===null&&this.callCpu(t)};callCpu(e){this.network?.requestCpu(e)===!0&&(this.cpuLevel=e,this.renderState())}get cpuBout(){return Object.values(this.state.players).some(e=>e.cpu===!0)}onRematch=()=>{this.rematchButton.disabled||this.state.stage!==`complete`||(this.rematchAttempts=1,this.rematchOpponent=this.cpuBout||this.state.role!==`fighter`?null:Object.values(this.state.players).find(e=>e.id!==this.state.playerId)?.name??null,this.authorize())};clearRematchTimers(){this.rematchTimer!==null&&window.clearTimeout(this.rematchTimer),this.rematchCountdownTimer!==null&&window.clearInterval(this.rematchCountdownTimer),this.rematchTimer=null,this.rematchCountdownTimer=null,this.clearCpuRematch()}scheduleCpuRematch(e){this.clearCpuRematch(),this.cpuRematch={level:e,at:Date.now()+gX},this.cpuRematchTimer=window.setInterval(()=>{let e=this.cpuRematch;e===null||this.state.stage!==`waiting`||this.state.role!==`fighter`||this.cpuLevel!==null?this.clearCpuRematch():Date.now()>=e.at&&(this.clearCpuRematch(),this.callCpu(e.level)),this.renderState()},250)}clearCpuRematch(){this.cpuRematchTimer!==null&&window.clearInterval(this.cpuRematchTimer),this.cpuRematchTimer=null,this.cpuRematch=null}awaitResultReveal(){this.resultRevealTimer!==null&&window.clearInterval(this.resultRevealTimer);let e=()=>{let e=this.renderer?.resultVisible??!0;this.overlay.hidden=this.state.stage===`complete`&&!e,(e||this.state.stage!==`complete`)&&this.resultRevealTimer!==null&&(window.clearInterval(this.resultRevealTimer),this.resultRevealTimer=null)};this.resultRevealTimer=window.setInterval(e,200),e()}startRematchCountdown(){this.clearRematchTimers();let e=this.state.role===`fighter`?`Rematch`:`Next bout`,t=()=>{let t=Math.ceil((this.finalReceivedAt+dX-Date.now())/1e3);this.rematchButton.hidden=this.state.stage!==`complete`,this.rematchButton.disabled=t>0,this.setText(this.rematchButton,t>0?`${e} in ${t}s`:e),t<=0&&this.rematchCountdownTimer!==null&&(window.clearInterval(this.rematchCountdownTimer),this.rematchCountdownTimer=null)};t(),this.rematchCountdownTimer=window.setInterval(t,1e3)}scheduleRematchRetry(){this.rematchTimer===null&&(this.rematchAttempts>=hX?this.fail(`rematch_unavailable`):(this.rematchAttempts+=1,this.setText(this.status,`The ring is still being cleared… trying again.`),this.rematchTimer=window.setTimeout(()=>{this.rematchTimer=null,this.authorize()},mX)))}async authorize(){let e=++this.generation;this.resetForAuthorization(),this.dispatch({type:`connecting`}),this.setText(this.status,`Securing Discord Activity session…`),this.retry.hidden=!0;try{let t=await this.authorizer.authorize(this.abort.signal);if(this.destroyed||e!==this.generation){t.destroy();return}this.session=t,this.dispatch({type:`bootstrap`,simulation:t.bootstrap.simulation}),this.dispatch({type:`authorized`,player:t.player}),this.input.onAction(e=>{this.renderer?.predictAction?.(e),this.network?.notifyAction()}),this.input.onHeldChange(()=>this.network?.notifyHeld());let n=t.takeTicket();if(n===null)throw Error(`ticket_unavailable`);let r=new qL(n,()=>this.input.frame(),{onMessage:e=>this.receive(e),onReconnect:e=>{this.dispatch({type:`reconnect-tick`,remainingMs:e}),this.renderer?.setReconnect(e),this.renderState()},onFatal:e=>this.fail(e),onFreshAuth:()=>{e===this.generation&&this.authorize()}});this.network=r,r.start(),this.setText(this.status,`Connecting to the ring…`)}catch(t){!this.abort.signal.aborted&&e===this.generation&&(this.reloadOnRetry=t instanceof kk&&t.reloadRequired,this.fail(Fk(t)))}}ensureRenderer(){if(this.renderer!==null||this.session===null||this.destroyed)return;let e=new QY(this.canvas,this.session.bootstrap.simulation,()=>this.settings.current,{localInput:()=>this.input.held(),inputSequenceOf:e=>this.network?.sequenceOf(e)??null,powerHeld:()=>this.input.powerHeld});e.onContact=(e,t)=>{this.audio.event(e,t),this.haptics.event(e,t)},e.onOwnPunch=(e,t,n)=>{this.audio.whoosh(e,t),this.soundedPunches.push(n),this.soundedPunches.length>8&&this.soundedPunches.shift()},e.onArcadeInjury=e=>this.audio.injury(e),e.onGore=e=>{this.audio.gore(e),this.haptics.gore(e),e.kind===`finish_him`?this.voice.shout(`Finish him!`):e.kind===`fatality`&&this.voice.shout(`Fatality.`)},e.onAnnouncement=e=>this.voice.speak(e),e.onCrowdCue=()=>this.audio.chant(),e.onRocked=(e,t)=>this.audio.rocked(e,t),this.renderer=e}receive(e){if(e.type===`error`){this.fail(e.code);return}e.type===`welcome`&&this.ensureRenderer(),(e.type===`welcome`||e.type===`resumed`)&&this.renderer?.resyncClock();let t=this.rematchAttempts>0;(e.type===`waiting`||e.type===`ready`)&&(this.rematchAttempts=0),e.type===`ready`&&(this.rematchOpponent=null),e.type===`ready`&&this.rememberStyle(e.players),e.type===`final`&&this.rematchAttempts>0&&e.match_id===this.lastFinalMatchId?this.scheduleRematchRetry():(this.dispatch({type:`message`,message:e}),e.type===`snapshot`&&this.receiveSnapshot(e.payload),e.type!==`select`&&e.type!==`ready`||e.players.some(e=>e.cpu===!0)||(this.cpuLevel=null),e.type===`waiting`&&(this.cpuLevel===null?t&&this.cpuRematchLevel!==null&&this.scheduleCpuRematch(this.cpuRematchLevel):this.callCpu(this.cpuLevel)),e.type===`final`&&(this.cpuRematchLevel=this.cpuBout?this.cpuLevel:null,this.rematchAttempts=0,this.lastFinalMatchId=e.match_id,this.finalReceivedAt=Date.now(),this.renderer?.setFinal(e),this.audio.result(e),this.startRematchCountdown(),this.awaitResultReveal()),this.renderer?.setPlayers(this.state.players,this.state.playerId,this.state.playerOrder),this.renderer?.setReconnect(this.state.reconnectMs),this.renderState())}get networkStats(){return{inputLatencyMs:this.network?.inputLatencyMs??null,resolutionScale:this.renderer?.resolutionScale??null,gpu:this.renderer?.memoryInfo??null}}receiveSnapshot(e){this.lastPhase===`countdown`&&e.phase!==`countdown`&&this.voice.finishLine(fX),this.lastPhase=e.phase,this.renderer?.setInputLatency(this.network?.inputLatencyMs??null),this.renderer?.push(e);let t=e.fighters.find(e=>e.player_id===this.state.playerId);this.input.setKnockdown(t?.is_downed===!0),t!==void 0&&this.audio.snapshot(e.tick,t.stamina,t.maximum_stamina,t.trauma.head+t.trauma.body),this.audio.roundClock(e.phase,e.round_number,e.phase_ticks_remaining,this.state.simulation?.tick_rate??30),this.audio.tension(WR(e));for(let t of this.feedbackEvents.accept(e.events)){if(uX.has(t.kind)||t.kind===`punch_start`&&t.action_id!==null&&this.soundedPunches.includes(t.action_id))continue;let n=t.kind===`punch_start`?e.fighters.find(e=>e.player_id===t.actor_id&&e.action_id===t.action_id):void 0;this.audio.event(t,n?.action_power===`power`),this.haptics.event(t)}}rememberStyle(e){let t=e.find(e=>e.id===this.state.playerId)?.style;this.state.role===`fighter`&&t!==void 0&&Wt(t)}dispatch(e){this.state=lX(this.state,e)}setText(e,t){e.textContent!==t&&(e.textContent=t)}renderState(){let e={bootstrapping:`Loading…`,authorizing:`Authorizing with Discord…`,connecting:`Connecting securely…`,waiting:this.state.role===`spectator`?`Waiting for the fighters…`:this.cpuLevel===null?this.cpuRematch===null?this.rematchOpponent===null?`Waiting for an opponent. Anyone in this channel can join with Play now.`:`Waiting for ${this.rematchOpponent} to take the rematch…`:`Rematch with the ${_X.find(e=>e.level===this.cpuRematch?.level)?.label??`computer`} in ${Math.max(1,Math.ceil((this.cpuRematch.at-Date.now())/1e3))}s, unless someone joins first.`:`Calling in the computer…`,select:`Pick how your fighter boxes.`,countdown:`Bout countdown.`,fight:`Round ${this.state.snapshot?.round_number??1} in progress.`,knockdown:`Knockdown count ${this.state.snapshot?.fighters.find(e=>e.player_id===this.state.playerId)?.get_up_count??0}.`,foul_recovery:`Foul recovery in progress.`,referee_down:`The referee is down. The bout goes on without him.`,finish:this.state.snapshot!==null&&Dr(this.state.snapshot.fighters)?.player_id===this.state.playerId?`You are out on your feet: one more punch kills you.`:`Finish him: one more punch kills.`,rest:`Between-round rest.`,paused:`Connection paused. ${Math.ceil(this.state.reconnectMs/1e3)} seconds remain.`,complete:this.cpuBout?`Bout complete. Scorecards are displayed. Bouts against the computer are unrated.`:`Bout complete. Scorecards and rating changes are displayed.`,fatal:BI(this.state.safeError??`safe_error`)},t=this.state.role===`spectator`;this.setText(this.status,t?`Spectating — ${e[this.state.stage]}`:e[this.state.stage]);let n=this.state.stage===`complete`&&this.state.final!==null;if(this.status.hidden=n||[`select`,`countdown`,`fight`,`knockdown`,`foul_recovery`,`referee_down`,`finish`,`rest`].includes(this.state.stage),this.overlay.toggleAttribute(`data-raised`,this.state.snapshot!==null),this.overlay.toggleAttribute(`data-result`,n),this.state.stage!==`complete`)this.overlay.hidden=!1,this.completeSince=null;else if(this.state.final===null){this.completeSince??=Date.now();let e=Date.now()-this.completeSince;this.overlay.hidden=e{this.resultWaitTimer=null,this.renderState()},pX-e+50))}this.roleIndicator.hidden=!t,this.controlsButton.hidden=t,t&&(this.controlsPanel.hidden=!0,this.controlsButton.setAttribute(`aria-expanded`,`false`));let r=this.state.snapshot?.fighters.find(e=>e.player_id===this.state.playerId),i=t?`Spectating. ${e[this.state.stage]}`:this.state.stage===`knockdown`&&r?.is_downed===!0?`Knockdown. Count ${r.get_up_count}. ${r.get_up_prompt===null?`Wait for your private rhythm instruction.`:`Press ${r.get_up_prompt===`get_up_left`?`left`:`right`} now.`}`:this.state.stage===`paused`?`Connection paused.`:e[this.state.stage];this.setText(this.liveFightStatus,i),this.corner.update(this.state.snapshot,this.state.playerId,this.state.role===`fighter`&&this.state.stage===`rest`),this.renderer?.setCornerPanelTop(this.corner.top()),this.stylePicker.update(this.state.stage===`select`?this.state.select:null,this.state.playerId,this.state.role),this.retry.hidden=this.state.stage!==`fatal`,this.setText(this.retry,this.reloadOnRetry?`Reload`:`Retry securely`),this.state.stage!==`complete`&&(this.rematchButton.hidden=!0),this.cpuPicker.hidden=t||this.state.stage!==`waiting`||this.cpuLevel!==null,this.setText(this.cpuPrompt,this.cpuRematch===null?this.rematchOpponent===null?`No one here yet? Fight the computer.`:`Or fight the computer instead:`:`Or start now:`);let a=!t&&(this.state.stage===`waiting`||this.state.stage===`countdown`);this.hint.hidden=!a,a&&this.setText(this.hint,nL(VI(),window.innerWidth)),this.overlay.toggleAttribute(`data-touch-hint`,a&&this.state.stage===`countdown`&&VI());let o=!t&&[`countdown`,`fight`,`knockdown`,`foul_recovery`,`referee_down`,`finish`].includes(this.state.stage),s=!t&&this.state.snapshot!==null&&(this.state.stage===`rest`||this.state.stage===`paused`);if(this.input.setActive(o,o||s),this.network?.setActive(o),this.renderFightSummary(),this.state.final!==null){let e=this.state.final;this.setText(this.finalSummary,`${e.method.replaceAll(`_`,` `)}. ${e.winner_id===null?`Draw`:`${this.state.players[e.winner_id]?.name??`Winner`} wins`}. Scorecards: ${e.scorecards.map(e=>`${e.judge}: ${e.player_one.reduce((e,t)=>e+t,0)} to ${e.player_two.reduce((e,t)=>e+t,0)}`).join(`; `)}. ${this.cpuBout?`Unrated bout against the computer.`:`Ratings: ${Object.entries(e.ratings).map(([e,t])=>`${this.state.players[e]?.name??`fighter`} ${t.before} to ${t.after}`).join(`; `)}.`}`)}}renderFightSummary(){let e=this.state.snapshot;if(e===null)return;let t=this.state.simulation?.tick_rate??30,n=Math.floor(this.summaryClock.ticks(e)/t),r=`${Math.floor(n/60)}:${String(n%60).padStart(2,`0`)}`,i=e.fighters.map(e=>{let t=this.state.players[e.player_id],n=e.injuries.length===0?`no injuries`:`injuries: ${e.injuries.map(e=>Ee(e).toLowerCase()).join(`, `)}`;return`${t?.name??`Fighter`}, ${t?.cpu===!0?`computer opponent`:`ELO ${t?.rating??`unknown`}`}, stamina ${Math.round(e.stamina)} of ${Math.round(e.maximum_stamina)}, guard ${Math.round(e.guard)}, poise ${Math.round(e.poise)}, conditioning ${Math.round(e.conditioning)}, blood ${Math.round(e.blood_volume/be*100)} percent, ${n}, ${e.warnings} warnings, ${e.knockdowns} knockdowns`}),a=e.fighters.find(e=>e.player_id===this.state.playerId),o=a?.is_downed===!0?a.get_up_prompt===null?`You are down. Count ${a.get_up_count}. Wait for your private rhythm instruction.`:`You are down. Count ${a.get_up_count}. Press ${a.get_up_prompt===`get_up_left`?`left`:`right`} now. Get-up progress ${a.get_up_meter} of ${a.get_up_required}.`:``;this.setText(this.fightSummary,`Round ${e.round_number}. ${e.phase.replace(`_`,` `)}. Clock ${r}. ${i.join(`. `)}. ${o}`.trim())}onRetry=()=>{this.reloadOnRetry?(this.reloading=!0,this.reloadPage()):this.authorize()};bindPanels(){let e=(e,t)=>{let n=this.root.querySelector(e),r=this.root.querySelector(t);n.addEventListener(`click`,()=>{r.hidden=!r.hidden,n.setAttribute(`aria-expanded`,String(!r.hidden))})};e(`[data-controls]`,`[data-controls-panel]`),e(`[data-settings]`,`[data-settings-panel]`);let t=this.root.querySelector(`[data-settings-panel]`);this.root.querySelector(`[data-settings]`).addEventListener(`click`,()=>{this.diagnosticsTimer!==null&&window.clearInterval(this.diagnosticsTimer),this.diagnosticsTimer=null,t.hidden||(this.refreshDiagnostics(),this.diagnosticsTimer=window.setInterval(()=>this.refreshDiagnostics(),1e3))});let n=this.root.querySelector(`[data-copy-diagnostics]`);n.addEventListener(`click`,()=>{let e=this.diagnosticsText(),t=()=>{this.setText(n,`Copied`),window.setTimeout(()=>this.setText(n,`Copy diagnostics`),1500)},r=()=>{let e=this.root.querySelector(`[data-diagnostics]`),t=window.getSelection();if(t===null)return;let r=document.createRange();r.selectNodeContents(e),t.removeAllRanges(),t.addRange(r),this.setText(n,`Selected. Copy manually`),window.setTimeout(()=>this.setText(n,`Copy diagnostics`),2500)},i=navigator.clipboard;i===void 0||typeof i.writeText!=`function`?r():i.writeText(e).then(t).catch(r)}),this.root.querySelector(`[data-volume]`).addEventListener(`input`,e=>{this.settings.update({volume:Number(e.target.value)}),this.audio.setVolume(),this.voice.settingsChanged()}),this.root.querySelector(`[data-haptics]`).addEventListener(`change`,e=>{this.settings.update({haptics:e.target.checked})}),this.root.querySelector(`[data-motion]`).addEventListener(`change`,e=>{let t=e.target.checked;this.settings.update({reducedMotion:t}),this.renderer?.setReducedMotion(t)}),this.root.querySelector(`[data-commentary]`).addEventListener(`change`,e=>{this.settings.update({commentary:e.target.checked})}),this.root.querySelector(`[data-announcer]`).addEventListener(`change`,e=>{let t=e.target.checked;this.settings.update({announcer:t}),t||this.voice.cancel()}),this.root.querySelector(`[data-blood]`).addEventListener(`change`,e=>{let t=e.target.value;this.settings.update({blood:t}),this.renderer?.setBloodLevel(t)}),this.root.querySelector(`[data-camera]`).addEventListener(`change`,e=>{let t=$Y.find(t=>t===e.target.value);t!==void 0&&this.settings.update({camera:t})})}diagnosticsText(){let e=this.networkStats,t=this.renderer?.diagnostics,n=t===void 0||t.frameMs<=0?`-`:(1e3/t.frameMs).toFixed(0);return[`stage: ${this.state.stage} · role: ${this.state.role??`-`}`,`input latency: ${e.inputLatencyMs===null?`-`:`${Math.round(e.inputLatencyMs)} ms`}`,`frame: ${t===void 0?`-`:`${t.frameMs.toFixed(1)} ms (${n} fps)`} · render scale: ${t?.resolutionScale??`-`}`,`gpu objects: ${t===void 0?`-`:`${t.gpu.geometries} geometries, ${t.gpu.textures} textures, ${t.gpu.programs} programs`}`,`graphics: ${t?.graphics??`-`}`,`browser: ${navigator.userAgent}`,`pointer: ${VI()?`coarse`:`fine`} · viewport: ${window.innerWidth}x${window.innerHeight} @${window.devicePixelRatio}`,`last error: ${this.state.safeError??`none`}`,`match: ${this.state.final?.match_id??`-`}`].join(` +`)}refreshDiagnostics(){this.setText(this.root.querySelector(`[data-diagnostics]`),this.diagnosticsText())}syncSettings(){let e=this.settings.current;this.root.querySelector(`[data-volume]`).value=String(e.volume),this.root.querySelector(`[data-haptics]`).checked=e.haptics,this.root.querySelector(`[data-motion]`).checked=e.reducedMotion,this.root.querySelector(`[data-blood]`).value=e.blood,this.root.querySelector(`[data-commentary]`).checked=e.commentary,this.syncAnnouncerSetting(),this.voice.onVoicesChanged=()=>this.syncAnnouncerSetting(),this.root.querySelector(`[data-camera]`).value=e.camera}syncAnnouncerSetting(){let e=this.root.querySelector(`[data-announcer]`),t=this.voice.hasVoice;e.checked=this.settings.current.announcer&&t,e.disabled=!t;let n=this.voice.supported?t?null:`This device has no English voice of its own`:`This browser cannot speak`;n===null?e.parentElement.removeAttribute(`title`):e.parentElement.title=n}fail(e){e===`room_closed`&&this.rematchAttempts>0?this.scheduleRematchRetry():(e===`client_outdated`&&(this.reloadOnRetry=!0),this.dispatch({type:`fatal`,code:e}),this.rematchOpponent=null,this.voice.cancel(),this.network?.dispose(),this.network=null,this.session?.destroy(),this.session=null,this.renderer?.destroy(),this.renderer=null,this.input.setActive(!1),this.input.reset(),this.renderState())}destroy(){this.destroyed||(this.destroyed=!0,this.generation+=1,this.abort.abort(),this.network?.dispose(),this.session?.destroy(),this.reloading||this.authorizer.close(),this.renderer?.destroy(),window.removeEventListener(`keydown`,this.onCameraKey),this.input.destroy(),this.corner.destroy(),this.stylePicker.destroy(),this.audio.destroy(),this.voice.destroy(),this.settings.destroy(),this.retry.removeEventListener(`click`,this.onRetry),this.rematchButton.removeEventListener(`click`,this.onRematch),this.cpuPicker.removeEventListener(`click`,this.onCpuPick),this.clearRematchTimers(),this.diagnosticsTimer!==null&&window.clearInterval(this.diagnosticsTimer),this.resultRevealTimer!==null&&window.clearInterval(this.resultRevealTimer),this.resultWaitTimer!==null&&window.clearTimeout(this.resultWaitTimer),this.diagnosticsTimer=null,this.root.replaceChildren())}};(new URLSearchParams(window.location.search).get(`styles`)??``).split(`,`);var bX={broadcast:{position:[0,1.88,7.15],lookAt:[0,1.12,0]},side:{position:[7.4,1.6,0],lookAt:[0,1.1,0]},top:{position:[.01,8.5,.01],lookAt:[0,0,0]},ringside:{position:[1.6,1.5,4.1],lookAt:[.2,1.25,0]}},xX=[[`hips`,`spine`],[`spine`,`head`],[`chest`,`shoulderL`],[`shoulderL`,`elbowL`],[`elbowL`,`gloveL`],[`chest`,`shoulderR`],[`shoulderR`,`elbowR`],[`elbowR`,`gloveR`],[`hips`,`hipL`],[`hipL`,`kneeL`],[`kneeL`,`ankleL`],[`hips`,`hipR`],[`hipR`,`kneeR`],[`kneeR`,`ankleR`]],SX=class{root;renderer=null;replay=null;raf=0;playing=!1;speed=1;virtualTick=0;carry=0;latencyMs=0;pendingQueue=[];destroyed=!1;overlays={skeleton:!1,hurtbox:!1,hitbox:!1};skeletonLines=[];hurtboxMeshes=[];hitboxMeshes=[];statusEl;metricsEl;canvas;constructor(e){this.root=e,e.innerHTML=`
HANDS LABloading replay…
@@ -5402,7 +5550,7 @@ void main() { -
`,this.canvas=e.querySelector(`canvas`),this.statusEl=e.querySelector(`[data-lab-status]`),this.metricsEl=e.querySelector(`[data-lab-metrics]`),this.bindControls()}async start(){let e=new URLSearchParams(window.location.search),t=e.get(`replay`)??`golden`,n=await fetch(`/replays/${t}.json`);if(n.ok||(n=await fetch(`/hands/replays/${t}.json`)),!n.ok)throw Error(`replay_load_failed:${n.status}`);this.replay=await n.json(),await mF(),this.renderer=new Rq(this.canvas,{tick_rate:this.replay.tick_rate,ring_half_width:500,ring_half_height:500},()=>({volume:0,haptics:!1,reducedMotion:!1,blood:`full`,commentary:!0,announcer:!1,camera:`broadcast`}),{manualClock:!0});let r=Object.fromEntries(this.replay.ticks[0].snapshot.payload.fighters.map(e=>[e.player_id,{id:e.player_id,name:e.player_id===`one`?`Azure Vector`:`Crimson Geometry`,avatar:null,rating:1500,connected:!0}]));this.renderer.setPlayers(r,`one`),this.buildOverlays();let i=e.get(`tick`);if(e.get(`metrics`)===`1`){await this.renderer.ready,this.exportMetrics(),this.setStatus(`metrics done`);return}if(i!==null){let t=Number(i);await this.renderer.ready,this.seek(t);let n=oJ[e.get(`camera`)??``]??oJ.broadcast;this.renderer.labSetCameraOverride(n.position,n.lookAt),this.overlays.skeleton=e.get(`skeleton`)===`1`,this.overlays.hurtbox=e.get(`hurtbox`)===`1`,this.overlays.hitbox=e.get(`hitbox`)===`1`,this.syncOverlayVisibility(),this.renderCurrentTick(),window.__labDebug={roots:this.renderer.labRigs.map(e=>e.position.toArray().map(e=>Number(e.toFixed(3)))),heads:this.renderer.labRigs.map(e=>{let t=e.getObjectByName(Qk.head??`head`);return t===void 0?null:t.getWorldPosition(new q).toArray().map(e=>Number(e.toFixed(3)))}),gloves:this.renderer.labRigs.map(e=>{let t=e.getObjectByName(Qk.gloveL??`gloveL`);return t===void 0?null:t.getWorldPosition(new q).toArray().map(e=>Number(e.toFixed(3)))}),material:(()=>{let e=null;return this.renderer.labRigs[0]?.traverse(t=>{if(e===null&&t instanceof Hv){let n=t.material;e={colorHex:n.color.getHexString(),hasMap:n.map!==null,mapImage:n.map?.image?.width??`none`,mapVersion:n.map?.version,clearcoat:n.clearcoat,opacity:n.opacity}}}),e})()},this.setStatus(`filmstrip tick ${t}`);return}this.playing=!0;let a=()=>{this.destroyed||(this.advance(),this.raf=requestAnimationFrame(a))};this.raf=requestAnimationFrame(a)}bindControls(){this.root.querySelector(`[data-lab='play']`).addEventListener(`click`,e=>{this.playing=!this.playing,e.target.textContent=this.playing?`Pause`:`Play`}),this.root.querySelector(`[data-lab='step']`).addEventListener(`click`,()=>{this.playing=!1,this.root.querySelector(`[data-lab='play']`).textContent=`Play`,this.virtualTick=Math.min(this.virtualTick+1,(this.replay?.ticks.length??1)-1),this.pushUpTo(this.virtualTick),this.renderCurrentTick()}),this.root.querySelector(`[data-lab='speed']`).addEventListener(`change`,e=>{this.speed=Number(e.target.value)}),this.root.querySelector(`[data-lab='camera']`).addEventListener(`change`,e=>{let t=oJ[e.target.value];this.renderer?.labSetCameraOverride(t.position,t.lookAt)});for(let e of[`skeleton`,`hurtbox`,`hitbox`])this.root.querySelector(`[data-lab='${e}']`).addEventListener(`change`,t=>{this.overlays[e]=t.target.checked,this.syncOverlayVisibility()});this.root.querySelector(`[data-lab='latency']`).addEventListener(`change`,e=>{this.latencyMs=Math.max(0,Math.min(500,Number(e.target.value)))}),this.root.querySelector(`[data-lab='metrics']`).addEventListener(`click`,()=>this.exportMetrics())}advance(){if(!this.playing||this.replay===null)return;let e=this.replay.ticks.length-1;if(!(this.virtualTick>=e)){for(this.carry+=this.speed;this.carry>=1&&this.virtualTick0?this.pendingQueue.push({at:performance.now()+this.latencyMs,tick:t}):this.renderer?.push(t.snapshot.payload))}drainLatencyQueue(){let e=performance.now();for(let t=this.pendingQueue.length-1;t>=0;--t){let n=this.pendingQueue[t];n.at<=e&&(this.renderer?.push(n.tick.snapshot.payload),this.pendingQueue.splice(t,1))}}seek(e,t=!0){if(this.replay===null||this.renderer===null)return;let n=Math.max(0,Math.min(e,this.replay.ticks.length-1));for(let e=0;e<=n;e+=1)this.renderer.push(this.replay.ticks[e].snapshot.payload),e>=n-15&&this.renderer.labEffects.update(1/30);this.virtualTick=n,this.renderOnSeek=t}renderOnSeek=!0;renderCurrentTick(e){if(this.replay===null||this.renderer===null)return;this.drainLatencyQueue(),this.renderer.labFrame(this.virtualTick/this.replay.tick_rate,e??this.renderOnSeek),this.renderer.labFrame((this.virtualTick+.5)/this.replay.tick_rate,e??this.renderOnSeek),this.updateOverlays();let t=this.replay.ticks[this.virtualTick]?.snapshot.payload.phase??``;this.setStatus(`tick ${this.virtualTick}/${this.replay.ticks.length-1} · ${t} · ${this.speed}×`)}buildOverlays(){let e=this.renderer;if(e===null)return;let t=new sy({color:8257448,depthTest:!1,transparent:!0,opacity:.9});for(let n of e.labRigs){let r=new iv;r.setAttribute(`position`,new U_(new Float32Array(sJ.length*6),3));let i=new yy(r,t);i.frustumCulled=!1,i.renderOrder=20,e.labScene.add(i),this.skeletonLines.push(i);let a=new Y(new Py(.13,.16,4,8),new yv({color:16735581,wireframe:!0,transparent:!0,opacity:.85,depthTest:!1}));a.renderOrder=21,a.position.y=.12,(n.getObjectByName(Qk.head??`head`)??n).add(a),this.hurtboxMeshes.push(a);let o=new Y(new Py(.21,.34,4,8),new yv({color:16758877,wireframe:!0,transparent:!0,opacity:.7,depthTest:!1}));o.renderOrder=21,o.position.y=.16,(n.getObjectByName(Qk.chest??`chest`)??n).add(o),this.hurtboxMeshes.push(o);for(let e of[`gloveL`,`gloveR`]){let t=new Y(new _b(.11,10,8),new yv({color:6141183,wireframe:!0,transparent:!0,opacity:.85,depthTest:!1}));t.renderOrder=22,(n.getObjectByName(Qk[e]??e)??n).add(t),this.hitboxMeshes.push(t)}}this.syncOverlayVisibility()}syncOverlayVisibility(){for(let e of this.skeletonLines)e.visible=this.overlays.skeleton;for(let e of this.hurtboxMeshes)e.visible=this.overlays.hurtbox;for(let e of this.hitboxMeshes)e.visible=this.overlays.hitbox}updateOverlays(){let e=this.renderer;if(e!==null)for(let[t,n]of e.labRigs.entries()){let e=this.skeletonLines[t];if(e===void 0||!e.visible)continue;let r=e.geometry.getAttribute(`position`),i=new q,a=new q;sJ.forEach(([e,t],o)=>{let s=n.getObjectByName(e),c=n.getObjectByName(t);s!==void 0&&c!==void 0&&(s.getWorldPosition(i),c.getWorldPosition(a),r.setXYZ(o*2,i.x,i.y,i.z),r.setXYZ(o*2+1,a.x,a.y,a.z))}),r.needsUpdate=!0}}jointWorld(e,t){let n=(this.renderer?.labRigs[e])?.getObjectByName(Qk[t]??t);return n==null?null:n.getWorldPosition(new q)}exportMetrics(){if(this.replay===null)return;let e={contactAlignment:[],maxRootStepMeters:0,footSlideMeters:0,phaseDriftTicks:0};for(let t of this.replay.ticks){let n=t.snapshot.payload.events.find(e=>[`hit`,`counter_hit`,`block`].includes(e.kind)),r=t.snapshot.payload.fighters[0].action_hand;if(n===void 0||r===null)continue;let i=Math.min(t.tick+1,this.replay.ticks.length-1);this.seek(i,!1),this.renderCurrentTick(!1);let a=this.jointWorld(0,r===`left`?`gloveL`:`gloveR`),o=this.jointWorld(1,`head`),c=this.jointWorld(1,`chest`);a!==null&&o!==null&&c!==null&&e.contactAlignment.push({tick:t.tick,kind:n.kind,gloveToHeadMeters:Number(Math.max(0,a.distanceTo(o)-s.head.radius).toFixed(4)),gloveToTorsoMeters:Number(Math.max(0,a.distanceTo(c)-s.torso.radius).toFixed(4))})}this.seek(0,!1);let t=null,n=null;for(let r of this.replay.ticks){this.seek(r.tick,!1),this.renderCurrentTick(!1);let i=this.renderer.labRigs[0].position.x;n!==null&&(e.maxRootStepMeters=Math.max(e.maxRootStepMeters,Math.abs(i-n))),n=i;let a=r.snapshot.payload.fighters[0],o=Math.hypot(a.velocity_x,a.velocity_y),s=this.replay.ticks.slice(Math.max(0,r.tick-30),r.tick+1).some(e=>e.snapshot.payload.fighters[0].is_downed);if(o===0&&!a.is_downed&&!s&&r.snapshot.payload.phase===`fight`){let n=[this.jointWorld(0,`ankleL`),this.jointWorld(0,`ankleR`)].filter(e=>e!==null);t!==null&&n.length===2&&(e.footSlideMeters=Math.max(e.footSlideMeters,Number(Math.max(n[0].distanceTo(t[0]),n[1].distanceTo(t[1])).toFixed(4)))),t=n}else t=null}this.metricsEl.textContent=` contacts: ${e.contactAlignment.map(e=>`${e.kind}@t${e.tick} glove-head ${e.gloveToHeadMeters}m`).join(` · `)} · max root step ${e.maxRootStepMeters.toFixed(3)}m · foot slide ${e.footSlideMeters}m`,window.__labDebug={roots:this.renderer.labRigs.map(e=>e.position.toArray().map(e=>Number(e.toFixed(3)))),graphsActive:this.renderer.graphs!==null,heads:this.renderer.labRigs.map(e=>{let t=e.getObjectByName(Qk.head??`head`);return t===void 0?null:t.getWorldPosition(new q).toArray().map(e=>Number(e.toFixed(3)))})};let r=new Blob([JSON.stringify(e,null,1)],{type:`application/json`}),i=document.createElement(`a`);i.href=URL.createObjectURL(r),i.download=`hands-lab-metrics.json`,i.click(),URL.revokeObjectURL(i.href)}setStatus(e){this.statusEl.textContent!==e&&(this.statusEl.textContent=e)}destroy(){this.destroyed||(this.destroyed=!0,cancelAnimationFrame(this.raf),this.renderer?.destroy(),this.root.replaceChildren())}};function lJ(e){let t=new cJ(e);return t.start().catch(t=>{e.querySelector(`[data-lab-status]`).textContent=`lab failed: ${String(t)}`}),()=>t.destroy()}var uJ={referee:{outfit:Pj,look:hj.referee},corner_blue:{outfit:Fj,look:hj.blueCorner},corner_red:{outfit:Ij,look:hj.redCorner},cutman:{outfit:Lj,look:hj.blueCutman}},dJ=()=>({player_id:`lab`,x:0,y:0,facing:1,facing_x:0,facing_y:-1e3,velocity_x:0,velocity_y:0,stance:`orthodox`,style:`balanced`,defense:`none`,stamina:1e3,maximum_stamina:1e3,conditioning:1e3,guard:700,guard_broken:!1,poise:600,trauma:{head:0,body:0,left_eye:0,right_eye:0,left_cut:0,right_cut:0,swelling:0,bleeding:0},knockdowns:0,warnings:0,deductions:0,stunned_ticks:0,is_downed:!1,action:null,action_hand:null,action_target:null,action_power:null,action_id:null,action_key:null,action_start_tick:0,action_startup_ticks:0,action_active_ticks:0,action_recovery_ticks:0,action_contact_tick:null,queued_actions:0,clinch_startup_ticks:0,clinch_ticks:0,is_foul_recovery_target:!1,taunt_ticks:0,corner_choice:null,get_up_prompt:null,get_up_meter:0,get_up_required:0,get_up_count:0,get_up_window_start_tick:0,get_up_window_end_tick:0,last_input_sequence:-1,injuries:[],blood_volume:1e3}),fJ=.45,pJ=.3,mJ={face:[.25,1.55,1],portrait:[.12,1.62,.62],eyes:[-.2,1.65,.44],floor:[1.62,.3,.18],hand:[.55,1.05,.75],front:[0,1.35,3.4],side:[3.4,1.3,.2],"three-quarter":[2.4,1.5,2.6],top:[.01,4.5,.6],back:[.2,1.4,-3.4],low:[1.8,.5,2.6],wide:[3.4,2.7,3.6]},hJ=class{root;renderer;scene=new u_;camera;graph=null;boxer=null;trails=[];trailGlove=new q;treatEye=new q(0,1.22,.78);treatFacing=new q(0,0,-1);treatTarget=new q;skeletonHelper=null;effects=null;shieldClock=1/0;shieldEvent=0;mouth=new q;headTurn=new rg;burstRim=new Float32Array;burstStump={position:new q,quaternion:new rg,across:new q,scratch:new q};raf=0;previous=performance.now();elapsed=0;params=new URLSearchParams(window.location.search);reactionFired=!1;carnage=null;injuries=[];inflictions=[];killed=!1;vomitClock=0;headAt=new q;statusEl;constructor(e){this.root=e,e.innerHTML=`
+
`,this.canvas=e.querySelector(`canvas`),this.statusEl=e.querySelector(`[data-lab-status]`),this.metricsEl=e.querySelector(`[data-lab-metrics]`),this.bindControls()}async start(){let e=new URLSearchParams(window.location.search),t=e.get(`replay`)??`golden`,n=await fetch(`/replays/${t}.json`);if(n.ok||(n=await fetch(`/hands/replays/${t}.json`)),!n.ok)throw Error(`replay_load_failed:${n.status}`);this.replay=await n.json(),await YC(),this.renderer=new QY(this.canvas,{tick_rate:this.replay.tick_rate,ring_half_width:500,ring_half_height:500},()=>({volume:0,haptics:!1,reducedMotion:!1,blood:`full`,commentary:!0,announcer:!1,camera:`broadcast`}),{manualClock:!0});let r=Object.fromEntries(this.replay.ticks[0].snapshot.payload.fighters.map(e=>[e.player_id,{id:e.player_id,name:e.player_id===`one`?`Azure Vector`:`Crimson Geometry`,avatar:null,rating:1500,connected:!0}]));this.renderer.setPlayers(r,`one`),this.buildOverlays();let i=e.get(`tick`);if(e.get(`metrics`)===`1`){await this.renderer.ready,this.exportMetrics(),this.setStatus(`metrics done`);return}if(i!==null){let t=Number(i);await this.renderer.ready,this.seek(t);let n=bX[e.get(`camera`)??``]??bX.broadcast;this.renderer.labSetCameraOverride(n.position,n.lookAt),this.overlays.skeleton=e.get(`skeleton`)===`1`,this.overlays.hurtbox=e.get(`hurtbox`)===`1`,this.overlays.hitbox=e.get(`hitbox`)===`1`,this.syncOverlayVisibility(),this.renderCurrentTick(),window.__labDebug={roots:this.renderer.labRigs.map(e=>e.position.toArray().map(e=>Number(e.toFixed(3)))),heads:this.renderer.labRigs.map(e=>{let t=e.getObjectByName(gy.head??`head`);return t===void 0?null:t.getWorldPosition(new z).toArray().map(e=>Number(e.toFixed(3)))}),gloves:this.renderer.labRigs.map(e=>{let t=e.getObjectByName(gy.gloveL??`gloveL`);return t===void 0?null:t.getWorldPosition(new z).toArray().map(e=>Number(e.toFixed(3)))}),material:(()=>{let e=null;return this.renderer.labRigs[0]?.traverse(t=>{if(e===null&&t instanceof rl){let n=t.material;e={colorHex:n.color.getHexString(),hasMap:n.map!==null,mapImage:n.map?.image?.width??`none`,mapVersion:n.map?.version,clearcoat:n.clearcoat,opacity:n.opacity}}}),e})()},this.setStatus(`filmstrip tick ${t}`);return}this.playing=!0;let a=()=>{this.destroyed||(this.advance(),this.raf=requestAnimationFrame(a))};this.raf=requestAnimationFrame(a)}bindControls(){this.root.querySelector(`[data-lab='play']`).addEventListener(`click`,e=>{this.playing=!this.playing,e.target.textContent=this.playing?`Pause`:`Play`}),this.root.querySelector(`[data-lab='step']`).addEventListener(`click`,()=>{this.playing=!1,this.root.querySelector(`[data-lab='play']`).textContent=`Play`,this.virtualTick=Math.min(this.virtualTick+1,(this.replay?.ticks.length??1)-1),this.pushUpTo(this.virtualTick),this.renderCurrentTick()}),this.root.querySelector(`[data-lab='speed']`).addEventListener(`change`,e=>{this.speed=Number(e.target.value)}),this.root.querySelector(`[data-lab='camera']`).addEventListener(`change`,e=>{let t=bX[e.target.value];this.renderer?.labSetCameraOverride(t.position,t.lookAt)});for(let e of[`skeleton`,`hurtbox`,`hitbox`])this.root.querySelector(`[data-lab='${e}']`).addEventListener(`change`,t=>{this.overlays[e]=t.target.checked,this.syncOverlayVisibility()});this.root.querySelector(`[data-lab='latency']`).addEventListener(`change`,e=>{this.latencyMs=Math.max(0,Math.min(500,Number(e.target.value)))}),this.root.querySelector(`[data-lab='metrics']`).addEventListener(`click`,()=>this.exportMetrics())}advance(){if(!this.playing||this.replay===null)return;let e=this.replay.ticks.length-1;if(!(this.virtualTick>=e)){for(this.carry+=this.speed;this.carry>=1&&this.virtualTick0?this.pendingQueue.push({at:performance.now()+this.latencyMs,tick:t}):this.renderer?.push(t.snapshot.payload))}drainLatencyQueue(){let e=performance.now();for(let t=this.pendingQueue.length-1;t>=0;--t){let n=this.pendingQueue[t];n.at<=e&&(this.renderer?.push(n.tick.snapshot.payload),this.pendingQueue.splice(t,1))}}seek(e,t=!0){if(this.replay===null||this.renderer===null)return;let n=Math.max(0,Math.min(e,this.replay.ticks.length-1));for(let e=0;e<=n;e+=1)this.renderer.push(this.replay.ticks[e].snapshot.payload),e>=n-15&&this.renderer.labEffects.update(1/30);this.virtualTick=n,this.renderOnSeek=t}renderOnSeek=!0;renderCurrentTick(e){if(this.replay===null||this.renderer===null)return;this.drainLatencyQueue(),this.renderer.labFrame(this.virtualTick/this.replay.tick_rate,e??this.renderOnSeek),this.renderer.labFrame((this.virtualTick+.5)/this.replay.tick_rate,e??this.renderOnSeek),this.updateOverlays();let t=this.replay.ticks[this.virtualTick]?.snapshot.payload.phase??``;this.setStatus(`tick ${this.virtualTick}/${this.replay.ticks.length-1} · ${t} · ${this.speed}×`)}buildOverlays(){let e=this.renderer;if(e===null)return;let t=new Sl({color:8257448,depthTest:!1,transparent:!0,opacity:.9});for(let n of e.labRigs){let r=new yc;r.setAttribute(`position`,new ic(new Float32Array(xX.length*6),3));let i=new Pl(r,t);i.frustumCulled=!1,i.renderOrder=20,e.labScene.add(i),this.skeletonLines.push(i);let a=new V(new Yl(.13,.16,4,8),new Pc({color:16735581,wireframe:!0,transparent:!0,opacity:.85,depthTest:!1}));a.renderOrder=21,a.position.y=.12,(n.getObjectByName(gy.head??`head`)??n).add(a),this.hurtboxMeshes.push(a);let o=new V(new Yl(.21,.34,4,8),new Pc({color:16758877,wireframe:!0,transparent:!0,opacity:.7,depthTest:!1}));o.renderOrder=21,o.position.y=.16,(n.getObjectByName(gy.chest??`chest`)??n).add(o),this.hurtboxMeshes.push(o);for(let e of[`gloveL`,`gloveR`]){let t=new V(new Mu(.11,10,8),new Pc({color:6141183,wireframe:!0,transparent:!0,opacity:.85,depthTest:!1}));t.renderOrder=22,(n.getObjectByName(gy[e]??e)??n).add(t),this.hitboxMeshes.push(t)}}this.syncOverlayVisibility()}syncOverlayVisibility(){for(let e of this.skeletonLines)e.visible=this.overlays.skeleton;for(let e of this.hurtboxMeshes)e.visible=this.overlays.hurtbox;for(let e of this.hitboxMeshes)e.visible=this.overlays.hitbox}updateOverlays(){let e=this.renderer;if(e!==null)for(let[t,n]of e.labRigs.entries()){let e=this.skeletonLines[t];if(e===void 0||!e.visible)continue;let r=e.geometry.getAttribute(`position`),i=new z,a=new z;xX.forEach(([e,t],o)=>{let s=n.getObjectByName(e),c=n.getObjectByName(t);s!==void 0&&c!==void 0&&(s.getWorldPosition(i),c.getWorldPosition(a),r.setXYZ(o*2,i.x,i.y,i.z),r.setXYZ(o*2+1,a.x,a.y,a.z))}),r.needsUpdate=!0}}jointWorld(e,t){let n=(this.renderer?.labRigs[e])?.getObjectByName(gy[t]??t);return n==null?null:n.getWorldPosition(new z)}exportMetrics(){if(this.replay===null)return;let e={contactAlignment:[],maxRootStepMeters:0,footSlideMeters:0,phaseDriftTicks:0};for(let t of this.replay.ticks){let n=t.snapshot.payload.events.find(e=>[`hit`,`counter_hit`,`block`].includes(e.kind)),r=t.snapshot.payload.fighters[0].action_hand;if(n===void 0||r===null)continue;let i=Math.min(t.tick+1,this.replay.ticks.length-1);this.seek(i,!1),this.renderCurrentTick(!1);let a=this.jointWorld(0,r===`left`?`gloveL`:`gloveR`),o=this.jointWorld(1,`head`),c=this.jointWorld(1,`chest`);a!==null&&o!==null&&c!==null&&e.contactAlignment.push({tick:t.tick,kind:n.kind,gloveToHeadMeters:Number(Math.max(0,a.distanceTo(o)-s.head.radius).toFixed(4)),gloveToTorsoMeters:Number(Math.max(0,a.distanceTo(c)-s.torso.radius).toFixed(4))})}this.seek(0,!1);let t=null,n=null;for(let r of this.replay.ticks){this.seek(r.tick,!1),this.renderCurrentTick(!1);let i=this.renderer.labRigs[0].position.x;n!==null&&(e.maxRootStepMeters=Math.max(e.maxRootStepMeters,Math.abs(i-n))),n=i;let a=r.snapshot.payload.fighters[0],o=Math.hypot(a.velocity_x,a.velocity_y),s=this.replay.ticks.slice(Math.max(0,r.tick-30),r.tick+1).some(e=>e.snapshot.payload.fighters[0].is_downed);if(o===0&&!a.is_downed&&!s&&r.snapshot.payload.phase===`fight`){let n=[this.jointWorld(0,`ankleL`),this.jointWorld(0,`ankleR`)].filter(e=>e!==null);t!==null&&n.length===2&&(e.footSlideMeters=Math.max(e.footSlideMeters,Number(Math.max(n[0].distanceTo(t[0]),n[1].distanceTo(t[1])).toFixed(4)))),t=n}else t=null}this.metricsEl.textContent=` contacts: ${e.contactAlignment.map(e=>`${e.kind}@t${e.tick} glove-head ${e.gloveToHeadMeters}m`).join(` · `)} · max root step ${e.maxRootStepMeters.toFixed(3)}m · foot slide ${e.footSlideMeters}m`,window.__labDebug={roots:this.renderer.labRigs.map(e=>e.position.toArray().map(e=>Number(e.toFixed(3)))),graphsActive:this.renderer.graphs!==null,heads:this.renderer.labRigs.map(e=>{let t=e.getObjectByName(gy.head??`head`);return t===void 0?null:t.getWorldPosition(new z).toArray().map(e=>Number(e.toFixed(3)))})};let r=new Blob([JSON.stringify(e,null,1)],{type:`application/json`}),i=document.createElement(`a`);i.href=URL.createObjectURL(r),i.download=`hands-lab-metrics.json`,i.click(),URL.revokeObjectURL(i.href)}setStatus(e){this.statusEl.textContent!==e&&(this.statusEl.textContent=e)}destroy(){this.destroyed||(this.destroyed=!0,cancelAnimationFrame(this.raf),this.renderer?.destroy(),this.root.replaceChildren())}};function CX(e){let t=new SX(e);return t.start().catch(t=>{e.querySelector(`[data-lab-status]`).textContent=`lab failed: ${String(t)}`}),()=>t.destroy()}var wX={referee:{outfit:Gy,look:Cy.referee},corner_blue:{outfit:Ky,look:Cy.blueCorner},corner_red:{outfit:qy,look:Cy.redCorner},cutman:{outfit:Jy,look:Cy.blueCutman}},TX=()=>({player_id:`lab`,x:0,y:0,facing:1,facing_x:0,facing_y:-1e3,velocity_x:0,velocity_y:0,stance:`orthodox`,style:`balanced`,defense:`none`,stamina:1e3,maximum_stamina:1e3,conditioning:1e3,guard:700,guard_broken:!1,poise:600,trauma:{head:0,body:0,left_eye:0,right_eye:0,left_cut:0,right_cut:0,swelling:0,bleeding:0},knockdowns:0,warnings:0,deductions:0,stunned_ticks:0,is_downed:!1,action:null,action_hand:null,action_target:null,action_power:null,action_id:null,action_key:null,action_start_tick:0,action_startup_ticks:0,action_active_ticks:0,action_recovery_ticks:0,action_contact_tick:null,queued_actions:0,clinch_startup_ticks:0,clinch_ticks:0,is_foul_recovery_target:!1,taunt_ticks:0,corner_choice:null,get_up_prompt:null,get_up_meter:0,get_up_required:0,get_up_count:0,get_up_window_start_tick:0,get_up_window_end_tick:0,last_input_sequence:-1,injuries:[],blood_volume:1e3}),EX=.45,DX=.3,OX={face:[.25,1.55,1],portrait:[.12,1.62,.62],eyes:[-.2,1.65,.44],floor:[1.62,.3,.18],hand:[.55,1.05,.75],front:[0,1.35,3.4],side:[3.4,1.3,.2],"three-quarter":[2.4,1.5,2.6],top:[.01,4.5,.6],back:[.2,1.4,-3.4],low:[1.8,.5,2.6],wide:[3.4,2.7,3.6]},kX=class{root;renderer;scene=new Ts;camera;graph=null;boxer=null;trails=[];trailGlove=new z;treatEye=new z(0,1.22,.78);treatFacing=new z(0,0,-1);treatTarget=new z;skeletonHelper=null;effects=null;shieldClock=1/0;shieldEvent=0;mouth=new z;headTurn=new vo;burstRim=new Float32Array;burstStump={position:new z,quaternion:new vo,across:new z,scratch:new z};raf=0;previous=performance.now();elapsed=0;params=new URLSearchParams(window.location.search);reactionFired=!1;carnage=null;injuries=[];inflictions=[];killed=!1;vomitClock=0;worn=!1;headAt=new z;statusEl;constructor(e){this.root=e,e.innerHTML=`
HANDS POSE LABloading…
-
`,this.statusEl=e.querySelector(`[data-status]`);let t=e.querySelector(`[data-canvas]`);this.renderer=new AT({canvas:t,antialias:!0,preserveDrawingBuffer:!0}),this.renderer.setPixelRatio(Math.min(2,window.devicePixelRatio||1)),this.renderer.shadowMap.enabled=!0,this.renderer.toneMapping=4,this.camera=new Ox(38,1,.1,60);let n=mJ[this.params.get(`cam`)??`three-quarter`]??mJ[`three-quarter`];this.camera.position.set(...n),this.params.get(`cam`)===`hand`?this.camera.lookAt(.27,.84,.12):this.params.get(`cam`)===`portrait`?this.camera.lookAt(0,1.6,.05):this.params.get(`cam`)===`eyes`?this.camera.lookAt(.01,1.6,.06):this.params.get(`cam`)===`floor`?this.camera.lookAt(1.3,0,-.24):this.params.get(`cam`)===`wide`?this.camera.lookAt(0,.45,-.2):this.camera.lookAt(0,this.params.get(`cam`)===`face`?1.5:1,0),this.setupLighting()}setupLighting(){this.scene.background=new J(`#101318`),this.scene.add(new gx(`#8fa0c8`,`#1a1c22`,1.4));let e=new Fx(`#fff1dc`,2.6);e.position.set(2.5,5,3),e.castShadow=!0,e.shadow.mapSize.set(2048,2048),this.scene.add(e);let t=new Fx(`#9fb8ff`,1.2);t.position.set(-3,3,-3),this.scene.add(t);let n=new Y(new Fy(4,48),new Ab({color:`#3c4a7a`,roughness:.9}));n.rotation.x=-Math.PI/2,n.receiveShadow=!0,this.scene.add(n);let r=new uS(4,16,8952251,3358810);r.position.y=.002,this.scene.add(r)}synthesize(e){let t=this.params.get(`pose`)??`idle`,n=this.params.get(`stance`)===`southpaw`?`southpaw`:`orthodox`,r={...dJ(),stance:n},i=this.params.get(`trauma`);i===`light`&&(r.trauma={head:220,body:260,left_eye:190,right_eye:60,left_cut:40,right_cut:0,swelling:120,bleeding:60}),i===`heavy`&&(r.trauma={head:900,body:700,left_eye:720,right_eye:380,left_cut:520,right_cut:190,swelling:620,bleeding:520}),i===`cut`&&(r.trauma={head:420,body:120,left_eye:380,right_eye:120,left_cut:300,right_cut:0,swelling:260,bleeding:380});let a=i?.split(`,`).map(Number)??[];if(a.length===8&&a.every(Number.isFinite)){let[e,t,n,i,o,s,c,l]=a;r.trauma={head:e,body:t,left_eye:n,right_eye:i,left_cut:o,right_cut:s,swelling:c,bleeding:l}}let o={...dJ(),player_id:`other`,x:0,y:-150,facing_x:0,facing_y:1e3},s=Math.floor(e*30),c=/^(jab|straight|hook|uppercut)_(left|right)(_body)?(_power)?$/.exec(t);if(c!==null){let e=c[1],t=c[2],n=c[3]===`_body`?`body`:`head`,i=c[4]===`_power`?`power`:`normal`,a={jab:[4,2,7],straight:[6,2,10],hook:[7,3,12],uppercut:[8,2,13]}[e],o=a[0]+a[1]+a[2],l=Math.floor(s/(o+12))*(o+12)+6;s>=l&&s=fJ&&t<3.4,r.stunned_ticks=t=pJ&&(t===null||e{let i=Math.min(.05,(r-this.previous)/1e3);this.previous=r,t===null?(this.elapsed=e===null?this.elapsed+i:Number(e),this.step(e===null?i:1/60)):this.step(0),this.renderer.render(this.scene,this.camera),this.raf=requestAnimationFrame(n)};this.raf=requestAnimationFrame(n)}step(e){let t=this.graph;if(t===null)return;let n=this.renderer.domElement.clientWidth,r=this.renderer.domElement.clientHeight;n>0&&r>0&&(this.renderer.domElement.width!==n||this.renderer.domElement.height!==r)&&(this.renderer.setSize(n,r,!1),this.camera.aspect=n/r,this.camera.updateProjectionMatrix());let{fighter:i,opponent:a,sampledTick:o,head:s}=this.synthesize(this.elapsed),c=this.params.get(`pose`)??``;if(/^(hit|block)_/.test(c)){let n=this.elapsed%1.6;if(this.params.has(`freeze`)?!this.reactionFired&&this.elapsed>=.02:n=.27999999999999997){this.reactionFired=!0;let e=this.params.get(`hit`)??`straight`,n=e===`body`?`hook`:e;t.react(`hit`,e===`body`?`body`:`head`,1,n,this.params.get(`hand`)===`left`?`left`:`right`,Number(this.params.get(`amount`)??420))}this.params.get(`pose`)===`knockdown`&&this.params.get(`fall`)===`prone`&&this.elapsed%6=.02:this.elapsed%1.63)){this.shieldClock=0,this.shieldEvent+=1;let e=this.boxer.bone(`head`);e.getWorldQuaternion(this.headTurn),e.getWorldPosition(this.mouth).add(new q(0,.045,.12).applyQuaternion(this.headTurn)),this.effects.ejectMouthpiece(0,this.mouth,this.headTurn,1,this.shieldEvent,1920728,!0)}this.effects?.update(e);for(let[t,n]of[`gloveL`,`gloveR`].entries())this.carnage?.hasGlove(0,t===0?`left`:`right`)===!1?this.trails[t]?.reset():(this.boxer.rig.bones[n].getWorldPosition(this.trailGlove),this.trails[t]?.update(this.trailGlove,e,this.camera.position,e>0));window.__poseLab={head:this.boxer.bone(`head`).getWorldPosition(new q).toArray().map(e=>Number(e.toFixed(3))),gloveL:this.boxer.bone(`gloveL`).getWorldPosition(new q).toArray().map(e=>Number(e.toFixed(3))),gloveR:this.boxer.bone(`gloveR`).getWorldPosition(new q).toArray().map(e=>Number(e.toFixed(3))),ankleL:this.boxer.bone(`ankleL`).getWorldPosition(new q).toArray().map(e=>Number(e.toFixed(3))),ankleR:this.boxer.bone(`ankleR`).getWorldPosition(new q).toArray().map(e=>Number(e.toFixed(3))),kneeL:this.boxer.bone(`kneeL`).getWorldPosition(new q).toArray().map(e=>Number(e.toFixed(3))),kneeR:this.boxer.bone(`kneeR`).getWorldPosition(new q).toArray().map(e=>Number(e.toFixed(3))),metrics:this.boxer.rig.metrics,mouthpiece:this.effects!==null&&this.effects.mouthpiecePosition(0,this.mouth)?this.mouth.toArray().map(e=>Number(e.toFixed(3))):null}}get bloodSetting(){let e=this.params.get(`blood`);return e===`reduced`||e===`off`?e:`full`}startCarnage(){let e=e=>(this.params.get(e)??``).split(`,`).filter(e=>fe.includes(e));this.injuries.push(...e(`injuries`));for(let[t,n]of e(`inflict`).entries())this.inflictions.push({injury:n,at:1+t*.8,done:!1});(this.injuries.length>0||this.inflictions.length>0||[`fatality`,`dead`,`bloodvol`,`dazed`,`vomit`].some(e=>this.params.has(e)))&&this.graph!==null&&(this.effects??=new sW(this.scene),this.effects.setBloodLevel(this.bloodSetting),this.effects.setCamera(this.camera),this.carnage=new Yz(this.effects,ZK),this.carnage.attach(0,this.graph))}stepCarnage(e){let t=this.carnage,n=this.graph;if(t===null||n===null||this.effects===null)return;for(let[e,n]of this.inflictions.entries())n.done||this.elapsed=1&&(i!==null||me.includes(r??``))&&(this.killed=!0,i===null?this.kill(t,r):t.die(0,i));let a=this.params.get(`dazed`)===`1`&&!this.killed;n.setDazed(a),this.params.get(`vomit`)===`1`&&(this.vomitClock+=e,this.vomitClock>=3&&(this.vomitClock=0,t.vomit(0,Math.round(this.elapsed*10))));let o=Number(this.params.get(`bloodvol`)??1e3),s=fe.filter(e=>this.injuries.includes(e));t.sync(0,{injuries:s,blood_volume:Number.isFinite(o)?o:1e3},{blood:this.bloodSetting,reducedMotion:!1},e,this.elapsed,a)}kill(e,t){let n=this.boxer,r=this.effects,i=n.bone(`head`);n.root.updateMatrixWorld(!0),i.getWorldQuaternion(this.headTurn),i.getWorldPosition(this.headAt).add(new q(0,.12,.02).applyQuaternion(this.headTurn)),t===`decapitation`||t===`spine_rip`?(r.decapitate(0,this.headAt,this.headTurn,1,31,11105359,XK(n,this.headAt,this.headTurn)),n.setDecapitated(!0)):t===`head_burst`&&(r.burstHead(0,this.headAt,1,31),n.setHeadBurst(!0)),e.fatality(0,t,31,1),e.die(0,`fatality:${t}`)}destroy(){cancelAnimationFrame(this.raf),this.carnage?.dispose(),this.effects?.dispose(),this.graph?.dispose(),this.renderer.dispose(),this.root.replaceChildren()}};function gJ(e){let t=new hJ(e);return t.start().catch(()=>void 0),()=>t.destroy()}var _J=document.querySelector(`#app`);if(_J===null)throw Error(`app_root_missing`);var vJ,yJ=new URLSearchParams(window.location.search),bJ=window.location.pathname.endsWith(`/hands/lab`)||yJ.get(`lab`)===`1`;if(window.location.pathname.endsWith(`/hands/model-lab`)||yJ.get(`model-lab`)===`1`)vJ=gJ(_J);else if(bJ)vJ=lJ(_J);else{let e=new aJ(_J);e.start(),vJ=()=>e.destroy()}window.addEventListener(`pagehide`,vJ,{once:!0}); \ No newline at end of file +`,this.statusEl=e.querySelector(`[data-status]`);let t=e.querySelector(`[data-canvas]`);this.renderer=new qh({canvas:t,antialias:!0,preserveDrawingBuffer:!0}),this.renderer.setPixelRatio(Math.min(2,window.devicePixelRatio||1)),this.renderer.shadowMap.enabled=!0,this.renderer.toneMapping=4,this.camera=new Wd(38,1,.1,60);let n=OX[this.params.get(`cam`)??`three-quarter`]??OX[`three-quarter`];this.camera.position.set(...n),this.params.get(`cam`)===`hand`?this.camera.lookAt(.27,.84,.12):this.params.get(`cam`)===`portrait`?this.camera.lookAt(0,1.6,.05):this.params.get(`cam`)===`eyes`?this.camera.lookAt(.01,1.6,.06):this.params.get(`cam`)===`floor`?this.camera.lookAt(1.3,0,-.24):this.params.get(`cam`)===`wide`?this.camera.lookAt(0,.45,-.2):this.camera.lookAt(0,this.params.get(`cam`)===`face`?1.5:1,0),this.setupLighting()}setupLighting(){this.scene.background=new B(`#101318`),this.scene.add(new Md(`#8fa0c8`,`#1a1c22`,1.4));let e=new Zd(`#fff1dc`,2.6);e.position.set(2.5,5,3),e.castShadow=!0,e.shadow.mapSize.set(2048,2048),this.scene.add(e);let t=new Zd(`#9fb8ff`,1.2);t.position.set(-3,3,-3),this.scene.add(t);let n=new V(new Xl(4,48),new Ku({color:`#3c4a7a`,roughness:.9}));n.rotation.x=-Math.PI/2,n.receiveShadow=!0,this.scene.add(n);let r=new Df(4,16,8952251,3358810);r.position.y=.002,this.scene.add(r)}synthesize(e){let t=this.params.get(`pose`)??`idle`,n=this.params.get(`stance`)===`southpaw`?`southpaw`:`orthodox`,r={...TX(),stance:n},i=this.params.get(`trauma`);i===`light`&&(r.trauma={head:220,body:260,left_eye:190,right_eye:60,left_cut:40,right_cut:0,swelling:120,bleeding:60}),i===`heavy`&&(r.trauma={head:900,body:700,left_eye:720,right_eye:380,left_cut:520,right_cut:190,swelling:620,bleeding:520}),i===`cut`&&(r.trauma={head:420,body:120,left_eye:380,right_eye:120,left_cut:300,right_cut:0,swelling:260,bleeding:380});let a=i?.split(`,`).map(Number)??[];if(a.length===8&&a.every(Number.isFinite)){let[e,t,n,i,o,s,c,l]=a;r.trauma={head:e,body:t,left_eye:n,right_eye:i,left_cut:o,right_cut:s,swelling:c,bleeding:l}}let o=Number(this.params.get(`gap`)??150),s={...TX(),player_id:`other`,x:0,y:-o,facing_x:0,facing_y:1e3},c=Math.floor(e*30),l=/^(jab|straight|hook|uppercut)_(left|right)(_body)?(_power)?$/.exec(t);if(l!==null){let e=l[1],t=l[2],n=l[3]===`_body`?`body`:`head`,i=l[4]===`_power`?`power`:`normal`,a={jab:[4,2,7],straight:[6,2,10],hook:[7,3,12],uppercut:[8,2,13]}[e],o=a[0]+a[1]+a[2],s=Math.floor(c/(o+12))*(o+12)+6;c>=s&&c=EX&&t<3.4,r.stunned_ticks=t=DX&&(t===null||e{let i=Math.min(.05,(r-this.previous)/1e3);this.previous=r,t===null?(this.elapsed=e===null?this.elapsed+i:Number(e),this.step(e===null?i:1/60)):this.step(0),this.renderer.render(this.scene,this.camera),this.raf=requestAnimationFrame(n)};this.raf=requestAnimationFrame(n)}step(e){let t=this.graph;if(t===null)return;let n=this.renderer.domElement.clientWidth,r=this.renderer.domElement.clientHeight;n>0&&r>0&&(this.renderer.domElement.width!==n||this.renderer.domElement.height!==r)&&(this.renderer.setSize(n,r,!1),this.camera.aspect=n/r,this.camera.updateProjectionMatrix());let{fighter:i,opponent:a,sampledTick:o,head:s}=this.synthesize(this.elapsed),c=this.params.get(`pose`)??``;if(/^(hit|block)_/.test(c)){let n=this.elapsed%1.6;if(this.params.has(`freeze`)?!this.reactionFired&&this.elapsed>=.02:n=.27999999999999997){this.reactionFired=!0;let e=this.params.get(`hit`)??`straight`,n=e===`body`?`hook`:e;t.react(`hit`,e===`body`?`body`:`head`,1,n,this.params.get(`hand`)===`left`?`left`:`right`,Number(this.params.get(`amount`)??420))}this.params.get(`pose`)===`knockdown`&&this.params.get(`fall`)===`prone`&&this.elapsed%6=.02:this.elapsed%1.63)){this.shieldClock=0,this.shieldEvent+=1;let e=this.boxer.bone(`head`);e.getWorldQuaternion(this.headTurn),e.getWorldPosition(this.mouth).add(new z(0,.045,.12).applyQuaternion(this.headTurn)),this.effects.ejectMouthpiece(0,this.mouth,this.headTurn,1,this.shieldEvent,1920728,!0)}this.effects?.update(e);for(let[t,n]of[`gloveL`,`gloveR`].entries())this.carnage?.hasGlove(0,t===0?`left`:`right`)===!1?this.trails[t]?.reset():(this.boxer.rig.bones[n].getWorldPosition(this.trailGlove),this.trails[t]?.update(this.trailGlove,e,this.camera.position,e>0));window.__poseLab={head:this.boxer.bone(`head`).getWorldPosition(new z).toArray().map(e=>Number(e.toFixed(3))),gloveL:this.boxer.bone(`gloveL`).getWorldPosition(new z).toArray().map(e=>Number(e.toFixed(3))),gloveR:this.boxer.bone(`gloveR`).getWorldPosition(new z).toArray().map(e=>Number(e.toFixed(3))),ankleL:this.boxer.bone(`ankleL`).getWorldPosition(new z).toArray().map(e=>Number(e.toFixed(3))),ankleR:this.boxer.bone(`ankleR`).getWorldPosition(new z).toArray().map(e=>Number(e.toFixed(3))),kneeL:this.boxer.bone(`kneeL`).getWorldPosition(new z).toArray().map(e=>Number(e.toFixed(3))),kneeR:this.boxer.bone(`kneeR`).getWorldPosition(new z).toArray().map(e=>Number(e.toFixed(3))),metrics:this.boxer.rig.metrics,mouthpiece:this.effects!==null&&this.effects.mouthpiecePosition(0,this.mouth)?this.mouth.toArray().map(e=>Number(e.toFixed(3))):null}}get bloodSetting(){let e=this.params.get(`blood`);return e===`reduced`||e===`off`?e:`full`}startCarnage(){let e=e=>(this.params.get(e)??``).split(`,`).filter(e=>me.includes(e));this.injuries.push(...e(`injuries`));for(let[t,n]of e(`inflict`).entries())this.inflictions.push({injury:n,at:1+t*.8,done:!1});if(!(this.injuries.length>0||this.inflictions.length>0||[`fatality`,`dead`,`bloodvol`,`dazed`,`vomit`,`xray`,`wear`].some(e=>this.params.has(e)))||this.graph===null)return;this.effects??=new _K(this.scene),this.effects.setBloodLevel(this.bloodSetting),this.effects.setCamera(this.camera),this.carnage=new aH(this.effects,dY),this.carnage.attach(0,this.graph);let t=this.params.get(`xray`);t!==null&&this.carnage.holdXray(0,t)}stepCarnage(e){let t=this.carnage,n=this.graph;if(t===null||n===null||this.effects===null)return;for(let[e,n]of this.inflictions.entries())n.done||this.elapsed=1&&(i!==null||ge.includes(r??``))&&(this.killed=!0,i===null?this.kill(t,r):t.die(0,i));let a=this.params.get(`dazed`)===`1`&&!this.killed;n.setDazed(a),this.params.get(`vomit`)===`1`&&(this.vomitClock+=e,this.vomitClock>=3&&(this.vomitClock=0,t.vomit(0,Math.round(this.elapsed*10))));let o=Number(this.params.get(`bloodvol`)??1e3),s=me.filter(e=>this.injuries.includes(e));t.sync(0,{injuries:s,blood_volume:Number.isFinite(o)?o:1e3},{blood:this.bloodSetting,reducedMotion:!1},e,this.elapsed,a);let c=Number(this.params.get(`wear`)??0);if(!this.worn&&c>0&&this.elapsed>=.5){this.worn=!0;let e=[[`head`,.06,.07,.1],[`body`,.1,.02,.14],[`head`,-.05,.11,.1],[`body`,-.09,-.06,.14]];for(let r=0;rvoid 0),()=>t.destroy()}var jX=document.querySelector(`#app`);if(jX===null)throw Error(`app_root_missing`);var MX,NX=new URLSearchParams(window.location.search),PX=window.location.pathname.endsWith(`/hands/lab`)||NX.get(`lab`)===`1`;if(window.location.pathname.endsWith(`/hands/model-lab`)||NX.get(`model-lab`)===`1`)MX=AX(jX);else if(PX)MX=CX(jX);else{let e=new yX(jX);e.start(),MX=()=>e.destroy()}window.addEventListener(`pagehide`,MX,{once:!0}); \ No newline at end of file diff --git a/web/hands/src/audio.ts b/web/hands/src/audio.ts index 88b0fc8f..a10dacd3 100644 --- a/web/hands/src/audio.ts +++ b/web/hands/src/audio.ts @@ -1,6 +1,7 @@ import { INJURY_SOUNDS } from "./assets/injury-sounds"; import { fatalityOf, injuryKind, type FatalityId, type GoreCue, type InjuryKind } from "./injuries"; import type { ArcadeInjury } from "./render/renderer"; +import { XRAY_SNAP_SECONDS } from "./render/xray"; /** Finishers without a voice of their own borrow the nearest one. */ const BORROWED_VOICE: Partial>> = { head_burst: "decapitation", eye_left: "jaw_dislocation", eye_right: "jaw_dislocation", ribs_left: "shoulder_left", ribs_right: "shoulder_right" }; @@ -461,8 +462,11 @@ export class AudioFeedback { switch (cue.kind) { case "injury": { const sound = INJURY_SOUND[injuryKind(cue.injury)]; - if (explicit) this.wound(sound, 0); - else this.impact(0.3, false, 0.9); + if (explicit) { + this.wound(sound, 0); + // Every injury that cracks is a bone, shown breaking in its X-ray a moment after the punch. + if (sound === "crack") this.xray(); + } else this.impact(0.3, false, 0.9); this.ooh(1); this.crowdSwell(0.8); if (sound !== "crack") this.crowdVoice({ ...GROAN, delay: 0.45 }); @@ -501,6 +505,13 @@ export class AudioFeedback { else this.chop(delay); } + /** The X-ray of a breaking bone: a hum that rises to the snap, the bone going in close-up, and the wet give of the marrow. */ + private xray(): void { + this.tone({ from: 90, to: 440, duration: XRAY_SNAP_SECONDS, type: "sine", gain: 0.1, delay: 0 }); + this.crack(XRAY_SNAP_SECONDS); + this.noise({ duration: 0.16, frequency: 520, sweepTo: 170, gain: 0.2, type: "lowpass", q: 4, delay: XRAY_SNAP_SECONDS + 0.03, offset: 0.3 }); + } + /** A bone breaking: a dry snap, the dull knock of what it was holding up, and the splintering after it. */ private crack(delay: number): void { this.noise({ duration: 0.03, frequency: 3400, sweepTo: 1800, gain: 0.34, type: "bandpass", q: 2.2, delay }); diff --git a/web/hands/src/dev-fixtures.ts b/web/hands/src/dev-fixtures.ts index c781b496..fd603505 100644 --- a/web/hands/src/dev-fixtures.ts +++ b/web/hands/src/dev-fixtures.ts @@ -1,4 +1,4 @@ -import { REST_CORNER_OFFSET } from "./manifest"; +import { REST_CORNER_OFFSET, punchTiming } from "./manifest"; import * as THREE from "three"; import { FATALITY_IDS, INJURY_IDS, fatalityFor, parseDeathCause, type InjuryId } from "./injuries"; import { SharedActionIntent } from "./input/action-buffer"; @@ -32,6 +32,14 @@ const base = (id: string): Draft => ({ const PUNCHES = ["jab", "straight", "hook", "uppercut"] as const; +/** Where a `calm` fighter stands at `seconds`: the one on the `side` (-1 or 1) of the centre the pair turns round. */ +function calmPlace(seconds: number, gap: number, walking: boolean, side: number): { x: number; y: number } { + const turn = walking ? seconds * 0.3 : 0; + const half = (gap + (walking ? Math.sin(seconds * 0.9) * 35 : 0)) / 2; + const drift = walking ? Math.sin(seconds * 0.47) * 70 : 0; + return { x: drift + side * Math.cos(turn) * half, y: side * Math.sin(turn) * half }; +} + export function runDevelopmentFixture(root: HTMLElement): () => void { root.innerHTML = `
HANDS · DEV FIXTUREProduction never enters this harness
`; const bloodParam = new URLSearchParams(window.location.search).get("blood"); @@ -56,6 +64,8 @@ export function runDevelopmentFixture(root: HTMLElement): () => void { let tick = 0; let eventId = 0; const refereeBlowsShown = new Set(); + const refereeAt = { x: 0, y: 140 }; + let brokenCycle = -1; let finalSent = false; let bellRung = false; let thrownWindow = -1; @@ -98,23 +108,33 @@ export function runDevelopmentFixture(root: HTMLElement): () => void { } // `mouthpiece=1` puts the gum shields back before every exchange so each big head shot knocks one out. if (new URLSearchParams(window.location.search).get("mouthpiece") === "1" && cycle < 0.1) renderer.labEffects.clearMouthpieces(); - if (cycle < 0.55 && one.taunt_ticks === 0 && two.taunt_ticks === 0 && !closing) { + if (cycle < 0.75 && one.taunt_ticks === 0 && two.taunt_ticks === 0 && !closing) { const punch = PUNCHES[Math.floor(t / 3.2) % PUNCHES.length]!; attacker.action = punch; attacker.action_hand = Math.floor(t / 3.2) % 3 === 0 ? "right" : "left"; attacker.action_target = Math.floor(t / 3.2) % 4 === 1 ? "body" : "head"; attacker.action_power = Math.floor(t / 3.2) % 5 === 2 ? "power" : "normal"; + // `wear=1` names each punch as the engine does, so it leaves its mark where its glove lands and its blood on both men. + if (new URLSearchParams(window.location.search).get("wear") === "1") attacker.action_key = `${punch}:${attacker.action_hand}:${attacker.action_target}:${attacker.action_power}`; defender.defense = Math.floor(t / 6.4) % 2 === 0 ? "guard_high" : "none"; const punchWindow = Math.floor(t / 3.2); + // The punch is a real action instance, so the fighters throw it and it lands on its contact tick. + const sparId = `spar-${punchWindow}`; + const sparStart = Math.round(punchWindow * 3.2 * 30); + const sparTiming = punchTiming(punch, attacker.action_target, attacker.action_power); + Object.assign(attacker, { + action_id: sparId, action_key: `${punch}:${attacker.action_hand}:${attacker.action_target}:${attacker.action_power}`, action_start_tick: sparStart, + action_startup_ticks: sparTiming.startup, action_active_ticks: sparTiming.active, action_recovery_ticks: sparTiming.recovery, + }); if (thrownWindow !== punchWindow) { thrownWindow = punchWindow; eventId += 1; - events.push({ event_id: eventId, tick, kind: "punch_start", actor_id: attacker.player_id, target_id: null, amount: 0, detail: `${attacker.action_hand}:${punch}:${attacker.action_target}`, blood: 0, direction: 0, action_id: null }); + events.push({ event_id: eventId, tick, kind: "punch_start", actor_id: attacker.player_id, target_id: null, amount: 0, detail: `${attacker.action_hand}:${punch}:${attacker.action_target}`, blood: 0, direction: 0, action_id: sparId }); } - if (cycle >= 0.2 && landedWindow !== punchWindow) { + if (tick >= sparStart + sparTiming.startup && landedWindow !== punchWindow) { landedWindow = punchWindow; eventId += 1; - events.push({ event_id: eventId, tick, kind: "hit", actor_id: attacker.player_id, target_id: defender.player_id, amount: 210, detail: `${attacker.action_hand}:${punch}:${attacker.action_target}`, blood: 100, direction: attacker.facing, action_id: null }); + events.push({ event_id: eventId, tick: sparStart + sparTiming.startup, kind: "hit", actor_id: attacker.player_id, target_id: defender.player_id, amount: 210, detail: `${attacker.action_hand}:${punch}:${attacker.action_target}`, blood: 100, direction: attacker.facing, action_id: sparId }); defender.stunned_ticks = 12; } } @@ -129,6 +149,9 @@ export function runDevelopmentFixture(root: HTMLElement): () => void { const flash = finisher === "flash"; const pinned = search.get("pin") === "1"; const knockdownCycle = finisher === null ? t % 14 : (t < 2.5 ? 0 : 12); + // `referee=count` puts the red fighter down six seconds into each cycle, in the engine's knockdown phase, so the + // referee counts over him from his place beside him until the cycle ends. + const downAt = search.get("referee") === "count" ? 6 : 11; // A body shot that puts him on a knee a third of a second after it lands. const bodyCollapse = finisher === "body" && t >= 2.5 && t < 2.85; // The sparring stops for the body shot; a punch on a fighter who is down would be an arcade finisher. @@ -156,14 +179,15 @@ export function runDevelopmentFixture(root: HTMLElement): () => void { eventId += 1; events.push({ event_id: eventId, tick, kind: "knockdown", actor_id: one.player_id, target_id: two.player_id, amount: 1, detail: "body", blood: 0, direction: 0, action_id: "fixture-body" }); } - } else if (knockdownCycle > 11 && knockdownCycle < 13.4) { + } else if (knockdownCycle > downAt && knockdownCycle < (downAt < 11 ? 14 : 13.4)) { two.is_downed = !flash; two.action = null; two.x = 140; two.y = 40; one.x = -60; one.y = -30; - const trigger = finisher === null ? knockdownCycle > 11 && knockdownCycle < 11.15 : t >= 2.5 && t < 2.65; + two.get_up_count = Math.floor(knockdownCycle - downAt); + const trigger = finisher === null ? knockdownCycle > downAt && knockdownCycle < downAt + 0.15 : t >= 2.5 && t < 2.65; if (trigger) { eventId += 1; // `finisher=head` severs the head, `burst` bursts it with a big counter, `eye` forces an eye out @@ -209,6 +233,27 @@ export function runDevelopmentFixture(root: HTMLElement): () => void { one.x = 292; one.y = 284; } + // `calm=1` stands both fighters in their stances at `gap` (150 without one) with nothing scripted, to judge how + // they stand; `calm=walk` has them circle each other while the pair drifts and the gap opens and closes, and + // `guard=high|low` has them hold that guard. + const calm = search.get("calm"); + if (calm !== null) { + events.length = 0; + const spacing = Number.isFinite(fixedGap) && fixedGap > 0 ? fixedGap : 150; + const guard = search.get("guard"); + for (const [fighter, side] of [[one, -1], [two, 1]] as const) { + const now = calmPlace(t, spacing, calm === "walk", side); + const next = calmPlace(t + 1 / 30, spacing, calm === "walk", side); + const other = calmPlace(t, spacing, calm === "walk", -side); + const apart = Math.hypot(other.x - now.x, other.y - now.y) || 1; + Object.assign(fighter, { + x: Math.round(now.x), y: Math.round(now.y), velocity_x: next.x - now.x, velocity_y: next.y - now.y, + facing: -side, facing_x: Math.round(((other.x - now.x) / apart) * 1000), facing_y: Math.round(((other.y - now.y) / apart) * 1000), + action: null, taunt_ticks: 0, stunned_ticks: 0, clinch_ticks: 0, is_downed: false, + defense: guard === "high" ? "guard_high" : guard === "low" ? "guard_low" : "none", + }); + } + } if (forcedRest) { const corner = search.get("corner"); for (const [fighter, sign] of [[one, -1], [two, 1]] as const) { @@ -348,9 +393,29 @@ export function runDevelopmentFixture(root: HTMLElement): () => void { if (t >= blows[1]!.at) official = { ...official, alive: false }; refereeDownFor = t >= blows[1]!.at ? Math.max(0, blows[1]!.at + 5 - t) : 0; } + // `referee=break` stands the referee where the engine does, 62 units off the middle of the two on his own side of + // them, following them at its pace, and has him break each clinch a moment after it is tied. + if (search.get("referee") === "break") { + const midX = (one.x + two.x) / 2; + const midY = (one.y + two.y) / 2; + const across = Math.hypot(one.y - two.y, two.x - one.x) || 1; + const side = (refereeAt.x - midX) * (one.y - two.y) + (refereeAt.y - midY) * (two.x - one.x) >= 0 ? 62 : -62; + const dx = midX + ((one.y - two.y) / across) * side - refereeAt.x; + const dy = midY + ((two.x - one.x) / across) * side - refereeAt.y; + const step = Math.min(1, 18 / Math.max(1, Math.hypot(dx, dy))); + refereeAt.x += dx * step; + refereeAt.y += dy * step; + const look = Math.hypot(midX - refereeAt.x, midY - refereeAt.y) || 1; + official = { ...official, x: Math.round(refereeAt.x), y: Math.round(refereeAt.y), facing_x: Math.round(((midX - refereeAt.x) / look) * 1000), facing_y: Math.round(((midY - refereeAt.y) / look) * 1000) }; + if (tauntCycle > 4.3 && tauntCycle < 5.1 && brokenCycle !== Math.floor(t / 12)) { + brokenCycle = Math.floor(t / 12); + eventId += 1; + events.push({ event_id: eventId, tick, kind: "referee_break", actor_id: null, target_id: null, amount: 0, detail: "", blood: 0, direction: 0, action_id: null }); + } + } const flashOver = flash && t >= 2.5; const snapshot: EngineSnapshot = { - tick, phase: decided || flashOver || dead ? "complete" : finishing ? "finish" : introducing ? "countdown" : forcedRest ? "rest" : refereeDownFor > 0 ? "referee_down" : "fight", round_number: search.get("intro") === "1" ? 1 : 3, phase_ticks_remaining: decided || dead ? 0 : finishing ? Math.round((killAt - t) * 30) : introducing ? Math.max(0, 90 - tick) : forcedRest ? Math.max(0, 450 - tick) : Math.max(0, 5400 - tick), + tick, phase: decided || flashOver || dead ? "complete" : finishing ? "finish" : introducing ? "countdown" : forcedRest ? "rest" : refereeDownFor > 0 ? "referee_down" : downAt < 11 && two.is_downed ? "knockdown" : "fight", round_number: search.get("intro") === "1" ? 1 : 3, phase_ticks_remaining: decided || dead ? 0 : finishing ? Math.round((killAt - t) * 30) : introducing ? Math.max(0, 90 - tick) : forcedRest ? Math.max(0, 450 - tick) : Math.max(0, 5400 - tick), fighters: [{ ...one }, { ...two }], referee: official, events, diff --git a/web/hands/src/gore-feedback.test.ts b/web/hands/src/gore-feedback.test.ts index 505dc98f..a7d73191 100644 --- a/web/hands/src/gore-feedback.test.ts +++ b/web/hands/src/gore-feedback.test.ts @@ -2,6 +2,7 @@ import { AnnouncerVoice } from "./announcer"; import { AudioFeedback } from "./audio"; import { HapticFeedback } from "./haptics"; import { FATALITY_IDS, INJURY_IDS, type DeathCause, type GoreCue } from "./injuries"; +import { XRAY_SNAP_SECONDS } from "./render/xray"; import type { Settings } from "./settings"; const full: Settings = { volume: 1, haptics: true, reducedMotion: false, blood: "full", camera: "broadcast", commentary: true, announcer: true }; @@ -167,6 +168,16 @@ describe("gore heard", () => { expect(longest(rip)).toBeGreaterThanOrEqual(0.5); }); + it("snaps a bone twice, as the punch lands and again as its X-ray shows it go, and only when that is drawn", async () => { + const snaps = async (injury: (typeof INJURY_IDS)[number], settings: Settings = full): Promise => + wet((await heard({ kind: "injury", injury }, settings)).noises).filter((noise) => noise.filters[0]!.frequency.set[0]!.value === 3400).map((noise) => noise.start).sort((a, b) => a - b); + const broken = await snaps("ribs_left_broken"); + expect(broken).toHaveLength(2); + expect(broken[1]! - broken[0]!).toBeCloseTo(XRAY_SNAP_SECONDS, 5); + expect(await snaps("ear_left_torn")).toHaveLength(0); + expect(await snaps("ribs_left_broken", { ...full, blood: "reduced" })).toHaveLength(0); + }); + it("pumps a severed limb's blood out in beats after the chop", async () => { const { noises, context } = await heard({ kind: "injury", injury: "forearm_right_severed" }); const late = wet(noises).filter((noise) => noise.start - context.currentTime >= 0.25 && noise.filters[0]!.type === "bandpass" && noise.stop - noise.start > 0.15).map((noise) => noise.start - context.currentTime); diff --git a/web/hands/src/haptics.ts b/web/hands/src/haptics.ts index cfbe7063..f3cfefc8 100644 --- a/web/hands/src/haptics.ts +++ b/web/hands/src/haptics.ts @@ -1,4 +1,5 @@ import { fatalityOf, type GoreCue } from "./injuries"; +import { XRAY_SNAP_SECONDS, breakFor } from "./render/xray"; import { coarsePointer } from "./input/touch"; import type { Settings } from "./settings"; import type { CombatEvent } from "./types"; @@ -19,6 +20,8 @@ const patterns: Readonly> = { const gorePatterns: Readonly> = { injury: [150, 0.55, 0.6], vomit: [90, 0.15, 0.45], finish_him: [180, 0.65, 0.3], fatality: [180, 0.65, 0.65], death: [170, 0.5, 0.12], }; +/** The second jolt of a broken bone, as its X-ray shows it snap. */ +const BONE_SNAP: Pattern = [120, 0.65, 0.5]; export class HapticFeedback { constructor(private readonly settings: () => Settings) {} @@ -38,6 +41,8 @@ export class HapticFeedback { gore(cue: GoreCue): void { if (!this.settings().haptics || (cue.kind === "death" && fatalityOf(cue.cause) !== null)) return; this.rumble(gorePatterns[cue.kind]); + const current = this.settings(); + if (cue.kind === "injury" && breakFor(cue.injury) !== null && current.blood === "full" && !current.reducedMotion) setTimeout(() => this.rumble(BONE_SNAP), XRAY_SNAP_SECONDS * 1000); } private rumble(pattern: Pattern): void { diff --git a/web/hands/src/lab/model-lab.ts b/web/hands/src/lab/model-lab.ts index d2fe0b50..386a0857 100644 --- a/web/hands/src/lab/model-lab.ts +++ b/web/hands/src/lab/model-lab.ts @@ -8,6 +8,7 @@ import { OFFICIAL_LOOKS, lookFor, type FighterLook } from "../render/looks"; import { BLUE_CORNER_OUTFIT, CUTMAN_OUTFIT, RED_CORNER_OUTFIT, REFEREE_OUTFIT, type OfficialOutfit } from "../render/outfit"; import { GloveTrail } from "../render/trails"; import { worldMapping } from "../render/world"; +import type { BreakSite } from "../render/xray"; import type { FighterSnapshot, Hand, PunchClass, Target } from "../types"; /** @@ -15,19 +16,22 @@ import type { FighterSnapshot, Hand, PunchClass, Target } from "../types"; * every authored pose can be inspected from any angle without a match. * Query parameters: pose (idle, guard_high, guard_low, slip_left, slip_right, * weave, pull, jab_left, straight_right, hook_left, uppercut_right, ..., - * hit_head, hit_body, block, knockdown, getup, stunned, taunt, clinch, seated, celebrate, wave_off, break, touch_gloves, walk, + * hit_head, hit_body, block, knockdown, getup, stunned, taunt, clinch, seated, celebrate, wave_off, break, touch_gloves, + * walk_[_] or walk_ at `speed` engine units a tick, * ragdoll: a knockout fall under physics from `hit` (jab|straight|hook|uppercut|body) thrown with * `hand` (left|right) for `amount` damage, getting up after `getup` seconds when given), * t (seconds into the pose), stance (orthodox|southpaw), cam (front|side| * three-quarter|top|back), skeleton (1), outfit (referee|corner_blue|corner_red|cutman) to * show a ring official, whose poses are idle, count, attend, treat, wave_off and break, and - * player (any id) to show the fighter that player gets. + * player (any id) to show the fighter that player gets, and gap (engine units to the other man, 150 unless given). * * The engine's injuries: injuries (ids, comma separated) are carried from the start; inflict (ids) * happen one after another from one second in, each with its moment; fatality (an id) kills him at * one second; dead (bled_out|brain|gutted) kills him at one second; bloodvol (0..1000) is the blood * he has left; dazed (1) is the FINISH HIM daze; vomit (1) makes him vomit every three seconds; blood - * (full|reduced|off) is the blood setting. + * (full|reduced|off) is the blood setting; xray (skull|jaw|nose|ribs_left|arm_right|knee_left|...) holds + * his skeleton up with that bone broken; wear (a count) lands that many bloody punches on him at half a + * second, round his face and ribs, for the marks and the spatter they leave. */ const OUTFITS: Readonly> = { @@ -101,6 +105,7 @@ export class ModelLab { private readonly inflictions: { readonly injury: InjuryId; readonly at: number; done: boolean }[] = []; private killed = false; private vomitClock = 0; + private worn = false; private readonly headAt = new THREE.Vector3(); private readonly statusEl: HTMLElement; @@ -161,7 +166,9 @@ export class ModelLab { const [head, body, leftEye, rightEye, leftCut, rightCut, swelling, bleeding] = values as [number, number, number, number, number, number, number, number]; fighter.trauma = { head, body, left_eye: leftEye, right_eye: rightEye, left_cut: leftCut, right_cut: rightCut, swelling, bleeding }; } - const opponent = { ...base(), player_id: "other", x: 0, y: -150, facing_x: 0, facing_y: 1000 } as FighterSnapshot; + // `gap` is how far off the other man stands, in engine units: the stance opens up beyond about 215. + const gap = Number(this.params.get("gap") ?? 150); + const opponent = { ...base(), player_id: "other", x: 0, y: -gap, facing_x: 0, facing_y: 1000 } as FighterSnapshot; const tick = Math.floor(seconds * 30); const punch = /^(jab|straight|hook|uppercut)_(left|right)(_body)?(_power)?$/.exec(pose); if (punch !== null) { @@ -209,18 +216,20 @@ export class ModelLab { } else if (pose === "exhausted") { fighter.stamina = 80; } else if (pose.startsWith("walk")) { - const direction = pose.split("_")[1] ?? "forward"; - const speed = 6; - fighter.velocity_x = direction === "left" ? -speed : direction === "right" ? speed : 0; - fighter.velocity_y = direction === "forward" ? speed : direction === "back" ? -speed : 0; - const mapping = worldMapping({ tick_rate: 30, ring_half_width: 500, ring_half_height: 500 }); - const travel = seconds * speed * 30; - fighter.x = Math.round(Math.sin(seconds * 0.9) * 0); - fighter.y = Math.round(((travel % 400) - 200) * (direction === "forward" ? 1 : direction === "back" ? -1 : 0)); - fighter.x = Math.round(((travel % 400) - 200) * (direction === "right" ? 1 : direction === "left" ? -1 : 0)); - void mapping; + // `walk_[_]` or `walk_`, his own way, at `speed` engine units a tick. + // He faces the engine's -y with his left on its +x. + const words = pose.split("_").slice(1); + const aside = words.includes("left") ? 1 : words.includes("right") ? -1 : 0; + const ahead = words.includes("back") ? -1 : words.includes("forward") || aside === 0 ? 1 : 0; + const pace = Number(this.params.get("speed") ?? 6); + fighter.velocity_x = (aside * pace) / Math.hypot(ahead, aside); + fighter.velocity_y = (-ahead * pace) / Math.hypot(ahead, aside); + const ticks = (((seconds * 30 * pace) % 400) - 200) / pace; + fighter.x = Math.round(fighter.velocity_x * ticks); + fighter.y = Math.round(fighter.velocity_y * ticks); } - const head = new THREE.Vector3(0, 1.5, 150 * (3.05 / 500)); + // The other man's head, at the height a fighter in his stance carries it. + const head = new THREE.Vector3(0, 1.62, gap * (3.05 / 500)); return { fighter, opponent, sampledTick: tick, head }; } @@ -386,13 +395,16 @@ export class ModelLab { const listed = (name: string): InjuryId[] => (this.params.get(name) ?? "").split(",").filter((id): id is InjuryId => (INJURY_IDS as readonly string[]).includes(id)); this.injuries.push(...listed("injuries")); for (const [index, injury] of listed("inflict").entries()) this.inflictions.push({ injury, at: 1 + index * 0.8, done: false }); - const wanted = this.injuries.length > 0 || this.inflictions.length > 0 || ["fatality", "dead", "bloodvol", "dazed", "vomit"].some((name) => this.params.has(name)); + const wanted = this.injuries.length > 0 || this.inflictions.length > 0 || ["fatality", "dead", "bloodvol", "dazed", "vomit", "xray", "wear"].some((name) => this.params.has(name)); if (!wanted || this.graph === null) return; this.effects ??= new Effects3D(this.scene); this.effects.setBloodLevel(this.bloodSetting); this.effects.setCamera(this.camera); this.carnage = new Carnage(this.effects, bakeFlungPiece); this.carnage.attach(0, this.graph); + // `xray=` holds the whole skeleton up with that bone broken. + const xray = this.params.get("xray"); + if (xray !== null) this.carnage.holdXray(0, xray as BreakSite); } private stepCarnage(dt: number): void { @@ -424,6 +436,16 @@ export class ModelLab { const blood = Number(this.params.get("bloodvol") ?? 1000); const injuries = INJURY_IDS.filter((id) => this.injuries.includes(id)); carnage.sync(0, { injuries, blood_volume: Number.isFinite(blood) ? blood : 1000 }, { blood: this.bloodSetting, reducedMotion: false }, dt, this.elapsed, dazed); + const wear = Number(this.params.get("wear") ?? 0); + if (!this.worn && wear > 0 && this.elapsed >= 0.5) { + this.worn = true; + const spots: readonly (readonly [Target, number, number, number])[] = [["head", 0.06, 0.07, 0.1], ["body", 0.1, 0.02, 0.14], ["head", -0.05, 0.11, 0.1], ["body", -0.09, -0.06, 0.14]]; + for (let punch = 0; punch < wear; punch += 1) { + const [target, x, y, z] = spots[punch % spots.length]!; + graph.boxer.rig.bones[target === "head" ? "head" : "chest"].getWorldPosition(this.headAt); + carnage.land(0, 0, null, target, 260, 100, this.headAt.add(this.mouth.set(x, y, z))); + } + } } /** A fatality as the renderer shows it: the head off or burst for the ones that start there, then the rest. */ diff --git a/web/hands/src/render/boxer-look.test.ts b/web/hands/src/render/boxer-look.test.ts new file mode 100644 index 00000000..9309602e --- /dev/null +++ b/web/hands/src/render/boxer-look.test.ts @@ -0,0 +1,213 @@ +import * as THREE from "three"; +import { describe, expect, it } from "vitest"; +import { FaceLife } from "./face"; +import { SkinnedBoxer, loadBoxerGlb } from "./graph"; +import { LookShading, OFFICIAL_LOOKS } from "./looks"; +import { REFEREE_OUTFIT } from "./outfit"; +import { footShadowOpacity } from "./renderer"; +import { BONE_ADAPTER } from "./skeleton"; +import { SKIN_LIGHT_GLSL } from "./skin"; +import { TRUNKS_HEM } from "./trunks"; + +const gltf = await loadBoxerGlb(); +const fighter = (): SkinnedBoxer => new SkinnedBoxer(gltf, { skin: 0xb0703f, gear: 0x1d4ed8 }); +const referee = (): SkinnedBoxer => new SkinnedBoxer(gltf, { skin: 0xc79b76, gear: 0x3b57b8, look: OFFICIAL_LOOKS.referee, outfit: REFEREE_OUTFIT }); + +function mesh(boxer: SkinnedBoxer, name: string): THREE.SkinnedMesh { + let found: THREE.SkinnedMesh | null = null; + boxer.root.traverse((object) => { + if (object instanceof THREE.SkinnedMesh && object.name === name) found = object; + }); + if (found === null) throw new Error(`no mesh ${name}`); + return found; +} + +function compile(material: THREE.Material): { uniforms: Record; vertexShader: string; fragmentShader: string } { + const shader = { uniforms: {} as Record, vertexShader: THREE.ShaderLib.physical.vertexShader, fragmentShader: THREE.ShaderLib.physical.fragmentShader }; + material.onBeforeCompile(shader as unknown as THREE.WebGLProgramParametersWithUniforms, null as unknown as THREE.WebGLRenderer); + return shader; +} + +/** The lowest vertex, the widest and deepest the legs get below the crotch, and every bone the skin hangs from. */ +function measure(trunks: THREE.SkinnedMesh): { hem: number; waist: number; width: number; depth: number; bones: Set } { + const position = trunks.geometry.getAttribute("position"); + const skinIndex = trunks.geometry.getAttribute("skinIndex"); + const skinWeight = trunks.geometry.getAttribute("skinWeight"); + const out = { hem: Infinity, waist: -Infinity, width: 0, depth: 0, bones: new Set() }; + let back = Infinity; + let front = -Infinity; + for (let vertex = 0; vertex < position.count; vertex += 1) { + const y = position.getY(vertex); + out.hem = Math.min(out.hem, y); + out.waist = Math.max(out.waist, y); + if (y < 55) { + out.width = Math.max(out.width, Math.abs(position.getX(vertex))); + back = Math.min(back, position.getZ(vertex)); + front = Math.max(front, position.getZ(vertex)); + } + for (let slot = 0; slot < 4; slot += 1) if (skinWeight.getComponent(vertex, slot) > 0) out.bones.add(trunks.skeleton.bones[skinIndex.getComponent(vertex, slot)]!.name); + } + out.depth = front - back; + return out; +} + +describe("a fighter's trunks", () => { + const scanned = measure(mesh(referee(), "BoxerPants")); + const tailored = measure(mesh(fighter(), "BoxerPants")); + + it("end above the knee and over the top of the thigh's skin, where the scan hung past the knee", () => { + const knee = 39.4; + expect(scanned.hem).toBeLessThan(knee); + expect(tailored.hem).toBeCloseTo(TRUNKS_HEM, 2); + expect(tailored.hem).toBeGreaterThan(knee + 4); + // The scan left the legs open under the trunks: the thigh's skin starts at 49. + expect(tailored.hem).toBeLessThan(49 - 3); + }); + + it("are taken in round the legs and keep the waistband", () => { + expect(tailored.width).toBeLessThan(scanned.width - 1.2); + expect(tailored.depth).toBeLessThan(scanned.depth * 0.82); + expect(tailored.waist).toBeCloseTo(scanned.waist, 6); + }); + + it("hang from the thighs alone, so a bent knee does not drag the hem", () => { + expect(scanned.bones.has(BONE_ADAPTER.kneeL!) || scanned.bones.has(BONE_ADAPTER.kneeR!)).toBe(true); + expect(tailored.bones.has(BONE_ADAPTER.kneeL!)).toBe(false); + expect(tailored.bones.has(BONE_ADAPTER.kneeR!)).toBe(false); + }); + + it("are one geometry for every fighter, and an official keeps the scan for his trousers", () => { + expect(mesh(fighter(), "BoxerPants").geometry).toBe(mesh(fighter(), "BoxerPants").geometry); + expect(mesh(referee(), "BoxerPants").geometry).not.toBe(mesh(fighter(), "BoxerPants").geometry); + }); +}); + +describe("a fighter's skin", () => { + it("scatters each light past the edge of its shadow and takes its relief from the scan, on top of the injuries and the look", () => { + const boxer = fighter(); + for (const name of ["BoxerHead", "BoxerBody"]) { + const material = mesh(boxer, name).material as THREE.MeshPhysicalMaterial; + const shader = compile(material); + expect(shader.fragmentShader).toContain(SKIN_LIGHT_GLSL); + expect(shader.fragmentShader.indexOf("#include ")).toBeLessThan(shader.fragmentShader.indexOf("RE_Direct_Skin")); + expect(shader.fragmentShader).toContain("uInjuryBruise"); + expect(material.bumpMap).toBe(material.map); + expect(material.customProgramCacheKey()).toContain("-skin"); + } + }); + + it("is left plain on an official", () => { + const shader = compile(mesh(referee(), "BoxerHead").material as THREE.MeshStandardMaterial); + expect(shader.fragmentShader).not.toContain("RE_Direct_Skin"); + }); +}); + +describe("the face", () => { + const still = (face: FaceLife, seconds: number, effort = false, spent = 0, dazed = 0, out = false, reducedMotion = false): void => { + for (let frame = 0; frame < seconds * 60; frame += 1) face.update(1 / 60, reducedMotion, effort, spent, dazed, out); + }; + + it("blinks every few seconds, the eyes open in between, and two fighters not together", () => { + const blinks = (seed: number): number[] => { + const face = new FaceLife(seed); + const starts: number[] = []; + let shut = false; + for (let frame = 0; frame < 20 * 60; frame += 1) { + face.update(1 / 60, false, false, 0, 0, false); + if (face.lids > 0.6 && !shut) starts.push(frame / 60); + shut = face.lids > 0.6; + expect(face.mouth).toBeLessThan(0.01); + } + return starts; + }; + const one = blinks(1); + expect(one.length).toBeGreaterThanOrEqual(3); + expect(one.length).toBeLessThanOrEqual(10); + for (let index = 1; index < one.length; index += 1) expect(one[index]! - one[index - 1]!).toBeGreaterThan(2); + expect(blinks(2)).not.toEqual(one); + }); + + it("squeezes the eyes shut and knocks the mouth open on a clean head shot, and lets go within a second", () => { + const face = new FaceLife(3); + face.flinch(1, true); + face.update(1 / 60, false, false, 0, 0, false); + expect(face.lids).toBeGreaterThan(0.9); + still(face, 0.1); + expect(face.mouth).toBeGreaterThan(0.4); + expect(face.brow).toBeGreaterThan(0.3); + still(face, 1); + expect(face.lids).toBeLessThan(0.05); + expect(face.mouth).toBeLessThan(0.05); + }); + + it("knocks the wind out through the mouth on a body shot more than it shuts the eyes", () => { + const face = new FaceLife(3); + face.flinch(1, false); + still(face, 0.1); + expect(face.mouth).toBeGreaterThan(face.lids); + }); + + it("grits behind a power punch, gasps when spent and closes its eyes on the canvas", () => { + const effort = new FaceLife(4); + still(effort, 0.3, true); + expect(effort.brow).toBeGreaterThan(0.9); + expect(effort.lids).toBeGreaterThan(0.3); + const spent = new FaceLife(4); + let widest = 0; + let narrowest = 1; + for (let frame = 0; frame < 120; frame += 1) { + spent.update(1 / 60, false, false, 1, 0, false); + if (frame > 30) { + widest = Math.max(widest, spent.mouth); + narrowest = Math.min(narrowest, spent.mouth); + } + } + expect(widest).toBeGreaterThan(0.45); + expect(narrowest).toBeLessThan(0.15); + const out = new FaceLife(4); + still(out, 0.5, false, 0, 0, true); + expect(out.lids).toBeGreaterThan(0.95); + expect(out.mouth).toBeGreaterThan(0.3); + }); + + it("neither blinks nor heaves with reduced motion, and still answers a blow", () => { + const face = new FaceLife(5); + for (let frame = 0; frame < 20 * 60; frame += 1) { + face.update(1 / 60, true, false, 1, 0, false); + expect(face.lids).toBeLessThan(0.01); + if (frame > 60) expect(face.mouth).toBeCloseTo(0.3, 2); + } + face.flinch(1, true); + face.update(1 / 60, true, false, 0, 0, false); + expect(face.lids).toBeGreaterThan(0.9); + }); + + it("is painted before the injuries, so an eye swollen shut or forced out covers a blink", () => { + const boxer = fighter(); + const shader = compile(boxer.headMesh.material as THREE.Material); + const blink = shader.fragmentShader.indexOf("uLookExpression.x"); + expect(blink).toBeGreaterThan(0); + expect(blink).toBeLessThan(shader.fragmentShader.indexOf("vec4 lid = uInjuryLid[e];")); + expect(shader.vertexShader).toContain("vLookJaw = jawDrop;"); + boxer.flinch(1, true); + boxer.updateFace(1 / 60, false, false, 0, 0, false); + expect((shader.uniforms.uLookExpression!.value as THREE.Vector3).x).toBeGreaterThan(0.9); + }); + + it("is left off a baked head, which is posed on the CPU without it", () => { + const material = new THREE.MeshStandardMaterial(); + new LookShading(material, true); + const shader = compile(material); + expect(shader.fragmentShader).not.toContain("uLookExpression"); + expect(shader.vertexShader).not.toContain("uLookExpression"); + }); +}); + +describe("the shadow under a boot", () => { + it("is darkest with the foot planted and gone once it is lifted", () => { + expect(footShadowOpacity(0)).toBeCloseTo(0.9, 6); + expect(footShadowOpacity(-0.02)).toBeCloseTo(0.9, 6); + expect(footShadowOpacity(0.08)).toBeCloseTo(0.45, 6); + expect(footShadowOpacity(0.2)).toBe(0); + }); +}); diff --git a/web/hands/src/render/carnage.test.ts b/web/hands/src/render/carnage.test.ts index 282208d5..14c77d50 100644 --- a/web/hands/src/render/carnage.test.ts +++ b/web/hands/src/render/carnage.test.ts @@ -403,7 +403,9 @@ describe("a fatality on the fighter", () => { ring.step(2); }; turn("reduced"); - const whole = (): unknown[] => [ring.mutilation.isPartGone("upper_body"), ring.effects.hasPart("0:upper_body"), ring.effects.openWounds, ring.effects.gutsOut(0), ring.effects.eyeOut(0, "left"), ring.effects.eyeOut(0, "right")]; + // The wounds the fatality opened: a man just dead also lets his bladder go, which is none of them. + const wounds = (): number => ring.effects.openWounds - (ring.effects.woundStrength(0, "crotch") > 0 ? 1 : 0); + const whole = (): unknown[] => [ring.mutilation.isPartGone("upper_body"), ring.effects.hasPart("0:upper_body"), wounds(), ring.effects.gutsOut(0), ring.effects.eyeOut(0, "left"), ring.effects.eyeOut(0, "right")]; expect(whole(), fatality).toEqual([false, false, 0, false, false, false]); // He is still dead, and turning it back up does not kill him a second time. turn("full"); diff --git a/web/hands/src/render/carnage.ts b/web/hands/src/render/carnage.ts index 27543219..d3d3828b 100644 --- a/web/hands/src/render/carnage.ts +++ b/web/hands/src/render/carnage.ts @@ -5,6 +5,7 @@ import type { BakedPart, DebrisKind, Effects3D, GoreDebris, SprayDirection } fro import type { BoxingGraph, SkinnedBoxer } from "./graph"; import { Mutilation, fighterMesh, inBodyPart } from "./mutilation"; import type { CanonicalBone } from "./rig"; +import { BoneXray, breakFor, type BreakSite } from "./xray"; /** * Freezes a piece of one of a fighter's meshes, as he is posed, into a rigid piece measured from a pivot and @@ -71,11 +72,12 @@ const GUTTED_LINKS = 36; const TERROR = 0.45; /** A fighter bleeding at least this hard, as a wound's strength, treads it across the canvas. */ const TRACKING_BLEED = 0.25; -/** Metres a boot travels between the prints it leaves, how far ahead of the ankle the middle of its sole is, and how far off the canvas the ankle of a planted foot may be. */ +/** Metres a boot travels between the prints it leaves, how far ahead of the ankle the middle of its sole is, and how far off the canvas the ball of a planted foot may be. */ const STRIDE = 0.3; const SOLE_AHEAD = 0.08; const PLANTED_SLACK = 0.012; const FEET = ["ankleL", "ankleR"] as const; +const BALLS = ["toeL", "toeR"] as const; /** * A body whose waist is lower than this, in metres, is on the canvas. It smears every so many metres it * slides; moved further than a jump between two frames, it was put there (a replay's cut) and smears nothing. @@ -86,6 +88,37 @@ const DRAG_JUMP = 0.5; const DRAG_WIDTH = 0.3; /** Metres in front of his mouth that what he vomits lands. */ const VOMIT_REACH = 0.4; +/** + * How much of the other man's blood is on a fighter for the blood that man has lost (as a share of all of it) + * and for each injury he carries, and how much a punch's blood adds for each point of it. + */ +const SPATTER_PER_LOST = 2.2; +const SPATTER_PER_INJURY = 0.12; +const SPATTER_PER_BLOOD = 0.0004; +/** A punch's own blood lands on the man it came from this much as heavily as on the man who threw it. */ +const OWN_SPATTER = 0.4; +/** Blood from a cut runs this far when it is fresh, as a multiple of the shader's run, and this much further for all the blood he has lost. */ +const RUN_FRESH = 0.6; +const RUN_PER_LOST = 4; +const RUN_MOST = 1.1; +/** The mark a punch leaves is this deep for each point of its damage, between these. */ +const MARK_PER_DAMAGE = 1 / 500; +const MARK_LEAST = 0.18; +const MARK_MOST = 0.55; +/** Gloves this soaked drip, a drop every so many seconds when they are soaked through, from this far under the wrist. */ +const GLOVE_DRIPS = 0.45; +const GLOVE_DRIP_SECONDS = 0.5; +const GLOVE_DROP = 0.08; +const GLOVES = ["gloveL", "gloveR"] as const; +/** The torso in bind space, where a body punch leaves its mark: above the trunks and inside the arms. */ +const TORSO = { bottom: 80, top: 108, half: 17 } as const; +/** Drops a punch squeezes out of a wound already open where it lands, for a wound at full strength, and the teeth it knocks from a jaw already broken. */ +const SQUEEZED_DROPS = 70; +const LOOSE_TEETH = 2; +/** A man who dies lets go: his bladder empties for this long, as hard as a wound of this strength, and what leaves him pools this wide under him, in metres. */ +const LETS_GO_SECONDS = 7; +const LETS_GO = 0.5; +const LETS_GO_POOL = 0.28; const SIDES: readonly Side[] = ["left", "right"]; const EYE_OUT: Readonly> = { left: "eye_left_out", right: "eye_right_out" }; const EYE_SITE: Readonly> = { left: "eye_left", right: "eye_right" }; @@ -143,6 +176,17 @@ interface Body { /** Where his body lay when it last smeared the canvas, and whether it is lying on it. */ readonly dragged: THREE.Vector3; sliding: boolean; + /** The bone a punch last broke in him, the tick it landed on, and the way it went: a replay of that punch breaks it again. */ + broke: { readonly site: BreakSite; readonly tick: number; readonly x: number; readonly z: number } | null; + /** How much blood punches have thrown onto him, 0 to 1, and how much of his own he has lost, as a share. */ + spatter: number; + lost: number; + /** Seconds until his gloves next drip, and the drops they have shed. */ + dripIn: number; + dripped: number; + /** When he died, in seconds, and whether what left him as he lay has pooled under him. */ + diedAt: number; + voided: boolean; } const UP = new THREE.Vector3(0, 1, 0); @@ -161,20 +205,28 @@ export class Carnage { private readonly axis = new THREE.Vector3(); private readonly scratch = new THREE.Vector3(); private readonly turn = new THREE.Quaternion(); + private readonly matrix = new THREE.Matrix4(); private readonly skullOffset = new THREE.Vector3(); private readonly injuries = new Set(); private time = 0; private settings: CarnageSettings = { blood: "full", reducedMotion: false }; - constructor(private readonly effects: Effects3D, private readonly bake: BakePiece) {} + /** The X-ray a breaking bone is shown in. */ + readonly xray = new BoneXray(); + + constructor(private readonly effects: Effects3D, private readonly bake: BakePiece) { + effects.scene.add(this.xray.root); + } /** Takes on a fighter's body. Its mutilation is made here and disposed of with the carnage. */ attach(index: number, graph: BoxingGraph): Mutilation { this.bodies[index]?.mutilation.dispose(); + this.xray.prepare(graph.boxer); const body: Body = { graph, mutilation: new Mutilation(graph.boxer), shown: new Set(), early: new Map(), awaited: new Map(), inflicted: new Set(), fatalWounds: new Map(), forced: new Set(), fatalParts: [], burst: new Set(), fatality: null, dead: null, gutsDropAt: null, gibbed: false, - vomitUntil: 0, printed: [new THREE.Vector3(), new THREE.Vector3()], dragged: new THREE.Vector3(), sliding: false, + vomitUntil: 0, printed: [new THREE.Vector3(), new THREE.Vector3()], dragged: new THREE.Vector3(), sliding: false, broke: null, + spatter: 0, lost: 0, dripIn: 0, dripped: 0, diedAt: 0, voided: false, }; this.bodies[index] = body; return body.mutilation; @@ -247,9 +299,14 @@ export class Carnage { // Anything that stood a dead man back up (the end of a replay) is undone here. if (body.dead !== null && !body.graph.isDead) body.graph.die(body.dead); body.mutilation.update(dt, time); + if (this.xray.owner === index) { + if (graphic && !body.gibbed) this.xray.update(dt); + else this.xray.stop(); + } // Blown to pieces, nothing of him is drawn. boxer.root.visible = !body.gibbed; if (body.gibbed) return; + this.wear(body, index, drained, dt); // A wound on a part of him that is gone has nowhere to pour from, and an eye nothing to hang from. const halved = body.mutilation.isPartGone("upper_body"); @@ -267,6 +324,10 @@ export class Carnage { if (site === "crotch" && terrified && body.dead === null) { strength = TERROR; fluid = "urine"; + } else if (site === "crotch" && body.dead !== null && time < body.diedAt + LETS_GO_SECONDS) { + // Dead, everything in him lets go. + strength = LETS_GO; + fluid = "urine"; } if (!graphic || (halved ? !LOWER_WOUNDS.has(site) : HEAD_WOUNDS.has(site) && (headless || (faceless && site !== "mouth")))) strength = 0; if (fluid === "blood") pouring += strength; @@ -306,8 +367,14 @@ export class Carnage { if (graphic && body.dead === null && pouring >= TRACKING_BLEED) this.track(body, Math.min(1, pouring)); if (body.dead === null || !body.mutilation.anchor("waist", this.position, this.axis)) return; this.effects.setCorpse(index, graphic ? this.position : null); - // A body sliding across the canvas smears what it lies in. const lying = graphic && this.position.y < LYING; + // As he comes to rest, what he let go of pools under him. + if (lying && !body.voided) { + body.voided = true; + this.effects.puddle(this.position.x, this.position.z, LETS_GO_POOL, "urine", index + 311); + this.effects.puddle(this.position.x - this.axis.x * 0.1, this.position.z - this.axis.z * 0.1, LETS_GO_POOL * 0.6, "bile", index + 313); + } + // A body sliding across the canvas smears what it lies in. const moved = Math.hypot(this.position.x - body.dragged.x, this.position.z - body.dragged.z); if (!lying || !body.sliding || moved > DRAG_JUMP) body.dragged.copy(this.position); else if (moved > DRAG_STEP) { @@ -328,6 +395,96 @@ export class Carnage { return shown === undefined || !this.graphic || !(shown.has(GLOVE_LOST[hand][0]) || shown.has(GLOVE_LOST[hand][1])); } + /** + * The fight on his skin and gear: the other man's blood that has landed on him (what punches threw there, and + * never less than that man's lost blood and wounds account for, so a late spectator sees it too), his own + * blood running further the more of it he has lost, and soaked gloves dripping. + */ + private wear(body: Body, index: number, drained: number, dt: number): void { + const boxer = body.graph.boxer; + const graphic = this.graphic; + const other = this.bodies[1 - index] ?? null; + body.lost = drained; + const thrown = other === null ? 0 : other.lost * SPATTER_PER_LOST + other.shown.size * SPATTER_PER_INJURY; + const worn = graphic ? Math.min(1, Math.max(body.spatter, thrown)) : 0; + boxer.headInjury.setSpatter(worn * 0.8); + boxer.bodyInjury.setSpatter(worn); + // The graph sets the gear from his trauma each frame: what has landed on him soaks it at least this far. + boxer.setGloveBlood(Math.max(boxer.gloveBloodLevel, worn)); + boxer.setTrunksBlood(Math.max(boxer.trunksBloodLevel, worn * 0.7)); + const run = this.settings.blood === "off" ? 1 : RUN_FRESH + Math.min(RUN_MOST, drained * RUN_PER_LOST); + boxer.headInjury.setRun(run); + boxer.bodyInjury.setRun(run); + if (this.settings.blood === "off") { + boxer.headInjury.clearMarks(); + boxer.bodyInjury.clearMarks(); + } + if (!graphic || body.dead !== null || boxer.gloveBloodLevel < GLOVE_DRIPS) return; + body.dripIn -= dt; + if (body.dripIn > 0) return; + body.dripIn = GLOVE_DRIP_SECONDS / boxer.gloveBloodLevel; + body.dripped += 1; + const hand = body.dripped % 2; + if (!this.hasGlove(index, SIDES[hand]!)) return; + boxer.rig.bones[GLOVES[hand]!].getWorldPosition(this.position); + this.position.y -= GLOVE_DROP; + this.effects.shed(this.position, index * 4099 + body.dripped); + } + + /** + * A clean punch lands: `puncher`'s `hand` on `victim`'s head or body, for `amount` damage and `blood`. It + * leaves its mark where the glove is (at `point` when the hand is not known), the blood it knocks out of him + * lands on both men and stays, and it squeezes more out of every wound already open where it lands: each + * spurts the way the punch went, and a jaw already broken sheds more teeth. + */ + land(victim: number, puncher: number, hand: Side | null, target: "head" | "body", amount: number, blood: number, point: THREE.Vector3, eventId = 0, direction: number | SprayDirection = 1): void { + const thrower = this.bodies[puncher] ?? null; + const struck = this.bodies[victim] ?? null; + if (thrower !== null && hand !== null && this.hasGlove(puncher, hand)) thrower.graph.boxer.rig.bones[GLOVES[hand === "left" ? 0 : 1]].getWorldPosition(this.scratch); + else this.scratch.copy(point); + this.bruise(victim, this.scratch, target, amount); + if (!this.graphic) return; + if (blood > 0 && thrower !== null) thrower.spatter = Math.min(1, thrower.spatter + blood * SPATTER_PER_BLOOD); + if (blood > 0 && struck !== null) struck.spatter = Math.min(1, struck.spatter + blood * SPATTER_PER_BLOOD * OWN_SPATTER); + if (struck === null || struck.gibbed) return; + for (let slot = 0; slot < WOUND_SITES.length; slot += 1) { + const site = WOUND_SITES[slot]!; + const strength = this.effects.woundStrength(victim, site); + if (strength <= 0 || (target === "head" ? !HEAD_WOUNDS.has(site) : HEAD_WOUNDS.has(site) || LOWER_WOUNDS.has(site))) continue; + if (struck.mutilation.anchor(site, this.position, this.axis)) this.effects.sprayFluid("blood", this.position, direction, Math.round(SQUEEZED_DROPS * strength), eventId + slot + 1, 0.8); + } + if (target === "head" && struck.shown.has("broken_jaw") && struck.mutilation.anchor("mouth", this.position, this.axis)) this.effects.spawnTeeth(this.position, direction, LOOSE_TEETH, eventId); + } + + /** + * A clean punch of `amount` damage lands on his head or body, the glove at `point` in the world: it leaves + * its mark on the skin nearest that, which darkens to a bruise and splits when it is hit again. + */ + bruise(index: number, point: THREE.Vector3, target: "head" | "body", amount: number): void { + const body = this.bodies[index]; + if (body === null || body === undefined || body.gibbed || this.settings.blood === "off") return; + const boxer = body.graph.boxer; + const mesh = target === "head" ? boxer.headMesh : fighterMesh(boxer, "body"); + if (mesh === null || !body.mutilation.skinMatrix(target, target === "head" ? "head" : "chest", this.matrix)) return; + const at = this.position.copy(point).applyMatrix4(this.matrix.invert()); + const bind = mesh.geometry.getAttribute("position"); + let nearest = Number.POSITIVE_INFINITY; + let found = -1; + for (let vertex = 0; vertex < bind.count; vertex += 1) { + const x = bind.getX(vertex); + const y = bind.getY(vertex); + if (target === "body" && (y < TORSO.bottom || y > TORSO.top || Math.abs(x) > TORSO.half)) continue; + const distance = (x - at.x) ** 2 + (y - at.y) ** 2 + (bind.getZ(vertex) - at.z) ** 2; + if (distance < nearest) { + nearest = distance; + found = vertex; + } + } + if (found < 0) return; + const weight = THREE.MathUtils.clamp(amount * MARK_PER_DAMAGE, MARK_LEAST, MARK_MOST); + (target === "head" ? boxer.headInjury : boxer.bodyInjury).mark(bind.getX(found), bind.getY(found), bind.getZ(found), weight); + } + /** Whether the fighter is bringing something up now: its gush is this class's to keep on his mouth. */ vomiting(index: number): boolean { return this.time < (this.bodies[index]?.vomitUntil ?? 0); @@ -347,9 +504,9 @@ export class Carnage { /** * The moment an injury happens, as its punch lands: what it tears off and throws. Shown once; false when it - * has been shown already or there is nobody to show it on. + * has been shown already or there is nobody to show it on. `tick` is the tick the punch landed on. */ - inflict(index: number, injury: InjuryId, eventId: number, direction: number | SprayDirection): boolean { + inflict(index: number, injury: InjuryId, eventId: number, direction: number | SprayDirection, tick = -1): boolean { const body = this.bodies[index]; if (body === null || body === undefined) return false; body.awaited.delete(injury); @@ -358,6 +515,12 @@ export class Carnage { body.early.set(injury, this.time + EARLY_SECONDS); body.shown.add(injury); if (!this.graphic) return true; + const site = breakFor(injury); + if (site !== null) { + const push = typeof direction === "number" ? { x: Math.sign(direction), z: 0 } : direction; + body.broke = { site, tick, x: push.x, z: push.z }; + this.xray.start(index, body.graph.boxer, body.mutilation, site, push.x, push.z); + } const effects = this.effects; const at = this.position; const axis = this.axis; @@ -469,6 +632,40 @@ export class Carnage { return true; } + /** + * A knockout replay reaches its punch, which landed on `tick`: the bone that punch broke is shown breaking + * again, in the replay's slow motion. False when the punch broke none, or nothing explicit is drawn. + */ + rebreak(index: number, tick: number): boolean { + const body = this.bodies[index]; + const broke = body?.broke ?? null; + if (body === null || body === undefined || broke === null || broke.tick !== tick || !this.graphic || body.gibbed) return false; + this.xray.start(index, body.graph.boxer, body.mutilation, broke.site, broke.x, broke.z); + return true; + } + + /** + * Draws the cut-in of a breaking bone over the picture just rendered, without the mist that hangs round a + * punch and would veil it, and without `backdrop` (the arena and its crowd), which it has no need to draw again. + */ + drawBreak(renderer: THREE.WebGLRenderer, scene: THREE.Scene, camera: THREE.Camera, backdrop: THREE.Object3D): void { + if (this.xray.owner < 0) return; + const mist = this.effects.mistPoints; + const misty = mist.visible; + const there = backdrop.visible; + mist.visible = false; + backdrop.visible = false; + this.xray.drawInset(renderer, scene, camera); + mist.visible = misty; + backdrop.visible = there; + } + + /** Holds the whole skeleton up with the bone at `site` broken, for the lab. */ + holdXray(index: number, site: BreakSite): void { + const body = this.bodies[index]; + if (body !== null && body !== undefined) this.xray.start(index, body.graph.boxer, body.mutilation, site, 1, 0, true); + } + /** He brings up blood and bile, doubled over, for `seconds`, and it pools where it lands. */ vomit(index: number, eventId: number, seconds = 1.3): void { const body = this.bodies[index]; @@ -598,6 +795,7 @@ export class Carnage { if (body === null || body === undefined) return; const first = body.dead === null; body.dead = cause; + if (first) body.diedAt = this.time; if (!body.graph.isDead) body.graph.die(cause); if (first && (cause === "brain" || cause === "gutted") && this.graphic) this.vomit(index, index + 77, 2.2); } @@ -606,17 +804,20 @@ export class Carnage { undoDeath(index: number): void { const body = this.bodies[index]; if (body === null || body === undefined) return; + if (this.xray.owner === index) this.xray.stop(); this.unmaim(body, index); body.dead = null; body.fatality = null; body.sliding = false; body.vomitUntil = 0; + body.voided = false; // His wounds, gut and eyes are shown again from his injuries on the next frame. this.effects.restoreFighter(index); } dispose(): void { for (const body of this.bodies) body?.mutilation.dispose(); + this.xray.dispose(); this.bodies.fill(null); } @@ -636,13 +837,17 @@ export class Carnage { /** His boots are in what pours from him: each one leaves its print where it comes down, as dark as he bleeds. */ private track(body: Body, strength: number): void { const boxer = body.graph.boxer; - const planted = boxer.rig.metrics.ankleHeight + PLANTED_SLACK; + // A boxer stands on the balls of his feet with a heel up, so it is the ball that tells a planted foot: the pose + // rests it this high, where the sole meets the toes. + const { ankleHeight, footLength } = boxer.rig.metrics; + const planted = ankleHeight * (1 - footLength / Math.hypot(footLength, ankleHeight)) + PLANTED_SLACK; boxer.root.getWorldDirection(this.axis); const yaw = Math.atan2(this.axis.x, this.axis.z); for (let foot = 0; foot < FEET.length; foot += 1) { + const ball = boxer.rig.bones[BALLS[foot]!].getWorldPosition(this.position).y; boxer.rig.bones[FEET[foot]!].getWorldPosition(this.position); const printed = body.printed[foot]!; - if (this.position.y > planted || Math.hypot(this.position.x - printed.x, this.position.z - printed.z) < STRIDE) continue; + if (ball > planted || Math.hypot(this.position.x - printed.x, this.position.z - printed.z) < STRIDE) continue; printed.copy(this.position); this.effects.footprint(this.position.x + this.axis.x * SOLE_AHEAD, this.position.z + this.axis.z * SOLE_AHEAD, yaw, foot === 0, strength); } diff --git a/web/hands/src/render/effects.ts b/web/hands/src/render/effects.ts index 35cf2599..713ca06e 100644 --- a/web/hands/src/render/effects.ts +++ b/web/hands/src/render/effects.ts @@ -860,7 +860,7 @@ export class Effects3D { private readonly flies: Float32Array; /** `bloodCanvasSize` is the resolution blood on the canvas is painted at, in pixels across the ring. */ - constructor(private readonly scene: THREE.Scene, bloodCanvasSize = 1024, private readonly budget: GoreBudget = DESKTOP_GORE) { + constructor(readonly scene: THREE.Scene, bloodCanvasSize = 1024, private readonly budget: GoreBudget = DESKTOP_GORE) { this.dropletPositions = new Float32Array(budget.droplets * 3); this.dropletColors = new Float32Array(budget.droplets * 3); this.dropletBuffers = { @@ -3098,6 +3098,13 @@ export class Effects3D { this.canvasBlood.pool(finite(x), finite(z), Math.max(0.02, finite(radius, 0.1)), 0.95 * look.soak, stamp, look.pool); } + /** A drop of blood lets go of what it hung from (a soaked glove) and falls. */ + shed(at: THREE.Vector3, eventId: number): void { + if (this.bloodLevel !== "full") return; + const rand = seeded(eventId * 7919 + 11); + this.spawnDroplet(finite(at.x) + (rand() - 0.5) * 0.05, finite(at.y, 1), finite(at.z) + (rand() - 0.5) * 0.05, (rand() - 0.5) * 0.2, -0.1, (rand() - 0.5) * 0.2, fluidShade("blood", rand()), 1.6, true); + } + /** A drag mark in blood on the canvas from one place to another, `width` metres wide. */ smear(fromX: number, fromZ: number, toX: number, toZ: number, width: number): void { if (this.bloodLevel !== "full") return; diff --git a/web/hands/src/render/face.ts b/web/hands/src/render/face.ts new file mode 100644 index 00000000..6e3c0472 --- /dev/null +++ b/web/hands/src/render/face.ts @@ -0,0 +1,71 @@ +/** + * What a fighter's face is doing, as the three things the head's shader can show: how far the lids are + * shut, how far the mouth hangs open and how hard the brow is drawn down. He blinks; a clean shot squeezes + * his eyes shut and knocks his mouth open; he grits his teeth behind a power punch; spent, he gasps; dazed, + * his lids droop and his jaw slackens; and on the canvas his eyes are closed. + */ +const BLINK_SECONDS = 0.16; +const BLINK_EVERY = [2.2, 5.6] as const; +/** A flinch is on the face at once and gone in about a third of a second. */ +const FLINCH_DECAY = 5.5; +const EXPRESSION_RATE = 14; +const GASPS_PER_SECOND = 1.4; + +export class FaceLife { + lids = 0; + mouth = 0; + brow = 0; + private seed: number; + private blinkIn: number; + private blink = 0; + private wince = 0; + private gape = 0; + private breath = 0; + + /** `seed` staggers the blinks so two fighters never blink together. */ + constructor(seed: number) { + this.seed = (seed >>> 0) || 1; + this.blinkIn = this.nextBlink(); + } + + private nextBlink(): number { + this.seed = (Math.imul(this.seed, 1664525) + 1013904223) >>> 0; + return BLINK_EVERY[0] + (this.seed / 4294967296) * (BLINK_EVERY[1] - BLINK_EVERY[0]); + } + + /** A blow landing, `force` 0 to 1: one to the head shuts the eyes, one to the body knocks the wind out through the mouth. */ + flinch(force: number, head: boolean): void { + const hurt = Math.min(1, Math.max(0, force)); + this.wince = Math.max(this.wince, head ? 0.55 + 0.45 * hurt : 0.3 + 0.4 * hurt); + this.gape = Math.max(this.gape, head ? 0.25 + 0.6 * hurt : 0.5 + 0.5 * hurt); + } + + /** + * `effort` while a power punch is thrown, `spent` and `dazed` 0 to 1, `out` on the canvas. With reduced + * motion the face still answers what happens to him but neither blinks nor heaves. + */ + update(dt: number, reducedMotion: boolean, effort: boolean, spent: number, dazed: number, out: boolean): void { + const step = Math.max(0, dt); + this.wince = Math.max(0, this.wince - this.wince * FLINCH_DECAY * step - 0.2 * step); + this.gape = Math.max(0, this.gape - this.gape * FLINCH_DECAY * 0.6 * step - 0.15 * step); + if (!reducedMotion && !out) { + this.blinkIn -= step; + if (this.blinkIn <= 0) { + this.blink = BLINK_SECONDS; + this.blinkIn = this.nextBlink(); + } + this.breath += step * GASPS_PER_SECOND * Math.PI * 2; + } + this.blink = Math.max(0, this.blink - step); + const blinking = this.blink > 0 ? Math.sin((this.blink / BLINK_SECONDS) * Math.PI) : 0; + const gasp = reducedMotion ? 0.3 : 0.3 + 0.25 * Math.sin(this.breath); + const lids = out ? 1 : Math.max(blinking, this.wince, effort ? 0.4 : 0, dazed * 0.55); + const mouth = out ? 0.45 : Math.max(this.gape, effort ? 0.3 : 0, spent * gasp, dazed * 0.35); + const brow = out ? 0 : Math.max(effort ? 1 : 0, this.wince * 0.8); + const blend = 1 - Math.exp(-EXPRESSION_RATE * step); + // A blink and a wince are already timed: easing them again would lose them between two frames. + this.lids = Math.max(blinking, this.wince, this.lids + (lids - this.lids) * blend); + this.mouth += (mouth - this.mouth) * blend; + this.brow += (brow - this.brow) * blend; + } +} diff --git a/web/hands/src/render/fighter-presentation.test.ts b/web/hands/src/render/fighter-presentation.test.ts index 158c3932..e62af0e6 100644 --- a/web/hands/src/render/fighter-presentation.test.ts +++ b/web/hands/src/render/fighter-presentation.test.ts @@ -100,7 +100,8 @@ describe("taunt", () => { const outstretched = Math.max(...reach); let beckons = 0; let curled = false; - for (const z of reach) { + // Counted while he taunts: afterwards the glove goes back to the guard, which at this range is drawn in by his face. + for (const z of reach.slice(0, 120)) { if (!curled && z < outstretched - 0.15) { curled = true; beckons += 1; diff --git a/web/hands/src/render/footwork.test.ts b/web/hands/src/render/footwork.test.ts new file mode 100644 index 00000000..fd8c0138 --- /dev/null +++ b/web/hands/src/render/footwork.test.ts @@ -0,0 +1,329 @@ +import * as THREE from "three"; +import { MAX_SPEED } from "../manifest"; +import { fighter as baseFighter } from "../test/fixtures"; +import type { FighterSnapshot, Stance } from "../types"; +import { BoxingGraph, SkinnedBoxer, loadBoxerGlb } from "./graph"; +import { STANCE } from "./poser"; +import { worldPosition, type CanonicalBone } from "./rig"; +import { worldMapping } from "./world"; + +const mapping = worldMapping({ tick_rate: 30, ring_half_width: 500, ring_half_height: 500 }); +const gltf = await loadBoxerGlb(); + +/** The other man, out of range to the side, so the stance stays the open one wherever the fighter walks. */ +const opponent: FighterSnapshot = { ...baseFighter("two"), x: 400, y: 0, facing_x: -1000, facing_y: 0 }; +/** How far off the canvas the ball of a foot is while it steps, at least. */ +const LIFTED = 0.004; + +/** A fighter at the centre of the ring facing world +z, so his left is world +x, with each frame's feet measured. */ +class Walker { + readonly boxer = new SkinnedBoxer(gltf, { skin: 0xb0703f, gear: 0x1d4ed8 }); + readonly graph = new BoxingGraph(this.boxer, mapping); + readonly idle: FighterSnapshot; + private frame = 0; + private x = 0; + private y = 0; + /** The height of the ball of each planted foot, left then right. */ + private readonly ground: [number, number]; + + constructor(stance: Stance = "orthodox", id = "one") { + this.idle = { ...baseFighter(id), stance, facing_x: 0, facing_y: -1000, x: 0, y: 0 }; + this.stand(40); + this.ground = [this.at("toeL").y, this.at("toeR").y]; + } + + at(bone: CanonicalBone): THREE.Vector3 { + this.boxer.root.updateMatrixWorld(true); + return worldPosition(this.boxer.rig.bones[bone], new THREE.Vector3()); + } + + /** Which feet are off the canvas, left then right. */ + get lifted(): [boolean, boolean] { + return [this.at("toeL").y > this.ground[0] + LIFTED, this.at("toeR").y > this.ground[1] + LIFTED]; + } + + private show(fighter: FighterSnapshot): void { + this.graph.update(fighter, opponent, 1 / 60, this.frame / 60, false, "full", this.frame / 2); + this.frame += 1; + } + + stand(frames: number, fighter: Partial = {}): void { + for (let count = 0; count < frames; count += 1) this.show({ ...this.idle, ...fighter, x: this.x, y: this.y }); + } + + /** One frame of walking `ahead` and to his `left` (each -1, 0 or 1) at `pace` engine units a tick. */ + walk(ahead: number, left: number, pace: number): void { + const scale = pace / Math.hypot(ahead, left); + const velocity = { velocity_x: left * scale, velocity_y: -ahead * scale }; + this.x += velocity.velocity_x / 2; + this.y += velocity.velocity_y / 2; + this.show({ ...this.idle, ...velocity, x: this.x, y: this.y }); + } +} + +const DIRECTIONS = [["forward", 1, 0], ["back", -1, 0], ["to his left", 0, 1], ["to his right", 0, -1], ["forward and left", 1, 1], ["forward and right", 1, -1], ["back and left", -1, 1], ["back and right", -1, -1]] as const; +const STANCES: readonly Stance[] = ["orthodox", "southpaw"]; +const PACES = [3, 6, MAX_SPEED] as const; + +describe("boxing footwork", () => { + it.each(STANCES)("steps first with the foot nearer the way he goes and drags the other after it, %s", (stance) => { + const lead = stance === "orthodox" ? "left" : "right"; + const rear = stance === "orthodox" ? "right" : "left"; + const first: Readonly> = { forward: lead, back: rear, "to his left": "left", "to his right": "right" }; + for (const [name, ahead, left] of DIRECTIONS) { + const expected = first[name]; + if (expected === undefined) continue; + for (const pace of PACES) { + const walker = new Walker(stance); + const order: string[] = []; + let was = walker.lifted; + for (let frame = 0; frame < 60 && order.length < 4; frame += 1) { + walker.walk(ahead, left, pace); + const now = walker.lifted; + if (now[0] && !was[0]) order.push("left"); + if (now[1] && !was[1]) order.push("right"); + was = now; + } + const other = expected === "left" ? "right" : "left"; + expect(order, `${name} at ${pace}`).toEqual([expected, other, expected, other]); + } + } + }); + + it.each(STANCES)("never crosses his feet, brings them together or lunges, whichever way and however fast he walks, %s", (stance) => { + const length = STANCE.leadFoot.z - STANCE.rearFoot.z; + const width = STANCE.leadFoot.x - STANCE.rearFoot.x; + const leadAnkle = stance === "orthodox" ? "ankleL" : "ankleR"; + const rearAnkle = stance === "orthodox" ? "ankleR" : "ankleL"; + for (const [name, ahead, left] of DIRECTIONS) { + for (const pace of PACES) { + const walker = new Walker(stance); + for (let frame = 0; frame < 90; frame += 1) { + walker.walk(ahead, left, pace); + const label = `${name} at ${pace}, frame ${frame}`; + // The lead foot stays in front of the rear one, and his left foot on his left. + const apart = walker.at(leadAnkle).z - walker.at(rearAnkle).z; + const astride = walker.at("ankleL").x - walker.at("ankleR").x; + expect(apart, label).toBeGreaterThan(length * 0.6); + expect(apart, label).toBeLessThan(length + 0.3); + expect(astride, label).toBeGreaterThan(width * 0.35); + expect(astride, label).toBeLessThan(width + 0.3); + } + } + } + }); + + it("leaves a planted foot where it is: only a foot in the air moves over the canvas", () => { + for (const [name, ahead, left] of DIRECTIONS) { + for (const pace of PACES) { + const walker = new Walker(); + let was = walker.lifted; + let last = [walker.at("toeL"), walker.at("toeR")] as const; + let steps = 0; + for (let frame = 0; frame < 90; frame += 1) { + walker.walk(ahead, left, pace); + const now = walker.lifted; + const toes = [walker.at("toeL"), walker.at("toeR")] as const; + for (const side of [0, 1] as const) { + if (now[side] && !was[side]) steps += 1; + if (!now[side] && !was[side]) expect(Math.hypot(toes[side].x - last[side].x, toes[side].z - last[side].z), `${name} at ${pace}, frame ${frame}`).toBeLessThan(0.002); + } + was = now; + last = toes; + } + expect(steps, `${name} at ${pace}`).toBeGreaterThan(3); + } + } + }); + + it("takes short steps close to the canvas, quicker rather than longer the faster he goes", () => { + const stride = (pace: number): { length: number; height: number; seconds: number } => { + const walker = new Walker(); + const ground = walker.at("toeL").y; + let height = 0; + let was = false; + const landings: { frame: number; z: number }[] = []; + for (let frame = 0; frame < 120; frame += 1) { + walker.walk(1, 0, pace); + height = Math.max(height, walker.at("toeL").y - ground); + const lifted = walker.lifted[0]; + if (was && !lifted) landings.push({ frame, z: walker.at("toeL").z }); + was = lifted; + } + const [first, second] = landings.slice(-2) as [{ frame: number; z: number }, { frame: number; z: number }]; + return { length: second.z - first.z, height, seconds: (second.frame - first.frame) / 60 }; + }; + const walking = stride(3); + const running = stride(MAX_SPEED); + for (const gait of [walking, running]) { + expect(gait.height).toBeGreaterThan(0.015); + expect(gait.height).toBeLessThan(0.06); + expect(gait.length).toBeLessThan(0.45); + } + expect(walking.length).toBeLessThan(0.28); + expect(running.seconds).toBeLessThan(walking.seconds * 0.7); + }); + + it("turns on the lead foot when the other man circles: the rear foot steps round first and more often", () => { + const walker = new Walker(); + const steps = [0, 0]; + const order: number[] = []; + let was = walker.lifted; + // He turns to his left through a quarter of a circle in a second and a half without leaving his place. + for (let frame = 1; frame <= 90; frame += 1) { + const turn = (frame / 90) * (Math.PI / 2); + walker.stand(1, { facing_x: Math.round(Math.sin(turn) * 1000), facing_y: -Math.round(Math.cos(turn) * 1000) }); + const now = walker.lifted; + for (const side of [0, 1] as const) { + if (now[side] && !was[side]) { + steps[side]! += 1; + order.push(side); + } + } + was = now; + } + expect(order[0]).toBe(1); + expect(steps[1]).toBeGreaterThan(steps[0]!); + expect(steps[1]).toBeGreaterThanOrEqual(2); + }); + + it("sets his feet again in the stance when he stops", () => { + const walker = new Walker(); + for (let frame = 0; frame < 45; frame += 1) walker.walk(1, 1, MAX_SPEED); + walker.stand(60); + const root = walker.boxer.root.position; + const apart = walker.at("ankleL").sub(walker.at("ankleR")); + expect(Math.abs(apart.z - (STANCE.leadFoot.z - STANCE.rearFoot.z))).toBeLessThan(0.1); + expect(Math.abs(apart.x - (STANCE.leadFoot.x - STANCE.rearFoot.x))).toBeLessThan(0.1); + expect(Math.abs((walker.at("ankleL").z + walker.at("ankleR").z) / 2 - root.z - (STANCE.leadFoot.z + STANCE.rearFoot.z) / 2)).toBeLessThan(0.08); + }); +}); + +describe("idle", () => { + /** How one series moves with another: 1 in step, -1 in opposite step, near 0 unrelated. */ + const together = (a: readonly number[], b: readonly number[]): number => { + const mean = (values: readonly number[]): number => values.reduce((sum, value) => sum + value, 0) / values.length; + const meanA = mean(a); + const meanB = mean(b); + let cross = 0; + let squareA = 0; + let squareB = 0; + for (let index = 0; index < a.length; index += 1) { + cross += (a[index]! - meanA) * (b[index]! - meanB); + squareA += (a[index]! - meanA) ** 2; + squareB += (b[index]! - meanB) ** 2; + } + return cross / Math.sqrt(squareA * squareB); + }; + + it("is never still: he bounces on the balls of his feet with his heels pulsing, and a planted foot stays planted through it", () => { + const walker = new Walker(); + const toes = [walker.at("toeL"), walker.at("toeR")] as const; + const hips: number[] = []; + const heels: [number[], number[]] = [[], []]; + const gloves = new THREE.Box3(); + const head = new THREE.Box3(); + for (let frame = 0; frame < 480; frame += 1) { + walker.stand(1); + hips.push(walker.at("hips").y); + heels[0].push(walker.at("ankleL").y); + heels[1].push(walker.at("ankleR").y); + gloves.expandByPoint(walker.at("gloveL")); + head.expandByPoint(walker.at("head")); + expect(walker.at("toeL").distanceTo(toes[0]), `left foot, frame ${frame}`).toBeLessThan(1e-4); + expect(walker.at("toeR").distanceTo(toes[1]), `right foot, frame ${frame}`).toBeLessThan(1e-4); + } + const range = (values: readonly number[]): number => Math.max(...values) - Math.min(...values); + // A light bounce: the hips a centimetre or two, each heel pulsing with it, the head and the lead glove drifting. + expect(range(hips)).toBeGreaterThan(0.012); + expect(range(hips)).toBeLessThan(0.05); + expect(range(heels[0])).toBeGreaterThan(0.008); + expect(range(heels[1])).toBeGreaterThan(0.008); + expect(head.max.x - head.min.x).toBeGreaterThan(0.015); + expect(head.max.x - head.min.x).toBeLessThan(0.12); + expect(gloves.max.z - gloves.min.z).toBeGreaterThan(0.05); + // More than one wave: the bounce comes and goes, so the hips' peaks are not all the same height. + const peaks = hips.filter((value, index) => index > 0 && index < hips.length - 1 && value > hips[index - 1]! && value >= hips[index + 1]!); + expect(peaks.length).toBeGreaterThan(8); + expect(range(peaks)).toBeGreaterThan(0.003); + }); + + it("gives each fighter his own rhythm, so two of them never move in unison", () => { + const one = new Walker("orthodox", "one"); + const two = new Walker("orthodox", "two"); + const bounce: [number[], number[]] = [[], []]; + const sway: [number[], number[]] = [[], []]; + const gloves: [number[], number[]] = [[], []]; + for (let frame = 0; frame < 600; frame += 1) { + for (const [index, walker] of [one, two].entries()) { + walker.stand(1); + bounce[index]!.push(walker.at("hips").y); + sway[index]!.push(walker.at("head").x); + gloves[index]!.push(walker.at("gloveL").z); + } + } + expect(Math.abs(together(bounce[0], bounce[1]))).toBeLessThan(0.5); + expect(Math.abs(together(sway[0], sway[1]))).toBeLessThan(0.6); + expect(Math.abs(together(gloves[0], gloves[1]))).toBeLessThan(0.6); + }); + + it("breathes harder and deeper, drops his hands and stands flatter on his feet when he is spent, and still bounces a little", () => { + // Behind a raised guard, so the lead hand's pawing does not move the shoulders. + const measure = (stamina: number): { glove: number; heel: number; bounce: number; breaths: number; depth: number } => { + const walker = new Walker(); + walker.stand(240, { stamina, defense: "guard_high" }); + const hips: number[] = []; + // The shoulders draw up and in as he breathes in. + const shoulders: number[] = []; + let glove = 0; + let heel = 0; + for (let frame = 0; frame < 600; frame += 1) { + walker.stand(1, { stamina, defense: "guard_high" }); + hips.push(walker.at("hips").y); + shoulders.push(walker.at("shoulderL").distanceTo(walker.at("shoulderR"))); + glove += walker.at("gloveL").y / 600; + heel += walker.at("ankleR").y / 600; + } + const middle = (Math.max(...shoulders) + Math.min(...shoulders)) / 2; + const breaths = shoulders.filter((value, index) => index > 0 && value > middle && shoulders[index - 1]! <= middle).length; + return { glove, heel, bounce: Math.max(...hips) - Math.min(...hips), breaths, depth: Math.max(...shoulders) - Math.min(...shoulders) }; + }; + const fresh = measure(1000); + const spent = measure(60); + expect(spent.glove).toBeLessThan(fresh.glove - 0.08); + expect(spent.heel).toBeLessThan(fresh.heel - 0.01); + expect(fresh.breaths).toBeGreaterThanOrEqual(2); + expect(spent.breaths).toBeGreaterThan(fresh.breaths * 2); + expect(spent.depth).toBeGreaterThan(fresh.depth * 2); + expect(spent.bounce).toBeLessThan(fresh.bounce); + expect(spent.bounce).toBeGreaterThan(0.004); + }); + + it("paws with the lead hand now and then and brings it straight back", () => { + const walker = new Walker(); + const reach: number[] = []; + for (let frame = 0; frame < 900; frame += 1) { + walker.stand(1); + reach.push(walker.at("gloveL").z - walker.at("head").z); + } + const sorted = [...reach].sort((a, b) => a - b); + const usual = sorted[Math.floor(sorted.length / 2)]!; + let paws = 0; + let out = false; + let longest = 0; + let held = 0; + for (const value of reach) { + const reaching = value > usual + 0.05; + if (reaching && !out) paws += 1; + held = reaching ? held + 1 : 0; + longest = Math.max(longest, held); + out = reaching; + } + expect(paws).toBeGreaterThanOrEqual(3); + expect(paws).toBeLessThan(15); + // Out and back inside a third of a second: a paw, not a pose. + expect(longest).toBeLessThan(20); + // It eases out: no frame carries the glove more than a few centimetres. + for (let index = 1; index < reach.length; index += 1) expect(Math.abs(reach[index]! - reach[index - 1]!)).toBeLessThan(0.035); + }); +}); diff --git a/web/hands/src/render/graph.ts b/web/hands/src/render/graph.ts index 9a777e65..4076f973 100644 --- a/web/hands/src/render/graph.ts +++ b/web/hands/src/render/graph.ts @@ -4,7 +4,7 @@ import { clone as cloneSkeleton } from "three/examples/jsm/utils/SkeletonUtils.j import { armState, type DeathCause, type InjuryId } from "../injuries"; import { COUNT_TICKS, EVASION_TICKS, GLOVE_HITBOX_RADIUS, GUARD_BLOCK_MINIMUM, HITSTOP_MS, HURTBOXES, RECOVERY_SPEED_PERCENT, TICK_RATE, cancelsRecovery, punchTiming, recoveryCancelAge, totalTicks, type PunchTiming } from "../manifest"; import type { BloodLevel } from "../settings"; -import type { CombatEvent, FighterSnapshot, Hand, Power, PunchAction, PunchClass, SemanticAction, Target } from "../types"; +import type { CombatEvent, FighterSnapshot, FighterStyle, Hand, Power, PunchAction, PunchClass, SemanticAction, Target } from "../types"; import { FIGHTER_GLB_GZIP_BASE64 } from "../assets/fighter-glb"; import { BONE_ADAPTER } from "./skeleton"; export { BONE_ADAPTER }; @@ -13,7 +13,10 @@ import { wearCornerColour } from "./gear"; import { BODY_SITES, BODY_SWELL_CORE, EYE_LIDS, HEAD_SITES, HEAD_SWELL_CORE, InjuryShading, applyBodyTrauma, applyHeadTrauma, trunksBloodFor } from "./injury"; import { LookShading, SCANNED_LOOK, type FighterLook } from "./looks"; import { applyOutfitShading, buildCuffGeometry, buildHandGeometry, type OfficialOutfit, type OutfitPart } from "./outfit"; -import { PoseSolver, STANCE, easeIn, easeOut, mirrorX, smoothstep, vec, type FootTarget, type HandTarget, type PoseDescription } from "./poser"; +import { lightSkin } from "./skin"; +import { tailorTrunks } from "./trunks"; +import { FaceLife } from "./face"; +import { HIPS_TO_THIGH, PoseSolver, STANCE, STANCE_MANNERS, easeIn, easeOut, mirrorX, smoothstep, vec, type FootTarget, type HandTarget, type PoseDescription, type StanceManner } from "./poser"; import { KnockoutRagdoll, blowImpulse, fallStyleFor, type FallStyle, type Twitch } from "./ragdoll"; import { ropeExcess } from "./ring"; import { SolvedRig, frameFromAxes, worldPosition, worldQuaternion } from "./rig"; @@ -30,10 +33,14 @@ const MATERIAL_TEXTURE: Readonly> = { ShoesMat0: "shoes", PantsMat0: "pants", }; +/** Glove leather takes a soft highlight, the trunks are satin and the boots duller than either. */ +const GEAR_ROUGHNESS: Readonly> = { GlovesMat0: 0.33, PantsMat0: 0.44, ShoesMat0: 0.5 }; const cachedTextures = new Map(); const cachedTextureLoads = new Map>(); let cachedGltf: Promise | null = null; let loadedScene: THREE.Object3D | null = null; +/** The fighters' trunks, tailored once from the scanned ones every fighter shares; officials wear the scan as trousers. */ +const tailoredTrunks = new Map(); function configureFighterTexture(texture: THREE.Texture): THREE.Texture { texture.colorSpace = THREE.SRGBColorSpace; @@ -84,6 +91,7 @@ export function loadBoxerGlb(): Promise { */ export function releaseFighterGpu(): void { releaseSharedGpu(loadedScene, cachedTextures.values()); + for (const trunks of tailoredTrunks.values()) trunks.dispose(); } export function releaseSharedGpu(scene: THREE.Object3D | null, textures: Iterable): void { @@ -173,7 +181,7 @@ export function applyFighterSkin(target: THREE.Object3D, palette: BoxerPaletteCo // Only a fighter's skin takes the clearcoat that sweat shows on; the outfit makes an official's shirt cloth. material = isSkin && !official ? new THREE.MeshPhysicalMaterial({ map, color, roughness: 0.58, metalness: 0.02, clearcoat: 0.25, clearcoatRoughness: 0.6 }) - : new THREE.MeshStandardMaterial({ map, color, roughness: isSkin ? 0.58 : 0.4, metalness: isSkin ? 0.02 : 0.03 }); + : new THREE.MeshStandardMaterial({ map, color, roughness: isSkin ? 0.58 : GEAR_ROUGHNESS[sourceName] ?? 0.4, metalness: isSkin ? 0.02 : 0.03 }); material.name = sourceName; bySource.set(sourceName, material); owned.push(material); @@ -184,9 +192,15 @@ export function applyFighterSkin(target: THREE.Object3D, palette: BoxerPaletteCo if (outfit !== undefined && part !== undefined) applyOutfitShading(material, part, outfit); else if (sourceName === "PantsMat0") trunksBlood = wearCornerColour(material, false, "trunks"); else if (sourceName === "GlovesMat0") gloveBlood = wearCornerColour(material); + if (isSkin && !official) lightSkin(material); pressOntoCanvas(material); } object.material = material; + if (!official && object.name === "BoxerPants") { + let trunks = tailoredTrunks.get(object.geometry); + if (trunks === undefined) tailoredTrunks.set(object.geometry, (trunks = tailorTrunks(object.geometry, object.skeleton.bones.map((bone) => bone.name)))); + object.geometry = trunks; + } object.castShadow = !official; object.receiveShadow = true; object.frustumCulled = false; @@ -218,6 +232,10 @@ const SCANNED_SKIN = new THREE.Color().setRGB(0.6, 0.32, 0.19, THREE.LinearSRGBC export type ArcadeDislocation = "jaw" | "shoulder_left" | "shoulder_right"; /** What the cutman has in his hand: the enswell for a cut or a swelling, a water bottle for the breath. */ export type CutmanProp = "enswell" | "bottle"; +/** What the referee is about beyond watching the fight: standing back while a man is finished. */ +export type RefereeDuty = "watch" | "stand_back"; +/** A corner man at the ropes: working on his fighter, grieving over him, or cheering him. */ +export type CornerMood = "work" | "mourn" | "cheer"; const smooth = (current: number, target: number, rate: number, dt: number): number => current + (target - current) * (1 - Math.exp(-rate * dt)); const smoothAngle = (current: number, target: number, rate: number, dt: number): number => { @@ -248,6 +266,7 @@ export class SkinnedBoxer { readonly headInjury: InjuryShading; readonly bodyInjury: InjuryShading; private readonly headLook: LookShading; + private readonly face: FaceLife; private readonly bareHand: THREE.MeshStandardMaterial | null; constructor(gltf: GLTF, palette: BoxerPaletteColors) { @@ -291,6 +310,7 @@ export class SkinnedBoxer { this.rig = new SolvedRig(this.root); // Last on, so it runs first in the shader: the look, then the clothes over it, then the injuries. this.headLook = new LookShading(this.headMeshes[0]!.material as THREE.MeshStandardMaterial); + this.face = new FaceLife(palette.gear ^ palette.skin); this.bareHand = palette.outfit === undefined ? null : this.addHands(palette.outfit); this.setLook(palette.look ?? SCANNED_LOOK); const rigMetrics = this.rig.metrics; @@ -421,6 +441,17 @@ export class SkinnedBoxer { for (const material of this.skinMaterials) if (material instanceof THREE.MeshPhysicalMaterial) material.clearcoat = value; } + /** A blow landing on him shows on his face: `force` 0 to 1, to the head or the body. */ + flinch(force: number, head: boolean): void { + this.face.flinch(force, head); + } + + /** Moves the face on by `dt` and shows it (see FaceLife for what it answers to). */ + updateFace(dt: number, reducedMotion: boolean, effort: boolean, spent: number, dazed: number, out: boolean): void { + this.face.update(dt, reducedMotion, effort, spent, dazed, out); + this.headLook.setExpression(this.face.lids, this.face.mouth, this.face.brow); + } + dispose(): void { for (const material of this.ownedMaterials) material.dispose(); for (const geometry of this.ownedGeometries) geometry.dispose(); @@ -494,7 +525,7 @@ const ROPE_HOLD_OPEN = 1.6; */ const ROPE_LEAN_FULL = 0.25; const ROPE_LEAN_ROOM = 0.12; -const ROPE_LEAN_PITCH = 0.3; +const ROPE_LEAN_PITCH = 0.33; const ROPE_LEAN_ROLL = 0.3; const ROPE_LEAN_RATE = 8; @@ -675,6 +706,23 @@ export class BoxingGraph { /** A body uppercut folds the fighter over it once the lift has peaked. */ private foldDelay = 0; private pendingFold = 0; + /** The elbow clamps down over struck ribs a moment after the blow (+ right, - left). */ + private coverDelay = 0; + private pendingCover = 0; + /** A shot to the liver, low on his right, is felt half a beat late: then the knee goes and he folds over it. */ + private liverDelay = 0; + private pendingLiver = 0; + /** The arms thrown by a blow to the head: the gloves lag the head and swing after it (x to his left, y up, z ahead). */ + private readonly armKick: Spring3 = { value: new THREE.Vector3(), velocity: new THREE.Vector3() }; + /** How far a clean, hard shot has dropped his hands and floated them apart; they come back over a beat. */ + private handsDrop = 0; + private guardWasBroken = false; + /** Seeds what a rocked man does, and changes with every blow he takes, so no two spells on rubber legs are alike. */ + private hurtSeed = 1; + /** Seconds he has been out on his feet this spell, its own phase, and when his legs next lurch under him. */ + private rockedTime = 0; + private rockedPhase = 0; + private nextLurch = 0; private guardKick = 0; private guardHigh = 0; private guardLow = 0; @@ -687,17 +735,40 @@ export class BoxingGraph { private crouchExtra = 0; private bouncePhase = 0; private weightPhase = 0; + private breathPhase = 0; private stunPhase = 0; private feintTimer = 2; - private feint = 0; + /** Seconds since the lead hand last pawed, and how many times it has. */ + private pawAge = PAW_SECONDS; + private pawCount = 0; + /** His own place in the idle rhythms (0..1, from his id), unset until he is first shown. */ + private idleSeed = -1; + /** His own manner of standing: his style's, a little his own once `standLike` has named him. */ + private readonly manner: StanceManner = { ...STANCE_MANNERS.balanced, lead: new THREE.Vector3(), rear: new THREE.Vector3() }; + private mannerStyle: FighterStyle | null = null; + private mannerSeed = 0; + /** His breath this frame (-1 out to 1 in, deeper when he is spent), and how battered he is (0 fresh to 1). */ + private breath = 0; + private battered = 0; + /** How far his weight is carried the way he walks, in his own frame (x to his left, y ahead). */ + private readonly walkLean = new THREE.Vector2(); + /** The foot that is ahead the way he walks and the one whose turn it is to step (0 his left, 1 his right), or -1 standing. */ + private leadingFoot = -1; + private nextFoot = -1; + /** His facing when the feet were last stepped, to tell when he is turning. */ + private steppedYaw = 0; private stunAmount = 0; private tired = 0; private clinchWeight = 0; private foulWeight = 0; private tauntWeight = 0; private crowding = 0; + /** How far the other man's nearness has drawn the guard in from the long-range stance. */ + private tight = 0; /** How far he has stepped into the punch he is throwing, out of the tall, tucked stance of the inside. */ private punchCommit = 0; + /** How clearly the punch being thrown is missing, out of reach or evaded: a miss carries him further than a punch that lands. */ + private punchMiss = 0; /** How far, in his own frame (x to the side, y ahead), the fighter is leaning his head away from the other's. */ private readonly headSpace = new THREE.Vector2(); private readonly ownHead = new THREE.Vector3(); @@ -818,6 +889,31 @@ export class BoxingGraph { private refereeCounting = false; /** Render tick the referee's count last changed on; the counting arm is timed from it. */ private countChangedTick: number | null = null; + /** How far into the count's posture the referee is, so it comes out of his rest and goes back into it, and how far up his counting arm is: held where the count ends. */ + private countWeight = 0; + private countPump = 0; + /** The point (world) the referee's eyes are held on, when one is given. */ + private readonly watchPoint = new THREE.Vector3(); + private watching = false; + /** What the referee is about beyond watching, and how far into standing back he is. */ + private duty: RefereeDuty = "watch"; + private backWeight = 0; + /** Whether the wave-off is the slow one that follows a death. */ + private waveSlow = false; + /** A corner man's mood at the ropes, how far into grief or joy he is, and how hard a cutman works (0..1). */ + private mood: CornerMood = "work"; + private mournWeight = 0; + private cheerWeight = 0; + private treatUrgency = 0; + /** Where an official is looking, in his own frame. */ + private gazeYaw = 0; + private gazePitch = 0; + /** An official's walk: his travel in his own frame (x to his left, z ahead, m/s), how far his feet are turned into it, and whether he is backing away. */ + private readonly travel = new THREE.Vector3(); + private strideYaw = 0; + private backing = false; + /** The way each of an official's feet points (world yaw): it turns only while the foot is off the canvas. */ + private readonly footYaw: [number, number] = [0, 0]; /** Knockout physics; officials have none, except a referee who can be knocked out. */ private readonly ragdoll: KnockoutRagdoll | null; /** Knocked out on his feet (a flash knockout): down although the engine never counts him. */ @@ -976,12 +1072,18 @@ export class BoxingGraph { this.hitstop = 0; this.hitstopScale = 1; this.hitstopLag = 0; - for (const spring of [this.headKick, this.torsoKick, this.rootKick, this.coverKick]) { + for (const spring of [this.headKick, this.torsoKick, this.rootKick, this.coverKick, this.armKick]) { spring.value.set(0, 0, 0); spring.velocity.set(0, 0, 0); } this.foldDelay = 0; this.pendingFold = 0; + this.coverDelay = 0; + this.pendingCover = 0; + this.liverDelay = 0; + this.pendingLiver = 0; + this.handsDrop = 0; + this.rockedTime = 0; this.guardKick = 0; this.stunAmount = 0; this.windedTime = 0; @@ -1022,9 +1124,13 @@ export class BoxingGraph { this.laidOut = downed; } - /** Referee wave-off: both arms sweep crossing in front of the chest to call the fight. */ - waveOff(seconds = 2.6): void { + /** + * Referee wave-off: both arms cross above his head and swing wide again to call the fight; `slow` for the heavy, + * deliberate one over a dead man. + */ + waveOff(seconds = 2.6, slow = false): void { this.waveTime = seconds; + this.waveSlow = slow; } /** Ticks left in the opening countdown, or null outside it; drives the glove touch before the bell. */ @@ -1032,22 +1138,28 @@ export class BoxingGraph { this.countdownTicks = ticksRemaining; } - /** Cornerman: lean in over the top rope and work on the seated fighter while attending. */ - attend(active: boolean): void { + /** + * Cornerman: lean in over the top rope while attending: working on the seated fighter, a forearm on the rope and a + * hand talking; hands to his head over his dead fighter (`mourn`); arms thrown up for his winner (`cheer`). + */ + attend(active: boolean, mood: CornerMood = "work"): void { this.attending = active; + this.mood = mood; } /** - * Cutman: crouch by a seated fighter and press the enswell on the eye at `eye` (world). `facing` is - * the direction the fighter's face points and `side` is 1 when the eye is the fighter's left. + * Cutman: go down on one knee by a seated fighter and press the enswell on the eye at `eye` (world). `facing` is + * the direction the fighter's face points and `side` is 1 when the eye is the fighter's left. `urgency` (0..1) is + * how bad the cut is: he swabs faster and wider. */ - treat(eye: THREE.Vector3 | null, facing?: THREE.Vector3, side = 1, prop: CutmanProp = "enswell"): void { + treat(eye: THREE.Vector3 | null, facing?: THREE.Vector3, side = 1, prop: CutmanProp = "enswell", urgency = 0): void { this.treating = eye !== null; if (eye === null) return; this.treatTarget.copy(eye); if (facing !== undefined) this.treatFacing.copy(facing); this.treatSide = side; this.treatProp = prop; + this.treatUrgency = urgency; } /** @@ -1080,11 +1192,18 @@ export class BoxingGraph { return this.breakTime > 0; } - /** Where the two fighters stand (world, on the canvas): the break puts a palm on each one's chest. */ - aimBreak(first: THREE.Vector3, second: THREE.Vector3): void { + /** + * Where the two fighters stand (world, on the canvas): the break puts a palm on each one's chest, and the referee's + * eyes go from one to the other unless `watched` (world) holds them: a man on the canvas, one in trouble. `duty` + * is what else he is about: standing back with his hands up and open while a man is finished. + */ + aimBreak(first: THREE.Vector3, second: THREE.Vector3, watched: THREE.Vector3 | null = null, duty: RefereeDuty = "watch"): void { this.breakFighters[0].copy(first); this.breakFighters[1].copy(second); this.breakAimed = true; + this.watching = watched !== null; + if (watched !== null) this.watchPoint.copy(watched); + this.duty = duty; } private makeHand(): { position: THREE.Vector3; knuckles: THREE.Vector3; palm: THREE.Vector3; pole: THREE.Vector3 } { @@ -1478,7 +1597,12 @@ export class BoxingGraph { */ react(kind: ReactionKind, target: Target = "head", direction = 1, punchClass: PunchClass | null = null, hand: Hand | null = null, amount = 90): void { const force = clamp(amount / HARDEST_HIT, 0, 1); - const scale = (0.55 + force * 1.05) * (kind === "block" ? 0.35 : 1); + if (kind === "hit") this.boxer.flinch(force, target === "head"); + // A man already hurt there gives more to the same punch; a jab to a fresh man is a flick. + const trauma = this.shownFighter?.trauma; + const hurt = trauma === undefined ? 0 : clamp((target === "body" ? trauma.body : trauma.head) / 700, 0, 1); + const scale = (0.4 + force * 1.2) * (1 + 0.5 * hurt) * (kind === "block" ? 0.35 : 1); + this.hurtSeed = (Math.imul(this.hurtSeed + Math.round(amount) + 1, 1664525) + 1013904223) >>> 0; const lateral = hand === "left" ? 1 : hand === "right" ? -1 : direction >= 0 ? -1 : 1; if (target === "body") { switch (punchClass) { @@ -1488,7 +1612,12 @@ export class BoxingGraph { this.torsoKick.velocity.x += 3 * scale; this.torsoKick.velocity.z += 4.6 * scale * lateral; this.rootKick.velocity.x += 0.5 * scale * lateral; - this.coverKick.velocity.x += 2.2 * scale * lateral; + this.coverDelay = 0.09; + this.pendingCover = 2.4 * scale * lateral; + if (lateral > 0 && kind === "hit" && force > 0.25) { + this.liverDelay = 0.28; + this.pendingLiver = scale * (0.4 + force); + } break; case "uppercut": // Up under the ribs: the blow lifts him onto his toes and straightens him, then he folds over it. @@ -1507,28 +1636,46 @@ export class BoxingGraph { this.guardKick = Math.max(this.guardKick, 0.6 * scale); } else { if (kind === "hit") this.guardKick = Math.max(this.guardKick, 0.4 * scale); + // The head goes the way the punch travelled and the shoulders turn after it. switch (punchClass) { case "hook": this.headKick.velocity.x += 2.6 * scale * lateral; this.headKick.velocity.z -= 0.7 * scale; - this.torsoKick.velocity.z += 0.9 * scale * lateral; + this.torsoKick.velocity.y += 3.4 * scale * lateral; + this.torsoKick.velocity.z -= 1.2 * scale * lateral; break; case "uppercut": this.headKick.velocity.y += 2.2 * scale; this.headKick.velocity.z -= 1.2 * scale; - this.torsoKick.velocity.x -= 1.2 * scale; + this.torsoKick.velocity.x -= 1.6 * scale; break; case "straight": this.headKick.velocity.z -= 2.4 * scale; - this.torsoKick.velocity.x -= 0.6 * scale; + this.headKick.velocity.x += 0.5 * scale * lateral; + this.torsoKick.velocity.x -= 1 * scale; + this.torsoKick.velocity.y += 1.4 * scale * lateral; break; default: this.headKick.velocity.z -= 1.5 * scale; - this.torsoKick.velocity.x -= 0.35 * scale; + this.torsoKick.velocity.x -= 0.5 * scale; + this.torsoKick.velocity.y += 0.5 * scale * lateral; break; } this.rootKick.velocity.z -= 0.45 * scale; - if (kind === "block") this.guardKick = Math.max(this.guardKick, 0.9 * scale); + if (kind === "block") { + // Caught on the gloves: they are driven back into him and his weight rocks onto the rear foot. + this.guardKick = Math.max(this.guardKick, Math.min(1.2, 2.4 * scale)); + this.rootKick.velocity.z -= 1.1 * scale; + this.torsoKick.velocity.x -= 1.2 * scale; + } else { + this.rootKick.velocity.y -= 1.1 * scale * force; + // The arms are thrown the way the head went, and a clean shot hard enough drops his hands for a beat. + const thrown = 1.7 * scale * force; + if (punchClass === "hook") this.armKick.velocity.add(this.scratchE.set(lateral, 0.3, -0.2).multiplyScalar(thrown)); + else if (punchClass === "uppercut") this.armKick.velocity.add(this.scratchE.set(0, 1, -0.4).multiplyScalar(thrown)); + else this.armKick.velocity.add(this.scratchE.set(0.3 * lateral, 0.7, -0.4).multiplyScalar(thrown)); + this.handsDrop = Math.max(this.handsDrop, clamp((force - 0.35) * 2, 0, 1) * (0.5 + 0.5 * hurt)); + } } if (kind === "hit") { this.dentSurface(target, lateral, punchClass, force); @@ -1584,15 +1731,146 @@ export class BoxingGraph { else this.boxer.headInjury.impact(punchClass === "jab" ? "nose" : "mouth", [0, 0, -depth], 4.5); } + /** Where foot `index` (0 his left, 1 his right) stands in the stance, from his root in his own frame. */ + private footPlace(index: number, mirror: number, out: THREE.Vector3): THREE.Vector3 { + if (this.squareWeight > 0.5) return out.set(index === 0 ? 0.16 : -0.16, 0, index === 0 ? 0.02 : -0.02); + const offset = (index === 0) === (mirror > 0) ? STANCE.leadFoot : STANCE.rearFoot; + // His own base, wider the more he has been hurt. Chest to chest it shortens, so the two lead feet do not + // tread on each other. + return out.set(offset.x * mirror * this.manner.width * (1 + BATTERED_BASE * this.battered), 0, offset.z * this.manner.length * (1 - INSIDE_BASE * this.crowding)); + } + + /** Names the man this fighter is, so that he stands a little in his own way within his style. */ + standLike(id: string): void { + this.mannerSeed = idleSeedFor(id) + 1; + this.mannerStyle = null; + } + + /** Takes `style`'s stance as his own, varied by who he is once he has been named. */ + private keyManner(style: FighterStyle): void { + const base = STANCE_MANNERS[style]; + const own = this.manner; + this.mannerStyle = style; + Object.assign(own, base, { lead: own.lead.copy(base.lead), rear: own.rear.copy(base.rear) }); + if (this.mannerSeed === 0) return; + // Seven unrelated shares of -1..1 from his name. + const vary = (nth: number): number => ((Math.abs(Math.sin(this.mannerSeed * (nth * 7.31 + 3.17)) * 43758.5453) % 1) * 2 - 1); + own.rise += vary(1) * 0.012; + own.length *= 1 + vary(2) * 0.05; + own.width *= 1 + vary(3) * 0.06; + own.lead.y += vary(4) * 0.025; + own.lead.z += vary(5) * 0.03; + own.flare += vary(6) * 0.12; + own.spring *= 1 + vary(7) * 0.2; + own.bob *= 1 + vary(1) * vary(4) * 0.4; + own.rock *= 1 + vary(2) * vary(6) * 0.3; + } + + /** + * An official's feet: a shoulder's width apart, one a little ahead of the other, re-set now and then as he stands. + * Travelling, he walks: his feet turn the way he goes, or stay toward the action as he backs away from it, and + * each in turn swings a stride ahead of him. + */ + private stepOfficialFeet(dt: number, speed: number, velocityWorld: THREE.Vector3, rootPosition: THREE.Vector3, yaw: number): void { + const walking = speed > OFFICIAL_WALK_SPEED; + const ahead = velocityWorld.x * Math.sin(yaw) + velocityWorld.z * Math.cos(yaw); + const left = velocityWorld.x * Math.cos(yaw) - velocityWorld.z * Math.sin(yaw); + let turn = 0; + if (walking) { + if (ahead < -0.35 * speed) this.backing = true; + else if (ahead > -0.05 * speed) this.backing = false; + turn = this.backing ? Math.atan2(-left, -ahead) : Math.atan2(left, ahead); + } + this.strideYaw = smooth(this.strideYaw, turn, 6, dt); + const settle = 1 - Math.exp(-8 * dt); + this.travel.x += (left - this.travel.x) * settle; + this.travel.z += (ahead - this.travel.z) * settle; + const desired = this.scratch; + const rotate = this.scratchQ.setFromAxisAngle(worldUpVector, yaw + this.strideYaw); + // Standing, one foot is a little ahead of the other; walking, they pass either side of him. + const stagger = walking ? 0 : Math.sin(this.weightPhase * 0.17) >= 0 ? 0.045 : -0.045; + const duration = clamp(0.42 / Math.max(speed, 0.01), 0.22, 0.34); + const stride = speed * duration * 0.4; + for (let index = 0; index < 2; index += 1) { + const foot = this.feet[index]!; + const side = index === 0 ? 1 : -1; + desired.set(side * 0.15, 0, side * stagger).applyQuaternion(rotate).add(rootPosition); + desired.y = 0; + const toes = yaw + this.strideYaw * 0.85 + side * 0.2; + if (!this.feetInitialized) { + foot.planted.copy(desired); + foot.progress = 1; + foot.stepping = false; + this.footYaw[index] = toes; + continue; + } + // Standing, a planted foot keeps its line until he has turned too far over it, then pivots where it is. + const twist = Math.atan2(Math.sin(this.footYaw[index]! - toes), Math.cos(this.footYaw[index]! - toes)); + if (!walking && Math.abs(twist) > 0.8) this.footYaw[index] = toes + Math.sign(twist) * 0.8; + if (foot.stepping) { + foot.progress = Math.min(1, foot.progress + dt / foot.duration); + this.footYaw[index] = smoothAngle(this.footYaw[index]!, toes, 14, dt); + if (foot.progress >= 1) { + foot.stepping = false; + foot.planted.copy(foot.to); + } + continue; + } + const other = this.feet[1 - index]!; + if (other.stepping) continue; + const offX = desired.x - foot.planted.x; + const offZ = desired.z - foot.planted.z; + const drift = Math.hypot(offX, offZ); + // How far each foot trails him along his way. + const lag = walking ? (offX * velocityWorld.x + offZ * velocityWorld.z) / speed : 0; + seatedScratch.set(-side * 0.15, 0, -side * stagger).applyQuaternion(rotate).add(rootPosition).sub(other.planted); + const otherLag = walking ? (seatedScratch.x * velocityWorld.x + seatedScratch.z * velocityWorld.z) / speed : 0; + // Walking, a foot is lifted once it trails him by most of a stride, at once when the other trails him too (he is + // setting off), and put down a stride ahead of where he will be, before the other is left out of reach. + // Turning where he stands, a foot left far out of place is brought back under him quickly. + const due = walking ? lag > (otherLag > 0 ? 0.05 : Math.max(0.05, stride * 0.8)) || drift > stride + 0.2 : drift > 0.085; + if (!due) continue; + foot.stepping = true; + foot.progress = 0; + foot.duration = walking ? clamp((0.22 - otherLag) / speed, 0.16, duration) : drift > 0.12 ? 0.2 : 0.32; + foot.from.copy(foot.planted); + foot.to.copy(desired).addScaledVector(velocityWorld, foot.duration * 1.6); + foot.to.y = 0; + } + this.feetInitialized = true; + } + + /** + * Boxing footwork: the foot nearer the way he is going steps first and the other closes up to the stance behind + * it, so the feet never cross or come together, and a planted foot stays where it is. Standing, he turns on the + * lead foot while the rear one steps round. + */ private stepFeet(dt: number, mirror: number, speed: number, velocityWorld: THREE.Vector3, rootPosition: THREE.Vector3, yaw: number): void { + // Out of his stance he walks as any man does. + if (this.referee || this.squareWeight > 0.5) { + this.stepOfficialFeet(dt, speed, velocityWorld, rootPosition, yaw); + return; + } const desired = this.scratch; const rotate = this.scratchQ.setFromAxisAngle(worldUpVector, yaw); - for (let index = 0; index < 2; index += 1) { + const rearIndex = mirror > 0 ? 1 : 0; + let leading = -1; + if (speed > WALKING_SPEED) { + const left = this.footPlace(0, mirror, desired).applyQuaternion(rotate).dot(velocityWorld); + leading = left >= this.footPlace(1, mirror, desired).applyQuaternion(rotate).dot(velocityWorld) ? 0 : 1; + } + // Setting off or changing direction, the order starts again with the leading foot. + if (leading !== this.leadingFoot) { + this.leadingFoot = leading; + this.nextFoot = leading; + } + const first = leading < 0 ? rearIndex : leading; + const turning = Math.abs(yaw - this.steppedYaw) > TURNING_RATE * dt; + this.steppedYaw = yaw; + for (let turn = 0; turn < 2; turn += 1) { + const index = turn === 0 ? first : 1 - first; const foot = this.feet[index]!; - const isLead = (index === 0) === (mirror > 0); - const offset = isLead ? STANCE.leadFoot : STANCE.rearFoot; - if (this.referee || this.squareWeight > 0.5) desired.set((index === 0 ? 0.16 : -0.16), 0, index === 0 ? 0.02 : -0.02).applyQuaternion(rotate).add(rootPosition); - else desired.set(offset.x * mirror, 0, offset.z).applyQuaternion(rotate).add(rootPosition); + this.footPlace(index, mirror, desired).applyQuaternion(rotate).add(rootPosition); desired.y = 0; if (this.daze > 0.001) this.stumble(index, desired, yaw); if (!this.feetInitialized) { @@ -1611,15 +1889,25 @@ export class BoxingGraph { } const other = this.feet[1 - index]!; const drift = foot.planted.distanceTo(desired); - const threshold = (speed > 0.05 ? 0.09 : 0.14) * this.stepSlack; - if (drift > threshold && !other.stepping) { - foot.stepping = true; - foot.progress = 0; - foot.duration = clamp(0.24 - speed * 0.07, 0.15, 0.24) * this.stepPace[index]!; - foot.from.copy(foot.planted); - foot.to.copy(desired).addScaledVector(velocityWorld, foot.duration * 0.6); - foot.to.y = 0; + let due: boolean; + if (leading < 0) { + due = drift > (index === rearIndex || !turning ? STEP_SLACK_STANDING : STEP_SLACK_PIVOT) * this.stepSlack && !other.stepping; + } else { + // At a walk the feet take turns, each once he has left it behind; at speed the follower leaves the canvas + // before the leader lands. + const landed = !other.stepping || other.progress >= 1 - 0.6 * clamp((speed - 0.4) / 1, 0, 1); + const behind = this.scratchD.subVectors(desired, foot.planted).dot(velocityWorld) > 0; + due = this.nextFoot === index && behind && drift > STEP_SLACK_WALKING * this.stepSlack && landed; } + if (!due) continue; + foot.stepping = true; + foot.progress = 0; + foot.duration = clamp(0.2 - speed * 0.05, 0.11, 0.2) * this.stepPace[index]!; + foot.from.copy(foot.planted); + // The leader reaches past its place; the follower lands on its own. + foot.to.copy(desired).addScaledVector(velocityWorld, foot.duration * (index === leading ? 1.3 : 1)); + foot.to.y = 0; + if (leading >= 0) this.nextFoot = 1 - index; } this.feetInitialized = true; } @@ -1633,7 +1921,7 @@ export class BoxingGraph { } const t = easeOut(foot.progress, 1.6); out.copy(foot.from).lerp(foot.to, t); - return Math.sin(foot.progress * Math.PI) * 0.055 * this.stepLift[index]; + return Math.sin(foot.progress * Math.PI) * STEP_LIFT * this.stepLift[index]; } update( @@ -1714,7 +2002,11 @@ export class BoxingGraph { this.breakTime = Math.max(0, this.breakTime - dt); this.breakWeight = smooth(this.breakWeight, this.breakTime > 0 && this.downState === "up" ? 1 : 0, 6, dt); this.attendWeight = smooth(this.attendWeight, this.attending ? 1 : 0, 2.5, dt); - this.squareWeight = smooth(this.squareWeight, this.verdictSide !== 0 ? 1 : 0, 3, dt); + this.mournWeight = smooth(this.mournWeight, this.mood === "mourn" ? 1 : 0, 2.5, dt); + this.cheerWeight = smooth(this.cheerWeight, this.mood === "cheer" ? 1 : 0, 2.5, dt); + // Between rounds, before the first bell and for the verdict he is out of his stance, standing at his ease. + const atEase = !this.referee && (this.verdictSide !== 0 || this.resting || (this.countdownTicks !== null && this.countdownTicks > TOUCH_WALK_IN_START_TICKS)); + this.squareWeight = smooth(this.squareWeight, atEase ? 1 : 0, 3, dt); this.raisedWeight = smooth(this.raisedWeight, this.verdictSide !== 0 && (this.verdict === "winner" || this.verdict === "level") ? 1 : 0, 3.2, dt); this.bowedWeight = smooth(this.bowedWeight, this.verdictSide !== 0 && this.verdict === "loser" ? 1 : 0, 2.2, dt); for (const index of [0, 1] as const) this.wristWeights[index] = smooth(this.wristWeights[index], this.wrists[index] !== null ? 1 : 0, 3.2, dt); @@ -1730,6 +2022,7 @@ export class BoxingGraph { const stamina = fighter.stamina / Math.max(1, fighter.maximum_stamina); this.tired = smooth(this.tired, clamp((0.55 - stamina) / 0.5, 0, 1), 2, dt); this.stunAmount = smooth(this.stunAmount, Math.min(1, fighter.stunned_ticks / 24), 8, dt); + boxer.updateFace(dt, reducedMotion, this.punchActive && this.punchPower === "power", this.tired, this.stunAmount, this.isDown); const defending = fighter.defense; this.guardHigh = smooth(this.guardHigh, defending === "guard_high" ? 1 : 0, DEFENCE_RATE, dt); this.guardLow = smooth(this.guardLow, defending === "guard_low" ? 1 : 0, DEFENCE_RATE, dt); @@ -1746,6 +2039,8 @@ export class BoxingGraph { const gap = Math.hypot(this.mapping.x(opponent.x) - this.mapping.x(fighter.x), this.mapping.z(opponent.y) - this.mapping.z(fighter.y)); const crowded = this.referee || fighter.is_downed || opponent.is_downed ? 0 : 1 - smoothstep(CROWDED_GAP, OPEN_GAP, gap); this.crowding = smooth(this.crowding, crowded, 9, dt); + const near = this.referee || fighter.is_downed || opponent.is_downed ? 0 : 1 - smoothstep(TIGHT_GAP, LONG_GAP, gap); + this.tight = smooth(this.tight, near, 9, dt); let apart = Number.POSITIVE_INFINITY; if (this.hasLiveHead && !this.referee && this.downState === "up") { const own = this.boxer.rig.bones.head.getWorldPosition(this.ownHead); @@ -1770,6 +2065,7 @@ export class BoxingGraph { springStep(this.torsoKick, dt, 150, 7, 0.7); springStep(this.rootKick, dt, 120, 8, 0.12); springStep(this.coverKick, dt, 110, 15, 0.3); + springStep(this.armKick, dt, 55, 6, 0.3); if (this.foldDelay > 0) { this.foldDelay -= dt; if (this.foldDelay <= 0) { @@ -1777,6 +2073,47 @@ export class BoxingGraph { this.pendingFold = 0; } } + if (this.coverDelay > 0) { + this.coverDelay -= dt; + if (this.coverDelay <= 0) { + this.coverKick.velocity.x += this.pendingCover; + this.pendingCover = 0; + } + } + if (this.liverDelay > 0) { + this.liverDelay -= dt; + if (this.liverDelay <= 0) { + this.rootKick.velocity.y -= 1.4 * this.pendingLiver; + this.torsoKick.velocity.x += 2.6 * this.pendingLiver; + this.torsoKick.velocity.z += 1.6 * this.pendingLiver; + this.pendingLiver = 0; + } + } + this.handsDrop = Math.max(0, this.handsDrop - dt * 1.5); + // A broken guard throws his arms open. + if (fighter.guard_broken && !this.guardWasBroken) { + this.handsDrop = 1; + this.guardKick = 1.2; + } + this.guardWasBroken = fighter.guard_broken; + // Out on his feet, his legs lurch under him at odd moments, differently every spell. + if (this.stunAmount > 0.25 && this.downState === "up" && !this.referee) { + if (this.rockedTime === 0) { + this.rockedPhase = this.hurtRandom() * Math.PI * 2; + this.nextLurch = 0.1 + this.hurtRandom() * 0.2; + } + this.rockedTime += dt; + if (this.rockedTime >= this.nextLurch) { + const lurch = this.stunAmount; + this.rootKick.velocity.x += (this.hurtRandom() - 0.5) * 1.4 * lurch; + this.rootKick.velocity.z += (this.hurtRandom() - 0.6) * 1.2 * lurch; + this.rootKick.velocity.y -= this.hurtRandom() * 0.9 * lurch; + this.torsoKick.velocity.z += (this.hurtRandom() - 0.5) * 1.5 * lurch; + this.nextLurch = this.rockedTime + 0.3 + this.hurtRandom() * 0.5; + } + } else if (this.stunAmount < 0.02) { + this.rockedTime = 0; + } this.guardKick = Math.max(0, this.guardKick - dt * 2.4); this.ragdoll?.tick(dt); @@ -1784,21 +2121,55 @@ export class BoxingGraph { this.stepDeath(dt); this.stepInjuries(dt); - const bounceTempo = (1.9 - this.tired * 0.7) * (1 - this.stunAmount * 0.6); + // The idle rhythms run on his own clock, so no two fighters move in unison. + if (this.idleSeed < 0) { + this.idleSeed = idleSeedFor(fighter.player_id); + this.bouncePhase = this.idleSeed * 19; + this.weightPhase = this.idleSeed * 43; + this.breathPhase = this.idleSeed * 71; + } + const seed = this.idleSeed; + if (fighter.style !== this.mannerStyle) this.keyManner(fighter.style); + const own = this.manner; + // The beating he has taken shows in how he stands, before it puts him down. + this.battered = smooth(this.battered, clamp((fighter.trauma.head + fighter.trauma.body - BATTERED_FROM) / BATTERED_SPAN, 0, 1), 1.5, dt); + const battered = this.battered; + const life = time * (0.93 + seed * 0.14) + seed * 37; + const bounceTempo = (2.1 - this.tired * 0.8) * (1 - this.stunAmount * 0.6) * (0.94 + seed * 0.12) * own.tempo; this.bouncePhase += dt * bounceTempo * Math.PI * 2 * motionScale; - this.weightPhase += dt * 0.55 * Math.PI * 2 * motionScale; + this.weightPhase += dt * (0.42 + seed * 0.1) * Math.PI * 2 * motionScale; + this.breathPhase += dt * (0.3 + this.tired * 0.75) * Math.PI * 2; this.stunPhase += dt * 5.5; + // The lead hand paws at the other man now and then, one time in three twice. this.feintTimer -= dt; - if (this.feintTimer <= 0 && !this.punchActive && speed < 0.05 && this.downState === "up") { - this.feintTimer = 2.5 + (this.bouncePhase % 1.7); - this.feint = 1; + this.pawAge += dt; + if (this.feintTimer <= 0 && !this.punchActive && speed < 1 && this.downState === "up") { + this.pawCount += 1; + const roll = Math.abs(Math.sin(this.pawCount * 12.9898 + seed * 78.233) * 43758.5453) % 1; + this.feintTimer = roll < 0.3 ? PAW_SECONDS * 1.2 : 1.4 + roll * 2.6; + this.pawAge = 0; } - this.feint = Math.max(0, this.feint - dt * 3.5); + // Out in the first two fifths of its time and back in the rest. + const pawing = this.pawAge / PAW_SECONDS; + const reach = pawing < 1 ? Math.sin(Math.PI * 0.5 * (smoothstep(0, 0.4, pawing) + smoothstep(0.4, 1, pawing))) : 0; + const paw = this.referee ? 0 : reach * own.paw * (1 - 0.7 * this.tight) * (1 - 0.6 * this.tired) * (1 - this.stunAmount) * (1 - battered) * clamp(1 - this.guardHigh - this.guardLow, 0, 1) * motionScale; + // How much spring is in his legs, the bounce itself (which comes in surges), the rock of his weight from foot + // to foot at half its pace, and his breath. + const spring = this.referee ? 0 : (1 - this.stunAmount) * (1 - 0.6 * this.tired) * (1 - 0.7 * battered) * (speed > 0.6 ? 0.5 : 1) * own.spring; + const hop = Math.sin(this.bouncePhase) * (0.7 + 0.3 * Math.sin(life * 0.83 + 1.7)) * spring; + const rock = Math.sin(this.bouncePhase * 0.5 + 0.6) * spring * own.rock; + const breath = Math.sin(this.breathPhase) * (1 + 2 * this.tired); + this.breath = breath; // Feet. const rootPosition = this.scratchC.set(this.rootX, 0, this.rootZ); // Getting up, the feet are planted again under him and step as he turns or walks, ready for the standing pose. if (this.downState === "up" || this.downState === "rising") this.stepFeet(dt, mirror, speed, velocityWorld, rootPosition, this.yaw); + // His weight goes the way he walks, ahead of his feet. + const cosYaw = Math.cos(this.yaw); + const sinYaw = Math.sin(this.yaw); + this.walkLean.x = smooth(this.walkLean.x, clamp((velocityWorld.x * cosYaw - velocityWorld.z * sinYaw) * 0.03, -0.04, 0.04), 8, dt); + this.walkLean.y = smooth(this.walkLean.y, clamp((velocityWorld.x * sinYaw + velocityWorld.z * cosYaw) * 0.03, -0.04, 0.04), 8, dt); const rootQuatInverse = this.scratchQ.setFromAxisAngle(worldUpVector, -this.yaw); const lead = mirror > 0 ? this.foot.L : this.foot.R; const rear = mirror > 0 ? this.foot.R : this.foot.L; @@ -1813,26 +2184,41 @@ export class BoxingGraph { rear.position.y = ankleRest + rearLift; mirrorX(STANCE.leadToe, mirror, lead.toe); mirrorX(STANCE.rearToe, mirror, rear.toe); - lead.heel = 0; - rear.heel = 0; + // The heels pulse with the bounce and the rock, a planted foot pushes off its ball as the other steps, and a + // tired or stunned man stands flat. + const flat = clamp(this.tired * 0.6 + this.stunAmount + battered * 0.6, 0, 1); + const push = (leadLift + rearLift) * 3; + lead.heel = Math.max(0, STANCE.leadHeel + (own.heel - 1) * 0.12) + (0.5 + 0.5 * hop) * 0.09 * spring + Math.max(0, -rock) * 0.06 + push; + rear.heel = STANCE.rearHeel * own.heel * (1 - 0.7 * flat) + (0.5 + 0.5 * hop) * 0.07 * spring + Math.max(0, rock) * 0.07 + push; + // The referee stands flat on both feet. + if (this.referee) lead.heel = rear.heel = push; lead.pole.copy(lead.toe).setY(0.35).normalize(); rear.pole.copy(rear.toe).setY(0.35).normalize(); // Torso baseline. const torso = this.torso; const blade = STANCE.bladeYaw * mirror; - const bounce = Math.sin(this.bouncePhase) * 0.012 * (1 - this.stunAmount) * (speed > 0.6 ? 0.6 : 1); - const sway = Math.sin(this.weightPhase) * 0.02; - let crouch = 0.012 + this.tired * 0.03 + this.stunAmount * 0.05; - torso.hips.set(sway * mirror + Math.sin(this.stunPhase * 0.9) * 0.05 * this.stunAmount, STANCE.hipsHeight - crouch + bounce, 0.0); + const bounce = hop * 0.013; + const sway = (Math.sin(this.weightPhase) * 0.018 + Math.sin(life * 0.31 + 2.2) * 0.008) * motionScale * (0.5 + 0.5 * own.bob); + let crouch = 0.012 + this.tired * 0.03 + this.stunAmount * 0.05 + battered * 0.025; + torso.hips.set( + sway * mirror + Math.sin(this.stunPhase * 0.9) * 0.05 * this.stunAmount + this.walkLean.x, + STANCE.hipsHeight + own.rise - crouch + bounce + breath * 0.002, + rock * 0.018 + this.walkLean.y + own.weight, + ); torso.hipsYaw = blade; torso.hipsPitch = 0.02 + this.tired * 0.08; torso.hipsRoll = Math.sin(this.stunPhase) * 0.09 * this.stunAmount; - torso.shouldersYaw = blade * 0.88; - torso.spinePitch = 0.16 + this.tired * 0.16 + Math.sin(time * (2.1 + this.tired * 1.8)) * 0.012; - torso.spineRoll = Math.sin(this.stunPhase * 1.3) * 0.06 * this.stunAmount; - torso.headYaw = -0.12 * mirror + Math.sin(time * 0.9) * 0.05 + Math.sin(this.stunPhase * 0.7) * 0.25 * this.stunAmount; - torso.headPitch = 0.12 + Math.sin(time * 1.7) * 0.02 + this.stunAmount * 0.18; + torso.shouldersYaw = blade * STANCE.shoulderBlade; + // He leans toward the other man, which in his turned trunk is part pitch and part roll, and rounds his back over + // his chest; the lean eases as the other man comes close. + const lean = (STANCE.lean + own.lean) * (1 - 0.5 * this.tight); + torso.spinePitch = STANCE.hunch + lean * Math.cos(blade) + this.tired * 0.16 + battered * 0.06 - breath * 0.012 + this.walkLean.y; + torso.spineRoll = lean * Math.sin(blade) + Math.sin(this.stunPhase * 1.3) * 0.06 * this.stunAmount - this.walkLean.x + + (Math.sin(life * 0.61 + 2) * 0.018 + Math.sin(life * 1.43) * 0.008) * motionScale * own.bob; + torso.headYaw = -0.12 * mirror + Math.sin(life * 0.9) * 0.05 + Math.sin(this.stunPhase * 0.7) * 0.25 * this.stunAmount; + // Between exchanges a battered man's head hangs. + torso.headPitch = STANCE.chinTuck + Math.sin(life * 1.7) * 0.02 + this.stunAmount * 0.18 + battered * 0.2 * (1 - this.punchCommit); torso.headRoll = Math.sin(this.stunPhase * 1.1) * 0.14 * this.stunAmount; torso.headOffset.set(0, 0, 0); @@ -1841,18 +2227,28 @@ export class BoxingGraph { const rearHand = mirror > 0 ? this.hand.R : this.hand.L; const headRest = this.headRestChar(mirror); const guardBlend = clamp(this.guardHigh + this.guardLow, 0, 1); - const leadTarget = this.scratch.copy(STANCE.relaxedLead).lerp(STANCE.guardHighLead, this.guardHigh).lerp(STANCE.guardLowLead, this.guardLow); - const rearTarget = this.scratchB.copy(STANCE.relaxedRear).lerp(STANCE.guardHighRear, this.guardHigh).lerp(STANCE.guardLowRear, this.guardLow); - leadTarget.y -= this.tired * 0.12 + this.stunAmount * 0.22; - rearTarget.y -= this.tired * 0.1 + this.stunAmount * 0.2; + // At range each glove is where his own manner carries it; close in every man's guard is the same tight one, + // but for the arm a shell lays across the body. + const range = 1 - this.crowding; + const leadTarget = this.scratch.copy(STANCE.relaxedLead).lerp(STANCE.tightLead, this.tight); + leadTarget.x += own.lead.x * range; + leadTarget.y += own.lead.y * range; + leadTarget.z += own.lead.z * range * (1 - this.tight * (1 - own.shell)); + leadTarget.lerp(STANCE.guardHighLead, this.guardHigh).lerp(STANCE.guardLowLead, this.guardLow); + const rearTarget = this.scratchB.copy(STANCE.relaxedRear).lerp(STANCE.tightRear, this.tight).addScaledVector(own.rear, range).lerp(STANCE.guardHighRear, this.guardHigh).lerp(STANCE.guardLowRear, this.guardLow); + leadTarget.y -= this.tired * 0.12 + this.stunAmount * 0.22 + battered * 0.06; + rearTarget.y -= this.tired * 0.1 + this.stunAmount * 0.2 + battered * 0.05; // A spent guard, raised or not, sags from the cheekbones toward the chest: the opening shows. leadTarget.y -= this.guardSpent * GUARD_SPENT_DROP; rearTarget.y -= this.guardSpent * GUARD_SPENT_DROP; leadTarget.z -= this.guardSpent * 0.04; rearTarget.z -= this.guardSpent * 0.03; - leadTarget.z += this.feint * 0.1 + Math.sin(time * 2.3) * 0.012 * motionScale; - leadTarget.x += Math.sin(time * 1.9) * 0.01 * motionScale; - rearTarget.y += Math.cos(time * 2.7) * 0.01 * motionScale; + // The gloves float and re-set on their own periods, and rise and fall with his breath. + leadTarget.z += paw * 0.11 + Math.sin(life * 2.3) * 0.012 * motionScale; + leadTarget.x += Math.sin(life * 1.9) * 0.01 * motionScale; + leadTarget.y += paw * 0.02 + Math.sin(life * 1.27 + 1) * 0.008 * motionScale + breath * 0.004; + rearTarget.y += Math.cos(life * 2.7) * 0.006 * motionScale + breath * 0.004; + rearTarget.x += Math.sin(life * 1.13 + 2) * 0.004 * motionScale; leadTarget.z -= this.guardKick * 0.07; rearTarget.z -= this.guardKick * 0.05; leadTarget.y -= this.guardKick * 0.02; @@ -1866,39 +2262,67 @@ export class BoxingGraph { mirrorX(STANCE.rearPalm, mirror, rearHand.palm); mirrorX(STANCE.leadPole, mirror, leadHand.pole); mirrorX(STANCE.rearPole, mirror, rearHand.pole); - let shrugLead = 0.15 * guardBlend; - let shrugRear = 0.25 * guardBlend; + // Close in, the lead elbow tucks to the ribs with the glove; at range his elbows are as far out as he carries them. + leadHand.pole.x *= 1 - 0.6 * this.tight; + const loose = range * (1 - guardBlend); + leadHand.pole.x += own.flare * mirror * loose; + rearHand.pole.x -= own.flare * mirror * loose; + if (own.shell > 0) { + const shell = own.shell * loose; + leadHand.knuckles.lerp(this.scratchD.set(-0.8 * mirror, 0.1, 0.6), shell).normalize(); + leadHand.palm.lerp(this.scratchD.set(-0.3 * mirror, 0.35, -0.9), shell).normalize(); + leadHand.pole.lerp(this.scratchD.set(0.5 * mirror, -0.8, -0.35), shell).normalize(); + } + torso.shouldersYaw += blade * 0.07 * paw; + let shrugLead = STANCE.leadShrug + (0.6 - STANCE.leadShrug) * guardBlend + breath * 0.12 + paw * 0.2 + own.shrug * loose; + let shrugRear = STANCE.rearShrug + (0.5 - STANCE.rearShrug) * guardBlend + breath * 0.12 + Math.min(0, own.shrug) * loose; + if (guardBlend > 0.001) { + // A shell: the forearms upright with the elbows under the gloves and in, palms to his face, and a crouch behind it, + // deeper behind the low guard, which brings the elbows down over the ribs. + leadHand.pole.lerp(mirrorX(STANCE.guardHighLeadPole, mirror, this.scratch), this.guardHigh).lerp(mirrorX(STANCE.guardLowLeadPole, mirror, this.scratch), this.guardLow).normalize(); + rearHand.pole.lerp(mirrorX(STANCE.guardHighRearPole, mirror, this.scratch), this.guardHigh).lerp(mirrorX(STANCE.guardLowRearPole, mirror, this.scratch), this.guardLow).normalize(); + leadHand.knuckles.lerp(mirrorX(STANCE.guardKnuckles, mirror, this.scratch), guardBlend).normalize(); + rearHand.knuckles.lerp(mirrorX(STANCE.guardKnuckles, -mirror, this.scratch), guardBlend).normalize(); + leadHand.palm.lerp(mirrorX(STANCE.guardPalm, mirror, this.scratch), guardBlend).normalize(); + rearHand.palm.lerp(mirrorX(STANCE.guardPalm, -mirror, this.scratch), guardBlend).normalize(); + torso.hips.y -= 0.03 * this.guardHigh + 0.08 * this.guardLow; + torso.spinePitch += 0.05 * this.guardHigh + 0.2 * this.guardLow; + torso.headPitch += 0.08 * guardBlend; + } if (this.hurt) this.applyHurtStance(time, mirror, leadHand, rearHand, headRest); - // Defensive body movement. - if (Math.abs(this.slip) > 0.001) { + // Defensive body movement: from the knees and the waist, eyes on the opponent, the gloves going with the head. + if (Math.abs(this.slip) > 0.001 || this.weave > 0.001 || this.pull > 0.001) { + const hipsX = torso.hips.x; + const hipsY = torso.hips.y; + const hipsZ = torso.hips.z; + const pitchBefore = torso.spinePitch; + const rollBefore = torso.spineRoll; + const yawBefore = torso.shouldersYaw; + // A slip turns the shoulders with it and puts the weight over the foot on that side. const s = this.slip; - torso.headOffset.x += s * 0.13; - torso.spineRoll += -s * 0.28; - torso.hips.x += s * 0.03; - torso.hips.y -= Math.abs(s) * 0.05; - torso.spinePitch += Math.abs(s) * 0.12; - torso.headRoll += -s * 0.2; - } - if (this.weave > 0.001) { + torso.shouldersYaw += s * 0.22; + torso.hipsYaw += s * 0.1; + this.leanHead(s * 0.18, 0); + torso.hips.x += s * 0.05; + torso.hips.y -= Math.abs(s) * 0.04; + // A weave drops at the knees and passes under the punch in a U, from the lead side to the rear. const w = this.weave; const phase = clamp(this.weaveTime / WEAVE_SECONDS, 0, 1); const arc = Math.sin(phase * Math.PI); - torso.hips.y -= w * 0.2; - torso.spinePitch += w * 0.42; - torso.headOffset.x += w * (1 - 2 * phase) * 0.16 * mirror; - torso.headOffset.y -= w * arc * 0.08; - torso.spineRoll += w * (1 - 2 * phase) * 0.18 * mirror; - leadHand.position.y -= w * 0.1; - rearHand.position.y -= w * 0.1; - } - if (this.pull > 0.001) { + const across = w * (1 - 2 * phase) * mirror; + torso.hips.y -= w * (0.08 + 0.14 * arc); + torso.hips.x += across * 0.04; + this.leanHead(across * 0.14, w * (0.04 + 0.06 * arc)); + // A pull sits back onto the rear leg and takes the head straight back out of range. const p = this.pull; - torso.spinePitch -= p * 0.34; - torso.hips.z -= p * 0.11; - torso.hips.x -= p * 0.05 * mirror; - torso.headOffset.z -= p * 0.06; - torso.headPitch -= p * 0.1; + torso.hips.z -= p * 0.1; + torso.hips.y -= p * 0.03; + this.leanHead(0, -p * 0.2); + torso.headPitch -= p * 0.06; + const travel = this.headTravel(this.scratch, hipsX, hipsY, hipsZ, pitchBefore, rollBefore, yawBefore); + leadHand.position.add(travel); + rearHand.position.add(travel); } // Inside, the fighter stands taller with the guard tucked in and the head off the centre line, @@ -1908,7 +2332,7 @@ export class BoxingGraph { const inside = this.crowding * (1 - this.clinchWeight) * (1 - this.punchCommit); if (inside > 0.001) { torso.headOffset.x -= inside * 0.075; - torso.headOffset.z -= inside * 0.05; + torso.headOffset.z -= inside * 0.04; torso.headYaw -= inside * 0.2; torso.spinePitch -= inside * 0.07; torso.hips.z -= inside * 0.05; @@ -1948,16 +2372,15 @@ export class BoxingGraph { // Punch. if (this.punchActive) { - shrugLead = 0; - shrugRear = 0; const shrug = this.applyPunch(mirror, leadHand, rearHand, lead, rear, headRest); this.punchReach = shrug; - if ((this.punchHand === "left") === (mirror > 0)) shrugLead = shrug; - else shrugRear = shrug; + // The punching shoulder goes out with the glove from where the stance carries it; the other stays shrugged. + if ((this.punchHand === "left") === (mirror > 0)) shrugLead = Math.max(shrugLead, shrug); + else shrugRear = Math.max(shrugRear, shrug); } if (this.referee) { - this.applyRefereePose(mirror, leadHand, rearHand, lead, rear, headRest, time, sampledTick, fighter.stunned_ticks); + shrugLead = shrugRear = this.applyRefereePose(mirror, leadHand, rearHand, lead, rear, time, sampledTick, dt, fighter.stunned_ticks); this.applyReactions(leadHand, rearHand, lead, rear); } @@ -1995,7 +2418,14 @@ export class BoxingGraph { if (this.touchWeight > 0.001 && this.downState === "up") this.applyTouchGlovesPose(this.touchWeight, mirror, leadHand, rearHand); if (this.celebration > 0.001 && this.downState === "up") this.applyCelebratePose(this.celebration, time, mirror, leadHand, rearHand, lead, rear); if (this.wave > 0.001 && this.downState === "up") this.applyWaveOffPose(this.wave, time, mirror, leadHand, rearHand); - if (this.squareWeight > 0.001 && this.downState === "up") this.applyVerdictPose(this.squareWeight, time, mirror, leadHand, rearHand, lead, rear, headRest); + if (this.squareWeight > 0.001 && this.downState === "up") { + this.applyVerdictPose(this.squareWeight, time, mirror, leadHand, rearHand, lead, rear, headRest); + // Out of his stance his heels are down and so are his shoulders, which heave if he is spent. + lead.heel *= 1 - this.squareWeight; + rear.heel *= 1 - this.squareWeight; + shrugLead = THREE.MathUtils.lerp(shrugLead, this.breath * 0.15, this.squareWeight); + shrugRear = THREE.MathUtils.lerp(shrugRear, this.breath * 0.15, this.squareWeight); + } if ((this.wristWeights[0] > 0.001 || this.wristWeights[1] > 0.001) && this.downState === "up") this.applyRaisePose(mirror, leadHand, rearHand); if (this.breakWeight > 0.001 && this.downState === "up") this.applyBreakPose(this.breakWeight, mirror, leadHand, rearHand); if (this.attendWeight > 0.001 && this.downState === "up") this.applyAttendPose(this.attendWeight, time, mirror, leadHand, rearHand); @@ -2096,7 +2526,8 @@ export class BoxingGraph { // southpaw's to his left, into the head of an orthodox opponent. Squared up, both rest it to the right. torso.hipsYaw *= 1 - c; torso.shouldersYaw *= 1 - c; - torso.spinePitch += c * (over ? 0.28 : 0.42) + struggle * 0.025 * c; + // He leans in on the other man by a set amount, whatever lean his stance already had. + torso.spinePitch += c * ((over ? 0.36 : 0.5) - torso.spinePitch) + struggle * 0.025 * c; torso.hips.z += c * (over ? 0.04 : 0.06); torso.hips.x += struggle * 0.02 * c; torso.hips.y -= c * (over ? 0 : 0.03) + Math.abs(struggle) * 0.012 * c; @@ -2308,7 +2739,43 @@ export class BoxingGraph { return 0.5; } - /** Punch mechanics. Returns the punching shoulder's shrug. */ + /** + * Bends the trunk at the waist so the head travels `dx` to his left and `dz` ahead of him, whichever way his + * shoulders are turned. + */ + private leanHead(dx: number, dz: number): void { + const torso = this.torso; + const sin = Math.sin(torso.shouldersYaw); + const cos = Math.cos(torso.shouldersYaw); + torso.spinePitch += (dx * sin + dz * cos) / HEAD_LEVER; + torso.spineRoll -= (dx * cos - dz * sin) / HEAD_LEVER; + } + + /** + * How far the head has travelled since the trunk had these hips, spine pitch and roll and shoulder turn: a glove + * held to the face goes with it. + */ + private headTravel(out: THREE.Vector3, hipsX: number, hipsY: number, hipsZ: number, pitch: number, roll: number, yaw: number): THREE.Vector3 { + const torso = this.torso; + const ahead = Math.sin(torso.spinePitch); + const across = -Math.sin(torso.spineRoll); + const sin = Math.sin(torso.shouldersYaw); + const cos = Math.cos(torso.shouldersYaw); + const aheadBefore = Math.sin(pitch); + const acrossBefore = -Math.sin(roll); + const sinBefore = Math.sin(yaw); + const cosBefore = Math.cos(yaw); + return out.set( + torso.hips.x - hipsX + HEAD_LEVER * (ahead * sin + across * cos - aheadBefore * sinBefore - acrossBefore * cosBefore), + torso.hips.y - hipsY + HEAD_LEVER * (Math.cos(torso.spinePitch) * Math.cos(torso.spineRoll) - Math.cos(pitch) * Math.cos(roll)), + torso.hips.z - hipsZ + HEAD_LEVER * (ahead * cos - across * sin - aheadBefore * cosBefore + acrossBefore * sinBefore), + ); + } + + /** + * Punch mechanics. The punch comes from the ground up: the feet and hips start it, the shoulders follow and the arm + * goes last; coming back, the hand is home before the body has settled. Returns how far the punching arm is out. + */ private applyPunch( mirror: number, leadHand: { position: THREE.Vector3; knuckles: THREE.Vector3; palm: THREE.Vector3; pole: THREE.Vector3 }, @@ -2323,10 +2790,14 @@ export class BoxingGraph { const startup = Math.max(1, timing.startup); const active = Math.max(0.5, timing.active); const recovery = Math.max(1, timing.recovery); + const punchClass = this.punchClass; + const swung = punchClass === "hook" || punchClass === "uppercut"; const isLead = (this.punchHand === "left") === (mirror > 0); const hand = isLead ? leadHand : rearHand; const other = isLead ? rearHand : leadHand; const side = isLead ? 1 : -1; + /** The punching hand's side in character space: 1 for his left. */ + const handX = side * mirror; const power = this.punchPower === "power" ? 1 : 0; const body = this.punchTarget === "body" ? 1 : 0; @@ -2334,90 +2805,149 @@ export class BoxingGraph { let windup: number; let phase: "startup" | "active" | "recovery"; // Every punch leaves the guard and eases into its windup instead of jumping on its first frame: - // the hand over the windup, its turn and the elbow over twice that. + // the hand over the windup, its turn and the elbow over twice that and no less than three fifths of + // the startup (the elbow of a jab stays in behind the glove), or three times for a hook or an + // uppercut, whose elbow comes up as the punch travels. let windupIn = 1; let onset = 1; // A power punch loads up first, through most of its longer startup: he sinks, turns his shoulders and hips away from // the punch and cocks the glove back, then unwinds into it. let load = 0; + // How far the legs and hips are into the punch, how far the shoulders, and the follow-through past the contact. + let drive = 1; + let turn = 1; + let follow = 0; + // How far a punch that found nothing has swung on past where the target was: late in its active ticks, eased out as it recovers. + let swing = 0; if (age < startup) { phase = "startup"; const u = age / startup; - const windupEnd = power === 1 ? POWER_LOAD : this.punchClass === "hook" ? 0.3 : this.punchClass === "uppercut" ? 0.45 : 0.18; + const windupEnd = power === 1 ? POWER_LOAD : punchClass === "hook" ? 0.3 : punchClass === "uppercut" ? 0.45 : 0.18; windup = smoothstep(0, windupEnd, u) * (1 - smoothstep(windupEnd, Math.min(1, windupEnd + 0.4), u)); extend = u <= windupEnd ? 0 : easeIn((u - windupEnd) / (1 - windupEnd), power === 1 ? POWER_SNAP : 1.65); windupIn = smoothstep(0, windupEnd, u); - onset = smoothstep(0, Math.min(1, windupEnd * 2), u); + onset = smoothstep(0, Math.min(1, swung ? windupEnd * 3 : Math.max(0.6, windupEnd * 2)), u); load = power * smoothstep(0, POWER_LOAD * 0.8, u) * (1 - smoothstep(POWER_LOAD, Math.min(1, POWER_LOAD + 0.3), u)); + drive = smoothstep(windupEnd * (power === 1 ? 0.85 : 0.5), windupEnd + (1 - windupEnd) * 0.75, u); + turn = smoothstep(windupEnd * (power === 1 ? 0.95 : 0.8), 1, u); } else if (age < startup + active) { phase = "active"; windup = 0; - extend = 1 + (0.06 + 0.05 * power) * Math.sin(((age - startup) / active) * Math.PI); + extend = 1; + const held = (age - startup) / active; + follow = Math.sin(held * Math.PI); + swing = smoothstep(0.2, 1, held); } else { phase = "recovery"; windup = 0; - extend = 1 - easeOut((age - startup - active) / recovery, 1.9); + const back = (age - startup - active) / recovery; + extend = 1 - easeOut(back, 1.9); + drive = 1 - smoothstep(0, 1, back); + turn = drive; + swing = 1 - smoothstep(0, 0.6, back); } - const e = clamp(extend, 0, 1.1); + const e = clamp(extend, 0, 1); // The swing follows its arc out to contact; on the way back the glove retracts straight to the // guard instead of retracing the arc (a hook must not swing back out wide). const travel = phase === "recovery" ? 1 : e; const retract = phase === "recovery" ? 1 - e : 0; + // His weight goes on through the target, further behind a power shot that landed, and much further when the + // punch found nothing there. + const through = (follow * (0.06 + 0.1 * power * this.followHead) + swing * 0.24 * this.punchMiss) * (1 + 0.5 * power); const guard = this.punchGuard.position.copy(hand.position); const guardKnuckles = this.punchGuard.knuckles.copy(hand.knuckles); const guardPalm = this.punchGuard.palm.copy(hand.palm); const guardPole = this.punchGuard.pole.copy(hand.pole); - // Torso rotation: lead punches blade further, rear punches square up. - const blade = STANCE.bladeYaw * mirror; + // What the body does behind the punch, for an orthodox fighter: the turn of the shoulders and of the hips, the + // weight's shift toward the opponent and toward the lead foot's side, the knees' bend, the lean into it, each heel's + // lift and each foot's pivot on its ball, and an uppercut's dip under the punching shoulder and drive up out of it. let yawTravel: number; let hipsTravel: number; - let hipsForward = 0; + let shiftZ: number; + let shiftX = 0; + let sink = 0.02; + let leanIn = 0.04; let heelRear = 0; let heelLead = 0; + let rearPivot = 0; let leadPivot = 0; let dip = 0; - switch (this.punchClass) { + let rise = 0; + switch (punchClass) { case "jab": - yawTravel = -0.2 * side; - hipsTravel = -0.06 * side; - hipsForward = 0.03; - heelRear = 0.18; + // Off the rear foot onto the lead one, the trunk barely turning. + yawTravel = isLead ? -0.16 : 0.7; + hipsTravel = isLead ? -0.04 : 0.5; + shiftZ = 0.035; + shiftX = 0.015; + sink = 0.01; + leanIn = 0.03; + heelRear = isLead ? 0.42 : 0.55; + rearPivot = isLead ? 0 : 0.3; break; case "straight": + // The rear heel turns out and lifts, the knee, hip and shoulder drive through and the weight lands on the bent lead leg. yawTravel = isLead ? -0.3 : 1.15 + 0.15 * power; - hipsTravel = isLead ? -0.1 : 1.05 + 0.1 * power; - hipsForward = 0.08; - heelRear = isLead ? 0.2 : 0.62; + hipsTravel = isLead ? -0.12 : 1 + 0.1 * power; + shiftZ = isLead ? 0.08 : 0.1 + 0.03 * power; + shiftX = isLead ? 0.02 : 0.04; + sink = 0.03; + leanIn = isLead ? 0.05 : 0.07; + heelRear = isLead ? 0.5 : 0.78; + rearPivot = isLead ? 0 : 0.55; break; case "hook": - yawTravel = isLead ? -0.95 - 0.2 * power : 1.35 + 0.2 * power; - hipsTravel = isLead ? -0.8 : 1.15; - heelRear = isLead ? 0.1 : 0.55; - heelLead = isLead ? 0.45 : 0; - leadPivot = isLead ? 0.5 : 0; - hipsForward = 0.02; + // A short turn of the hips over the pivoting foot on the punching side, the trunk upright on its axis: the + // lead hook lands with the chest half turned and the forearm across it. + yawTravel = isLead ? -0.5 - 0.15 * power : 1.25 + 0.2 * power; + hipsTravel = isLead ? -0.45 : 1.1; + shiftZ = isLead ? 0.02 : 0.06; + shiftX = isLead ? -0.02 : 0.05; + sink = 0.03; + leanIn = -0.05; + heelRear = isLead ? 0 : 0.7; + rearPivot = isLead ? 0 : 0.6; + heelLead = isLead ? 0.5 : 0; + leadPivot = isLead ? 0.6 : 0; break; default: - yawTravel = isLead ? -0.55 : 0.95; - hipsTravel = isLead ? -0.45 : 0.85; - heelRear = isLead ? 0.15 : 0.5; - dip = 0.12 + 0.05 * power; + // The knees and the punching shoulder dip, then the legs and hip drive the fist up. + yawTravel = isLead ? -0.3 : 1.15; + hipsTravel = isLead ? -0.25 : 0.95; + shiftZ = isLead ? 0.05 : 0.08; + shiftX = isLead ? 0 : 0.03; + sink = 0; + leanIn = -0.04; + heelRear = isLead ? 0 : 0.65; + rearPivot = isLead ? 0 : 0.5; + heelLead = isLead ? 0.35 : 0; + leadPivot = isLead ? 0.3 : 0; + dip = 0.09 + 0.04 * power; + rise = 0.03; break; } - const rotation = this.punchClass === "hook" ? smoothstep(0.15, 1, e) : e; - // The load turns him the other way from the punch's own turn. - const away = -Math.sign(yawTravel) * mirror * load; - torso.shouldersYaw = blade * 0.88 + yawTravel * mirror * rotation + POWER_LOAD_YAW * away; - torso.hipsYaw = blade + hipsTravel * mirror * rotation + POWER_LOAD_HIPS_YAW * away; - torso.hips.z += hipsForward * e - 0.04 * load; - torso.hips.x += (isLead ? 0.02 : 0.05) * mirror * e; - torso.hips.y -= body * 0.1 * e + dip * windup + dip * 0.3 * e + POWER_LOAD_DIP * load; - torso.spinePitch += 0.06 * e + body * 0.25 * e + dip * 1.4 * windup + 0.14 * load; - torso.headPitch += 0.05 * e + body * 0.12 * e + 0.1 * load; + const hipsX = torso.hips.x; + const hipsY = torso.hips.y; + const hipsZ = torso.hips.z; + const pitchBefore = torso.spinePitch; + const rollBefore = torso.spineRoll; + const yawBefore = torso.shouldersYaw; + // The load turns him the other way from the punch's own turn, and a hook or an uppercut coils without it. + const away = -Math.sign(yawTravel) * mirror * (load + (1 - power) * (swung ? 0.6 * windup : 0)); + torso.shouldersYaw += yawTravel * mirror * (turn + through) + POWER_LOAD_YAW * away; + torso.hipsYaw += hipsTravel * mirror * (drive + through * 0.5) + POWER_LOAD_HIPS_YAW * away; + // A punch at nothing pulls him forward after it. + torso.hips.z += shiftZ * (drive + through) - 0.04 * load + 0.07 * swing * this.punchMiss; + torso.hips.x += shiftX * mirror * (drive + through); + // A body shot is a change of level from the knees, the back kept fairly straight. + torso.hips.y -= (sink + body * BODY_LEVEL_CHANGE) * drive + dip * windup - rise * e + POWER_LOAD_DIP * load; + torso.spinePitch += leanIn * (turn + through) + body * 0.08 * drive + 0.08 * load + 0.08 * swing * this.punchMiss; + torso.spineRoll -= handX * dip * 1.8 * windup; + torso.headPitch += 0.03 * e + 0.06 * load; torso.headOffset.z += 0.02 * e; - torso.headYaw += -yawTravel * mirror * rotation * 0.35; + torso.headYaw += yawTravel * mirror * turn * 0.1; // Target in character space, measured from the rotated shoulder. const target = this.scratch; @@ -2432,58 +2962,92 @@ export class BoxingGraph { } else { target.set(0, body === 1 ? 1.15 : 1.5, 0.9); } - const shoulderSpan = 0.19 * side * mirror; + const shoulderSpan = 0.19 * handX; + const shoulderAhead = 0.04 + torso.spinePitch * 0.25; + const shoulderSin = Math.sin(torso.shouldersYaw); + const shoulderCos = Math.cos(torso.shouldersYaw); const shoulderChar = this.scratchD.set( - torso.hips.x + shoulderSpan * Math.cos(torso.shouldersYaw), - headRest.y - 0.22, - torso.hips.z + 0.04 + torso.spinePitch * 0.25 - shoulderSpan * Math.sin(torso.shouldersYaw), + torso.hips.x + shoulderSpan * shoulderCos + shoulderAhead * shoulderSin, + headRest.y + torso.hips.y - hipsY - 0.22, + torso.hips.z - shoulderSpan * shoulderSin + shoulderAhead * shoulderCos, ); - const dir = this.punchDir.copy(target).sub(shoulderChar); - const distance = dir.length(); - dir.normalize(); - const reach = 0.5 + 0.04 * power + (this.punchClass === "straight" ? 0.06 : 0) + (this.punchClass === "jab" ? 0.03 : 0) - - (this.punchClass === "hook" ? 0.08 : 0) - (this.punchClass === "uppercut" ? 0.08 : 0); - const contactDistance = Math.min(distance - HURTBOXES.head.radius - GLOVE_HITBOX_RADIUS + PUNCH_CONTACT_OFFSET, reach); - // Pressed together there is little room: the punch shortens and the elbow stays bent rather than - // the glove going past the contact point into the face. - const contact = this.punchContact.copy(shoulderChar).addScaledVector(dir, Math.max(0, contactDistance)); - rear.heel = heelRear * e; - lead.heel = heelLead * e; + const dir = this.punchDir; + // The arm stays bent through a hook and folded under an uppercut. + const reach = swung ? (punchClass === "hook" ? 0.45 : 0.36) + 0.03 * power : 0.5 + 0.04 * power + (punchClass === "straight" ? 0.06 : 0.03); + const standOff = HURTBOXES.head.radius + GLOVE_HITBOX_RADIUS - PUNCH_CONTACT_OFFSET; + const contact = this.punchContact; + // How far out of the arm's reach the target is. + let beyond = 0; + for (let pass = 0; pass < 2; pass += 1) { + const distance = dir.copy(target).sub(shoulderChar).length(); + dir.normalize(); + if (swung) { + // A hook comes round onto the side of the target and an uppercut up under it, as far as the bent arm reaches. + const flat = Math.max(1e-6, Math.hypot(dir.x, dir.z)); + const from = this.scratchC; + if (punchClass === "hook") from.set((-0.8 * dir.x + 0.6 * handX * dir.z) / flat, 0, (-0.8 * dir.z - 0.6 * handX * dir.x) / flat); + else from.set((-0.8 * dir.x) / flat, -0.6, (-0.8 * dir.z) / flat); + contact.copy(target).addScaledVector(from.normalize(), standOff).sub(shoulderChar); + } else { + // Pressed together there is little room: the punch shortens and the elbow stays bent rather than + // the glove going past the contact point into the face. + contact.copy(dir).multiplyScalar(Math.max(0, distance - standOff)); + } + const span = contact.length(); + beyond = span - reach; + if (pass === 0) { + // A target at the end of his reach draws his weight further in behind the punch. + const closer = clamp(beyond, 0, REACH_IN) * drive; + torso.hips.z += closer; + shoulderChar.z += closer; + } else if (swung) { + // Out of reach a hook still comes round level and an uppercut still comes up: it only falls short. + const flatReach = Math.sqrt(Math.max(0.01, reach * reach - contact.y * contact.y)); + const flatSpan = Math.hypot(contact.x, contact.z); + if (flatSpan > flatReach) contact.set(contact.x * flatReach / flatSpan, contact.y, contact.z * flatReach / flatSpan); + contact.add(shoulderChar); + } else { + contact.multiplyScalar(Math.min(1, reach / Math.max(1e-6, span))).add(shoulderChar); + } + } + if (heelRear > rear.heel) rear.heel += (heelRear - rear.heel) * drive; + if (heelLead > lead.heel) lead.heel += (heelLead - lead.heel) * drive; if (leadPivot > 0) { - const pivot = this.scratchQ.setFromAxisAngle(worldUpVector, -leadPivot * mirror * e); + const pivot = this.scratchQ.setFromAxisAngle(worldUpVector, -leadPivot * mirror * drive); lead.toe.applyQuaternion(pivot); lead.pole.applyQuaternion(pivot); } - if (heelRear > 0.3) { - const pivot = this.scratchQ.setFromAxisAngle(worldUpVector, 0.45 * mirror * e); + if (rearPivot > 0) { + const pivot = this.scratchQ.setFromAxisAngle(worldUpVector, rearPivot * mirror * drive); rear.toe.applyQuaternion(pivot); rear.pole.applyQuaternion(pivot); } - // Hand path. + // Hand path. A hook's elbow lifts beside the glove and an uppercut's glove drops to the ribs: neither swings back. const windupOffset = this.scratchE; - switch (this.punchClass) { + switch (punchClass) { case "hook": - windupOffset.set(0.22 * side * mirror, -0.06, -0.12); + windupOffset.set((0.1 + 0.03 * power) * handX, -0.05, -0.06); break; case "uppercut": - windupOffset.set(0.05 * side * mirror, -0.42, -0.02); + windupOffset.set(0.03 * handX, -0.26, -0.04); break; case "straight": - windupOffset.set(0.02 * side * mirror, -0.03, -0.09 - 0.05 * power); + windupOffset.set(0.02 * handX, -0.02, -0.04 - 0.05 * power); break; default: - windupOffset.set(0, -0.01, -0.05 - 0.04 * power); + windupOffset.set(0, -0.01, -0.02 - 0.07 * power); break; } - // Loading a power punch, the glove draws further back and drops, wider still for a hook. - windupOffset.x += (this.punchClass === "hook" ? 0.08 : 0) * side * mirror * power; + // Loading a power punch, the glove draws further back and drops. windupOffset.y -= 0.05 * power; - windupOffset.z -= 0.12 * power; + windupOffset.z -= (swung ? 0.07 : 0.12) * power; // A hook or uppercut keeps part of its windup until it travels, once the windup has eased in. - const start = this.punchStart.copy(guard).addScaledVector(windupOffset, Math.max(windup, this.punchClass === "hook" || this.punchClass === "uppercut" ? (1 - travel) * 0.6 * windupIn : 0)); - if (this.punchClass === "hook") { - // Horizontal sweep around the shoulder from the wide windup into the target. The radius runs + const start = this.punchStart.copy(guard).addScaledVector(windupOffset, Math.max(windup, swung ? (1 - travel) * 0.6 * windupIn : 0)); + // How far a punch that found nothing carries on past where the target was. + const carry = swing * this.punchMiss; + if (punchClass === "hook") { + // Horizontal sweep around the shoulder from the windup into the target. The radius runs // from the windup's to the contact's, measured flat, so the sweep ends on the contact point. const startRadius = Math.hypot(start.x - shoulderChar.x, start.z - shoulderChar.z); const contactRadius = Math.hypot(contact.x - shoulderChar.x, contact.z - shoulderChar.z); @@ -2491,33 +3055,32 @@ export class BoxingGraph { const endDir = this.punchSweepTo.copy(contact).sub(shoulderChar).setY(0).normalize(); const angle = Math.acos(clamp(startDir.dot(endDir), -1, 1)); // The sign of the cross product's vertical component: which way round the shoulder the sweep turns. - const turn = startDir.z * endDir.x - startDir.x * endDir.z >= 0 ? 1 : -1; + const round = startDir.z * endDir.x - startDir.x * endDir.z >= 0 ? 1 : -1; const sweep = smoothstep(0, 1, travel); // The start direction is not needed again, so it turns in place. - const rotated = startDir.applyAxisAngle(worldUpVector, angle * sweep * turn).normalize(); + const rotated = startDir.applyAxisAngle(worldUpVector, (angle * sweep + 0.5 * carry) * round).normalize(); hand.position.copy(shoulderChar).addScaledVector(rotated, THREE.MathUtils.lerp(startRadius, contactRadius, sweep)); hand.position.y = THREE.MathUtils.lerp(start.y, contact.y, sweep); - hand.pole.set(0.95 * side * mirror, 0.08, 0.3).normalize(); - hand.knuckles.copy(rotated).applyAxisAngle(worldUpVector, turn * Math.PI / 2).setY(0.05).normalize(); + // The elbow comes up level with the glove, whose target is above the shoulder for a hook to the head. + hand.pole.set(0.9 * handX, 0.2 + 0.5 * (1 - body), 0.25).normalize(); + hand.knuckles.copy(rotated).applyAxisAngle(worldUpVector, round * Math.PI / 2).setY(0.05).normalize(); hand.palm.set(0, -1, 0); - } else if (this.punchClass === "uppercut") { - const rise = smoothstep(0, 1, travel); - const low = start; - const mid = this.punchMid.copy(contact).lerp(low, 0.5); - mid.y = Math.min(low.y, contact.y) - 0.04; - mid.z += 0.08; - hand.position.copy(low).lerp(mid, rise * 2 > 1 ? 1 : rise * 2); - if (rise > 0.5) hand.position.copy(mid).lerp(contact, (rise - 0.5) * 2); - hand.pole.set(0.3 * side * mirror, -0.2, 1); - hand.knuckles.set(0.05 * side * mirror, 0.9, 0.35).normalize(); - hand.palm.set(-0.2 * side * mirror, 0.3, -0.95).normalize(); + } else if (punchClass === "uppercut") { + // Forward low and close to the body, then up under the target. + const up = smoothstep(0, 1, travel); + const mid = this.punchMid.set(start.x + (contact.x - start.x) * 0.6, Math.min(start.y, contact.y - 0.12), start.z + (contact.z - start.z) * 0.75); + hand.position.copy(start).multiplyScalar((1 - up) * (1 - up)).addScaledVector(mid, 2 * (1 - up) * up).addScaledVector(contact, up * up); + hand.position.y += 0.05 * follow + 0.14 * carry; + hand.pole.set(0.3 * handX, -1, -0.1).normalize(); + hand.knuckles.set(0.05 * handX, 0.9, 0.35).normalize(); + hand.palm.set(-0.2 * handX, 0.3, -0.95).normalize(); } else { - hand.position.copy(start).lerp(contact, Math.min(1, travel)); + hand.position.copy(start).lerp(contact, Math.min(1, travel)).addScaledVector(dir, 0.14 * carry); hand.position.y += Math.sin(clamp(travel, 0, 1) * Math.PI) * 0.025; - hand.pole.set(0.55 * side * mirror, -0.9, 0.35); + hand.pole.set(0.55 * handX, -0.9, 0.35); const pronate = smoothstep(0.55, 1, travel); - hand.knuckles.copy(dir).lerp(this.scratchC.set(0.1 * side * mirror, 0.55, 0.8), 1 - pronate).normalize(); - hand.palm.set(-0.9 * side * mirror, 0.2, -0.3).lerp(this.scratchC.set(0, -1, 0.1), pronate).normalize(); + hand.knuckles.copy(dir).lerp(this.scratchC.set(0.1 * handX, 0.55, 0.8), 1 - pronate).normalize(); + hand.palm.set(-0.9 * handX, 0.2, -0.3).lerp(this.scratchC.set(0, -1, 0.1), pronate).normalize(); } if (retract > 0) { @@ -2529,26 +3092,43 @@ export class BoxingGraph { if (onset < 1) { // The hand turns and the elbow lifts out of the guard over the windup too. The further the elbow // has to turn, the more it swings out on the way, so its pull never lines up with the arm, which - // would flip it in a frame. - const turn = (1 - hand.pole.dot(guardPole) / Math.max(1e-6, hand.pole.length() * guardPole.length())) / 2; + // would flip it in a frame; the swing itself eases in, so the elbow does not start with a jerk. + const flare = (1 - hand.pole.dot(guardPole) / Math.max(1e-6, hand.pole.length() * guardPole.length())) / 2; + const swingOut = Math.sin(Math.PI * onset); hand.knuckles.lerp(guardKnuckles, 1 - onset).normalize(); hand.palm.lerp(guardPalm, 1 - onset).normalize(); - hand.pole.lerp(guardPole, 1 - onset).addScaledVector(this.scratchC.set(side * mirror, 0, 0), ONSET_ELBOW_FLARE * turn * Math.sin(Math.PI * onset)).normalize(); + hand.pole.lerp(guardPole, 1 - onset).addScaledVector(this.scratchC.set(handX, 0, 0), ONSET_ELBOW_FLARE * flare * swingOut * swingOut).normalize(); } - // Non-punching hand protects the chin. - const chin = this.scratchE.set(-0.1 * side * mirror, headRest.y - 0.04, 0.12 + headRest.z); - other.position.lerp(chin, e * 0.7); + // The other glove comes to the jaw and stays on it as the head goes with the trunk. + const chin = this.scratchE.set(-0.11 * handX, headRest.y - 0.13, 0.13 + headRest.z); + other.position.lerp(chin, Math.max(turn, e) * 0.8).add(this.headTravel(this.scratchC, hipsX, hipsY, hipsZ, pitchBefore, rollBefore, yawBefore)); + const evaded = this.hasLiveHead ? smoothstep(0.08, 0.2, this.guardOpponentHead.distanceTo(this.liveOpponentHead)) * (1 - this.followHead) : 0; + this.punchMiss = Math.max(smoothstep(0.02, 0.12, beyond), evaded); return e; } - /** The spring kicks a punch left in the body: the head snapped back, the trunk bent round it, the feet knocked off line. */ + /** The next number, 0 to 1, of the sequence the blows he has taken seed. */ + private hurtRandom(): number { + this.hurtSeed = (Math.imul(this.hurtSeed, 1664525) + 1013904223) >>> 0; + return this.hurtSeed / 0x100000000; + } + + /** + * The spring kicks a punch left in the body: the head snapped the way the punch travelled with the shoulders turned + * after it, the trunk rocked back or bent round the glove, the knees given, the feet knocked off line. + */ private applyReactions(leadHand: HandTarget, rearHand: HandTarget, lead: { heel: number }, rear: { heel: number }): void { const torso = this.torso; - torso.headOffset.add(this.headKick.value); - torso.headPitch += -this.headKick.value.z * 2.4 + this.headKick.value.y * 1.6; - torso.headYaw += this.headKick.value.x * 2.2; - torso.headRoll += -this.headKick.value.x * 0.9; + const head = this.headKick.value; + // The neck gives first and the trunk goes after the head, so the skull never slides off the neck. + torso.headOffset.addScaledVector(head, 0.4); + this.leanHead(head.x * 0.6, head.z * 0.6); + torso.headPitch += head.z * 2.6 - head.y * 2; + torso.headYaw += head.x * 2.6; + torso.headRoll += -head.x * 1.1; + torso.shouldersYaw += this.torsoKick.value.y; + torso.hipsYaw += this.torsoKick.value.y * 0.4; torso.spinePitch += this.torsoKick.value.x; torso.spineRoll += this.torsoKick.value.z * 0.5; torso.hips.x += this.rootKick.value.x; @@ -2559,9 +3139,9 @@ export class BoxingGraph { rearHand.position.y -= this.torsoKick.value.x * 0.2; leadHand.position.z -= this.torsoKick.value.x * 0.1; } - // A body uppercut lifts the fighter onto his toes. + // A body uppercut lifts the fighter onto his toes; a heavy head shot buckles his knees while he is on his feet. const lift = Math.max(0, this.rootKick.value.y); - torso.hips.y += lift; + torso.hips.y += this.downState === "up" ? this.rootKick.value.y : lift; lead.heel += lift * 6; rear.heel += lift * 6; const cover = this.coverKick.value.x; @@ -2572,55 +3152,142 @@ export class BoxingGraph { near.position.z -= Math.abs(cover) * 0.25; near.pole.y -= Math.abs(cover) * 3; } + // The arms go after the head a beat late; a clean hard shot drops the hands and floats them apart before they come back. + const left = this.hand.L.position; + const right = this.hand.R.position; + left.add(this.armKick.value); + right.addScaledVector(this.armKick.value, 0.8); + const drop = smoothstep(0, 1, this.handsDrop); + left.set(left.x + 0.07 * drop, left.y - 0.24 * drop, left.z - 0.04 * drop); + right.set(right.x - 0.07 * drop, right.y - 0.22 * drop, right.z - 0.03 * drop); + // A block gives at the forearms and sits him back onto the rear leg. + torso.hips.y -= this.guardKick * 0.02; + // Out on his feet: rubber legs that give and catch on no fixed beat, the hips swimming under him, the head lolling + // after them late, the guard sinking and floating apart. + const rocked = this.downState === "up" && !this.referee ? this.stunAmount : 0; + if (rocked > 0.01) { + const t = this.rockedTime; + const a = this.rockedPhase; + const give = Math.max(0, Math.sin(t * 3.3 + a) * Math.sin(t * 1.9 + a * 1.7)); + const float = 0.5 + 0.5 * Math.sin(t * 1.1 + a * 1.7); + torso.hips.y -= rocked * (0.02 + 0.08 * give); + torso.hips.x += rocked * 0.04 * Math.sin(t * 2.1 + a * 2.9); + torso.hips.z += rocked * 0.03 * Math.sin(t * 1.3 + a); + torso.headRoll += rocked * 0.2 * Math.sin(t * 2.1 + a * 2.9 - 1.1); + torso.headPitch += rocked * 0.1 * Math.sin(t * 1.3 + a - 0.9); + left.set(left.x + rocked * 0.07 * float, left.y - rocked * 0.05 * float, left.z); + right.set(right.x - rocked * 0.07 * float, right.y - rocked * 0.08 * (1 - float), right.z); + } } - /** Square, hands-low official's posture with a raised counting arm during knockdowns. */ + /** The highest the hips can ride over this foot, on the given side, with the knee short of straight. */ + private legRoom(foot: { position: THREE.Vector3 }, side: number): number { + const torso = this.torso; + const dx = foot.position.x - torso.hips.x - side * HIPS_TO_THIGH.x * Math.cos(torso.hipsYaw); + const dz = foot.position.z - torso.hips.z + side * HIPS_TO_THIGH.x * Math.sin(torso.hipsYaw); + return foot.position.y + Math.sqrt(Math.max(0.04, OFFICIAL_LEG_REACH * OFFICIAL_LEG_REACH - dx * dx - dz * dz)) - HIPS_TO_THIGH.y; + } + + /** + * An official's posture: upright on soft knees, leaning a little toward the action with his hands ready in front of + * his belt, breathing and shifting his weight. His eyes go from one fighter to the other, or stay on the point he has + * been given to watch. Walking, his hips turn the way he goes and sink as his feet part. Over a knockdown he bends + * to the man on the canvas, a hand on his thigh, and chops the count down at him. Returns how far his shoulders are + * carried up. + */ private applyRefereePose( mirror: number, leadHand: { position: THREE.Vector3; knuckles: THREE.Vector3; palm: THREE.Vector3; pole: THREE.Vector3 }, rearHand: { position: THREE.Vector3; knuckles: THREE.Vector3; palm: THREE.Vector3; pole: THREE.Vector3 }, lead: { position: THREE.Vector3; toe: THREE.Vector3; heel: number; pole: THREE.Vector3 }, rear: { position: THREE.Vector3; toe: THREE.Vector3; heel: number; pole: THREE.Vector3 }, - headRest: THREE.Vector3, time: number, sampledTick: number, + dt: number, reeling = 0, - ): void { + ): number { const torso = this.torso; - torso.hipsYaw = 0; - torso.shouldersYaw = 0; - torso.hipsPitch = 0; - torso.spinePitch = 0.06; - torso.headYaw = Math.sin(time * 0.7) * 0.08; - torso.headPitch = 0.08; - torso.hips.y = STANCE.hipsHeight + 0.03; - torso.hips.x = 0; - torso.hips.z = 0; - lead.toe.set(0.12 * mirror, 0, 1).normalize(); - rear.toe.set(-0.12 * mirror, 0, 1).normalize(); + const lerp = THREE.MathUtils.lerp; + const count = (this.countWeight = smooth(this.countWeight, this.refereeCounting ? 1 : 0, 5, dt)); + let yawTo = Math.sin(time * 0.7) * 0.08; + let pitchTo = this.refereeCounting ? 0.75 : 0.06; + if (this.breakAimed) { + const seen = seatedScratch.copy(this.watching ? this.watchPoint : this.breakFighters[Math.sin(this.weightPhase * 0.32) + Math.sin(this.weightPhase * 0.125) > 0 ? 0 : 1]); + if (!this.watching) seen.y = OFFICIAL_EYE_LEVEL - 0.1; + seen.x -= this.rootX ?? 0; + seen.z -= this.rootZ; + seen.applyAxisAngle(worldUpVector, -this.yaw); + yawTo = clamp(Math.atan2(seen.x, seen.z), -1, 1) * 0.85; + pitchTo = clamp(Math.atan2(OFFICIAL_EYE_LEVEL - seen.y, Math.hypot(seen.x, seen.z)), -0.2, 0.85); + } + this.gazeYaw = smooth(this.gazeYaw, yawTo, 6, dt); + this.gazePitch = smooth(this.gazePitch, pitchTo, 6, dt); + // He bends only as far as the man he counts over is below him: one back on his feet is counted standing. + const stoop = count * smoothstep(0.2, 0.6, this.gazePitch); + const breath = Math.sin(time * 1.6); + const sway = Math.sin(this.weightPhase * 0.35) * 0.02 + Math.sin(this.weightPhase * 0.9 + 1) * 0.006; + const pace = Math.hypot(this.travel.x, this.travel.z); + const walk = Math.min(1, pace / 0.4); + torso.hipsYaw = this.strideYaw * 0.7; + torso.shouldersYaw = this.strideYaw * 0.2 + this.gazeYaw * 0.25; + torso.hipsPitch = 0.04 + stoop * 0.2; + torso.hipsRoll = 0; + torso.spinePitch = 0.1 + breath * 0.008 + clamp(this.travel.z, -1, 1.5) * 0.04 + count * 0.06 + stoop * 0.3; + torso.spineRoll = -sway * 0.6 - this.travel.x * 0.03; + torso.headYaw = this.gazeYaw; + torso.headPitch = 0.04 + this.gazePitch; + torso.headRoll = 0; + torso.hips.set(sway, 0, -stoop * 0.1); + const leadToes = this.footYaw[mirror > 0 ? 0 : 1] - this.yaw; + const rearToes = this.footYaw[mirror > 0 ? 1 : 0] - this.yaw; + lead.toe.set(Math.sin(leadToes), 0, Math.cos(leadToes)); + rear.toe.set(Math.sin(rearToes), 0, Math.cos(rearToes)); lead.pole.copy(lead.toe).setY(0.3).normalize(); rear.pole.copy(rear.toe).setY(0.3).normalize(); - const sway = Math.sin(time * 1.3) * 0.01; - leadHand.position.set(0.27 * mirror, 0.86 + sway, 0.12); - rearHand.position.set(-0.27 * mirror, 0.86 - sway, 0.12); - leadHand.pole.set(0.5 * mirror, -0.4, -0.8).normalize(); - rearHand.pole.set(-0.5 * mirror, -0.4, -0.8).normalize(); - leadHand.knuckles.set(0.15 * mirror, -0.9, 0.35).normalize(); - rearHand.knuckles.set(-0.15 * mirror, -0.9, 0.35).normalize(); - leadHand.palm.set(-0.9 * mirror, 0.1, 0.35).normalize(); - rearHand.palm.set(0.9 * mirror, 0.1, 0.35).normalize(); - if (this.refereeCounting) { + // Walking, the foot left behind comes up onto its toes and the arms swing against the legs. + const along = pace > 1e-3 ? walk / pace : 0; + lead.heel = clamp((-(lead.position.x * this.travel.x + lead.position.z * this.travel.z) * along - 0.08) * 3.5, 0, 0.75); + rear.heel = clamp((-(rear.position.x * this.travel.x + rear.position.z * this.travel.z) * along - 0.08) * 3.5, 0, 0.75); + const swing = ((lead.position.x - rear.position.x) * this.travel.x + (lead.position.z - rear.position.z) * this.travel.z) * (along / Math.max(pace, 1e-3)) * 0.1; + torso.hips.y = Math.max(OFFICIAL_HIPS_HEIGHT - 0.14, Math.min(OFFICIAL_HIPS_HEIGHT - stoop * 0.05, this.legRoom(lead, mirror), this.legRoom(rear, -mirror))); + const belt = torso.hips.y + 0.24 + breath * 0.004; + leadHand.position.set(0.16 * mirror - this.travel.x * swing, belt, 0.3 - this.travel.z * swing); + rearHand.position.set(-0.16 * mirror + this.travel.x * swing, belt - 0.015, 0.28 + this.travel.z * swing); + leadHand.pole.set(0.7 * mirror, -0.5, -0.5).normalize(); + rearHand.pole.set(-0.7 * mirror, -0.5, -0.5).normalize(); + leadHand.knuckles.set(-0.35 * mirror, 0.05, 0.9).normalize(); + rearHand.knuckles.set(0.35 * mirror, 0.05, 0.9).normalize(); + leadHand.palm.set(-0.65 * mirror, -0.75, 0.05).normalize(); + rearHand.palm.set(0.65 * mirror, -0.75, 0.05).normalize(); + if (count > 0.001) { // The arm comes up through each second of the count and chops down onto the next number. - this.countChangedTick ??= sampledTick; - const beat = clamp((sampledTick - this.countChangedTick) / COUNT_TICKS, 0, 1); - const pump = beat < COUNT_DROP_START ? easeOut(beat / COUNT_DROP_START) : 1 - easeIn((beat - COUNT_DROP_START) / (1 - COUNT_DROP_START), 2); - rearHand.position.set(-0.22 * mirror, headRest.y - 0.05 + pump * 0.12, 0.34 + pump * 0.08); - rearHand.pole.set(-0.9 * mirror, -0.3, 0.2).normalize(); - rearHand.knuckles.set(0, 0.7, 0.7).normalize(); - rearHand.palm.set(0, 0.3, -0.95).normalize(); - torso.spinePitch += 0.12; - torso.headPitch += 0.18; - leadHand.position.set(0.24 * mirror, 0.95, 0.08); + if (this.refereeCounting) { + this.countChangedTick ??= sampledTick; + const beat = clamp((sampledTick - this.countChangedTick) / COUNT_TICKS, 0, 1); + this.countPump = beat < COUNT_DROP_START ? easeOut(beat / COUNT_DROP_START) : 1 - easeIn((beat - COUNT_DROP_START) / (1 - COUNT_DROP_START), 2); + } + const pump = this.countPump; + rearHand.position.lerp(seatedScratch.set(-0.24 * mirror, torso.hips.y + lerp(0.34 - stoop * 0.14, 0.9, pump), lerp(0.74, 0.46, pump)), count); + rearHand.pole.lerp(seatedScratch.set(-0.9 * mirror, -0.3, 0.2), count).normalize(); + rearHand.knuckles.lerp(seatedScratch.set(0, lerp(-0.5, 1, pump), lerp(0.85, 0.25, pump)), count).normalize(); + rearHand.palm.lerp(seatedScratch.set(mirror, 0, 0.1), count).normalize(); + leadHand.position.lerp(seatedScratch.set(0.2 * mirror, torso.hips.y - 0.02, 0.12), stoop); + leadHand.knuckles.lerp(seatedScratch.set(-0.1 * mirror, -0.9, 0.4), stoop).normalize(); + leadHand.palm.lerp(seatedScratch.set(-0.3 * mirror, -0.2, -0.9), stoop).normalize(); + torso.spinePitch += (1 - pump) * 0.05 * count; + } + // A man is being finished: he shows his open hands and lets it happen. + const back = (this.backWeight = smooth(this.backWeight, this.duty === "stand_back" ? 1 : 0, 4, dt)); + if (back > 0.001) { + torso.spinePitch = lerp(torso.spinePitch, -0.04, back); + leadHand.position.lerp(seatedScratch.set(0.32 * mirror, torso.hips.y + 0.6, 0.2), back); + rearHand.position.lerp(seatedScratch.set(-0.32 * mirror, torso.hips.y + 0.6, 0.2), back); + leadHand.knuckles.lerp(seatedScratch.set(0.1 * mirror, 1, 0.1), back).normalize(); + rearHand.knuckles.lerp(seatedScratch.set(-0.1 * mirror, 1, 0.1), back).normalize(); + leadHand.palm.lerp(seatedScratch.set(0, 0.1, 1), back).normalize(); + rearHand.palm.lerp(seatedScratch.set(0, 0.1, 1), back).normalize(); + leadHand.pole.lerp(seatedScratch.set(0.6 * mirror, -0.8, -0.1), back).normalize(); + rearHand.pole.lerp(seatedScratch.set(-0.6 * mirror, -0.8, -0.1), back).normalize(); } if (reeling > 0) { // Punched, he staggers where he stands: knees going, head lolling, hands out for balance. @@ -2636,6 +3303,7 @@ export class BoxingGraph { leadHand.position.y -= 0.1 * reel; rearHand.position.y -= 0.1 * reel; } + return 0.05 + breath * 0.025; } private updateDownState(fighter: FighterSnapshot, dt: number, reducedMotion: boolean, speed: number): void { @@ -2987,6 +3655,27 @@ export class BoxingGraph { rear.heel = lerp(rear.heel, 0.45, blend); } + /** Down on the rear knee, `ahead` of his root: the lead foot flat in front, the rear shin along the canvas on its toes. */ + private kneelLegs( + blend: number, + mirror: number, + lead: { position: THREE.Vector3; toe: THREE.Vector3; heel: number; pole: THREE.Vector3 }, + rear: { position: THREE.Vector3; toe: THREE.Vector3; heel: number; pole: THREE.Vector3 }, + ahead: number, + ): void { + const lerp = THREE.MathUtils.lerp; + lead.position.x = lerp(lead.position.x, 0.24 * mirror, blend); + lead.position.z = lerp(lead.position.z, ahead + 0.3, blend); + rear.position.x = lerp(rear.position.x, -0.18 * mirror, blend); + rear.position.z = lerp(rear.position.z, ahead - 0.66, blend); + lead.heel = lerp(lead.heel, 0, blend); + rear.heel = lerp(rear.heel, 1.25, blend); + lead.toe.lerp(this.treatScratch.set(0.2 * mirror, 0, 1), blend).normalize(); + rear.toe.lerp(this.treatScratch.set(-0.1 * mirror, 0, 1), blend).normalize(); + lead.pole.lerp(this.treatScratch.set(0.25 * mirror, 0.4, 1), blend).normalize(); + rear.pole.lerp(this.treatScratch.set(-0.05 * mirror, -0.8, 0.6), blend).normalize(); + } + private applyAttendPose( blend: number, time: number, @@ -2996,23 +3685,64 @@ export class BoxingGraph { ): void { const torso = this.torso; const lerp = THREE.MathUtils.lerp; - const work = Math.sin(time * 3.1) * 0.03; + // He talks his fighter through it: the lead hand chops the points out, the head nods, the rear forearm lies on the rope. + const talk = Math.sin(time * 3.1) * 0.5 + Math.sin(time * 5.3 + 1) * 0.5; torso.hips.z = lerp(torso.hips.z, 0.12, blend); - torso.hips.y = lerp(torso.hips.y, STANCE.hipsHeight - 0.04, blend); + torso.hips.y = lerp(torso.hips.y, OFFICIAL_HIPS_HEIGHT - 0.06, blend); torso.hipsPitch = lerp(torso.hipsPitch, 0.3, blend); torso.spinePitch = lerp(torso.spinePitch, 0.42, blend); - torso.headPitch = lerp(torso.headPitch, 0.4, blend); - leadHand.position.lerp(seatedScratch.set(0.2 * mirror, 1.3 + work, 0.62), blend); - rearHand.position.lerp(seatedScratch.set(-0.18 * mirror, 1.24 - work, 0.58), blend); - leadHand.palm.lerp(seatedScratch.set(0, -0.6, 0.8), blend).normalize(); - rearHand.palm.lerp(seatedScratch.set(0, -0.6, 0.8), blend).normalize(); + torso.headPitch = lerp(torso.headPitch, 0.4 + talk * 0.05, blend); + torso.headYaw = lerp(torso.headYaw, Math.sin(time * 1.3) * 0.08, blend); + leadHand.position.lerp(seatedScratch.set(0.2 * mirror, 1.36 + talk * 0.06, 0.6 + talk * 0.04), blend); + rearHand.position.lerp(seatedScratch.set(-0.14 * mirror, 1.23, 0.6), blend); + leadHand.palm.lerp(seatedScratch.set(-0.8 * mirror, -0.2, 0.5), blend).normalize(); + rearHand.palm.lerp(seatedScratch.set(0, -0.9, 0.3), blend).normalize(); leadHand.knuckles.lerp(seatedScratch.set(0.1 * mirror, 0.5, 1), blend).normalize(); - rearHand.knuckles.lerp(seatedScratch.set(-0.1 * mirror, 0.5, 1), blend).normalize(); + rearHand.knuckles.lerp(seatedScratch.set(0.8 * mirror, 0.1, 0.6), blend).normalize(); leadHand.pole.lerp(seatedScratch.set(0.8 * mirror, -0.5, -0.1), blend).normalize(); - rearHand.pole.lerp(seatedScratch.set(-0.8 * mirror, -0.5, -0.1), blend).normalize(); + rearHand.pole.lerp(seatedScratch.set(-mirror, -0.1, 0.1), blend).normalize(); + const mourn = this.mournWeight * blend; + if (mourn > 0.001) { + // His fighter is dead: both hands go to his head and it drops. + torso.hipsPitch = lerp(torso.hipsPitch, 0.1, mourn); + torso.spinePitch = lerp(torso.spinePitch, 0.28, mourn); + torso.headPitch = lerp(torso.headPitch, 0.55, mourn); + torso.headYaw = lerp(torso.headYaw, 0, mourn); + const brow = torso.hips.y + 0.76; + leadHand.position.lerp(seatedScratch.set(0.14 * mirror, brow, 0.4), mourn); + rearHand.position.lerp(seatedScratch.set(-0.14 * mirror, brow, 0.4), mourn); + leadHand.knuckles.lerp(seatedScratch.set(-0.35 * mirror, 0.9, 0), mourn).normalize(); + rearHand.knuckles.lerp(seatedScratch.set(0.35 * mirror, 0.9, 0), mourn).normalize(); + leadHand.palm.lerp(seatedScratch.set(-mirror, -0.2, 0), mourn).normalize(); + rearHand.palm.lerp(seatedScratch.set(mirror, -0.2, 0), mourn).normalize(); + leadHand.pole.lerp(seatedScratch.set(mirror, -0.2, 0.3), mourn).normalize(); + rearHand.pole.lerp(seatedScratch.set(-mirror, -0.2, 0.3), mourn).normalize(); + } + const cheer = this.cheerWeight * blend; + if (cheer > 0.001) { + // His fighter has won: both arms go up and pump. + const pump = Math.sin(time * 8.5); + torso.hips.z = lerp(torso.hips.z, 0.04, cheer); + torso.hipsPitch = lerp(torso.hipsPitch, -0.02, cheer); + torso.spinePitch = lerp(torso.spinePitch, -0.06, cheer); + torso.spineRoll = lerp(torso.spineRoll, pump * 0.05, cheer); + torso.headPitch = lerp(torso.headPitch, -0.2, cheer); + const high = torso.hips.y + 0.93 + pump * 0.05; + leadHand.position.lerp(seatedScratch.set(0.36 * mirror, high, 0.06), cheer); + rearHand.position.lerp(seatedScratch.set(-0.36 * mirror, high - pump * 0.06, 0.06), cheer); + leadHand.knuckles.lerp(seatedScratch.set(0.15 * mirror, 1, 0), cheer).normalize(); + rearHand.knuckles.lerp(seatedScratch.set(-0.15 * mirror, 1, 0), cheer).normalize(); + leadHand.palm.lerp(seatedScratch.set(0, 0, 1), cheer).normalize(); + rearHand.palm.lerp(seatedScratch.set(0, 0, 1), cheer).normalize(); + leadHand.pole.lerp(seatedScratch.set(mirror, -0.3, -0.2), cheer).normalize(); + rearHand.pole.lerp(seatedScratch.set(-mirror, -0.3, -0.2), cheer).normalize(); + } } - /** Cutman work: a deep crouch before the seated fighter, the lead glove pressing the enswell on the eye, the rear hand steadying the jaw. */ + /** + * Cutman work: down on one knee before the seated fighter, his eyes on the wound, the lead glove pressing the enswell + * on the eye, the rear hand steadying the jaw; over a bad cut he swabs faster and wider. + */ private applyTreatPose( blend: number, time: number, @@ -3030,27 +3760,23 @@ export class BoxingGraph { const facing = this.treatFacingLocal.copy(this.treatFacing).applyQuaternion(inverse); const leftX = facing.z; const leftZ = -facing.x; - const press = Math.sin(time * 2.6) * 0.006; - torso.hips.lerp(this.treatScratch.set(0, 0.62, 0.04), blend); + const urgency = this.treatUrgency; + const stroke = time * lerp(2.6, 7, urgency); + const press = Math.sin(stroke) * lerp(0.006, 0.016, urgency); + const swab = Math.cos(stroke) * 0.03 * urgency; + torso.hips.lerp(this.treatScratch.set(0, 0.5, 0.1), blend); torso.hipsYaw = lerp(torso.hipsYaw, 0, blend); - torso.hipsPitch = lerp(torso.hipsPitch, 0.22, blend); + torso.hipsPitch = lerp(torso.hipsPitch, 0.14, blend); torso.hipsRoll = lerp(torso.hipsRoll, 0, blend); torso.shouldersYaw = lerp(torso.shouldersYaw, 0, blend); - torso.spinePitch = lerp(torso.spinePitch, 0.3, blend); - torso.headPitch = lerp(torso.headPitch, 0.2, blend); - lead.position.x = lerp(lead.position.x, 0.24 * mirror, blend); - lead.position.z = lerp(lead.position.z, 0.14, blend); - rear.position.x = lerp(rear.position.x, -0.2 * mirror, blend); - rear.position.z = lerp(rear.position.z, -0.2, blend); - rear.heel = lerp(rear.heel, 0.55, blend); - lead.toe.lerp(this.treatScratch.set(0.2 * mirror, 0, 1), blend).normalize(); - rear.toe.lerp(this.treatScratch.set(-0.1 * mirror, 0, 1), blend).normalize(); - lead.pole.lerp(this.treatScratch.set(0.25 * mirror, 0.4, 1), blend).normalize(); - rear.pole.lerp(this.treatScratch.set(-0.2 * mirror, 0.4, 1), blend).normalize(); + torso.spinePitch = lerp(torso.spinePitch, 0.26, blend); + torso.headYaw = lerp(torso.headYaw, clamp(Math.atan2(eye.x, eye.z - 0.25), -0.6, 0.6), blend); + torso.headPitch = lerp(torso.headPitch, clamp(Math.atan2(1.12 - eye.y, Math.hypot(eye.x, eye.z - 0.25)), -0.5, 0.6), blend); + this.kneelLegs(blend, mirror, lead, rear, 0.1); // The enswell's plate sits above the fist and presses on the eye; the bottle points from the fist into the mouth. const bottle = this.treatProp === "bottle"; const reach = bottle ? 0.3 : 0.08 - press; - leadHand.position.lerp(this.treatScratch.set(eye.x + facing.x * reach, eye.y + (bottle ? 0.02 : -0.07), eye.z + facing.z * reach), blend); + leadHand.position.lerp(this.treatScratch.set(eye.x + facing.x * reach + leftX * swab, eye.y + (bottle ? 0.02 : -0.07), eye.z + facing.z * reach + leftZ * swab), blend); if (bottle) leadHand.knuckles.lerp(this.treatScratch.set(-facing.x, -0.25, -facing.z), blend).normalize(); else leadHand.knuckles.lerp(this.treatScratch.set(0, 1, 0.05), blend).normalize(); leadHand.palm.lerp(bottle ? this.treatScratch.set(0, -1, 0) : this.treatScratch.set(-facing.x, 0, -facing.z), blend).normalize(); @@ -3071,7 +3797,7 @@ export class BoxingGraph { const torso = this.torso; const lerp = THREE.MathUtils.lerp; torso.hipsPitch = lerp(torso.hipsPitch, 0.14, blend); - torso.spinePitch = lerp(torso.spinePitch, 0.08, blend); + torso.spinePitch = lerp(torso.spinePitch, 0.2, blend); const leadTarget = this.scratchC.set(0.48 * mirror, 1.22, 0.52); const rearTarget = this.scratchD.set(-0.48 * mirror, 1.22, 0.52); if (this.breakAimed) { @@ -3115,14 +3841,14 @@ export class BoxingGraph { const lerp = THREE.MathUtils.lerp; const raised = this.raisedWeight; const bowed = this.bowedWeight; - const breath = Math.sin(time * 1.9) * 0.008; + const breath = this.breath * 0.006; torso.hips.x = lerp(torso.hips.x, this.verdictSide * 0.02 * raised, blend); - torso.hips.y = lerp(torso.hips.y, STANCE.hipsHeight + 0.03 + raised * 0.01 - bowed * 0.015, blend); + torso.hips.y = lerp(torso.hips.y, STAND_HIPS + raised * 0.005 - bowed * 0.02 - this.tired * 0.015, blend); torso.hips.z = lerp(torso.hips.z, 0, blend); torso.hipsYaw = lerp(torso.hipsYaw, 0, blend); torso.hipsPitch = lerp(torso.hipsPitch, 0, blend); torso.shouldersYaw = lerp(torso.shouldersYaw, 0, blend); - torso.spinePitch = lerp(torso.spinePitch, 0.05 - raised * 0.1 + bowed * 0.12, blend); + torso.spinePitch = lerp(torso.spinePitch, 0.04 - raised * 0.1 + bowed * 0.12 + this.tired * 0.1 - this.breath * 0.014, blend); torso.spineRoll = lerp(torso.spineRoll, -this.verdictSide * 0.06 * raised, blend); torso.headYaw = lerp(torso.headYaw, 0, blend); torso.headPitch = lerp(torso.headPitch, 0.04 - raised * 0.2 + bowed * 0.34, blend); @@ -3132,22 +3858,28 @@ export class BoxingGraph { rear.pole.lerp(seatedScratch.set(-0.12 * mirror, 0.3, 1), blend).normalize(); for (const [hand, side] of [[leadHand, mirror], [rearHand, -mirror]] as const) { const lifted = side === this.verdictSide ? raised : 0; - hand.position.lerp(seatedScratch.set(side * (0.27 + lifted * 0.11), lerp(0.88 + breath, headRest.y + 0.44, lifted), lerp(0.12, 0.05, lifted)), blend); + hand.position.lerp(seatedScratch.set(side * (0.27 + lifted * 0.11), lerp(STAND_HIPS + 0.06 + breath, headRest.y + 0.5, lifted), lerp(0.1, 0.05, lifted)), blend); hand.knuckles.lerp(seatedScratch.set(side * 0.15, lerp(-0.9, 1, lifted), lerp(0.35, 0, lifted)), blend).normalize(); hand.palm.lerp(seatedScratch.set(lerp(-0.9 * side, 0, lifted), 0.1, lerp(0.35, 1, lifted)), blend).normalize(); hand.pole.lerp(seatedScratch.set(side * lerp(0.5, 1, lifted), lerp(-0.4, 0.1, lifted), lerp(-0.8, -0.3, lifted)), blend).normalize(); } } - /** Referee: a hand around each wrist it has been given, just below the glove. */ + /** Referee: a hand around each wrist it has been given, just below the glove, the other hanging at his side, his face to the front. */ private applyRaisePose(mirror: number, leadHand: HandTarget, rearHand: HandTarget): void { const root = this.treatScratch.set(this.rootX ?? 0, 0, this.rootZ); const inverse = this.scratchQ.setFromAxisAngle(worldUpVector, -this.yaw); + const lifting = Math.max(this.wristWeights[0], this.wristWeights[1]); for (const [index, side] of [[0, 1], [1, -1]] as const) { const wrist = this.wrists[index] ?? this.wristTargets[index]; const weight = this.wristWeights[index]; - if (weight <= 0.001) continue; const hand = side === mirror ? leadHand : rearHand; + const free = lifting - weight; + hand.position.lerp(seatedScratch.set(side * 0.27, this.torso.hips.y - 0.06, 0.08), free); + hand.knuckles.lerp(seatedScratch.set(side * 0.15, -0.9, 0.35), free).normalize(); + hand.palm.lerp(seatedScratch.set(-0.9 * side, 0.1, 0.35), free).normalize(); + hand.pole.lerp(seatedScratch.set(side * 0.5, -0.4, -0.8), free).normalize(); + if (weight <= 0.001) continue; const held = seatedScratch.copy(wrist).sub(root).applyQuaternion(inverse); held.y -= 0.17; hand.position.lerp(held, weight); @@ -3155,7 +3887,8 @@ export class BoxingGraph { hand.palm.lerp(seatedScratch.set(side, 0, 0.2), weight).normalize(); hand.pole.lerp(seatedScratch.set(side * 0.6, -0.5, -0.6), weight).normalize(); } - this.torso.headPitch = THREE.MathUtils.lerp(this.torso.headPitch, -0.05, Math.max(this.wristWeights[0], this.wristWeights[1])); + this.torso.headYaw = THREE.MathUtils.lerp(this.torso.headYaw, 0, lifting); + this.torso.headPitch = THREE.MathUtils.lerp(this.torso.headPitch, -0.05, lifting); } private applyWaveOffPose( @@ -3167,20 +3900,22 @@ export class BoxingGraph { ): void { const torso = this.torso; const lerp = THREE.MathUtils.lerp; - const sweep = Math.cos(time * 7.5); - torso.hipsPitch = lerp(torso.hipsPitch, 0.08, blend); - torso.spinePitch = lerp(torso.spinePitch, 0.05, blend); - torso.headPitch = lerp(torso.headPitch, -0.1, blend); - // Arms all but straight, crossing below the chin and swinging wide past the shoulders, so the call - // reads from any side and the hands never come up over the face. - leadHand.position.lerp(seatedScratch.set(0.62 * sweep * mirror, 1.3 + Math.abs(sweep) * 0.1, 0.44), blend); - rearHand.position.lerp(seatedScratch.set(-0.62 * sweep * mirror, 1.24 + Math.abs(sweep) * 0.1, 0.36), blend); + // From wide and high the arms cross above the head and swing wide again, palms to the front: the call reads from any side. + const open = 0.5 + 0.5 * Math.cos(time * (this.waveSlow ? 3 : 7.5)); + torso.hipsPitch = lerp(torso.hipsPitch, 0.02, blend); + torso.spinePitch = lerp(torso.spinePitch, 0.02, blend); + torso.spineRoll = lerp(torso.spineRoll, (open - 0.5) * 0.05, blend); + torso.headYaw = lerp(torso.headYaw, 0, blend); + torso.headPitch = lerp(torso.headPitch, this.waveSlow ? 0.14 : 0, blend); + const reach = torso.hips.y + lerp(0.88, 0.92, open); + leadHand.position.lerp(seatedScratch.set(lerp(-0.14, 0.52, open) * mirror, reach, 0.17), blend); + rearHand.position.lerp(seatedScratch.set(-lerp(-0.14, 0.52, open) * mirror, reach, 0.1), blend); leadHand.palm.lerp(seatedScratch.set(0, 0, 1), blend).normalize(); rearHand.palm.lerp(seatedScratch.set(0, 0, 1), blend).normalize(); - leadHand.knuckles.lerp(seatedScratch.set(0, 1, 0), blend).normalize(); - rearHand.knuckles.lerp(seatedScratch.set(0, 1, 0), blend).normalize(); - leadHand.pole.lerp(seatedScratch.set(mirror, -0.2, -0.3), blend).normalize(); - rearHand.pole.lerp(seatedScratch.set(-mirror, -0.2, -0.3), blend).normalize(); + leadHand.knuckles.lerp(seatedScratch.set(lerp(-0.5, 0.5, open) * mirror, 0.85, 0), blend).normalize(); + rearHand.knuckles.lerp(seatedScratch.set(-lerp(-0.5, 0.5, open) * mirror, 0.85, 0), blend).normalize(); + leadHand.pole.lerp(seatedScratch.set(mirror, -0.3, -0.2), blend).normalize(); + rearHand.pole.lerp(seatedScratch.set(-mirror, -0.3, -0.2), blend).normalize(); } private applySeatedPose( @@ -3803,7 +4538,9 @@ export class BoxingGraph { worldQuaternion(glove, dangleTurn); // Where no forearm lies: hanging from the elbow, and kicked out to his side the more the upper arm itself hangs down. const hung = Math.max(0, -(joint.y - worldPosition(shoulder, dangleScratch).y) / lengths.upper); - const wrong = dangleWrong.set(s * (SNAP_OUT + SNAP_OUT_HUNG * hung * hung), -1, 0).applyAxisAngle(worldUpVector, this.yaw).normalize(); + // With the elbow on the canvas there is no room under it: the forearm lies out flat. + const room = clamp((joint.y - DANGLE_FLOOR) / lengths.lower, 0, 1); + const wrong = dangleWrong.set(s * (SNAP_OUT + SNAP_OUT_HUNG * hung * hung), -room, 0).applyAxisAngle(worldUpVector, this.yaw).normalize(); if (!forearm.live) { startDangle(forearm, snap > DANGLE_SETTLED && !placed ? dangleScratch.set(joint.x, joint.y - lengths.lower, joint.z) : wrist, joint); this.holdDangle(forearm.at, joint, lengths.lower, true, wrong); @@ -3898,9 +4635,16 @@ const STOOL_SEAT_HEIGHT = 0.44; const STOOL_CLEAR_SEATED = 0.2; /** The engine counts a knockdown one number a second; the counting arm starts down this far into each second. */ const COUNT_DROP_START = 0.75; +/** How high an official carries his hips standing upright, and the furthest his legs reach from them: his knees stay soft. */ +const OFFICIAL_HIPS_HEIGHT = 0.94; +const OFFICIAL_LEG_REACH = 0.836; +/** The pace, in m/s, above which an official is walking rather than shifting where he stands. */ +const OFFICIAL_WALK_SPEED = 0.12; +/** The height an official's eyes are at, standing. */ +const OFFICIAL_EYE_LEVEL = 1.72; /** Where the referee's palms press to break a clinch: on each fighter's chest, this far toward the other from his centre, at sternum height. */ -const BREAK_CHEST_DEPTH = 0.26; -const BREAK_CHEST_HEIGHT = 1.2; +const BREAK_CHEST_DEPTH = 0.2; +const BREAK_CHEST_HEIGHT = 1.26; const TOUCH_GLOVES_START_TICKS = 48; const TOUCH_GLOVES_END_TICKS = 14; /** Root-to-root distance at which the touch pose's gloves meet: each glove's front reaches 0.68 m ahead. */ @@ -3917,6 +4661,37 @@ const TAUNT_TICKS = 60; const TAUNT_BECKONS = 4; /** How far a spent guard's gloves sag, in metres: from the cheekbones to about the collarbones. */ const GUARD_SPENT_DROP = 0.15; +/** Between these gaps (metres between the fighters' feet) the guard draws in from the long-range stance. */ +const TIGHT_GAP = 0.8; +const LONG_GAP = 1.3; +/** The share of the stance's length the feet give up chest to chest. */ +const INSIDE_BASE = 0.35; +/** The hips of a man standing at his ease, his legs all but straight. */ +const STAND_HIPS = 0.93; +/** Head and body trauma from which a beating starts to show in the stance, and the further trauma that shows it in full. */ +const BATTERED_FROM = 500; +const BATTERED_SPAN = 900; +/** How much wider a man beaten that far plants his feet. */ +const BATTERED_BASE = 0.15; +/** Slower than this (metres a second) he is standing. */ +const WALKING_SPEED = 0.05; +/** How far (metres) a foot may be from its place before it steps: either foot standing, the lead foot while he turns on it, either at a walk. */ +const STEP_SLACK_STANDING = 0.07; +const STEP_SLACK_PIVOT = 0.14; +const STEP_SLACK_WALKING = 0.05; +/** Turning faster than this (radians a second) he pivots on the lead foot. */ +const TURNING_RATE = 0.2; +/** How high (metres) a step lifts the foot: close to the canvas. */ +const STEP_LIFT = 0.04; +/** How long the lead hand takes to paw out and back. */ +const PAW_SECONDS = 0.36; + +/** A fighter's place in the idle rhythms, 0..1 from his id. */ +function idleSeedFor(id: string): number { + let hash = 7; + for (let index = 0; index < id.length; index += 1) hash = (hash * 31 + id.charCodeAt(index)) % 9973; + return hash / 9973; +} const seatedScratch = new THREE.Vector3(); const JAW_DISLOCATION = new THREE.Quaternion().setFromEuler(new THREE.Euler(0.08, 0.2, -0.22)); @@ -4145,8 +4920,8 @@ const ALL_FOURS = downPose({ }); /** The get-up's second stage, on the rear knee with the lead foot planted and a glove on the knee. */ const ONE_KNEE = downPose({ - hips: vec(0, 0.47, -0.05), hipsYaw: STANCE.bladeYaw * 0.12, hipsPitch: 0.2, shouldersYaw: STANCE.bladeYaw * 0.4, spinePitch: 0.3, headPitch: 0.2, palmsDown: 1, - leadHand: vec(0.15, 0.68, 0.32), rearHand: vec(-0.26, 0.42, 0.02), leadFoot: vec(0.15, 0, 0.36), rearFoot: vec(-0.13, 0, -0.7), rearHeel: 1.2, + hips: vec(0, 0.41, -0.05), hipsYaw: STANCE.bladeYaw * 0.12, hipsPitch: 0.2, shouldersYaw: STANCE.bladeYaw * 0.4, spinePitch: 0.3, headPitch: 0.2, palmsDown: 1, + leadHand: vec(0.15, 0.68, 0.32), rearHand: vec(-0.26, 0.42, 0.02), leadFoot: vec(0.15, 0, 0.36), rearFoot: vec(-0.13, 0, -0.76), rearHeel: 1.2, }); /** Writes `base` mirrored for the stance, plus `twist` per unit of `side`, into `out`, with the feet raised by `ankle`. */ @@ -4409,6 +5184,12 @@ const POWER_SNAP = 2.1; const POWER_LOAD_YAW = 0.42; const POWER_LOAD_HIPS_YAW = 0.22; const POWER_LOAD_DIP = 0.08; +/** How far the hips drop for a punch to the body. */ +const BODY_LEVEL_CHANGE = 0.15; +/** How far the head travels for a radian of bend in the spine. */ +const HEAD_LEVER = 0.42; +/** How far his weight comes in behind a punch at the end of its reach. */ +const REACH_IN = 0.12; /** An opponent's punch seen early is held back unless its wind-up can play at this share of its speed or faster. */ const MIN_ANTICIPATION_RATE = 0.5; /** Presses closer together than this usually reach the server before the same step, where the newer one replaces the older. */ diff --git a/web/hands/src/render/injury-pose.test.ts b/web/hands/src/render/injury-pose.test.ts index b554191c..85b52d9e 100644 --- a/web/hands/src/render/injury-pose.test.ts +++ b/web/hands/src/render/injury-pose.test.ts @@ -108,25 +108,28 @@ function expectFinite(scene: Scene, label: string, standing = true): void { } describe("a fighter with no injuries", () => { - // Measured before injuries existed: hips, head, gloves, elbows, knees and ankles (left then right), to a tenth of a millimetre. - const BEFORE: Readonly> = { - idle: [-0.0062, 0.7809, -0.0053, -0.0663, 1.542, 0.0495, 0.0358, 1.301, 0.3744, -0.19, 1.3522, 0.1126, 0.185, 1.1253, 0.2718, -0.2447, 1.1637, -0.046, 0.0024, 0.5483, 0.3895, -0.2769, 0.4713, -0.0867, 0.12, 0.1246, 0.24, -0.1, 0.1246, -0.34], - guard_high: [-0.0062, 0.7809, -0.0053, -0.0663, 1.542, 0.0495, 0.0658, 1.501, 0.1844, -0.18, 1.4922, 0.1226, 0.1556, 1.407, 0.4006, -0.26, 1.2691, 0.036, 0.0024, 0.5483, 0.3895, -0.2769, 0.4713, -0.0867, 0.12, 0.1246, 0.24, -0.1, 0.1246, -0.34], - jab: [0.0399, 0.7773, 0.0281, -0.0426, 1.5326, 0.1102, 0.0343, 1.4139, 0.7342, -0.127, 1.4426, 0.1332, 0.0784, 1.3388, 0.4974, -0.1891, 1.2254, 0.021, 0.0196, 0.5413, 0.4187, -0.2718, 0.5034, -0.0572, 0.12, 0.1246, 0.24, -0.1173, 0.1574, -0.3256], - walk: [-0.0062, 0.7838, -0.7137, -0.06, 1.5443, -0.6517, 0.0396, 1.3039, -0.3245, -0.19, 1.355, -0.5937, 0.1855, 1.1296, -0.434, -0.2453, 1.1669, -0.7525, 0.0096, 0.5736, -0.3002, -0.3053, 0.5237, -0.6727, 0.12, 0.1246, -0.3433, -0.1, 0.1697, -0.8923], - }; - const MEASURED: readonly CanonicalBone[] = ["hips", "head", "gloveL", "gloveR", "elbowL", "elbowR", "kneeL", "kneeR", "ankleL", "ankleR"]; - - it("poses exactly as he did before there were any", () => { - for (const [pose, before] of Object.entries(BEFORE)) { + it("poses exactly as a fighter the injuries were never mentioned to", () => { + const timing = punchTiming("jab", "head", "normal"); + const walking = (frame: number): FighterSnapshot => ({ ...idle, y: frame * 3, velocity_y: 6 }); + const poses: Readonly FighterSnapshot>> = { + idle: () => idle, + guard_high: () => guarding, + jab: () => punching("jab", "left", 10), + walk: walking, + }; + for (const [pose, shown] of Object.entries(poses)) { const scene = new Scene().step(idle, 20); - const timing = punchTiming("jab", "head", "normal"); - if (pose === "idle") scene.step(idle, 40); - else if (pose === "guard_high") scene.step(guarding, 40); - else if (pose === "walk") scene.walk(40); - else scene.step(punching("jab", "left", 10), timing.startup * 2); - const now = MEASURED.flatMap((bone) => scene.at(bone).toArray()); - for (const [index, value] of before.entries()) expect(Math.abs(now[index]! - value), `${pose}: ${MEASURED[Math.floor(index / 3)]}`).toBeLessThan(1e-4); + // Never told of injuries, faintness or a daze. + const boxer = new SkinnedBoxer(gltf, { skin: 0xb0703f, gear: 0x1d4ed8 }); + const untold = new BoxingGraph(boxer, mapping); + for (let frame = 0; frame < 20; frame += 1) untold.update(idle, opponent, 1 / 60, frame / 60, false, "full", frame / 2, opponentHead); + const frames = pose === "jab" ? timing.startup * 2 : 40; + scene.step(shown, frames); + for (let frame = 0; frame < frames; frame += 1) untold.update(shown(frame), opponent, 1 / 60, (20 + frame) / 60, false, "full", (20 + frame) / 2, opponentHead); + boxer.root.updateMatrixWorld(true); + for (const name of Object.keys(RIG_BONES) as CanonicalBone[]) { + expect(scene.at(name).distanceTo(worldPosition(boxer.rig.bones[name], new THREE.Vector3())), `${pose}: ${name}`).toBeLessThan(1e-9); + } } }); @@ -428,9 +431,10 @@ describe("losing blood", () => { expect(gone.gloves).toBeGreaterThan(some.gloves * 1.8); expect(gone.head).toBeGreaterThan(some.head); expect(gone.head).toBeGreaterThan(0.08); - expect(some.sway).toBeGreaterThan(some.calm * 1.5); + // A sound fighter is never still either: he bounces, rocks and sways on his own. + expect(some.sway).toBeGreaterThan(some.calm * 1.3); expect(gone.sway).toBeGreaterThan(some.sway * 1.5); - expect(gone.sway).toBeGreaterThan(gone.calm * 3); + expect(gone.sway).toBeGreaterThan(gone.calm * 2.5); }); it("keeps his guard sagging and his head down straight through a replay's cut", () => { @@ -638,7 +642,8 @@ describe("death", () => { scene.step(idle, 90); expect(scene.graph.isDown).toBe(false); expect(scene.graph.fallBody).toBeNull(); - const fresh = new Scene().step(idle, 90); + // A fresh fighter at the same moment of his idle rhythms. + const fresh = new Scene().step(idle, scene.frame); for (const bone of ["hips", "head", "gloveL", "gloveR", "kneeL", "kneeR"] as const) expect(scene.at(bone).distanceTo(fresh.at(bone)), bone).toBeLessThan(0.03); }); diff --git a/web/hands/src/render/injury.ts b/web/hands/src/render/injury.ts index d21ae6c2..948fb369 100644 --- a/web/hands/src/render/injury.ts +++ b/web/hands/src/render/injury.ts @@ -380,6 +380,9 @@ uniform float uInjuryWash; uniform float uInjuryRaw; uniform vec4 uInjuryLid[2]; uniform vec2 uInjuryEyeOut; +uniform vec4 uInjuryXray; +uniform float uInjuryXrayShown; +uniform float uInjuryRun; varying vec3 vInjuryPos; float injuryWet = 0.0; ${SEVER} @@ -389,6 +392,8 @@ float injuryHash(float n) { return fract(sin(n) * 43758.5453123); } uniform float uInjuryWound[${WOUND_SLOTS}]; uniform float uInjuryExplicit; uniform float uInjuryPallor; +uniform vec4 uInjuryMark[${INJURY_MARKS}]; +uniform float uInjurySpatter; /** A cell's value. The cells repeat every 24, so what is hashed stays small enough for a phone's medium precision. */ float injuryCell(vec2 cell) { cell = mod(cell, 24.0); @@ -804,7 +809,7 @@ ${body ? BODY_FRAGMENT_WOUNDS : HEAD_FRAGMENT_WOUNDS} if (fk > 0.5 && blood < 0.3) break; if (fk > 1.5 && blood < 0.7) break; float seed = fract(sin(float(i) * 12.9898 + fk * 78.233) * 43758.5453); - float reach = (4.0 + blood * 18.0) * (fk < 0.5 ? 1.0 : 0.55 + 0.3 * seed); + float reach = (4.0 + blood * 18.0) * uInjuryRun * (fk < 0.5 ? 1.0 : 0.55 + 0.3 * seed); float start = (fk < 0.5 ? -0.3 : fk < 1.5 ? 0.4 : 0.05) * (0.6 + 0.6 * seed) * radius * 0.35; float t = clamp(drop / reach, 0.0, 1.0); float wander = (0.35 * sin(injuryPos.y * 1.3 + float(i) * 1.7 + fk * 2.1) + 0.15 * sin(injuryPos.y * 3.7 + fk)) * t; @@ -830,6 +835,55 @@ ${body ? BODY_FRAGMENT_WOUNDS : HEAD_FRAGMENT_WOUNDS} } injuryWet = max(injuryWet, w); } +#ifdef ${WOUNDS} + // Where punches landed: a red welt the shape of the glove, a bruise that darkens under it, and, hit again and again, a split that runs. + for (int m = 0; m < ${INJURY_MARKS}; m++) { + vec4 mark = uInjuryMark[m]; + if (mark.w <= 0.0) continue; + vec3 away = injuryPos - mark.xyz; + float ragged = 1.0 + 0.2 * sin(atan(away.y, away.x) * 4.0 + float(m) * 1.9); + float reach = length(away) / (${body ? "4.4" : "2.6"} * ragged); + if (reach > 1.6) continue; + float depth = min(mark.w, 1.0); + float welt = 1.0 - smoothstep(0.5, 1.0, reach); + float ring = smoothstep(0.45, 0.75, reach) * (1.0 - smoothstep(0.85, 1.15, reach)); + vec3 fresh = diffuseColor.rgb * vec3(1.0, 0.42, 0.4) + vec3(0.1, 0.0, 0.0); + vec3 marked = mix(fresh, injuryBruised(diffuseColor.rgb, depth), smoothstep(0.3, 0.9, depth)); + diffuseColor.rgb = mix(diffuseColor.rgb, marked, clamp(welt * (0.4 + 0.5 * depth) + ring * 0.4 * (1.0 - depth), 0.0, 0.9)); + float split = smoothstep(1.0, 1.5, mark.w) * uInjuryRaw * uInjuryExplicit; + if (split > 0.0) { + float slit = abs(away.y - 0.25 * sin(away.x * 2.4 + float(m))) + max(0.0, abs(away.x) - 1.3) * 2.0 + abs(away.z) * 0.2; + float gash = 1.0 - smoothstep(0.05, 0.16, slit); + float lip = (1.0 - smoothstep(0.12, 0.42, slit)) * (1.0 - gash); + float below = -away.y; + float run = (1.0 - smoothstep(0.1, 0.26, abs(away.x - 0.3 * sin(injuryPos.y * 1.7 + float(m))))) * step(0.0, below) * (1.0 - smoothstep(2.0, 2.0 + 6.0 * split * uInjuryRun, below)); + diffuseColor.rgb = mix(diffuseColor.rgb, rawFlesh, lip * split * 0.75); + diffuseColor.rgb = mix(diffuseColor.rgb, bloodColor, run * split * 0.92); + diffuseColor.rgb = mix(diffuseColor.rgb, cutColor, gash * split); + injuryWet = max(injuryWet, split * max(max(gash, lip * 0.6), run)); + } + } + // The other man's blood, where it flew onto him: a fine spray, fat drops that have run a little, and smears. + if (uInjurySpatter > 0.001) { + vec2 across = vec2(injuryPos.x + injuryPos.z * 0.6, injuryPos.y); + float amount = uInjurySpatter * smoothstep(-7.0, 1.0, injuryPos.z); + vec2 fineCell = floor(across * 2.6); + float fineSeed = injuryCell(fineCell); + vec2 fineAt = (vec2(injuryCell(fineCell + 7.0), injuryCell(fineCell + 13.0)) - 0.5) * 0.6; + float fine = (1.0 - smoothstep(0.08, 0.2, length(fract(across * 2.6) - 0.5 - fineAt))) * step(1.0 - amount * 0.5, fineSeed); + vec2 fatScale = vec2(0.7, 0.45); + vec2 fatCell = floor(across * fatScale); + float fatSeed = injuryCell(fatCell + 3.0); + vec2 fatAt = (vec2(injuryCell(fatCell + 17.0), injuryCell(fatCell + 5.0)) - 0.5) * 0.5; + vec2 off = (fract(across * fatScale) - 0.5 - fatAt) / fatScale; + float drop = 1.0 - smoothstep(0.2, 0.4, length(off * vec2(1.0, 0.8))); + float tail = (1.0 - smoothstep(0.05, 0.15, abs(off.x + 0.05 * sin(off.y * 9.0)))) * step(off.y, 0.0) * (1.0 - smoothstep(0.2, 0.3 + 0.8 * fatSeed, -off.y)); + float smear = smoothstep(0.74 - 0.2 * amount, 0.86, injuryNoise(across * 0.33 + 9.0)) * amount; + float spat = max(max(fine * 0.85, max(drop, tail) * step(1.0 - amount * 0.45, fatSeed)), smear * 0.6); + diffuseColor.rgb = mix(diffuseColor.rgb, mix(bloodColor, bloodEdge, 0.25 + 0.5 * fineSeed), spat * 0.92); + injuryWet = max(injuryWet, spat * 0.8); + } +#endif #ifdef ${OPEN} // Where a cut or a burst opens the head, its inside shows as raw flesh rather than nothing. if (!gl_FrontFacing) { @@ -838,6 +892,12 @@ ${body ? BODY_FRAGMENT_WOUNDS : HEAD_FRAGMENT_WOUNDS} } #endif injuryWet *= uInjuryWetness; + // Under the X-ray of a breaking bone the skin goes dark and glassy, and the bones are drawn through it. + if (uInjuryXrayShown > 0.0) { + float seen = (1.0 - smoothstep(uInjuryXray.w * 0.78, uInjuryXray.w, distance(injuryPos, uInjuryXray.xyz))) * uInjuryXrayShown; + diffuseColor.rgb = mix(diffuseColor.rgb, vec3(0.015, 0.045, 0.1), seen * 0.93); + injuryWet = max(injuryWet, seen * 0.6); + } } `; @@ -846,6 +906,13 @@ roughnessFactor = mix(roughnessFactor, 0.18, injuryWet); `; const IMPACT_RELEASE_RATE = 9; +/** The marks of landed punches a skin keeps, and how near an earlier one, in bind-space centimetres, a punch deepens it instead of leaving its own. */ +export const INJURY_MARKS = 6; +const MARK_MERGE = 2.4; +/** A fresh welt darkens to a bruise this deep at this rate a second; past 1, a mark has been hit until it split. */ +const MARK_BRUISED = 0.85; +const MARK_DARKENS = 0.02; +const MARK_LIMIT = 1.6; export class InjuryShading { readonly uniforms = { @@ -872,6 +939,11 @@ export class InjuryShading { uInjuryGone: { value: new Float32Array(GONE_SLOTS) }, uInjuryExplicit: { value: 1 }, uInjuryPallor: { value: 0 }, + uInjuryXray: { value: new THREE.Vector4(0, 0, 0, 0) }, + uInjuryXrayShown: { value: 0 }, + uInjuryRun: { value: 1 }, + uInjuryMark: { value: Array.from({ length: INJURY_MARKS }, () => new THREE.Vector4(0, 0, 0, 0)) }, + uInjurySpatter: { value: 0 }, }; private readonly index = new Map(); private readonly wounds: readonly string[]; @@ -952,12 +1024,76 @@ export class InjuryShading { } update(dt: number): void { + const marks = this.uniforms.uInjuryMark.value; + for (let slot = 0; slot < marks.length; slot += 1) { + const mark = marks[slot]!; + if (mark.w > 0 && mark.w < MARK_BRUISED) mark.w = Math.min(MARK_BRUISED, mark.w + MARK_DARKENS * dt); + } const push = this.uniforms.uInjuryImpactPush.value; if (push.lengthSq() < 1e-6) return; push.multiplyScalar(Math.exp(-IMPACT_RELEASE_RATE * dt)); if (push.lengthSq() < 1e-4) push.set(0, 0, 0); } + /** + * A punch lands at a bind-space point of the skin and leaves its mark there: a welt that darkens to a bruise. + * One that lands on an earlier mark deepens it, and past 1 splits it. The faintest mark makes way for a new one. + */ + mark(x: number, y: number, z: number, weight: number): void { + const marks = this.uniforms.uInjuryMark.value; + let faintest = marks[0]!; + for (let slot = 0; slot < marks.length; slot += 1) { + const mark = marks[slot]!; + if (mark.w > 0 && (mark.x - x) ** 2 + (mark.y - y) ** 2 + (mark.z - z) ** 2 < MARK_MERGE * MARK_MERGE) { + mark.w = Math.min(MARK_LIMIT, mark.w + weight); + return; + } + if (mark.w < faintest.w) faintest = mark; + } + faintest.set(x, y, z, Math.min(MARK_LIMIT, weight)); + this.refresh(); + } + + /** How deep the mark nearest a bind-space point is, 0 where the skin is unmarked within the reach of one. */ + markAt(x: number, y: number, z: number): number { + let depth = 0; + for (const mark of this.uniforms.uInjuryMark.value) if ((mark.x - x) ** 2 + (mark.y - y) ** 2 + (mark.z - z) ** 2 < MARK_MERGE * MARK_MERGE) depth = Math.max(depth, mark.w); + return depth; + } + + /** Takes the marks of punches off the skin: with blood turned off they are not shown. */ + clearMarks(): void { + let marked = false; + for (const mark of this.uniforms.uInjuryMark.value) { + marked ||= mark.w > 0; + mark.w = 0; + } + if (marked) this.refresh(); + } + + /** How much of another man's blood has landed on the skin, 0 to 1. */ + setSpatter(amount: number): void { + const spatter = THREE.MathUtils.clamp(amount, 0, 1) || 0; + if (spatter === this.uniforms.uInjurySpatter.value) return; + this.uniforms.uInjurySpatter.value = spatter; + this.refresh(); + } + + get spatter(): number { + return this.uniforms.uInjurySpatter.value; + } + + /** How far the blood from his cuts has run, as a multiple of what a fresh cut runs: it lengthens as he bleeds. */ + setRun(run: number): void { + this.uniforms.uInjuryRun.value = THREE.MathUtils.clamp(run, 0.3, 2) || 1; + } + + /** Shows the skin within `radius` of a bind-space point as an X-ray shows it, `shown` from 0 to 1 (see BoneXray). */ + setXray(x: number, y: number, z: number, radius: number, shown: number): void { + this.uniforms.uInjuryXray.value.set(x, y, z, radius); + this.uniforms.uInjuryXrayShown.value = shown; + } + get impactDepth(): number { return this.uniforms.uInjuryImpactPush.value.length(); } @@ -998,7 +1134,8 @@ export class InjuryShading { private get painted(): boolean { const wounds = this.uniforms.uInjuryWound.value; for (let slot = 0; slot < wounds.length; slot += 1) if (wounds[slot]! > 0) return true; - return this.uniforms.uInjuryPallor.value > 0; + for (const mark of this.uniforms.uInjuryMark.value) if (mark.w > 0) return true; + return this.uniforms.uInjuryPallor.value > 0 || this.uniforms.uInjurySpatter.value > 0; } /** Puts the skin on the shader its state needs: the plain one while it is whole and unmarked. */ @@ -1150,6 +1287,9 @@ export class InjuryShading { to.uInjuryGone.value.set(from.uInjuryGone.value); to.uInjuryExplicit.value = from.uInjuryExplicit.value; to.uInjuryPallor.value = from.uInjuryPallor.value; + for (const [index, mark] of to.uInjuryMark.value.entries()) mark.copy(from.uInjuryMark.value[index]!); + to.uInjurySpatter.value = from.uInjurySpatter.value; + to.uInjuryRun.value = from.uInjuryRun.value; this.refresh(); } @@ -1207,6 +1347,9 @@ export class InjuryShading { this.uniforms.uInjuryWound.value.fill(0); this.uniforms.uInjuryGone.value.fill(0); this.uniforms.uInjuryPallor.value = 0; + for (const mark of this.uniforms.uInjuryMark.value) mark.set(0, 0, 0, 0); + this.uniforms.uInjurySpatter.value = 0; + this.uniforms.uInjuryRun.value = 1; this.refresh(); } diff --git a/web/hands/src/render/looks.ts b/web/hands/src/render/looks.ts index 476a8bbe..8e08f3c7 100644 --- a/web/hands/src/render/looks.ts +++ b/web/hands/src/render/looks.ts @@ -169,11 +169,63 @@ export const LOOK_GROOM_GLSL = /* glsl */ ` #endif `; +/** + * The face's expression, on a live head only: `uLookExpression` is how far the lids are shut, how far the + * mouth hangs open and how hard the brow is drawn down, each 0 to 1 (see FaceLife). The head has one bone, so + * the jaw is dropped and the brow lowered here, in bind space. + */ +const EXPRESSION_DECLARATIONS = /* glsl */ ` +uniform vec3 uLookExpression; +varying float vLookJaw; +`; + +export const LOOK_EXPRESSION_SHAPE_GLSL = /* glsl */ ` +{ + vec3 p = position; + // Everything of the face under the seam of the lips drops with the jaw and swings back; the lips part between. + float jawDrop = (1.0 - smoothstep(115.1, 115.44, p.y)) * smoothstep(107.5, 110.0, p.y) * smoothstep(-5.5, 0.5, p.z); + vLookJaw = jawDrop; + transformed.y -= 1.3 * uLookExpression.y * jawDrop; + transformed.z -= 0.45 * uLookExpression.y * jawDrop; + float frown = (1.0 - smoothstep(0.0, 1.7, abs(p.y - 122.4))) * smoothstep(1.5, 3.5, p.z) * (1.0 - smoothstep(3.2, 5.6, abs(p.x))); + transformed.y -= 0.4 * uLookExpression.z * frown; + transformed.x -= sign(p.x) * 0.18 * uLookExpression.z * frown; +} +`; + +/** Exported so a test can read it. The injuries are painted after it, so an eye swollen shut or forced out covers a blink. */ +export const LOOK_EXPRESSION_GLSL = /* glsl */ ` +#ifdef USE_MAP +{ + vec3 p = vLookPos; + // The skin stretched between the parted lips, neither with the jaw nor with the skull, is the dark inside of + // the mouth, closing to its corners, with the teeth showing under the upper lip. + float parted = smoothstep(0.03, 0.3, uLookExpression.y) * (1.0 - smoothstep(1.6, 2.2, abs(p.x))) * smoothstep(2.6, 3.8, p.z) * smoothstep(114.2, 114.6, p.y); + float corner = 0.42 * smoothstep(0.7, 2.1, abs(p.x)); + float between = smoothstep(0.04 + corner, 0.12 + corner, vLookJaw) * (1.0 - smoothstep(0.88 - corner, 0.96 - corner, vLookJaw)); + float teeth = (1.0 - smoothstep(0.14, 0.22, vLookJaw)) * (1.0 - smoothstep(0.8, 1.3, abs(p.x))); + diffuseColor.rgb = mix(diffuseColor.rgb, mix(vec3(0.035, 0.006, 0.008), vec3(0.5, 0.44, 0.36), teeth), parted * between); + // The upper lid comes down over the eye along its own curve, a dark lash line at its edge. + vec3 lidSkin = ${SKIN} * diffuse * 0.72; + for (int e = 0; e < 2; e++) { + vec3 q = p - (e == 0 ? vec3(2.65, 120.65, 3.6) : vec3(-2.75, 120.75, 3.4)); + float across = q.x / 1.35; + float opening = (1.0 - smoothstep(0.8, 1.0, length(vec2(across, (q.y + 0.2) / 0.46)))) * smoothstep(-1.6, -0.8, q.z); + float edge = mix(0.3, -0.52, uLookExpression.x) - 0.2 * across * across; + float lid = opening * smoothstep(edge - 0.05, edge + 0.05, q.y); + float lash = opening * (1.0 - smoothstep(0.0, 0.09, abs(q.y - edge))) * smoothstep(0.0, 0.2, uLookExpression.x); + diffuseColor.rgb = mix(mix(diffuseColor.rgb, lidSkin, lid), vec3(0.03, 0.02, 0.018), lash * 0.7); + } +} +#endif +`; + export class LookShading { private readonly uniforms = { uLookHair: { value: new THREE.Color(SCANNED_LOOK.hair) }, uLookFace: { value: new THREE.Vector4() }, uLookGroom: { value: new THREE.Vector2() }, + uLookExpression: { value: new THREE.Vector3() }, }; private current: FighterLook = SCANNED_LOOK; @@ -189,11 +241,11 @@ export class LookShading { before.call(material, shader, renderer); Object.assign(shader.uniforms, uniforms); shader.vertexShader = shader.vertexShader - .replace("#include ", `#include \n${baked ? "attribute vec3 bindPosition;" : ""}\n${LOOK_MASKS_GLSL}`) - .replace("#include ", `${baked ? VERTEX_BAKED : LOOK_SHAPE_GLSL}\n#include `); + .replace("#include ", `#include \n${baked ? "attribute vec3 bindPosition;" : EXPRESSION_DECLARATIONS}\n${LOOK_MASKS_GLSL}`) + .replace("#include ", `${baked ? VERTEX_BAKED : LOOK_SHAPE_GLSL + LOOK_EXPRESSION_SHAPE_GLSL}\n#include `); shader.fragmentShader = shader.fragmentShader - .replace("#include ", `#include \n${LOOK_MASKS_GLSL}`) - .replace("#include ", `#include \n${LOOK_GROOM_GLSL}`); + .replace("#include ", `#include \n${baked ? "" : EXPRESSION_DECLARATIONS}${LOOK_MASKS_GLSL}`) + .replace("#include ", `#include \n${LOOK_GROOM_GLSL}${baked ? "" : LOOK_EXPRESSION_GLSL}`); }; material.customProgramCacheKey = () => `${beforeKey}-look-${baked ? "baked" : "live"}`; material.needsUpdate = true; @@ -207,6 +259,11 @@ export class LookShading { this.uniforms.uLookGroom.value.set(look.shaved, look.beard); } + /** The live face's expression, each 0 to 1: lids shut, mouth open, brow drawn down. A baked head has none. */ + setExpression(lids: number, mouth: number, brow: number): void { + this.uniforms.uLookExpression.value.set(lids, mouth, brow); + } + get look(): FighterLook { return this.current; } diff --git a/web/hands/src/render/mouthpiece.test.ts b/web/hands/src/render/mouthpiece.test.ts index 2317f9ca..453c8ad5 100644 --- a/web/hands/src/render/mouthpiece.test.ts +++ b/web/hands/src/render/mouthpiece.test.ts @@ -145,6 +145,7 @@ describe("gum shield", () => { mapping: { x: (value: number) => value / 100, z: (value: number) => value / 100 }, contactOn: () => new THREE.Vector3(), effects: { addEvent: () => undefined }, + carnage: { rebreak: () => false }, settings: () => ({ reducedMotion: false }), graphs: null, onContact: null, diff --git a/web/hands/src/render/mutilation.ts b/web/hands/src/render/mutilation.ts index 9e0b0eff..e8f38f69 100644 --- a/web/hands/src/render/mutilation.ts +++ b/web/hands/src/render/mutilation.ts @@ -838,6 +838,12 @@ export class Mutilation { return true; } + /** The same for the head's skin or the body's, by name. */ + skinMatrix(skin: "head" | "body", bone: CanonicalBone, out: THREE.Matrix4): boolean { + const mesh = skin === "head" ? this.boxer.headMesh : fighterMesh(this.boxer, "body"); + return mesh !== null && this.bindToWorld(mesh, bone, out); + } + /** The brain and the rim of the skull sized to the head as the fighter's look shapes it: a shaved head is smaller than a head of hair. */ private fitSkull(): void { const skull = this.skull; diff --git a/web/hands/src/render/officials.test.ts b/web/hands/src/render/officials.test.ts index 363298d5..8e8621c3 100644 --- a/web/hands/src/render/officials.test.ts +++ b/web/hands/src/render/officials.test.ts @@ -137,6 +137,142 @@ describe("referee count", () => { expect(heights[change - 6]! - heights[change]!).toBeGreaterThan(0.05); } }); + + it("bends into the count from his rest and straightens out of it with no jump", () => { + const referee = official(); + const graph = new BoxingGraph(referee, mapping, { referee: true }); + const self: FighterSnapshot = { ...baseFighter("referee"), x: 0, y: 160, facing_x: 0, facing_y: -1000 }; + const focus: FighterSnapshot = { ...baseFighter("focus"), x: 0, y: -140 }; + const hand = new THREE.Vector3(); + const head = new THREE.Vector3(); + let standing = 0; + let lowest = Infinity; + for (let frame = 0; frame < 420; frame += 1) { + const tick = frame / 2; + // He counts from the second second to the middle of the fifth, stopping with the arm on its way up. + const counting = frame >= 60 && frame < 265; + graph.setRefereeCount(counting, counting ? Math.floor((tick - 30) / COUNT_TICKS) : 0); + graph.update(self, focus, 1 / 60, frame / 60, false, "off", tick); + referee.root.updateMatrixWorld(true); + const before = hand.clone(); + worldPosition(referee.rig.bones.gloveR, hand); + worldPosition(referee.rig.bones.head, head); + if (frame === 59) standing = head.y; + if (counting) lowest = Math.min(lowest, head.y); + // The chop itself is fast; the count starting and ending eases the hand over, a few centimetres a frame at most. + if ((frame >= 60 && frame < 70) || frame >= 265) expect(hand.distanceTo(before)).toBeLessThan(0.08); + } + expect(lowest).toBeLessThan(standing - 0.15); + expect(head.y).toBeGreaterThan(standing - 0.01); + }); +}); + +describe("an official's posture", () => { + const stand = (x: number, y: number, velocityX = 0, velocityY = 0): FighterSnapshot => + ({ ...baseFighter("referee"), x, y, facing_x: 0, facing_y: -1000, velocity_x: velocityX, velocity_y: velocityY }); + const focus: FighterSnapshot = { ...baseFighter("focus"), x: 0, y: -140 }; + const bone = (boxer: SkinnedBoxer, name: "hips" | "head" | "gloveL" | "gloveR" | "hipL" | "kneeL" | "ankleL" | "hipR" | "kneeR" | "ankleR" | "toeL" | "toeR"): THREE.Vector3 => { + boxer.root.updateMatrixWorld(true); + return worldPosition(boxer.rig.bones[name], new THREE.Vector3()); + }; + + it("stands upright on soft knees with his hands ready in front of his belt, not hanging", () => { + const referee = official(); + const graph = new BoxingGraph(referee, mapping, { referee: true }); + for (let frame = 0; frame < 90; frame += 1) graph.update(stand(0, 160), focus, 1 / 60, frame / 60, false, "off", frame / 2); + const hips = bone(referee, "hips"); + expect(hips.y).toBeGreaterThan(0.92); + for (const side of ["L", "R"] as const) { + const knee = bone(referee, `knee${side}`); + const thigh = knee.clone().sub(bone(referee, `hip${side}`)); + const shin = bone(referee, `ankle${side}`).sub(knee); + expect(thigh.angleTo(shin)).toBeLessThan(0.55); + const hand = bone(referee, `glove${side}`); + expect(hand.y).toBeGreaterThan(hips.y + 0.15); + expect(hand.y).toBeLessThan(hips.y + 0.4); + expect(hand.z - hips.z).toBeGreaterThan(0.2); + } + expect(Math.abs(bone(referee, "ankleL").x - bone(referee, "ankleR").x)).toBeGreaterThan(0.24); + expect(Math.abs(bone(referee, "ankleL").x - bone(referee, "ankleR").x)).toBeLessThan(0.4); + }); + + it.each([["toward the action", 0, -6], ["away from it", 0, 6], ["across it", 6, 0]])("walks %s in strides, a foot at a time, and never slides a planted foot", (_way, velocityX, velocityY) => { + const referee = official(); + const graph = new BoxingGraph(referee, mapping, { referee: true }); + const last = { L: new THREE.Vector3(), R: new THREE.Vector3() }; + const planted = { L: new THREE.Vector3(), R: new THREE.Vector3() }; + const moving = { L: false, R: false }; + const strides: number[] = []; + let standing = 0; + let lowest = Infinity; + for (let frame = 0; frame < 300; frame += 1) { + // He stands for a second, then walks at the engine's referee pace. + const walked = Math.max(0, frame - 60) / 2; + const walking = frame >= 60; + graph.update(stand(walked * velocityX, 160 + walked * velocityY, walking ? velocityX : 0, walking ? velocityY : 0), focus, 1 / 60, frame / 60, false, "off", frame / 2); + const hips = bone(referee, "hips").y; + if (frame === 59) standing = hips; + let still = 0; + for (const side of ["L", "R"] as const) { + const toe = bone(referee, `toe${side}`); + const moved = toe.distanceTo(last[side]) > 1e-4; + if (!moved) still += 1; + if (!moved && moving[side] && frame > 60) { + if (planted[side].lengthSq() > 0 && frame > 120) strides.push(toe.distanceTo(planted[side])); + planted[side].copy(toe); + } + moving[side] = moved; + last[side].copy(toe); + } + if (frame > 0) expect(still).toBeGreaterThanOrEqual(1); + if (frame > 120) lowest = Math.min(lowest, hips); + } + // Walking strides, not a shuffle; and he stays up on his legs as he goes. + expect(strides.length).toBeGreaterThanOrEqual(3); + expect(Math.min(...strides)).toBeGreaterThan(0.5); + expect(lowest).toBeGreaterThan(standing - 0.1); + }); + + it("keeps his eyes on the man he is given to watch, and otherwise looks from one fighter to the other", () => { + const referee = official(); + const graph = new BoxingGraph(referee, mapping, { referee: true }); + const facing = (): THREE.Vector3 => { + referee.root.updateMatrixWorld(true); + return new THREE.Vector3(0, 0, 1).applyQuaternion(referee.rig.bones.head.getWorldQuaternion(new THREE.Quaternion())); + }; + const here = stand(0, 160); + const root = new THREE.Vector3(mapping.x(0), 0, mapping.z(160)); + const one = root.clone().add(new THREE.Vector3(0.7, 0, 1)); + const two = root.clone().add(new THREE.Vector3(-0.7, 0, 1)); + const turns: number[] = []; + for (let frame = 0; frame < 900; frame += 1) { + graph.aimBreak(one, two); + graph.update(here, focus, 1 / 60, frame / 60, false, "off", frame / 2); + turns.push(facing().x); + } + expect(Math.max(...turns)).toBeGreaterThan(0.3); + expect(Math.min(...turns)).toBeLessThan(-0.3); + for (let frame = 900; frame < 990; frame += 1) { + graph.aimBreak(one, two, two.clone().setY(0.25)); + graph.update(here, focus, 1 / 60, frame / 60, false, "off", frame / 2); + } + expect(facing().x).toBeLessThan(-0.3); + expect(facing().y).toBeLessThan(-0.4); + }); + + it("works on the seated fighter down toward one knee, the trailing leg on its toes", () => { + const cutman = official(); + const graph = new BoxingGraph(cutman, mapping, { referee: true }); + const eye = new THREE.Vector3(mapping.x(0), 1.18, mapping.z(160) + 0.6); + for (let frame = 0; frame < 150; frame += 1) { + graph.treat(eye, new THREE.Vector3(0, 0, -1), 1); + graph.update(stand(0, 160), focus, 1 / 60, frame / 60, false, "off", frame / 2); + } + const knee = bone(cutman, "kneeR"); + expect(knee.y).toBeLessThan(0.36); + expect(bone(cutman, "ankleR").z).toBeLessThan(knee.z - 0.25); + expect(bone(cutman, "kneeL").y).toBeGreaterThan(knee.y + 0.2); + }); }); describe("officials' materials", () => { diff --git a/web/hands/src/render/poser.test.ts b/web/hands/src/render/poser.test.ts index 54a4aedc..f5a8537a 100644 --- a/web/hands/src/render/poser.test.ts +++ b/web/hands/src/render/poser.test.ts @@ -242,9 +242,10 @@ describe("down and get-up poses", () => { if (frame % 3 !== 0) return; lowest = Math.min(lowest, lowestVertex(boxer)); if (frame < 60) return; - // Up off the canvas (the hips are high) the gloves and then the trunks' knees must still reach it. + // Up off the canvas (the hips are high) the gloves and then a knee must still reach it. The trunks are cut + // above the knee, so it is the leg's own skin that touches down. if (bone(boxer, "hips").y > 0.42) gloves = Math.min(gloves, lowestVertex(boxer, "GlovesMat0")); - if (bone(boxer, "head").y > 0.9) knees = Math.min(knees, lowestVertex(boxer, "PantsMat0")); + if (bone(boxer, "head").y > 0.9) knees = Math.min(knees, lowestVertex(boxer, "MBodyMat0")); }); expect(lowest).toBeGreaterThan(-0.02); expect(gloves).toBeLessThan(0.03); @@ -1279,9 +1280,10 @@ describe("decision ceremony", () => { const hand = bone(made, "gloveR"); expect(hand.distanceTo(new THREE.Vector3(-0.3, 1.73, 0.3))).toBeLessThan(0.04); expect(bone(made, "gloveL").y).toBeLessThan(1.05); + // Let go, the hand comes back down to its place in front of his belt. referee.raise(null, null); run(referee, square("referee"), { ...square("focus"), y: -300 }, 150, undefined); - expect(bone(made, "gloveR").y).toBeLessThan(1.05); + expect(bone(made, "gloveR").y).toBeLessThan(1.25); }); it("ends with the bout", () => { @@ -1319,11 +1321,44 @@ describe("infighting", () => { expect(toward * (open.head.z - inside.head.z)).toBeGreaterThan(0.03); }); - it("stands in the open stance at punching range", () => { + it("stands in the open stance at long range and draws the lead glove back by his face as the other man comes into punching range", () => { const open = settle(300); - const ranged = settle(170); - expect(Math.abs(open.glove - ranged.glove)).toBeLessThan(0.005); - expect(open.head.distanceTo(ranged.head)).toBeLessThan(0.005); + const long = settle(220); + expect(Math.abs(open.glove - long.glove)).toBeLessThan(0.005); + expect(open.head.distanceTo(long.head)).toBeLessThan(0.005); + const relaxed = (gapUnits: number): { glove: number; head: number } => { + const { boxer, graph } = makeGraph(); + run(graph, facingOpponent(baseFighter("one")), { ...opponentFor("two"), y: -gapUnits }, 90, undefined); + return { glove: bone(boxer, "gloveL").z, head: bone(boxer, "head").z }; + }; + const far = relaxed(240); + const punching = relaxed(150); + const close = relaxed(120); + // Out in front at range; at punching range two lead gloves this far out would cross in the middle. + expect(far.glove - far.head).toBeGreaterThan(0.3); + expect(punching.glove).toBeLessThan(far.glove - 0.1); + expect(punching.glove).toBeLessThan(mapping.z(-150) / 2 - 0.1); + expect(close.glove).toBeLessThan(punching.glove); + // He stands taller as the other man comes in without leaning away: the head gives under ten centimetres. + expect(far.head - close.head).toBeLessThan(0.1); + expect(close.glove).toBeGreaterThan(close.head); + }); + + it("draws the guard in smoothly as the other man steps in", () => { + const { boxer, graph } = makeGraph(); + const fighter = facingOpponent(baseFighter("one")); + run(graph, fighter, { ...opponentFor("two"), y: -240 }, 90, undefined); + let last = bone(boxer, "gloveL").clone(); + let jump = 0; + // He comes in from long range to chest to chest at the engine's top speed. + for (let frame = 0; frame < 60; frame += 1) { + const gap = Math.max(76, 240 - frame * 5); + graph.update(fighter, { ...opponentFor("two"), y: -gap }, 1 / 60, 1.5 + frame / 60, false, "full", 45 + frame / 2, undefined); + const glove = bone(boxer, "gloveL"); + jump = Math.max(jump, glove.distanceTo(last)); + last = glove.clone(); + } + expect(jump).toBeLessThan(0.03); }); }); @@ -1345,10 +1380,10 @@ describe("clinch hold", () => { expect(left.x - right.x).toBeGreaterThan(0.25); expect(bone(idle.boxer, "head").x - bone(boxer, "head").x).toBeGreaterThan(0.08); } - expect(bone(over.boxer, "gloveL").y).toBeGreaterThan(1.2); - expect(bone(over.boxer, "gloveR").y).toBeGreaterThan(1.15); - expect(bone(under.boxer, "gloveL").y).toBeLessThan(1.1); - expect(bone(under.boxer, "gloveR").y).toBeLessThan(1.1); + expect(bone(over.boxer, "gloveL").y).toBeGreaterThan(1.26); + expect(bone(over.boxer, "gloveR").y).toBeGreaterThan(1.21); + expect(bone(under.boxer, "gloveL").y).toBeLessThan(1.16); + expect(bone(under.boxer, "gloveR").y).toBeLessThan(1.16); expect(bone(over.boxer, "head").y).toBeGreaterThan(bone(under.boxer, "head").y); const sway: number[] = []; for (let frame = 0; frame < 40; frame += 1) { @@ -1497,15 +1532,16 @@ describe("two heads at close range", () => { const other = own.clone().addScaledVector(forward.normalize(), 0.06); for (let frame = 0; frame < 60; frame += 1) run(graph, fighter, opponent, 1, other, 20 + frame * 0.5, (40 + frame) / 60); expect(bone(boxer, "head").distanceTo(other)).toBeGreaterThan(0.15); - // Clear of it, he stands as he did. + // Clear of it, he stands as he did, give or take the sway of a man who is never still. for (let frame = 0; frame < 60; frame += 1) run(graph, fighter, opponent, 1, other.clone().addScaledVector(forward, 1), 50 + frame * 0.5, (100 + frame) / 60); - expect(bone(boxer, "head").distanceTo(own)).toBeLessThan(0.03); + expect(bone(boxer, "head").distanceTo(own)).toBeLessThan(0.05); }); }); describe("wave-off", () => { - it("sweeps both gloves wide across the chest, below the face, while waving the fight off", () => { - const { boxer, graph } = makeGraph(); + it("crosses the referee's hands above his head and swings them wide while waving the fight off", () => { + const boxer = new SkinnedBoxer(gltf, { skin: 0xc79b76, gear: 0x1b2230 }); + const graph = new BoxingGraph(boxer, mapping, { referee: true }); const fighter = facingOpponent(baseFighter("one")); const opponent = opponentFor("two"); graph.waveOff(4); @@ -1515,11 +1551,12 @@ describe("wave-off", () => { if (frame < 40) continue; const glove = bone(boxer, "gloveL"); const head = bone(boxer, "head"); - xs.push(glove.x); - expect(glove.y).toBeGreaterThan(0.95); - expect(glove.y).toBeLessThan(head.y - 0.05); + xs.push(glove.x - head.x); + expect(glove.y).toBeGreaterThan(head.y + 0.05); } - expect(Math.max(...xs) - Math.min(...xs)).toBeGreaterThan(0.6); + // Each hand goes from wide of its own shoulder to past the middle of his head. + expect(Math.max(...xs) - Math.min(...xs)).toBeGreaterThan(0.5); + expect(Math.max(...xs) * Math.min(...xs)).toBeLessThan(0); }); }); @@ -1557,22 +1594,28 @@ describe("skinned rig solver", () => { }); describe("runtime boxing graph", () => { - it("plants both feet on the authored stance and never slides them while idle", () => { + it("plants both feet on the authored stance, on the balls of the feet, and never slides them while idle", () => { const { boxer, graph } = makeGraph(); const fighter = facingOpponent(baseFighter("one")); - const opponent = opponentFor("two"); + // Out of range, where the stance is the authored one. + const opponent = { ...opponentFor("two"), y: -300 }; run(graph, fighter, opponent, 30, undefined); - const left = bone(boxer, "ankleL").clone(); - const right = bone(boxer, "ankleR").clone(); - expect(left.x).toBeCloseTo(STANCE.leadFoot.x, 2); - expect(left.z).toBeCloseTo(STANCE.leadFoot.z, 2); - expect(right.x).toBeCloseTo(STANCE.rearFoot.x, 2); - expect(right.z).toBeCloseTo(STANCE.rearFoot.z, 2); - expect(left.y).toBeCloseTo(boxer.rig.metrics.ankleHeight, 2); + // The ball of each foot is where the authored ankle and toe direction put it, however far the heel is raised. + const { ankleHeight, footLength } = boxer.rig.metrics; + const sole = footLength * footLength / Math.hypot(footLength, ankleHeight); + const left = bone(boxer, "toeL").clone(); + const right = bone(boxer, "toeR").clone(); + expect(left.x).toBeCloseTo(STANCE.leadFoot.x + STANCE.leadToe.x / STANCE.leadToe.length() * sole, 2); + expect(left.z).toBeCloseTo(STANCE.leadFoot.z + STANCE.leadToe.z / STANCE.leadToe.length() * sole, 2); + expect(right.x).toBeCloseTo(STANCE.rearFoot.x + STANCE.rearToe.x / STANCE.rearToe.length() * sole, 2); + expect(right.z).toBeCloseTo(STANCE.rearFoot.z + STANCE.rearToe.z / STANCE.rearToe.length() * sole, 2); + // The rear heel is off the canvas and the lead foot nearly flat. + expect(bone(boxer, "ankleR").y).toBeGreaterThan(ankleHeight + 0.03); + expect(bone(boxer, "ankleL").y).toBeLessThan(bone(boxer, "ankleR").y); run(graph, fighter, opponent, 120, undefined, 15, 0.5); - expect(bone(boxer, "ankleL").distanceTo(left)).toBeLessThan(1e-4); - expect(bone(boxer, "ankleR").distanceTo(right)).toBeLessThan(1e-4); - expect(bone(boxer, "head").y).toBeGreaterThan(1.45); + expect(bone(boxer, "toeL").distanceTo(left)).toBeLessThan(1e-4); + expect(bone(boxer, "toeR").distanceTo(right)).toBeLessThan(1e-4); + expect(bone(boxer, "head").y).toBeGreaterThan(1.5); }); it("steps instead of sliding when the authoritative root moves", () => { @@ -2043,7 +2086,8 @@ describe("hand-over to the get-up", () => { // The body used to freeze where the physics left it and then snap 1.3 m into the get-up; turning the bones // straight from the fall's pose to the get-up's then swung limbs up to 0.85 m in a frame and 0.5 m through the canvas. expect(jump().distance, jump().at).toBeLessThan(0.16); - expect(lowest(), "skin under the canvas").toBeGreaterThan(-0.03); + // A glove lying on the canvas rests on its wrist and fist, and its padding reaches a few centimetres below them. + expect(lowest(), "skin under the canvas").toBeGreaterThan(-0.06); expect(bone(boxer, "head").y).toBeGreaterThan(1.4); }); diff --git a/web/hands/src/render/poser.ts b/web/hands/src/render/poser.ts index acf669dc..200b1c00 100644 --- a/web/hands/src/render/poser.ts +++ b/web/hands/src/render/poser.ts @@ -1,5 +1,6 @@ import * as THREE from "three"; import { SolvedRig, worldPosition, worldQuaternion, type CanonicalBone } from "./rig"; +import type { FighterStyle } from "../types"; /** * Character-space boxing pose description and the solver that applies it to @@ -217,27 +218,97 @@ export class PoseSolver { /** Constants describing the authored orthodox stance in character space. */ export const STANCE = { - bladeYaw: -1.05, - hipsHeight: 0.8, - leadFoot: vec(0.12, 0, 0.24), - rearFoot: vec(-0.1, 0, -0.34), - leadToe: vec(-0.34, 0, 0.94), - rearToe: vec(-0.77, 0, 0.64), + bladeYaw: -0.68, + /** How much further than the hips the shoulders are turned from square. */ + shoulderBlade: 1.18, + hipsHeight: 0.875, + leadFoot: vec(0.13, 0, 0.2), + rearFoot: vec(-0.15, 0, -0.25), + leadToe: vec(-0.26, 0, 0.97), + rearToe: vec(-0.68, 0, 0.73), + /** Heel lift in radians: the rear heel is off the canvas, the lead foot light. */ + leadHeel: 0.05, + rearHeel: 0.3, + /** How far the trunk leans toward the opponent from the hips, in radians, and how far it rounds forward over the chest. */ + lean: 0.09, + hunch: 0.15, + chinTuck: 0.24, + /** How far each shoulder is carried up and forward. */ + leadShrug: 0.45, + rearShrug: 0.25, /** Hand offsets relative to the head bone. */ - relaxedLead: vec(0.11, -0.22, 0.36), - relaxedRear: vec(-0.11, -0.16, 0.1), - guardHighLead: vec(0.14, -0.02, 0.17), - guardHighRear: vec(-0.1, -0.02, 0.11), - guardLowLead: vec(0.15, -0.36, 0.22), - guardLowRear: vec(-0.13, -0.34, 0.12), - leadPole: vec(0.45, -1, 0.2), - rearPole: vec(-0.5, -1, -0.05), - leadKnuckles: vec(0.1, 0.55, 0.8), + relaxedLead: vec(0.12, -0.15, 0.44), + relaxedRear: vec(-0.07, -0.11, 0.18), + /** The same with the other man close: the lead glove drawn back by the face. */ + tightLead: vec(0.13, -0.11, 0.29), + tightRear: vec(-0.08, -0.1, 0.15), + guardHighLead: vec(0.1, -0.12, 0.33), + guardHighRear: vec(-0.1, -0.11, 0.24), + guardLowLead: vec(0.11, -0.3, 0.27), + guardLowRear: vec(-0.11, -0.3, 0.25), + /** Where the elbows go behind each guard, and how the lead glove is turned in both (the rear mirrors it). */ + guardHighLeadPole: vec(0.15, -1, 0.35), + guardHighRearPole: vec(-0.15, -1, 0.35), + guardLowLeadPole: vec(0.3, -1, -0.1), + guardLowRearPole: vec(-0.3, -1, -0.1), + guardKnuckles: vec(-0.05, 1, 0.15), + guardPalm: vec(-0.6, 0, -0.8), + leadPole: vec(0.3, -1, 0.1), + rearPole: vec(-0.35, -1, -0.15), + leadKnuckles: vec(0.05, 0.75, 0.65), leadPalm: vec(-0.9, 0.15, -0.35), - rearKnuckles: vec(-0.05, 0.7, 0.7), + rearKnuckles: vec(-0.05, 0.85, 0.5), rearPalm: vec(0.95, 0.1, -0.25), } as const; +/** + * How one man's stance differs from the authored one. Lengths are metres and angles radians added to it; the + * rest are shares of its own. The gloves' offsets hold at range and give way to the common guard close in. + */ +export interface StanceManner { + /** How much taller he stands. */ + rise: number; + /** His base's length and width. */ + length: number; + width: number; + /** How far forward he carries his weight, and how much further he leans in. */ + weight: number; + lean: number; + /** Where he carries each glove, from the authored one's place (x to his lead side). */ + readonly lead: THREE.Vector3; + readonly rear: THREE.Vector3; + /** How far his elbows stand out from his ribs, and how much higher he carries the lead shoulder. */ + flare: number; + shrug: number; + /** How far the lead arm lies across his body, the fist turned over, as in a shell. */ + shell: number; + /** The size and pace of his bounce, his rock from foot to foot and the sway of his head. */ + spring: number; + tempo: number; + rock: number; + bob: number; + /** How high he keeps his heels, and how readily he paws with the lead hand. */ + heel: number; + paw: number; +} + +const manner = (own: Partial): StanceManner => ({ + rise: 0, length: 1, width: 1, weight: 0, lean: 0, lead: vec(0, 0, 0), rear: vec(0, 0, 0), flare: 0, shrug: 0, shell: 0, spring: 1, tempo: 1, rock: 1, bob: 1, heel: 1, paw: 1, ...own, +}); + +/** The stance each fighting style stands in; `balanced` is the authored one. */ +export const STANCE_MANNERS: Readonly> = { + balanced: manner({}), + // Tall and light on his toes behind a long lead hand, rocking in and out. + boxer: manner({ rise: 0.022, width: 0.9, length: 1.04, lean: -0.03, lead: vec(0, 0.02, 0.07), flare: -0.1, spring: 0.7, tempo: 1.25, rock: 1.7, bob: 0.8, heel: 1.3, paw: 1.4 }), + // Wide and flat-footed, loaded on the rear leg, heavy shoulders over hands carried low and wide. + slugger: manner({ rise: -0.015, width: 1.22, length: 0.94, weight: -0.035, lead: vec(0.04, -0.07, -0.05), rear: vec(-0.04, -0.06, 0), flare: 0.3, shrug: -0.15, spring: 0.3, tempo: 0.8, rock: 0.5, bob: 0.6, heel: 0.3, paw: 0.5 }), + // A deep crouch behind both gloves high on the cheeks, elbows in, weight forward and the head never still. + swarmer: manner({ rise: -0.045, width: 1.06, length: 0.9, weight: 0.035, lean: 0.06, lead: vec(-0.03, 0.05, -0.14), rear: vec(0, 0.03, -0.02), flare: -0.3, spring: 0.9, tempo: 1.1, rock: 0.8, bob: 2.6, paw: 0.3 }), + // A shell: the lead glove low across the body with that shoulder rolled up to the chin, weight back, still. + counter_puncher: manner({ rise: 0.005, width: 0.94, length: 1.05, weight: -0.04, lean: -0.05, lead: vec(-0.11, -0.3, -0.2), rear: vec(0.01, 0.01, -0.02), shrug: 0.45, shell: 1, spring: 0.3, tempo: 0.8, rock: 0.4, bob: 0.4, heel: 0.8, paw: 0.2 }), +}; + export function mirrorX(v: THREE.Vector3, mirror: number, out = new THREE.Vector3()): THREE.Vector3 { return out.set(v.x * mirror, v.y, v.z); } diff --git a/web/hands/src/render/punch-aim.test.ts b/web/hands/src/render/punch-aim.test.ts index 2417d819..be7dee75 100644 --- a/web/hands/src/render/punch-aim.test.ts +++ b/web/hands/src/render/punch-aim.test.ts @@ -191,7 +191,7 @@ describe("punches that find the referee", () => { } it("lands on his head, thrown at him from the start when that is already known and turned onto him when the verdict comes in mid-flight", () => { - const referee = new THREE.Vector3(0.22, 1.55, mapping.z(-75)); + const referee = new THREE.Vector3(0.22, 1.62, mapping.z(-75)); const past = throwPast("never", referee); const known = throwPast("known", referee); const late = throwPast("late", referee); diff --git a/web/hands/src/render/punch-form.test.ts b/web/hands/src/render/punch-form.test.ts new file mode 100644 index 00000000..4867c1dd --- /dev/null +++ b/web/hands/src/render/punch-form.test.ts @@ -0,0 +1,339 @@ +import * as THREE from "three"; +import { punchTiming, type PunchTiming } from "../manifest"; +import { fighter as baseFighter } from "../test/fixtures"; +import type { FighterSnapshot, Hand, Power, PunchClass, Target } from "../types"; +import { BoxingGraph, SkinnedBoxer, loadBoxerGlb } from "./graph"; +import { worldPosition, worldQuaternion, type CanonicalBone } from "./rig"; +import { worldMapping } from "./world"; + +const mapping = worldMapping({ tick_rate: 30, ring_half_width: 500, ring_half_height: 500 }); +const gltf = await loadBoxerGlb(); + +type Stance = FighterSnapshot["stance"]; + +/** The fighter stands at the origin facing world +z, so character space and world space coincide. */ +const standing = (stance: Stance): FighterSnapshot => ({ ...baseFighter("one"), stance, facing_x: 0, facing_y: -1000, x: 0, y: 0 }); +const opponentAt = (units: number): FighterSnapshot => ({ ...baseFighter("two"), x: 0, y: -units, facing_x: 0, facing_y: 1000 }); +/** The opponent's head, at the height a fighter in his stance carries it. */ +const headAt = (units: number): THREE.Vector3 => new THREE.Vector3(0, 1.62, mapping.z(-units)); + +function makeGraph(): { boxer: SkinnedBoxer; graph: BoxingGraph } { + const boxer = new SkinnedBoxer(gltf, { skin: 0xb0703f, gear: 0x1d4ed8 }); + return { boxer, graph: new BoxingGraph(boxer, mapping) }; +} + +const bone = (boxer: SkinnedBoxer, name: CanonicalBone): THREE.Vector3 => { + boxer.root.updateMatrixWorld(true); + return worldPosition(boxer.rig.bones[name], new THREE.Vector3()); +}; + +/** The bones of one arm, by the side of the body it is on. */ +const arm = (hand: Hand): { shoulder: CanonicalBone; elbow: CanonicalBone; glove: CanonicalBone } => + hand === "left" ? { shoulder: "shoulderL", elbow: "elbowL", glove: "gloveL" } : { shoulder: "shoulderR", elbow: "elbowR", glove: "gloveR" }; + +/** The angle at the elbow in degrees: 180 is a straight arm. */ +function elbowAngle(boxer: SkinnedBoxer, hand: Hand): number { + const bones = arm(hand); + const elbow = bone(boxer, bones.elbow); + return THREE.MathUtils.radToDeg(bone(boxer, bones.shoulder).sub(elbow).angleTo(bone(boxer, bones.glove).sub(elbow))); +} + +/** How far the line of the shoulders or of the hips is turned, in radians: positive brings the right side forward. */ +const turnOf = (boxer: SkinnedBoxer, left: CanonicalBone, right: CanonicalBone): number => { + const l = bone(boxer, left); + const r = bone(boxer, right); + return Math.atan2(r.z - l.z, l.x - r.x); +}; + +interface Thrown { + readonly boxer: SkinnedBoxer; + readonly graph: BoxingGraph; + /** Plays the punch on to `age` ticks after its start, half a tick a frame, calling `each` after every frame. */ + readonly to: (age: number, each?: (age: number) => void) => void; + readonly timing: PunchTiming; +} + +/** Settles a fighter in his stance `units` from an opponent and starts a server punch at tick 100. */ +function throwPunch(punchClass: PunchClass, hand: Hand, target: Target, units: number, stance: Stance = "orthodox", power: Power = "normal"): Thrown { + const { boxer, graph } = makeGraph(); + const opponent = opponentAt(units); + const head = headAt(units); + const idle = standing(stance); + for (let frame = 0; frame < 40; frame += 1) graph.update(idle, opponent, 1 / 60, frame / 60, false, "full", 80 + frame / 2, head); + const timing = punchTiming(punchClass, target, power); + const punch: FighterSnapshot = { + ...idle, action: punchClass, action_hand: hand, action_target: target, action_power: power, action_id: "p1", action_key: `${punchClass}:${hand}:${target}:${power}`, + action_start_tick: 100, action_startup_ticks: timing.startup, action_active_ticks: timing.active, action_recovery_ticks: timing.recovery, + }; + let tick = 100; + const to = (age: number, each?: (age: number) => void): void => { + while (tick < 100 + age - 1e-6) { + tick += 0.5; + // The graph advances the punch half a tick from the authoritative age it is given. + graph.update(punch, opponent, 1 / 60, tick / 30, false, "full", tick - 0.5, head); + each?.(tick - 100); + } + }; + return { boxer, graph, to, timing }; +} + +const STANCES = ["orthodox", "southpaw"] as const; +const leadHand = (stance: Stance): Hand => (stance === "orthodox" ? "left" : "right"); +const rearHand = (stance: Stance): Hand => (stance === "orthodox" ? "right" : "left"); + +describe("hook form", () => { + it("lands with the elbow bent near a right angle and level with the glove, from either hand and stance", () => { + for (const stance of STANCES) { + for (const hand of ["left", "right"] as const) { + for (const units of [90, 110, 124]) { + const { boxer, to, timing } = throwPunch("hook", hand, "head", units, stance); + to(timing.startup); + const label = `${stance} ${hand} hook at ${units}`; + const bones = arm(hand); + // Pressed close the arm folds tighter, but it never straightens into a swing. + expect(elbowAngle(boxer, hand), label).toBeGreaterThan(45); + expect(elbowAngle(boxer, hand), label).toBeLessThan(135); + expect(Math.abs(bone(boxer, bones.elbow).y - bone(boxer, bones.glove).y), label).toBeLessThan(0.1); + } + } + } + }); + + it("stays a bent arm when it swings at nothing", () => { + const { boxer, to, timing } = throwPunch("hook", "left", "head", 200); + let straightest = 0; + to(timing.startup + timing.active + timing.recovery, () => { straightest = Math.max(straightest, elbowAngle(boxer, "left")); }); + expect(straightest).toBeLessThan(140); + }); +}); + +describe("uppercut form", () => { + it("dips, then comes up under the chin with the arm folded and the elbow under the glove", () => { + for (const stance of STANCES) { + for (const hand of ["left", "right"] as const) { + const { boxer, to, timing } = throwPunch("uppercut", hand, "head", 95, stance); + const bones = arm(hand); + const guard = bone(boxer, bones.glove).y; + const hips = bone(boxer, "hips").y; + let lowestGlove = Infinity; + let lowestHips = Infinity; + to(timing.startup, () => { + lowestGlove = Math.min(lowestGlove, bone(boxer, bones.glove).y); + lowestHips = Math.min(lowestHips, bone(boxer, "hips").y); + }); + const label = `${stance} ${hand} uppercut`; + // The glove drops to the ribs and no further, and the knees dip under it. + expect(guard - lowestGlove, label).toBeGreaterThan(0.1); + expect(guard - lowestGlove, label).toBeLessThan(0.4); + expect(hips - lowestHips, label).toBeGreaterThan(0.04); + // At contact the legs have driven back up, the glove is at chin height in front of him and the arm is folded. + expect(bone(boxer, "hips").y, label).toBeGreaterThan(lowestHips + 0.04); + expect(bone(boxer, bones.glove).y - lowestGlove, label).toBeGreaterThan(0.15); + expect(elbowAngle(boxer, hand), label).toBeLessThan(115); + expect(bone(boxer, bones.glove).y - bone(boxer, bones.elbow).y, label).toBeGreaterThan(0.08); + } + } + }); +}); + +describe("body shots", () => { + it("change level from the knees with the back kept fairly straight", () => { + for (const [punchClass, hand] of [["jab", "left"], ["straight", "right"], ["hook", "left"]] as const) { + const head = throwPunch(punchClass, hand, "head", 120); + head.to(head.timing.startup); + const body = throwPunch(punchClass, hand, "body", 120); + body.to(body.timing.startup); + const lean = (boxer: SkinnedBoxer): number => bone(boxer, "neck").sub(bone(boxer, "hips")).y; + // The hips come down a hand's breadth or more, and the trunk stays nearly as upright as for the head shot. + expect(bone(head.boxer, "hips").y - bone(body.boxer, "hips").y, punchClass).toBeGreaterThan(0.1); + expect(lean(head.boxer) - lean(body.boxer), punchClass).toBeLessThan(0.06); + } + }); +}); + +describe("the hand that is not punching", () => { + it("is on the jaw from the contact to the end of the punch's active ticks, going with the head", () => { + for (const stance of STANCES) { + for (const [punchClass, hand] of [["jab", leadHand(stance)], ["straight", rearHand(stance)], ["hook", leadHand(stance)], ["uppercut", rearHand(stance)]] as const) { + const { boxer, to, timing } = throwPunch(punchClass, hand, "head", 120, stance); + const other = arm(hand === "left" ? "right" : "left").glove; + to(timing.startup); + let furthest = bone(boxer, other).distanceTo(bone(boxer, "head")); + to(timing.startup + timing.active, () => { furthest = Math.max(furthest, bone(boxer, other).distanceTo(bone(boxer, "head"))); }); + expect(furthest, `${stance} ${punchClass}`).toBeLessThan(0.3); + expect(bone(boxer, other).y, `${stance} ${punchClass}`).toBeGreaterThan(bone(boxer, "neck").y - 0.12); + } + } + }); +}); + +describe("a rear straight", () => { + it("is driven from the ground up: the hips turn ahead of the shoulders and the shoulders ahead of the arm", () => { + for (const stance of STANCES) { + const hand = rearHand(stance); + const { boxer, to, timing } = throwPunch("straight", hand, "head", 150, stance); + const sign = stance === "orthodox" ? 1 : -1; + const hips0 = turnOf(boxer, "hipL", "hipR"); + const shoulders0 = turnOf(boxer, "shoulderL", "shoulderR"); + const reach0 = bone(boxer, arm(hand).glove).z - bone(boxer, arm(hand).shoulder).z; + to(timing.startup * 0.5); + const hipsMid = (turnOf(boxer, "hipL", "hipR") - hips0) * sign; + const shouldersMid = (turnOf(boxer, "shoulderL", "shoulderR") - shoulders0) * sign; + const reachMid = bone(boxer, arm(hand).glove).z - bone(boxer, arm(hand).shoulder).z - reach0; + to(timing.startup); + const hipsEnd = (turnOf(boxer, "hipL", "hipR") - hips0) * sign; + const shouldersEnd = (turnOf(boxer, "shoulderL", "shoulderR") - shoulders0) * sign; + const reachEnd = bone(boxer, arm(hand).glove).z - bone(boxer, arm(hand).shoulder).z - reach0; + // The shoulders pass square and the rear heel has come up off the canvas. + expect(hipsEnd, stance).toBeGreaterThan(0.7); + expect(shouldersEnd, stance).toBeGreaterThan(0.9); + expect(hipsMid / hipsEnd, stance).toBeGreaterThan(shouldersMid / shouldersEnd + 0.1); + expect(shouldersMid / shouldersEnd, stance).toBeGreaterThan(reachMid / reachEnd + 0.1); + const rear = stance === "orthodox" ? "R" : "L"; + expect(bone(boxer, `ankle${rear}`).y, stance).toBeGreaterThan(boxer.rig.metrics.ankleHeight + 0.05); + } + }); + + it("carries on past the target when it misses, and stops on it when it lands", () => { + const reachOf = (units: number): { contact: number; furthest: number } => { + const { boxer, to, timing } = throwPunch("straight", "right", "head", units); + to(timing.startup); + const contact = bone(boxer, "gloveR").z; + let furthest = contact; + to(timing.startup + timing.active + timing.recovery, () => { furthest = Math.max(furthest, bone(boxer, "gloveR").z); }); + return { contact, furthest }; + }; + const landed = reachOf(140); + const missed = reachOf(230); + expect(landed.furthest - landed.contact).toBeLessThan(0.02); + expect(missed.furthest - missed.contact).toBeGreaterThan(0.06); + }); +}); + +describe("guards", () => { + /** Holds `defense` until it has settled and returns the pose. */ + const held = (defense: FighterSnapshot["defense"], stance: Stance): SkinnedBoxer => { + const { boxer, graph } = makeGraph(); + const fighter = { ...standing(stance), defense }; + for (let frame = 0; frame < 60; frame += 1) graph.update(fighter, opponentAt(150), 1 / 60, frame / 60, false, "full", frame / 2, headAt(150)); + return boxer; + }; + + it("hold the high guard as a shell: gloves at the face, forearms upright, elbows in under them", () => { + for (const stance of STANCES) { + const boxer = held("guard_high", stance); + const head = bone(boxer, "head"); + for (const hand of ["left", "right"] as const) { + const bones = arm(hand); + const glove = bone(boxer, bones.glove); + const elbow = bone(boxer, bones.elbow); + const label = `${stance} ${hand}`; + // The wrists sit under the head bone with the gloves standing up in front of the face. + expect(glove.distanceTo(head), label).toBeLessThan(0.34); + expect(glove.z, label).toBeGreaterThan(head.z); + // The forearm is within 45 degrees of upright and the elbow is no wider than the shoulder. + expect(glove.clone().sub(elbow).normalize().y, label).toBeGreaterThan(Math.cos(THREE.MathUtils.degToRad(45))); + expect(Math.abs(elbow.x - head.x), label).toBeLessThan(Math.abs(bone(boxer, bones.shoulder).x - head.x) + 0.06); + } + } + }); + + it("hold the low guard over the body: elbows tucked down on the ribs, gloves still up under the chin, a deeper crouch", () => { + for (const stance of STANCES) { + const high = held("guard_high", stance); + const low = held("guard_low", stance); + for (const hand of ["left", "right"] as const) { + const bones = arm(hand); + const label = `${stance} ${hand}`; + expect(bone(high, bones.elbow).y - bone(low, bones.elbow).y, label).toBeGreaterThan(0.12); + // The gloves stay between the chest and the chin rather than dropping to the hips. + expect(bone(low, bones.glove).y, label).toBeGreaterThan(bone(low, "chest").y + 0.1); + expect(bone(low, bones.glove).y, label).toBeLessThan(bone(low, "head").y); + expect(bone(low, bones.glove).y, label).toBeGreaterThan(bone(low, bones.elbow).y + 0.12); + } + expect(bone(high, "hips").y - bone(low, "hips").y, stance).toBeGreaterThan(0.03); + } + }); + + it("keep the gloves at the face through a slip, a weave and a pull", () => { + for (const stance of STANCES) { + const idle = held("none", stance); + const rest = bone(idle, "gloveR").sub(bone(idle, "head")); + for (const defense of ["slip_left", "slip_right", "pull"] as const) { + const boxer = held(defense, stance); + const label = `${stance} ${defense}`; + const moved = bone(boxer, "head").sub(bone(idle, "head")); + expect(Math.hypot(moved.x, moved.z), label).toBeGreaterThan(0.15); + // The rear glove is where it was against the head, give or take a hand. + expect(bone(boxer, "gloveR").sub(bone(boxer, "head")).distanceTo(rest), label).toBeLessThan(0.1); + } + } + }); +}); + +describe("taking a punch", () => { + /** Two fighters in lockstep, one hit, so the idle sway cancels out: the largest difference `sample` shows over a third of a second. */ + const struck = (react: (graph: BoxingGraph) => void, sample: (boxer: SkinnedBoxer) => number, frames = 20): { most: number; least: number } => { + const hit = makeGraph(); + const reference = makeGraph(); + const fighter = standing("orthodox"); + for (const { graph } of [hit, reference]) for (let frame = 0; frame < 30; frame += 1) graph.update(fighter, opponentAt(150), 1 / 60, frame / 60, false, "full", frame / 2); + react(hit.graph); + let most = -Infinity; + let least = Infinity; + for (let frame = 0; frame < frames; frame += 1) { + for (const { graph } of [hit, reference]) graph.update(fighter, opponentAt(150), 1 / 60, 0.5 + frame / 60, false, "full", 15 + frame / 2); + const difference = sample(hit.boxer) - sample(reference.boxer); + most = Math.max(most, difference); + least = Math.min(least, difference); + } + return { most, least }; + }; + /** How far the face is tipped up, as the height of the head's forward axis. */ + const chinUp = (boxer: SkinnedBoxer): number => new THREE.Vector3(0, 0, 1).applyQuaternion(worldQuaternion(boxer.rig.bones.head, new THREE.Quaternion())).y; + const shoulderTurn = (boxer: SkinnedBoxer): number => turnOf(boxer, "shoulderL", "shoulderR"); + + it("throws the head back, chin up, on a straight and an uppercut, harder for a harder hit", () => { + const light = struck((graph) => graph.react("hit", "head", 1, "straight", "right", 30), chinUp).most; + const heavy = struck((graph) => graph.react("hit", "head", 1, "straight", "right", 140), chinUp).most; + expect(light).toBeGreaterThan(0.05); + expect(heavy).toBeGreaterThan(light * 1.5); + expect(struck((graph) => graph.react("hit", "head", 1, "uppercut", "right", 90), chinUp).most).toBeGreaterThan(0.15); + // The head goes back and the trunk rocks back after it. + expect(struck((graph) => graph.react("hit", "head", 1, "straight", "right", 90), (boxer) => bone(boxer, "head").z).least).toBeLessThan(-0.06); + expect(struck((graph) => graph.react("hit", "head", 1, "straight", "right", 90), (boxer) => bone(boxer, "neck").z).least).toBeLessThan(-0.03); + }); + + it("turns the shoulders the way a hook travelled, either way", () => { + // A left hook comes from his right: his face and chest are turned to his left, the right shoulder coming forward. + expect(struck((graph) => graph.react("hit", "head", 1, "hook", "left", 90), shoulderTurn).most).toBeGreaterThan(0.1); + expect(struck((graph) => graph.react("hit", "head", 1, "hook", "right", 90), shoulderTurn).least).toBeLessThan(-0.1); + }); + + it("buckles the knees under a heavy head shot and not under a light one", () => { + const hips = (boxer: SkinnedBoxer): number => bone(boxer, "hips").y; + expect(struck((graph) => graph.react("hit", "head", 1, "straight", "right", 140), hips).least).toBeLessThan(-0.03); + expect(struck((graph) => graph.react("hit", "head", 1, "jab", "left", 25), hips).least).toBeGreaterThan(-0.01); + }); + + it("jolts the guard back into him and rocks his weight back on a block", () => { + const blocked = (graph: BoxingGraph): void => graph.react("block", "head", 1, "straight", "right", 90); + expect(struck(blocked, (boxer) => bone(boxer, "gloveL").z).least).toBeLessThan(-0.03); + expect(struck(blocked, (boxer) => bone(boxer, "hips").z).least).toBeLessThan(-0.008); + // The head is not snapped as it is by a punch that got through. + const through = struck((graph) => graph.react("hit", "head", 1, "straight", "right", 90), chinUp).most; + expect(struck(blocked, chinUp).most).toBeLessThan(through * 0.6); + }); + + it("still shows on a fighter who is hit in the middle of his own punch", () => { + const thrown = (hit: boolean): number => { + const { boxer, graph, to, timing } = throwPunch("straight", "right", "head", 150); + to(timing.startup - 1); + if (hit) graph.react("hit", "head", 1, "hook", "left", 120); + let furthest = -Infinity; + to(timing.startup + timing.active, () => { furthest = Math.max(furthest, bone(boxer, "head").x); }); + return furthest; + }; + expect(thrown(true) - thrown(false)).toBeGreaterThan(0.05); + }); +}); diff --git a/web/hands/src/render/renderer-carnage.test.ts b/web/hands/src/render/renderer-carnage.test.ts index 9fcbb545..545c5e0a 100644 --- a/web/hands/src/render/renderer-carnage.test.ts +++ b/web/hands/src/render/renderer-carnage.test.ts @@ -22,7 +22,7 @@ const fakeGraph = () => ({ }); const fakeCarnage = () => ({ inflict: vi.fn((..._args: unknown[]) => true), expect: vi.fn(), vomit: vi.fn(), fatality: vi.fn((..._args: unknown[]) => true), die: vi.fn(), undoDeath: vi.fn(), - gibbed: vi.fn(() => false), hasGlove: vi.fn((..._args: unknown[]) => true), + gibbed: vi.fn(() => false), hasGlove: vi.fn((..._args: unknown[]) => true), rebreak: vi.fn((..._args: unknown[]) => false), }); /** A renderer that takes snapshots and stages the end of the bout, with stand-ins for everything drawn. */ @@ -162,7 +162,7 @@ describe("the engine's gore on screen", () => { const { stub, heard } = watching("two"); const torn = combat("injury", { event_id: 9, tick: 40, detail: "arm_left_torn", amount: 200 }); present(stub, torn); - expect(stub.carnage.inflict).toHaveBeenCalledWith(1, "arm_left_torn", 9, expect.anything()); + expect(stub.carnage.inflict).toHaveBeenCalledWith(1, "arm_left_torn", 9, expect.anything(), 40); expect(stub.eventCallout).toMatchObject({ text: "LEFT ARM TORN OFF!" }); expect((stub.eventCallout as { until: number }).until).toBeGreaterThan(5); expect(heard).toEqual([{ kind: "injury", injury: "arm_left_torn" }]); diff --git a/web/hands/src/render/renderer-frame.test.ts b/web/hands/src/render/renderer-frame.test.ts index 767e07f5..0e00f2b2 100644 --- a/web/hands/src/render/renderer-frame.test.ts +++ b/web/hands/src/render/renderer-frame.test.ts @@ -29,6 +29,7 @@ type Settings = { reducedMotion: boolean; blood: "full" | "reduced" | "off"; cam function graph() { return { boxer: { root: new THREE.Object3D(), bone: () => null, setLook: vi.fn(), metrics: { headRestY: 1.52 }, rig: { bones: { gloveL: new THREE.Object3D(), gloveR: new THREE.Object3D() } } }, + standLike: vi.fn(), awaitVerdict: vi.fn(), announce: vi.fn(), setResting: vi.fn(), @@ -109,6 +110,7 @@ function frame(state: EngineSnapshot, overrides: Record = {}) { updateCornermen: vi.fn(), updateCutmen: vi.fn(), updateBlobShadows: vi.fn(), + updateFootShadows: vi.fn(), fireContacts: vi.fn(), followSpot: null, director: new CameraDirector(), diff --git a/web/hands/src/render/renderer-mechanics.test.ts b/web/hands/src/render/renderer-mechanics.test.ts index 54bbfd4e..fd0c6684 100644 --- a/web/hands/src/render/renderer-mechanics.test.ts +++ b/web/hands/src/render/renderer-mechanics.test.ts @@ -34,6 +34,7 @@ function pushStub(graphs: [FakeGraph, FakeGraph]): Record { contactPoint: new THREE.Vector3(), pendingContacts: [] as unknown[], effects: { addEvent: vi.fn() }, + carnage: { rebreak: vi.fn() }, manualClock: true, lastManualTime: 0, lastKnockdown: null, diff --git a/web/hands/src/render/renderer-scene.test.ts b/web/hands/src/render/renderer-scene.test.ts index 966120f6..35a3603d 100644 --- a/web/hands/src/render/renderer-scene.test.ts +++ b/web/hands/src/render/renderer-scene.test.ts @@ -23,6 +23,7 @@ function graph() { rig: { bones: { gloveL: new THREE.Object3D(), gloveR: new THREE.Object3D(), hips: new THREE.Object3D(), upperChest: new THREE.Object3D(), shoulderL: new THREE.Object3D(), shoulderR: new THREE.Object3D() } }, headInjury: new InjuryShading(null, HEAD_SITES), bodyInjury: new InjuryShading(null, BODY_SITES, { core: BODY_SWELL_CORE, wash: true }), }, + standLike: vi.fn(), setResting: vi.fn(), setCountdown: vi.fn(), setObstacle: vi.fn(), @@ -100,6 +101,7 @@ function frame(state: EngineSnapshot, overrides: Record = {}) { updateCornermen: vi.fn(), updateCutmen: vi.fn(), updateBlobShadows: vi.fn(), + updateFootShadows: vi.fn(), fireContacts: vi.fn(), followSpot: null, director: new CameraDirector(), diff --git a/web/hands/src/render/renderer.ts b/web/hands/src/render/renderer.ts index 5fa8504c..9a9c0275 100644 --- a/web/hands/src/render/renderer.ts +++ b/web/hands/src/render/renderer.ts @@ -226,6 +226,8 @@ const CORNERMAN_WORK_DISTANCE = 2.95; const REFEREE_BREAK_SPEED = 2.4; const CUTMAN_WALK_SECONDS = 1.6; const CUTMAN_IN_PLACE = 0.98; +/** The cut trauma at which a cutman works his fastest. */ +const CUTMAN_URGENT_CUT = 500; // Broadcast finish: a soft vignette and a whisper of grain, applied before tone mapping. const BROADCAST_FINISH_SHADER = { uniforms: { tDiffuse: { value: null }, uTime: { value: 0 }, uVignette: { value: 0.32 }, uGrain: { value: 0.035 }, uRocked: { value: 0 } }, @@ -512,6 +514,15 @@ function blobShadowTexture(): THREE.CanvasTexture { return new THREE.CanvasTexture(canvas); } +/** A boot's patch of shadow is this wide, and gone once the ankle is this far above where it rests. */ +const FOOT_SHADOW_SIZE = 0.42; +const FOOT_SHADOW_LIFT = 0.16; + +/** How dark the canvas is under a boot whose ankle is `lift` metres above its rest height. */ +export function footShadowOpacity(lift: number): number { + return 0.9 * THREE.MathUtils.clamp(1 - lift / FOOT_SHADOW_LIFT, 0, 1); +} + /** A severed head turns about the middle of the skull: this far from the head bone, in the bone's frame. */ const HEAD_PIVOT_OFFSET = new THREE.Vector3(0, 0.12, 0.02); const UP = new THREE.Vector3(0, 1, 0); @@ -1200,6 +1211,9 @@ export class FightRenderer { private cameraOverride: { position: THREE.Vector3; lookAt: THREE.Vector3 } | null = null; private readonly manualClock: boolean; private readonly blobShadows: THREE.Mesh[] = []; + /** The dark patch on the canvas under each boot: fighter one's left and right, then fighter two's. */ + private readonly footShadows: THREE.Mesh[] = []; + private readonly footPoint = new THREE.Vector3(); private readonly blobTexture: THREE.CanvasTexture; private readonly lights: THREE.Light[] = []; private keyLight: THREE.SpotLight | null = null; @@ -1408,10 +1422,21 @@ export class FightRenderer { this.blobShadows.push(blob); this.scene.add(blob); } + for (let i = 0; i < 4; i += 1) { + const contact = new THREE.Mesh(blobGeometry, new THREE.MeshBasicMaterial({ map: this.blobTexture, transparent: true, depthWrite: false })); + contact.rotation.x = -Math.PI / 2; + contact.position.y = 0.0075 + i * 0.0004; + contact.scale.set(FOOT_SHADOW_SIZE, FOOT_SHADOW_SIZE, 1); + contact.renderOrder = 1; + contact.visible = false; + this.footShadows.push(contact); + this.scene.add(contact); + } this.composer = new EffectComposer(this.renderer); this.composer.addPass(new RenderPass(this.scene, this.camera)); - const bloom = new UnrealBloomPass(new THREE.Vector2(1280, 720), 0.2, 0.45, 1.08); + // The threshold is above the lit canvas, so only the highlights on sweat, leather and the ropes glow. + const bloom = new UnrealBloomPass(new THREE.Vector2(1280, 720), 0.22, 0.35, 1.5); this.bloomPass = bloom; this.composer.addPass(bloom); this.finishPass = new ShaderPass(BROADCAST_FINISH_SHADER); @@ -1463,6 +1488,7 @@ export class FightRenderer { // compile where available) so neither the first frame with fighters nor the first bloody hit stalls the page. const staging = new THREE.Group(); staging.add(first.root, second.root, official.root, blueCorner.root, redCorner.root, blueCutman.root, redCutman.root, ...this.trails.map((trail) => trail.mesh), ...this.effects.compileStandIns(), ...mutilations.flatMap((mutilation) => mutilation.compileStandIns()), this.glows[0]!.standIn(), ...this.impactFlashes[0]!.standIns()); + staging.add(this.carnage.xray.standIn()); // A finisher opens a head, which a shader of its own draws, and another its shadow: the first // fighter's head is opened for the warm-up and closed again before it is drawn. const opened = first.headInjury.open; @@ -1755,7 +1781,7 @@ export class FightRenderer { private presentFinish(final: FinalMessage): void { const refereeDead = this.buffer.latest()?.referee.alive === false; - if (!refereeDead) this.referee?.waveOff(); + if (!refereeDead) this.referee?.waveOff(undefined, final.method === "death"); const fighters = this.buffer.latest()?.fighters; const loserIndex = fighters?.findIndex((fighter) => fighter.player_id !== final.winner_id && fighter.player_id !== null) ?? -1; // A man blown to pieces has no face left to close in on. @@ -2120,6 +2146,7 @@ export class FightRenderer { const spray = sprayDirection(snapshot.fighters[puncherIndex], recipient, this.mapping); this.contactOn(recipientIndex, recipient, event.detail.endsWith(":body"), spray, event.direction); this.effects.addEvent(event, this.contactPoint, this.settings().reducedMotion, spray); + this.carnage.rebreak(recipientIndex, event.tick); const puncher = puncherIndex >= 0 ? snapshot.fighters[puncherIndex] : undefined; const keyParts = puncher?.action_key?.split(":") ?? []; const punchClass = (keyParts[0] ?? null) as PunchClass | null; @@ -2640,6 +2667,8 @@ export class FightRenderer { graphs[recipientIndex]!.react(blocked ? "block" : "hit", targetKind, presentationEvent.direction, punchClass, punchHand, reactAmount); // A left hand lands on the right side of his head, where an eye hanging out of its socket bursts. if (isHit(event) && targetKind === "head" && punchHand !== null) this.carnage.punched(recipientIndex, punchHand === "left" ? "right" : "left", event.event_id); + // The punch stays on both of them: its mark where the glove landed, the blood it threw, and what it squeezed from wounds already open. + if (isHit(event) && punchHand !== null) this.carnage.land(recipientIndex, puncherIndex, punchHand, targetKind, event.amount, event.blood, this.contactPoint, event.event_id, spray ?? presentationEvent.direction); if (this.flashKnockout?.hitEventId === event.event_id) graphs[recipientIndex]!.knockOut(); } } @@ -2696,7 +2725,7 @@ export class FightRenderer { this.announceDeath(index); } else if (event.kind === "injury" && isInjuryId(event.detail)) { const injury = event.detail; - if (!this.carnage.inflict(index, injury, event.event_id, direction)) return; + if (!this.carnage.inflict(index, injury, event.event_id, direction, event.tick)) return; this.eventCallout = { text: `${injuryLabel(injury)}!`, until: this.frameSeconds + INJURY_CALLOUT_SECONDS }; this.arena.excite(INJURY_EXCITEMENT); const own = this.viewerId !== null && fighters[index]!.player_id === this.viewerId; @@ -2887,13 +2916,18 @@ export class FightRenderer { this.effects.setLowTier(low); } + /** + * A boxing ring's light: one warm key from the rig over the camera side that throws the only shadows, a weak + * cool fill from the other side so those shadows keep their depth, two cold rims from behind that edge the + * fighters off the crowd, and a spot behind and above that follows them and lights their heads and shoulders. + */ private setupLights(): void { - const hemisphere = new THREE.HemisphereLight("#3c4a72", "#07080c", 0.55); + const hemisphere = new THREE.HemisphereLight("#33416c", "#3b2c20", 0.6); this.scene.add(hemisphere); this.lights.push(hemisphere); - const key = new THREE.SpotLight("#fff1dc", 150, 24, 0.56, 0.55, 1.7); - key.position.set(0.6, 7.4, 1.2); + const key = new THREE.SpotLight("#fff0da", 185, 26, 0.56, 0.6, 1.7); + key.position.set(0.9, 7.2, 4.4); key.target.position.set(0, 0.6, 0); key.castShadow = true; key.shadow.mapSize.set(2048, 2048); @@ -2904,26 +2938,26 @@ export class FightRenderer { this.scene.add(key, key.target); this.lights.push(key); - const secondary = new THREE.SpotLight("#ffe6c8", 95, 24, 0.6, 0.6, 1.7); - secondary.position.set(-2.6, 7.0, -2.2); + const secondary = new THREE.SpotLight("#cfdcff", 55, 24, 0.6, 0.7, 1.7); + secondary.position.set(-3.6, 5.5, 2.2); secondary.target.position.set(0, 0.8, 0); this.scene.add(secondary, secondary.target); this.lights.push(secondary); const rims: Array<[string, number, number, number]> = [ - ["#8fa8ff", -5.5, 3.8, -5.4], - ["#7f95e8", 5.6, 3.6, -5.6], + ["#a9c0ff", -5.2, 3.4, -4.6], + ["#9db4ff", 5.2, 3.4, -4.6], ]; for (const [color, x, y, z] of rims) { - const rim = new THREE.SpotLight(color, 34, 30, 0.72, 0.9, 1.8); + const rim = new THREE.SpotLight(color, 170, 30, 0.6, 0.9, 1.8); rim.position.set(x, y, z); rim.target.position.set(0, 1.2, 0); this.scene.add(rim, rim.target); this.lights.push(rim); } - const follow = new THREE.SpotLight("#ffe8d0", 48, 22, 0.32, 0.8, 1.5); - follow.position.set(0, 5.8, 5.4); + const follow = new THREE.SpotLight("#e4ecff", 85, 22, 0.3, 0.8, 1.5); + follow.position.set(0, 6.4, -4.4); follow.target.position.set(0, 1, 0); this.scene.add(follow, follow.target); this.lights.push(follow); @@ -3137,6 +3171,7 @@ export class FightRenderer { this.updateCornermen(actorDt, seconds, snapshot, sampledTick); this.updateCutmen(actorDt, seconds, snapshot, sampledTick); this.updateBlobShadows(); + this.updateFootShadows(); this.fireContacts(sampledTick); if (this.replay === null) this.fireGore(sampledTick); this.presentFinishWhenShown(sampledTick); @@ -3193,6 +3228,8 @@ export class FightRenderer { if (render) { this.composer.render(); + // The cut-in of a breaking bone costs a second pass over the scene: a client at the bottom of the scale goes without. + if (this.bloomPass.enabled) this.carnage.drawBreak(this.renderer, this.scene, this.camera, this.arena.group); this.drawHudOverlay(snapshot); } @@ -3246,6 +3283,7 @@ export class FightRenderer { if (this.lookIds[index] === playerId) return; this.lookIds[index] = playerId; this.graphs?.[index]?.boxer.setLook(lookFor(playerId)); + this.graphs?.[index]?.standLike(playerId); } /** @@ -3426,6 +3464,23 @@ export class FightRenderer { } } + /** + * Darkens the canvas under each boot and lets it go as the boot lifts, so a planted foot looks planted and a + * step looks like one. It needs no shadow map, so it grounds the fighters on the low tier too. + */ + private updateFootShadows(): void { + for (const [index, contact] of this.footShadows.entries()) { + const seat = index >> 1; + const boxer = this.graphs?.[seat]?.boxer; + contact.visible = boxer !== undefined && boxer.root.visible && !this.carnage.gibbed(seat); + if (boxer === undefined || !contact.visible) continue; + boxer.rig.bones[index % 2 === 0 ? "ankleL" : "ankleR"].getWorldPosition(this.footPoint); + contact.position.x = this.footPoint.x; + contact.position.z = this.footPoint.z; + (contact.material as THREE.MeshBasicMaterial).opacity = footShadowOpacity(this.footPoint.y - boxer.metrics.ankleRestY); + } + } + private updateReferee(dt: number, time: number, snapshot: EngineSnapshot | null, sampledTick: number): void { const referee = this.referee; if (referee === null) return; @@ -3583,7 +3638,12 @@ export class FightRenderer { this.refereeYaw += yawDelta * (1 - Math.exp(-(breaking ? 8 : 3) * dt)); const state = refereeSnapshot(this.refereePosition, this.refereeYaw, this.refereeVelocity, this.mapping, official); referee.setRefereeCount(counted !== null, counted?.get_up_count ?? 0); - referee.aimBreak(this.tmpA, this.tmpB); + // His eyes stay on a man he counts over, down on the canvas or back on his feet, and on one in trouble. His way + // off the action is settled by now, so its vector carries the point. + const hurt = counted === null ? snapshot?.fighters.findIndex((fighter) => fighter.stunned_ticks > 0) ?? -1 : -1; + const hurtAt = hurt === 0 ? this.tmpA : this.tmpB; + const watched = counted !== null ? away.set(focusX, counted.is_downed ? 0.25 : 1.5, focusZ) : hurt >= 0 ? away.set(hurtAt.x, 1.5, hurtAt.z) : null; + referee.aimBreak(this.tmpA, this.tmpB, watched, snapshot?.phase === "finish" ? "stand_back" : "watch"); // He bleeds at the blood level the player chose, and falls the way reduced motion asks. const settings = this.settings(); referee.update(state.self, state.focus, dt, time, settings.reducedMotion, settings.blood, sampledTick); @@ -3659,12 +3719,16 @@ export class FightRenderer { const cornermen = this.cornermen; if (cornermen === null) return; const resting = cornersAtWork(snapshot, this.simulation.tick_rate); + const over = snapshot?.phase === "complete" ? this.final : null; for (const [index, graph] of cornermen.entries()) { const sign = index === 0 ? -1 : 1; - const reach = resting ? CORNERMAN_WORK_DISTANCE : CORNERMAN_APRON_DISTANCE; + // With the bout over he is at the ropes for a fighter who died or who won. + const mood = over === null ? "work" : this.deaths[index] !== null ? "mourn" : over.winner_id !== null && over.winner_id === snapshot?.fighters[index]?.player_id ? "cheer" : "work"; + const attending = resting || mood !== "work"; + const reach = attending ? CORNERMAN_WORK_DISTANCE : CORNERMAN_APRON_DISTANCE; this.cornermanPosition.set(sign * reach, 0, -sign * reach); const yaw = index === 0 ? (3 * Math.PI) / 4 : -Math.PI / 4; - graph.attend(resting); + graph.attend(attending, mood); const state = refereeSnapshot(this.cornermanPosition, yaw, this.cornermanVelocity, this.mapping); graph.update(state.self, state.focus, dt, time, false, "off", sampledTick); } @@ -3709,7 +3773,9 @@ export class FightRenderer { this.cutmanEye.x += Math.cos(fighterYaw) * work.side * work.lateral; this.cutmanEye.z -= Math.sin(fighterYaw) * work.side * work.lateral; this.cutmanEye.y += work.lift; - graph.treat(this.cutmanEye, this.cutmanFacing, work.side, work.prop); + const cuts = snapshot?.fighters[index]?.trauma; + const urgency = cuts === undefined || work.prop === "bottle" ? 0 : Math.min(1, Math.max(cuts.left_cut, cuts.right_cut) / CUTMAN_URGENT_CUT); + graph.treat(this.cutmanEye, this.cutmanFacing, work.side, work.prop, urgency); } else { graph.treat(null); } @@ -3860,7 +3926,7 @@ export class FightRenderer { this.keyLight?.shadow.map?.dispose(); this.keyLight?.shadow.dispose(); this.blobTexture.dispose(); - for (const blob of this.blobShadows) { + for (const blob of [...this.blobShadows, ...this.footShadows]) { this.scene.remove(blob); blob.geometry.dispose(); (blob.material as THREE.Material).dispose(); diff --git a/web/hands/src/render/ring.ts b/web/hands/src/render/ring.ts index 0245e411..a1616d47 100644 --- a/web/hands/src/render/ring.ts +++ b/web/hands/src/render/ring.ts @@ -173,7 +173,8 @@ export function buildRing(): BuiltRing { const canvasMap = ringCanvasTexture(); textures.push(canvasMap); - const canvasMat = new THREE.MeshStandardMaterial({ map: canvasMap, roughness: 0.88, metalness: 0 }); + // The canvas is the brightest thing under the lights: toned down so it holds its markings and the fighters' shadows. + const canvasMat = new THREE.MeshStandardMaterial({ map: canvasMap, color: "#c8c2b8", roughness: 0.84, metalness: 0 }); materials.push(canvasMat); const canvasGeo = new THREE.PlaneGeometry(RING_FIGHT_HALF * 2, RING_FIGHT_HALF * 2); geometries.push(canvasGeo); diff --git a/web/hands/src/render/skin.ts b/web/hands/src/render/skin.ts new file mode 100644 index 00000000..ef2e523c --- /dev/null +++ b/web/hands/src/render/skin.ts @@ -0,0 +1,42 @@ +import * as THREE from "three"; + +/** + * How a fighter's skin takes each light, on top of three's own surface. Light scatters under skin, so it + * carries a little way past the edge of a shadow and comes back out red, where a hard surface goes straight + * to black; and the fine hair and sweat on it catch a light at a grazing angle, which edges a shoulder or a + * jaw in the colour of the rim lights behind it. Exported so a test can read it. + */ +export const SKIN_LIGHT_GLSL = /* glsl */ ` +void RE_Direct_Skin( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + RE_Direct_Physical( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + float facing = dot( geometryNormal, directLight.direction ); + float scattered = saturate( ( facing + 0.45 ) / 1.45 ) - saturate( facing ); + reflectedLight.directDiffuse += directLight.color * BRDF_Lambert( material.diffuseColor ) * vec3( 1.0, 0.34, 0.2 ) * scattered; + float grazing = 1.0 - saturate( dot( geometryNormal, geometryViewDir ) ); + grazing *= grazing * grazing; + reflectedLight.directSpecular += directLight.color * saturate( facing + 0.15 ) * grazing * 0.05; +} +#undef RE_Direct +#define RE_Direct RE_Direct_Skin +`; + +/** + * The scanned skin textures carry the shading of the muscles under the light they were scanned in. Read as + * height, that relief tilts each pixel's normal, so a moving light catches the muscles instead of sliding + * over a smooth shell. + */ +const SKIN_RELIEF = 0.35; + +/** Gives a fighter's skin its scattering, its rim and its relief. Composes with a shader patch already on the material. */ +export function lightSkin(material: THREE.MeshStandardMaterial): void { + material.bumpMap = material.map; + material.bumpScale = SKIN_RELIEF; + const before = material.onBeforeCompile; + const beforeKey = Object.hasOwn(material, "customProgramCacheKey") ? material.customProgramCacheKey() : "plain"; + material.onBeforeCompile = (shader, renderer) => { + before.call(material, shader, renderer); + shader.fragmentShader = shader.fragmentShader.replace("#include ", `#include \n${SKIN_LIGHT_GLSL}`); + }; + material.customProgramCacheKey = () => `${beforeKey}-skin`; + material.needsUpdate = true; +} diff --git a/web/hands/src/render/trunks.ts b/web/hands/src/render/trunks.ts new file mode 100644 index 00000000..107911f9 --- /dev/null +++ b/web/hands/src/render/trunks.ts @@ -0,0 +1,64 @@ +import * as THREE from "three"; +import { BONE_ADAPTER } from "./skeleton"; + +/** + * The scanned trunks hang past the knee and stand five centimetres clear of the thigh all round, so in a + * boxer's crouch they read as a skirt and hide the legs. They are taken in once, in bind space (centimetres, + * +Z the front): each leg is shortened to end above the knee and drawn in toward its thigh, most at the seat + * and least at the front, and the waistband is left as it was. + */ +const HIP = { x: 7, y: 66.1, z: -3 } as const; +const KNEE = { x: 8.4, y: 39.4, z: -4.7 } as const; +const SCANNED_HEM = 36.1; +/** The scan left the legs open under the trunks: the skin of a thigh starts at 49, which the hem has to stay below. */ +export const TRUNKS_HEM = 44.5; +/** Only the legs are shortened: nothing at or above the crotch moves up. */ +const LEG_TOP = 62; +/** The legs are taken in fully below this height, and not at all from the waistband up. */ +const SLIM_FULL = 58; +const SLIM_NONE = 72; +const SLIM_OUTSIDE = 0.78; +const SLIM_FRONT = 0.85; +const SLIM_BACK = 0.66; + +const smoothstep = (edge0: number, edge1: number, value: number): number => { + const t = THREE.MathUtils.clamp((value - edge0) / (edge1 - edge0), 0, 1); + return t * t * (3 - 2 * t); +}; +const lerp = THREE.MathUtils.lerp; + +/** + * A tailored copy of the scanned trunks. The hem ends above the knee now, so everything the shin carried is + * carried by the thigh instead: a bent knee no longer drags the hem with it. `bones` are the skeleton's + * bone names in the order the skin indices count them. + */ +export function tailorTrunks(scanned: THREE.BufferGeometry, bones: readonly string[]): THREE.BufferGeometry { + const geometry = scanned.clone(); + const position = geometry.getAttribute("position"); + const skinIndex = geometry.getAttribute("skinIndex"); + const thighOf = new Map([ + [bones.indexOf(BONE_ADAPTER.kneeL!), bones.indexOf(BONE_ADAPTER.hipL!)], + [bones.indexOf(BONE_ADAPTER.kneeR!), bones.indexOf(BONE_ADAPTER.hipR!)], + ]); + for (let vertex = 0; vertex < position.count; vertex += 1) { + let x = position.getX(vertex); + let y = position.getY(vertex); + let z = position.getZ(vertex); + if (y < LEG_TOP) y = LEG_TOP - (LEG_TOP - y) * ((LEG_TOP - TRUNKS_HEM) / (LEG_TOP - SCANNED_HEM)); + const slim = 1 - smoothstep(SLIM_FULL, SLIM_NONE, y); + const along = THREE.MathUtils.clamp((HIP.y - y) / (HIP.y - KNEE.y), 0, 1); + const axisX = lerp(HIP.x, KNEE.x, along); + const axisZ = lerp(HIP.z, KNEE.z, along); + const outside = Math.abs(x) - axisX; + if (outside > 0) x = Math.sign(x) * (axisX + outside * lerp(1, SLIM_OUTSIDE, slim)); + z = axisZ + (z - axisZ) * lerp(1, z > axisZ ? SLIM_FRONT : SLIM_BACK, slim); + position.setXYZ(vertex, x, y, z); + for (let influence = 0; influence < skinIndex.itemSize; influence += 1) { + const thigh = thighOf.get(skinIndex.getComponent(vertex, influence)); + if (thigh !== undefined) skinIndex.setComponent(vertex, influence, thigh); + } + } + geometry.computeBoundingBox(); + geometry.computeBoundingSphere(); + return geometry; +} diff --git a/web/hands/src/render/xray.test.ts b/web/hands/src/render/xray.test.ts new file mode 100644 index 00000000..9bad08f3 --- /dev/null +++ b/web/hands/src/render/xray.test.ts @@ -0,0 +1,350 @@ +import * as THREE from "three"; +import { HapticFeedback } from "../haptics"; +import { INJURY_IDS, type InjuryId } from "../injuries"; +import type { BloodLevel, Settings } from "../settings"; +import { fighter as baseFighter } from "../test/fixtures"; +import type { FighterSnapshot } from "../types"; +import { Carnage } from "./carnage"; +import { Effects3D } from "./effects"; +import { BoxingGraph, SkinnedBoxer, loadBoxerGlb } from "./graph"; +import { EYE_LIDS, RIB_ENDS } from "./injury"; +import { bakeFlungPiece } from "./renderer"; +import { worldMapping } from "./world"; +import { XRAY_SECONDS, XRAY_SNAP_SECONDS, breakFor } from "./xray"; + +const mapping = worldMapping({ tick_rate: 30, ring_half_width: 500, ring_half_height: 500 }); +const gltf = await loadBoxerGlb(); + +const stands: readonly [FighterSnapshot, FighterSnapshot] = [ + { ...baseFighter("one"), facing_x: 0, facing_y: -1000, x: 0, y: 0 }, + { ...baseFighter("two"), x: 0, y: -150, facing_x: 0, facing_y: 1000 }, +]; + +/** Both fighters posed and shown the way the renderer does it, sixty times a second, with everything real but the GPU. */ +class Ring { + readonly effects = new Effects3D(new THREE.Scene()); + readonly carnage = new Carnage(this.effects, bakeFlungPiece); + readonly boxers = [new SkinnedBoxer(gltf, { skin: 0xb0703f, gear: 0x1d4ed8 }), new SkinnedBoxer(gltf, { skin: 0x6b4226, gear: 0xb91c1c })] as const; + readonly graphs = this.boxers.map((boxer) => new BoxingGraph(boxer, mapping)); + readonly mutilations = this.graphs.map((graph, index) => this.carnage.attach(index, graph)); + readonly injuries: [InjuryId[], InjuryId[]] = [[], []]; + readonly blood: [number, number] = [1000, 1000]; + frame = 0; + + constructor(readonly settings: { blood: BloodLevel; reducedMotion: boolean } = { blood: "full", reducedMotion: false }) { + this.effects.setBloodLevel(settings.blood); + this.step(2); + } + + step(frames = 1): this { + for (let count = 0; count < frames; count += 1) { + const seconds = this.frame / 60; + for (const index of [0, 1] as const) { + this.graphs[index]!.update(stands[index], stands[1 - index]!, 1 / 60, seconds, this.settings.reducedMotion, this.settings.blood, this.frame / 2); + this.carnage.sync(index, { injuries: this.injuries[index], blood_volume: this.blood[index] }, this.settings, 1 / 60, seconds); + } + this.effects.update(1 / 60); + this.frame += 1; + } + return this; + } + + /** Where a wound of fighter `index` is in the world now. */ + at(index: number, site: Parameters[0]): THREE.Vector3 { + const position = new THREE.Vector3(); + this.mutilations[index]!.anchor(site, position, new THREE.Vector3()); + return position; + } + + dispose(): void { + this.carnage.dispose(); + this.effects.dispose(); + } +} + +const seconds = (duration: number): number => Math.ceil(duration * 60); +const shown = (boxer: SkinnedBoxer): number => Math.max(boxer.headInjury.uniforms.uInjuryXrayShown.value, boxer.bodyInjury.uniforms.uInjuryXrayShown.value); + +describe("the X-ray of a breaking bone", () => { + it("breaks a bone for every injury that is one, and for no injury of the flesh", () => { + expect(INJURY_IDS.filter((injury) => breakFor(injury) !== null)).toEqual([ + "broken_nose", "broken_jaw", "skull_fractured", "shoulder_left_dislocated", "shoulder_right_dislocated", "arm_left_broken", "arm_right_broken", + "ribs_left_broken", "ribs_right_broken", "knee_left_blown", "knee_right_blown", + ]); + expect(breakFor("ribs_right_broken")).toBe("ribs_right"); + expect(breakFor("arm_left_torn")).toBeNull(); + }); + + it("shows his skeleton through the skin as the bone goes, snaps it a moment later, and then gives the skin back", () => { + const ring = new Ring(); + const xray = ring.carnage.xray; + expect(xray.root.visible).toBe(false); + expect(ring.carnage.inflict(1, "ribs_left_broken", 5, 1, 40)).toBe(true); + ring.step(); + expect([xray.owner, xray.breaking, xray.root.visible, xray.snapped]).toEqual([1, "ribs_left", true, false]); + expect(shown(ring.boxers[1])).toBeGreaterThan(0); + // Only the man whose bone it is goes glassy. + expect(shown(ring.boxers[0])).toBe(0); + const before = xray.root.children.filter((bone) => bone.visible).length; + ring.step(seconds(XRAY_SNAP_SECONDS) + 2); + expect(xray.snapped).toBe(true); + // Chips of bone and beads of marrow have left the break. + expect(xray.root.children.filter((bone) => bone.visible).length).toBeGreaterThan(before); + ring.step(seconds(XRAY_SECONDS)); + expect([xray.owner, xray.breaking, xray.root.visible]).toEqual([-1, null, false]); + expect(shown(ring.boxers[1])).toBe(0); + // It is shown once: the snapshot that lists the injury later starts nothing. + ring.injuries[1] = ["ribs_left_broken"]; + ring.step(4); + expect(xray.owner).toBe(-1); + ring.dispose(); + }); + + it("lies inside him as he is posed: every bone finite and within his reach, the window on the joint that broke", () => { + const ring = new Ring(); + ring.carnage.inflict(0, "knee_right_blown", 5, 1, 40); + ring.step(seconds(XRAY_SNAP_SECONDS) + 4); + ring.carnage.xray.root.updateMatrixWorld(true); + const hips = ring.boxers[0].rig.bones.hips.getWorldPosition(new THREE.Vector3()); + const at = new THREE.Vector3(); + const bones = ring.carnage.xray.root.children.filter((bone) => bone.visible); + expect(bones.length).toBeGreaterThan(20); + for (const bone of bones) { + at.setFromMatrixPosition(bone.matrixWorld); + expect(Number.isFinite(at.x + at.y + at.z)).toBe(true); + expect(at.distanceTo(hips)).toBeLessThan(1.3); + } + const material = (bones[0] as THREE.Mesh).material as THREE.ShaderMaterial; + const knee = ring.boxers[0].rig.bones.kneeR.getWorldPosition(new THREE.Vector3()); + expect((material.uniforms.uCenter!.value as THREE.Vector3).distanceTo(knee)).toBeLessThan(1e-6); + // The skin goes glassy round the same joint: in bind space, on his right leg and below the trunks. + const window = ring.boxers[0].bodyInjury.uniforms.uInjuryXray.value; + expect(window.x).toBeLessThan(-3); + expect(window.y).toBeLessThan(60); + expect(window.w).toBeGreaterThan(10); + ring.dispose(); + }); + + it.each([["reduced", false], ["off", false], ["full", true]] as const)("is not shown with blood %s and reduced motion %s", (blood, reducedMotion) => { + const ring = new Ring({ blood, reducedMotion }); + expect(ring.carnage.inflict(0, "broken_jaw", 5, 1, 40)).toBe(true); + ring.step(3); + expect(ring.carnage.xray.owner).toBe(-1); + expect(shown(ring.boxers[0])).toBe(0); + expect(ring.carnage.rebreak(0, 40)).toBe(false); + ring.dispose(); + }); + + it("is taken down at once when the blood is turned down while it shows", () => { + const ring = new Ring(); + ring.carnage.inflict(0, "skull_fractured", 5, 1, 40); + ring.step(3); + expect(ring.carnage.xray.owner).toBe(0); + ring.settings.blood = "reduced"; + ring.step(); + expect(ring.carnage.xray.owner).toBe(-1); + expect(shown(ring.boxers[0])).toBe(0); + ring.dispose(); + }); + + it("is shown again when the knockout replay reaches the punch that broke the bone, and for no other punch", () => { + const ring = new Ring(); + ring.carnage.inflict(1, "broken_jaw", 5, { x: 0, z: 1 }, 40); + ring.step(seconds(XRAY_SECONDS) + 4); + expect(ring.carnage.xray.owner).toBe(-1); + expect(ring.carnage.rebreak(1, 39)).toBe(false); + expect(ring.carnage.rebreak(0, 40)).toBe(false); + expect(ring.carnage.rebreak(1, 40)).toBe(true); + ring.step(); + expect([ring.carnage.xray.owner, ring.carnage.xray.breaking]).toEqual([1, "jaw"]); + // A replay that rewinds to before a death takes it down with everything else. + ring.carnage.undoDeath(1); + expect(ring.carnage.xray.owner).toBe(-1); + ring.dispose(); + }); +}); + +describe("the fight on their skin", () => { + it("leaves a punch's mark where the glove landed: a welt that darkens to a bruise, and splits when it is hit again", () => { + const ring = new Ring(); + const head = ring.boxers[1].headInjury; + const eye = EYE_LIDS[0]!; + expect(head.markAt(eye[0], eye[1], eye[2])).toBe(0); + ring.carnage.land(1, 0, null, "head", 200, 0, ring.at(1, "eye_left")); + const fresh = head.markAt(eye[0], eye[1], eye[2]); + expect(fresh).toBeGreaterThan(0.3); + expect(fresh).toBeLessThan(0.5); + expect(head.wounded).toBe(true); + // Nothing lands on the other eye, or on the body. + expect(head.markAt(EYE_LIDS[1]![0], EYE_LIDS[1]![1], EYE_LIDS[1]![2])).toBe(0); + expect(ring.boxers[1].bodyInjury.wounded).toBe(false); + ring.step(seconds(40)); + const bruised = head.markAt(eye[0], eye[1], eye[2]); + expect(bruised).toBeGreaterThan(0.8); + expect(bruised).toBeLessThan(1); + ring.carnage.land(1, 0, null, "head", 200, 0, ring.at(1, "eye_left")); + expect(head.markAt(eye[0], eye[1], eye[2])).toBeGreaterThan(1); + // A body shot marks the ribs it lands on. + const ribs = RIB_ENDS[1]!; + ring.carnage.land(1, 0, null, "body", 500, 0, ring.at(1, "ribs_left")); + expect(ring.boxers[1].bodyInjury.markAt(ribs[0], ribs[1], ribs[2])).toBeGreaterThan(0.5); + ring.dispose(); + }); + + it("marks the skin under the glove that threw the punch", () => { + const ring = new Ring(); + // Fighter one's left glove is held against fighter two's left ribs. + ring.boxers[0].rig.bones.gloveL.getWorldPosition(new THREE.Vector3()); + const glove = ring.at(1, "ribs_left"); + const bone = ring.boxers[0].rig.bones.gloveL; + bone.parent!.worldToLocal(bone.position.copy(glove)); + bone.updateMatrixWorld(true); + ring.carnage.land(1, 0, "left", "body", 300, 0, new THREE.Vector3(9, 9, 9)); + const ribs = RIB_ENDS[1]!; + expect(ring.boxers[1].bodyInjury.markAt(ribs[0], ribs[1], ribs[2])).toBeGreaterThan(0); + ring.dispose(); + }); + + it("keeps no marks with blood off", () => { + const ring = new Ring({ blood: "off", reducedMotion: false }); + ring.carnage.land(1, 0, null, "head", 200, 100, ring.at(1, "eye_left")); + ring.step(2); + expect(ring.boxers[1].headInjury.wounded).toBe(false); + const full = new Ring(); + full.carnage.land(1, 0, null, "head", 200, 100, full.at(1, "eye_left")); + full.settings.blood = "off"; + full.step(2); + const eye = EYE_LIDS[0]!; + expect(full.boxers[1].headInjury.markAt(eye[0], eye[1], eye[2])).toBe(0); + ring.dispose(); + full.dispose(); + }); + + it("throws a punch's blood on both men, more on the one who threw it, and it stays and soaks his gear", () => { + const ring = new Ring(); + for (let punch = 0; punch < 6; punch += 1) ring.carnage.land(1, 0, "left", "head", 200, 100, ring.at(1, "nose")); + ring.step(2); + const [thrower, struck] = ring.boxers; + expect(thrower.bodyInjury.spatter).toBeCloseTo(0.24, 5); + expect(thrower.headInjury.spatter).toBeGreaterThan(0); + expect(struck.bodyInjury.spatter).toBeGreaterThan(0); + expect(struck.bodyInjury.spatter).toBeLessThan(thrower.bodyInjury.spatter); + expect(thrower.bodyInjury.wounded).toBe(true); + expect(thrower.gloveBloodLevel).toBeGreaterThanOrEqual(0.24); + expect(thrower.trunksBloodLevel).toBeGreaterThan(0.1); + ring.step(seconds(20)); + expect(thrower.bodyInjury.spatter).toBeCloseTo(0.24, 5); + ring.dispose(); + }); + + it("shows a late spectator the blood on a man from what the other has lost and suffered, with no punch seen", () => { + const ring = new Ring(); + ring.blood[1] = 800; + ring.injuries[1] = ["broken_nose"]; + ring.step(2); + expect(ring.boxers[0].bodyInjury.spatter).toBeCloseTo(0.2 * 2.2 + 0.12, 5); + expect(ring.boxers[1].bodyInjury.spatter).toBe(0); + ring.dispose(); + }); + + it.each([["reduced", false], ["off", false], ["full", true]] as const)("throws none of it with blood %s and reduced motion %s", (blood, reducedMotion) => { + const ring = new Ring({ blood, reducedMotion }); + ring.blood[1] = 500; + for (let punch = 0; punch < 6; punch += 1) ring.carnage.land(1, 0, null, "head", 200, 100, ring.at(1, "nose")); + ring.step(seconds(2)); + for (const boxer of ring.boxers) expect([boxer.headInjury.spatter, boxer.bodyInjury.spatter]).toEqual([0, 0]); + expect(ring.effects.liveBloodParticles).toBe(0); + ring.dispose(); + }); + + it("runs his blood further down him the more of it he has lost", () => { + const ring = new Ring(); + const run = (): number => ring.boxers[0].headInjury.uniforms.uInjuryRun.value; + const fresh = run(); + ring.blood[0] = 850; + ring.step(2); + const later = run(); + ring.blood[0] = 300; + ring.step(2); + expect(fresh).toBeLessThan(1); + expect(later).toBeGreaterThan(fresh); + expect(run()).toBeGreaterThan(later); + expect(ring.boxers[0].bodyInjury.uniforms.uInjuryRun.value).toBe(run()); + ring.dispose(); + }); + + it("drips from gloves soaked through, and not from clean ones", () => { + const ring = new Ring(); + ring.step(seconds(2)); + expect(ring.effects.liveBloodParticles).toBe(0); + for (let punch = 0; punch < 20; punch += 1) ring.carnage.land(1, 0, null, "head", 200, 100, ring.at(1, "nose")); + ring.step(seconds(1.5)); + expect(ring.effects.liveBloodParticles).toBeGreaterThan(0); + ring.dispose(); + }); + + it("squeezes more out of the wounds already open where a punch lands, and teeth out of a jaw already broken", () => { + const ring = new Ring(); + ring.injuries[1] = ["broken_nose", "broken_jaw"]; + ring.step(2); + expect(ring.effects.woundStrength(1, "nose")).toBeGreaterThan(0); + const before = ring.effects.liveBloodParticles; + // A body shot is nowhere near his face. + ring.carnage.land(1, 0, null, "body", 200, 0, ring.at(1, "ribs_left"), 7, 1); + expect(ring.effects.liveBloodParticles).toBe(before); + expect(ring.effects.debrisCount("tooth")).toBe(0); + ring.carnage.land(1, 0, null, "head", 200, 0, ring.at(1, "nose"), 8, 1); + expect(ring.effects.liveBloodParticles).toBeGreaterThan(before + 10); + expect(ring.effects.debrisCount("tooth")).toBe(2); + ring.dispose(); + }); +}); + +describe("a man who dies", () => { + it("lets go: he wets himself for a few seconds, and it pools under him where he comes to rest", () => { + const ring = new Ring(); + ring.step(4); + expect(ring.effects.woundStrength(1, "crotch")).toBe(0); + const stains = ring.effects.canvasStains; + ring.carnage.die(1, "bled_out"); + ring.step(2); + expect(ring.effects.woundStrength(1, "crotch")).toBeGreaterThan(0.3); + expect(ring.effects.woundStrength(0, "crotch")).toBe(0); + ring.step(seconds(8)); + expect(ring.effects.woundStrength(1, "crotch")).toBe(0); + expect(ring.effects.canvasStains).toBeGreaterThan(stains); + ring.dispose(); + }); + + it("lets go of nothing that is drawn with the blood turned down", () => { + const ring = new Ring({ blood: "reduced", reducedMotion: false }); + ring.carnage.die(1, "bled_out"); + ring.step(seconds(4)); + expect(ring.effects.woundStrength(1, "crotch")).toBe(0); + expect(ring.effects.canvasStains).toBe(0); + ring.dispose(); + }); +}); + +describe("a broken bone heard and felt", () => { + const full: Settings = { volume: 1, haptics: true, reducedMotion: false, blood: "full", camera: "broadcast", commentary: true, announcer: true }; + + afterEach(() => { + vi.useRealTimers(); + Object.defineProperty(navigator, "getGamepads", { configurable: true, value: undefined }); + }); + + it("jolts the pad again as the X-ray shows the bone snap, and only for a bone, and only when it is shown", () => { + vi.useFakeTimers(); + const felt: number[] = []; + Object.defineProperty(navigator, "getGamepads", { configurable: true, value: () => [{ connected: true, vibrationActuator: { playEffect: (_type: string, pattern: { strongMagnitude: number }) => { felt.push(pattern.strongMagnitude); return Promise.resolve(); } } }] }); + new HapticFeedback(() => full).gore({ kind: "injury", injury: "arm_left_broken" }); + expect(felt).toHaveLength(1); + vi.advanceTimersByTime(XRAY_SNAP_SECONDS * 1000 + 1); + expect(felt).toHaveLength(2); + new HapticFeedback(() => full).gore({ kind: "injury", injury: "arm_left_torn" }); + new HapticFeedback(() => ({ ...full, blood: "reduced" })).gore({ kind: "injury", injury: "arm_left_broken" }); + vi.advanceTimersByTime(1000); + expect(felt).toHaveLength(4); + }); +}); diff --git a/web/hands/src/render/xray.ts b/web/hands/src/render/xray.ts new file mode 100644 index 00000000..43587a26 --- /dev/null +++ b/web/hands/src/render/xray.ts @@ -0,0 +1,594 @@ +import * as THREE from "three"; +import { mergeGeometries } from "three/examples/jsm/utils/BufferGeometryUtils.js"; +import type { InjuryId, Side, WoundSite } from "../injuries"; +import type { SkinnedBoxer } from "./graph"; +import { ELBOW_EXIT, KNEE_EXIT, RIB_ENDS } from "./injury"; +import { fighterMesh, type Mutilation } from "./mutilation"; +import type { CanonicalBone } from "./rig"; + +/** + * The X-ray of a bone breaking. When a punch breaks a bone the skin round it goes dark and glassy for a + * moment, the fighter's skeleton shows through it where it lies in him as he is posed, and the bone snaps: + * it shears or caves, chips fly and marrow bursts. Then the skin comes back with the injury on it. + * + * One skeleton serves both fighters: it is built from primitives in the skin's bind space (centimetres, + * T-pose) and rides the rig's bones, so it sits inside the body in any pose. The long bones run between the + * joints as they are now. It is drawn over the body with its depth squeezed in front of everything. + */ + +/** A bone a punch can break, by where it is. */ +export type BreakSite = "skull" | "jaw" | "nose" | `${"ribs" | "arm" | "knee" | "shoulder"}_${Side}`; + +/** The bone an injury breaks, or null when it breaks none. */ +export function breakFor(injury: InjuryId): BreakSite | null { + switch (injury) { + case "skull_fractured": return "skull"; + case "broken_jaw": return "jaw"; + case "broken_nose": return "nose"; + case "ribs_left_broken": return "ribs_left"; + case "ribs_right_broken": return "ribs_right"; + case "arm_left_broken": return "arm_left"; + case "arm_right_broken": return "arm_right"; + case "knee_left_blown": return "knee_left"; + case "knee_right_blown": return "knee_right"; + case "shoulder_left_dislocated": return "shoulder_left"; + case "shoulder_right_dislocated": return "shoulder_right"; + default: return null; + } +} + +/** Seconds into the X-ray at which the bone snaps, and how long the whole of it lasts. */ +export const XRAY_SNAP_SECONDS = 0.3; +export const XRAY_SECONDS = 1.35; +const FADE_IN = 0.07; +const FADE_OUT = 0.25; +/** + * The cut-in's side as a share of the screen's shorter side, how far down the screen its top is (on an upright + * phone it goes under the ring, clear of the callout and the commentary above it), and how far its camera + * stands off a head and a body, in metres. + */ +const INSET_SIZE = 0.4; +const INSET_TOP = 0.13; +const INSET_TOP_UPRIGHT = 0.6; +const INSET_HEAD_DISTANCE = 0.66; +const INSET_DISTANCE = 1.05; +const INSET_FRAME = new THREE.Color(0x9fd4ff); +const INSET_FLASH = new THREE.Color(0xffffff); +const INSET_BACK = new THREE.Color(0x020409); +/** How far past the break the skeleton shows for a moment as it snaps, as a multiple of the window. */ +const SNAP_PULSE = 5; +const CHIPS = 8; +const BLOBS = 6; + +type Triple = readonly [number, number, number]; +interface Spot { + /** The middle of the window in bind space, its radius there, and the wound whose place and facing it has in the world. */ + readonly center: Triple; + readonly radius: number; + readonly anchor: WoundSite; + /** The joint the window is on instead, for a limb: wherever the rig has it. */ + readonly joint?: CanonicalBone; +} +const sided = (site: Triple, side: Side): Triple => [side === "left" ? site[0] : -site[0], site[1], site[2]]; +function spotFor(site: BreakSite): Spot { + const side: Side = site.endsWith("_right") ? "right" : "left"; + const letter = side === "left" ? "L" : "R"; + if (site === "skull") return { center: [0, 123.5, -1], radius: 13, anchor: "skull" }; + if (site === "jaw") return { center: [0, 113.5, 2], radius: 10, anchor: "mouth" }; + if (site === "nose") return { center: [0, 118, 3], radius: 9, anchor: "nose" }; + if (site.startsWith("ribs")) return { center: sided(RIB_ENDS[1]!, side), radius: 26, anchor: `ribs_${side}` }; + if (site.startsWith("arm")) return { center: sided(ELBOW_EXIT, side), radius: 17, anchor: `elbow_${side}`, joint: `elbow${letter}` }; + if (site.startsWith("knee")) return { center: sided(KNEE_EXIT, side), radius: 20, anchor: `knee_${side}`, joint: `knee${letter}` }; + return { center: sided([15, 103.5, -5.5], side), radius: 15, anchor: `shoulder_${side}`, joint: `shoulder${letter}` }; +} + +const WHITE: Triple = [1, 1, 1]; +const DARK: Triple = [0.06, 0.07, 0.09]; +const SHADOW: Triple = [0.3, 0.32, 0.36]; +const MARROW: Triple = [1, 0, 0]; +const UP = new THREE.Vector3(0, 1, 0); + +function painted(geometry: THREE.BufferGeometry, tint: Triple): THREE.BufferGeometry { + geometry.deleteAttribute("uv"); + const count = geometry.getAttribute("position").count; + const colors = new Float32Array(count * 3); + for (let at = 0; at < count; at += 1) colors.set(tint, at * 3); + geometry.setAttribute("color", new THREE.BufferAttribute(colors, 3)); + return geometry; +} + +function ball(at: Triple, radii: Triple | number, tint: Triple = WHITE): THREE.BufferGeometry { + const geometry = new THREE.SphereGeometry(1, 10, 8); + if (typeof radii === "number") geometry.scale(radii, radii, radii); + else geometry.scale(radii[0], radii[1], radii[2]); + return painted(geometry.translate(at[0], at[1], at[2]), tint); +} + +const barFrom = new THREE.Vector3(); +const barTo = new THREE.Vector3(); +const barTurn = new THREE.Quaternion(); +const barMatrix = new THREE.Matrix4(); +function bar(from: Triple, to: Triple, radius: number, tint: Triple = WHITE, taper = 1): THREE.BufferGeometry { + barFrom.set(from[0], from[1], from[2]); + barTo.set(to[0], to[1], to[2]).sub(barFrom); + const length = barTo.length(); + const geometry = new THREE.CylinderGeometry(radius * taper, radius, length, 7, 1).translate(0, length / 2, 0); + barTurn.setFromUnitVectors(UP, barTo.divideScalar(length)); + return painted(geometry.applyMatrix4(barMatrix.compose(barFrom, barTurn, new THREE.Vector3(1, 1, 1))), tint); +} + +function merged(parts: THREE.BufferGeometry[]): THREE.BufferGeometry { + const whole = mergeGeometries(parts); + for (const part of parts) part.dispose(); + return whole; +} + +/** A long bone along +Y from the origin: a shaft with a knuckle at each end, and a thinner bone beside it when `twin` is given. */ +function longBone(length: number, radius: number, knob: number, twin = 0): THREE.BufferGeometry { + const parts = [bar([0, 0, 0], [0, length, 0], radius, WHITE, 0.85), ball([0, 0, 0], knob), ball([0, length, 0], knob * 0.85)]; + if (twin !== 0) parts.push(bar([twin, knob * 0.5, 0], [twin, length - knob * 0.5, 0], radius * 0.55)); + return merged(parts); +} + +/** One rib of the left or right side from `from` to `to` round the chest: 0 is the spine, 1 the breastbone. */ +function rib(side: number, level: number, from: number, to: number): THREE.BufferGeometry { + const profile = Math.sin(Math.PI * (0.24 + 0.62 * (level / 7))); + const points: THREE.Vector3[] = []; + for (let step = 0; step <= 6; step += 1) { + const angle = Math.PI * (from + ((to - from) * step) / 6); + points.push(new THREE.Vector3(side * 11.4 * profile * Math.sin(angle), 88.5 + level * 2.5 - 1.1 * (1 - Math.cos(angle)), -1.2 - 5.8 * profile * Math.cos(angle))); + } + return painted(new THREE.TubeGeometry(new THREE.CatmullRomCurve3(points), 8, 0.42, 5, false), WHITE); +} + +/** The ribs of one side, behind the break (spine to flank) or in front of it (flank to breastbone). */ +function ribs(side: number, front: boolean): THREE.BufferGeometry { + const parts: THREE.BufferGeometry[] = []; + // The lowest two float: they stop short of the breastbone. + for (let level = 0; level < 8; level += 1) parts.push(front ? rib(side, level, 0.5, level < 2 ? 0.72 : 0.93) : rib(side, level, 0.07, 0.5)); + return merged(parts); +} + +/** A row of teeth along the front of a jaw at height `y`, from one side of the mouth to the other. */ +function teeth(y: number, from: number, to: number): THREE.BufferGeometry[] { + const row: THREE.BufferGeometry[] = []; + for (let x = from; x <= to + 1e-6; x += 0.5) row.push(painted(new THREE.BoxGeometry(0.4, 0.85, 0.45).translate(x, y, 3.75 - 0.3 * x * x), WHITE)); + return row; +} + +/** The skull without its lower jaw: the cranium, the brow, the cheekbones, the upper jaw and its teeth, and the dark of the sockets and the nose. */ +function skull(): THREE.BufferGeometry { + return merged([ + ball([0, 121.6, -3], [5.6, 6.1, 7.3]), + ball([0, 116.8, 1.9], [3.2, 2.7, 2.7]), + ball([4, 118.5, 1.8], [1.5, 1.1, 1.8]), + ball([-4, 118.5, 1.8], [1.5, 1.1, 1.8]), + bar([-4.3, 122.3, 2.5], [4.3, 122.3, 2.5], 0.7), + ball([2.7, 120.6, 2.7], [1.5, 1.3, 1.35], DARK), + ball([-2.7, 120.6, 2.7], [1.5, 1.3, 1.35], DARK), + ball([0.45, 117.6, 4.05], [0.6, 1.1, 0.7], DARK), + ball([-0.45, 117.6, 4.05], [0.6, 1.1, 0.7], DARK), + ...teeth(115, -1.75, 1.75), + ]); +} + +/** Half of the lower jaw: the chin to the angle, the branch up to the hinge, and its row of teeth. */ +function jawHalf(side: number): THREE.BufferGeometry { + return merged([ + bar([side * 0.2, 111.7, 3.9], [side * 4.4, 112.3, -1.3], 0.75), + bar([side * 4.4, 112.3, -1.3], [side * 5, 116.8, -2.1], 0.62), + ball([side * 0.5, 111.7, 3.9], 0.95), + bar([side * 0.2, 113.1, 3.5], [side * 2.4, 113.2, 2], 0.4), + ...teeth(113.8, side > 0 ? 0.25 : -1.75, side > 0 ? 1.75 : -0.25), + ]); +} + +/** A caved plate of the skull over the brow and the cracks that run from it. */ +function fracture(): THREE.BufferGeometry { + const plate = painted(new THREE.SphereGeometry(1, 8, 5, Math.PI / 2 - 0.55, 1.1, 0.35, 0.7).scale(5.75, 6.25, 7.45).translate(0, 121.6, -3), SHADOW); + const on = (phi: number, theta: number): Triple => [-5.8 * Math.cos(phi) * Math.sin(theta), 121.6 + 6.3 * Math.cos(theta), -3 + 7.5 * Math.sin(phi) * Math.sin(theta)]; + const cracks: THREE.BufferGeometry[] = []; + const runs: readonly (readonly [number, number, number, number])[] = [[1.0, 0.35, 0.7, 0.05], [2.1, 0.4, 2.7, 0.2], [2.1, 1.05, 2.8, 1.2], [1.0, 1.05, 0.4, 1.3], [1.57, 1.05, 1.5, 1.5], [1.57, 0.35, 1.9, 0.02]]; + for (const [phi, theta, toPhi, toTheta] of runs) { + const middle = on((phi + toPhi) / 2 + 0.12, (theta + toTheta) / 2 + 0.05); + cracks.push(bar(on(phi, theta), middle, 0.22, DARK), bar(middle, on(toPhi, toTheta), 0.16, DARK)); + } + return merged([plate, ...cracks]); +} + +function spine(from: number, to: number, depth: number): THREE.BufferGeometry { + const parts: THREE.BufferGeometry[] = []; + for (let y = from; y < to; y += 2.3) parts.push(ball([0, y, depth], [1.45, 0.95, 1.3]), bar([0, y, depth - 1], [0, y - 0.7, depth - 2.6], 0.4)); + return merged(parts); +} + +function pelvis(): THREE.BufferGeometry { + const parts: THREE.BufferGeometry[] = [ball([0, 74.5, -4.3], [2.5, 3.4, 1.7]), bar([-4.6, 69.6, 1.6], [4.6, 69.6, 1.6], 0.8)]; + for (const side of [1, -1]) { + parts.push(ball([side * 6.4, 76.6, -1.6], [4.1, 3.5, 1.6]), bar([side * 6.6, 74, -0.6], [side * 4.6, 69.6, 1.6], 0.8), ball([side * 7.6, 72, -1.5], 1.6)); + } + return merged(parts); +} + +const VERTEX = /* glsl */ ` +varying vec3 vTint; +varying vec3 vWorld; +varying vec3 vNormalView; +varying vec3 vView; +void main() { + vTint = color; + vec4 world = modelMatrix * vec4(position, 1.0); + vWorld = world.xyz; + vec4 view = viewMatrix * world; + vView = -view.xyz; + vNormalView = normalMatrix * normal; + vec4 clip = projectionMatrix * view; + // In front of everything, and still in order among the bones. + clip.z = (clip.z / clip.w * 0.02 - 0.98) * clip.w; + gl_Position = clip; +} +`; + +const FRAGMENT = /* glsl */ ` +uniform vec3 uCenter; +uniform float uRadius; +uniform float uOpacity; +uniform float uFlash; +varying vec3 vTint; +varying vec3 vWorld; +varying vec3 vNormalView; +varying vec3 vView; +void main() { + float alpha = (1.0 - smoothstep(uRadius * 0.78, uRadius, distance(vWorld, uCenter))) * uOpacity; + if (alpha < 0.01) discard; + vec3 normal = normalize(vNormalView); + float rim = 1.0 - abs(dot(normal, normalize(vView))); + vec3 bone = mix(vec3(0.05, 0.11, 0.2), vec3(0.78, 0.9, 1.0), clamp(0.34 + 0.6 * pow(rim, 1.5) + 0.14 * normal.y, 0.0, 1.0)) * vTint; + vec3 marrow = vec3(0.85, 0.03, 0.05) * (0.55 + 0.7 * rim); + gl_FragColor = vec4(mix(bone, marrow, step(vTint.g + 0.5, vTint.r)) + uFlash, alpha); + #include + #include +} +`; + +interface Framed { + readonly mesh: THREE.Mesh; + readonly skin: "head" | "body"; + readonly bone: CanonicalBone; +} +interface Long { + readonly mesh: THREE.Mesh; + readonly from: CanonicalBone; + readonly to: CanonicalBone; + /** Its length as built, in bind units. */ + readonly length: number; +} + +export class BoneXray { + readonly root = new THREE.Group(); + private readonly uniforms = { uCenter: { value: new THREE.Vector3() }, uRadius: { value: 0 }, uOpacity: { value: 0 }, uFlash: { value: 0 } }; + private readonly material = new THREE.ShaderMaterial({ uniforms: this.uniforms, vertexShader: VERTEX, fragmentShader: FRAGMENT, vertexColors: true, transparent: true }); + private framed: Framed[] = []; + private longs: Long[] = []; + private readonly chips: THREE.Mesh[] = []; + private readonly sprays: THREE.Vector3[] = []; + private pieces: { + plate: THREE.Mesh; nasal: THREE.Mesh; jaw: readonly [THREE.Mesh, THREE.Mesh]; ribsFront: readonly [THREE.Mesh, THREE.Mesh]; + humerus: readonly [THREE.Mesh, THREE.Mesh]; shin: readonly [THREE.Mesh, THREE.Mesh]; stump: THREE.Mesh; shard: THREE.Mesh; + } | null = null; + private boxer: SkinnedBoxer | null = null; + private mutilation: Mutilation | null = null; + private site: BreakSite | null = null; + private spot: Spot = spotFor("skull"); + /** The middle of the window in bind space. */ + private readonly center = new THREE.Vector3(); + private fighter = -1; + private elapsed = 0; + private held = false; + private readonly push = new THREE.Vector3(); + private readonly matrix = new THREE.Matrix4(); + private readonly local = new THREE.Matrix4(); + private readonly turn = new THREE.Quaternion(); + private readonly from = new THREE.Vector3(); + private readonly to = new THREE.Vector3(); + private readonly along = new THREE.Vector3(); + private readonly across = new THREE.Vector3(); + private readonly axis = new THREE.Vector3(); + /** The way the break faces out of him. */ + private readonly outward = new THREE.Vector3(); + private readonly offset = new THREE.Vector3(); + private readonly one = new THREE.Vector3(1, 1, 1); + private readonly insetCamera = new THREE.PerspectiveCamera(30, 1, 0.05, 40); + private readonly canvasSize = new THREE.Vector2(); + private readonly clearColor = new THREE.Color(); + private readonly frameColor = new THREE.Color(); + private compiled: THREE.BufferGeometry | null = null; + + constructor() { + this.root.visible = false; + this.root.name = "BoneXray"; + } + + /** The fighter whose bone is breaking now, or -1. */ + get owner(): number { + return this.site === null ? -1 : this.fighter; + } + + get breaking(): BreakSite | null { + return this.site; + } + + /** Whether the bone has snapped in the X-ray that is showing. */ + get snapped(): boolean { + return this.site !== null && this.elapsed >= XRAY_SNAP_SECONDS; + } + + /** + * The cut-in: a close view of the break, drawn in a framed square over the picture just rendered, on the + * broken fighter's side of the screen. It looks at the side of him the break is on, from the viewer's side of that. + */ + drawInset(renderer: THREE.WebGLRenderer, scene: THREE.Scene, camera: THREE.Camera): void { + if (this.site === null || this.held || this.elapsed <= 0) return; + const size = renderer.getSize(this.canvasSize); + const side = Math.round(Math.min(size.x, size.y) * INSET_SIZE); + const border = Math.max(2, Math.round(side * 0.012)); + const left = this.fighter === 0 ? Math.round(side * 0.08) : size.x - side - Math.round(side * 0.08); + const bottom = size.y - side - Math.round(size.y * (size.y > size.x ? INSET_TOP_UPRIGHT : INSET_TOP)); + const center = this.uniforms.uCenter.value; + const eye = this.insetCamera; + // Side-on to the punch from the viewer's side, so the man who threw it is not in the way, turned a little toward the break. + const sideOn = eye.position.subVectors(camera.position, center).setY(0).normalize(); + sideOn.addScaledVector(this.push, -sideOn.dot(this.push)); + if (sideOn.lengthSq() < 0.12) sideOn.set(-this.push.z, 0, this.push.x); + sideOn.normalize().addScaledVector(this.outward, 0.4).setY(0).normalize(); + eye.position.multiplyScalar(this.spot.joint === undefined && this.spot.radius < 15 ? INSET_HEAD_DISTANCE : INSET_DISTANCE).add(center); + eye.position.y += 0.12; + eye.lookAt(center); + const clearAlpha = renderer.getClearAlpha(); + const shadows = renderer.shadowMap.autoUpdate; + renderer.getClearColor(this.clearColor); + renderer.shadowMap.autoUpdate = false; + renderer.setScissorTest(true); + // The frame flashes white as the bone goes. + const flash = this.uniforms.uFlash.value; + renderer.setClearColor(this.frameColor.copy(INSET_FRAME).lerp(INSET_FLASH, Math.min(1, flash * 2)), 1); + renderer.setScissor(left - border, bottom - border, side + border * 2, side + border * 2); + renderer.clear(true, true, false); + renderer.setClearColor(INSET_BACK, 1); + renderer.setScissor(left, bottom, side, side); + renderer.setViewport(left, bottom, side, side); + renderer.render(scene, eye); + renderer.setScissorTest(false); + renderer.setViewport(0, 0, size.x, size.y); + renderer.setClearColor(this.clearColor, clearAlpha); + renderer.shadowMap.autoUpdate = shadows; + } + + /** + * Shows the bone at `site` of a fighter breaking, pushed the way the punch went. With `hold` the whole + * skeleton stays up, broken, until `stop`: the lab's view of it. + */ + start(fighter: number, boxer: SkinnedBoxer, mutilation: Mutilation, site: BreakSite, pushX: number, pushZ: number, hold = false): void { + this.stop(); + this.prepare(boxer); + this.fighter = fighter; + this.boxer = boxer; + this.mutilation = mutilation; + this.site = site; + this.spot = spotFor(site); + this.center.set(this.spot.center[0], this.spot.center[1], this.spot.center[2]); + const body = fighterMesh(boxer, "body"); + const slot = this.spot.joint === undefined || body === null ? -1 : body.skeleton.bones.indexOf(boxer.rig.bones[this.spot.joint]); + // Where the skin of that joint is in bind space: what the joint's bind matrix carries to its origin. + if (slot >= 0) this.center.setFromMatrixPosition(this.matrix.multiplyMatrices(body!.skeleton.boneInverses[slot]!, body!.bindMatrix).invert()); + this.elapsed = hold ? XRAY_SECONDS * 0.5 : 0; + this.held = hold; + this.push.set(pushX, 0, pushZ); + if (this.push.lengthSq() < 1e-6) this.push.set(1, 0, 0); + this.push.normalize(); + // Chips and marrow leave the break in a cone round the punch's way, the same every time for the same bone. + let seed = site.length * 7 + 3; + const random = (): number => { + seed = (seed * 16807) % 2147483647; + return seed / 2147483647; + }; + for (const spray of this.sprays) spray.set(this.push.x * 0.9 + random() * 1.6 - 0.8, random() * 1.5 - 0.2, this.push.z * 0.9 + random() * 1.6 - 0.8).multiplyScalar(0.5 + random() * 0.9); + this.root.visible = true; + } + + /** Takes the X-ray down and gives the skin back. */ + stop(): void { + if (this.site === null) return; + this.boxer?.headInjury.setXray(0, 0, 0, 0, 0); + this.boxer?.bodyInjury.setXray(0, 0, 0, 0, 0); + this.site = null; + this.boxer = null; + this.mutilation = null; + this.root.visible = false; + } + + /** Once a frame while it shows, after the fighter is posed: the bones go where his are, and the break plays. */ + update(dt: number): void { + const { site, boxer, mutilation, pieces } = this; + if (site === null || boxer === null || mutilation === null || pieces === null) return; + if (!this.held) this.elapsed += dt; + const elapsed = this.elapsed; + if (elapsed >= XRAY_SECONDS || !mutilation.anchor(this.spot.anchor, this.uniforms.uCenter.value, this.outward)) { + this.stop(); + return; + } + if (this.spot.joint !== undefined) boxer.rig.bones[this.spot.joint].getWorldPosition(this.uniforms.uCenter.value); + const since = elapsed - XRAY_SNAP_SECONDS; + const snap = since < 0 ? 0 : 1 - Math.exp(-since * 20); + const pulse = since < 0 || this.held ? 0 : Math.exp(-since * 11); + const shown = Math.min(1, elapsed / FADE_IN, (XRAY_SECONDS - elapsed) / FADE_OUT); + const spot = this.spot; + const center = this.center; + const scale = 1 / boxer.rig.metrics.unitsPerMeter; + const radius = this.held ? 1000 : spot.radius * (1 + SNAP_PULSE * pulse); + boxer.headInjury.setXray(center.x, center.y, center.z, radius, shown); + boxer.bodyInjury.setXray(center.x, center.y, center.z, radius, shown); + this.uniforms.uRadius.value = radius * scale * 1.1; + this.uniforms.uOpacity.value = shown; + this.uniforms.uFlash.value = pulse * 0.55; + + const side = site.endsWith("_right") ? 1 : 0; + const sign = side === 1 ? -1 : 1; + for (const framed of this.framed) { + framed.mesh.visible = mutilation.skinMatrix(framed.skin, framed.bone, framed.mesh.matrix); + framed.mesh.matrixWorldNeedsUpdate = true; + } + // The broken piece moves in the bind frame of the bone that carries it, on top of where that bone has it. + const shift = (mesh: THREE.Mesh, pivot: Triple, turnAxis: Triple, angle: number, move: Triple): void => { + this.turn.setFromAxisAngle(this.axis.set(turnAxis[0], turnAxis[1], turnAxis[2]), angle); + this.local.compose(this.offset.set(pivot[0] + move[0], pivot[1] + move[1], pivot[2] + move[2]), this.turn, this.one); + mesh.matrix.multiply(this.local).multiply(this.matrix.makeTranslation(-pivot[0], -pivot[1], -pivot[2])); + }; + pieces.plate.visible &&= site === "skull" && snap > 0; + if (site === "jaw") { + shift(pieces.jaw[0], [0, 111.7, 3.9], [0, 1, 0], 0.3 * snap, [0.9 * snap, -0.7 * snap, 0]); + shift(pieces.jaw[1], [-5, 116.8, -2.1], [0, 0, 1], -0.16 * snap, [0.5 * snap, 0, 0]); + } else if (site === "nose") { + shift(pieces.nasal, [0, 120.4, 3.6], [0, 0, 1], 0.7 * snap, [0.5 * snap, -0.2 * snap, -0.5 * snap]); + } else if (site.startsWith("ribs")) { + shift(pieces.ribsFront[side]!, [sign * 11.2, 96, -1.2], [0, 1, 0], -sign * 0.5 * snap, [-sign * 0.9 * snap, 0, 0]); + } + + const bones = boxer.rig.bones; + for (const long of this.longs) { + bones[long.from].getWorldPosition(this.from); + bones[long.to].getWorldPosition(this.to); + const broken = (long.mesh === pieces.humerus[side] && (site.startsWith("arm") || site.startsWith("shoulder"))) || (long.mesh === pieces.shin[side] && site.startsWith("knee")); + long.mesh.visible = true; + if (broken && site.startsWith("arm")) { + // The upper arm snaps above the elbow: what is left of it on the shoulder, and the end that shears away. + long.mesh.visible = false; + this.along.subVectors(this.to, this.from); + this.across.crossVectors(this.along, this.push).normalize(); + if (this.across.lengthSq() < 0.5) this.across.set(0, 1, 0); + this.span(pieces.stump, this.from, this.to, long.length, scale); + this.to.copy(this.from).addScaledVector(this.along, 0.62); + this.offset.crossVectors(this.across, this.along).normalize(); + pieces.shard.position.copy(this.to).addScaledVector(this.offset, 0.022 * snap); + this.turn.setFromAxisAngle(this.across, 0.75 * snap); + pieces.shard.quaternion.copy(pieces.stump.quaternion).premultiply(this.turn); + pieces.shard.scale.copy(pieces.stump.scale); + continue; + } + if (broken && site.startsWith("shoulder")) this.from.addScaledVector(this.push, 0.035 * snap).y -= 0.04 * snap; + // A blown knee lets the shin out sideways from under the thigh. + if (broken && site.startsWith("knee")) this.from.addScaledVector(this.outward, 0.05 * snap); + this.span(long.mesh, this.from, this.to, long.length, scale); + } + const arm = site.startsWith("arm"); + pieces.stump.visible = arm; + pieces.shard.visible = arm; + + // Chips of bone and beads of marrow leave the break as it snaps, and fall. + const origin = this.uniforms.uCenter.value; + for (const [index, chip] of this.chips.entries()) { + chip.visible = since > 0; + if (since <= 0) continue; + const spray = this.sprays[index]!; + chip.position.copy(origin).addScaledVector(spray, since * 0.55); + chip.position.y -= 1.6 * since * since; + chip.rotation.set(since * 9 + index, since * 7, index); + chip.scale.setScalar((index < CHIPS ? 0.8 : 1.1) * scale * Math.max(0.2, 1 - since * (index < CHIPS ? 0.5 : 0.9))); + } + } + + /** A mesh on the bones' shader, drawn once off screen before the bout so the first broken bone compiles nothing. */ + standIn(): THREE.Mesh { + this.compiled ??= painted(new THREE.TetrahedronGeometry(0.01), WHITE); + const mesh = new THREE.Mesh(this.compiled, this.material); + mesh.frustumCulled = false; + return mesh; + } + + dispose(): void { + this.stop(); + for (const child of this.root.children) (child as THREE.Mesh).geometry.dispose(); + this.root.clear(); + this.compiled?.dispose(); + this.material.dispose(); + this.pieces = null; + } + + /** Lays a long bone from one joint to the other. */ + private span(mesh: THREE.Object3D, from: THREE.Vector3, to: THREE.Vector3, length: number, scale: number): void { + mesh.position.copy(from); + const reach = this.along.subVectors(to, from).length(); + mesh.quaternion.setFromUnitVectors(UP, this.along.divideScalar(reach || 1)); + mesh.scale.set(scale, reach / length, scale); + this.along.multiplyScalar(reach); + } + + /** Builds the skeleton to a fighter's proportions, once: before the bout, so that a bone breaking builds nothing. Both fighters are one model. */ + prepare(boxer: SkinnedBoxer): void { + if (this.pieces !== null) return; + const add = (geometry: THREE.BufferGeometry): THREE.Mesh => { + const mesh = new THREE.Mesh(geometry, this.material); + mesh.frustumCulled = false; + mesh.renderOrder = 40; + this.root.add(mesh); + return mesh; + }; + const frame = (geometry: THREE.BufferGeometry, skin: "head" | "body", bone: CanonicalBone): THREE.Mesh => { + const mesh = add(geometry); + mesh.matrixAutoUpdate = false; + this.framed.push({ mesh, skin, bone }); + return mesh; + }; + const metrics = boxer.rig.metrics; + const units = metrics.unitsPerMeter; + const long = (geometry: THREE.BufferGeometry, from: CanonicalBone, to: CanonicalBone, length: number): THREE.Mesh => { + const mesh = add(geometry); + this.longs.push({ mesh, from, to, length }); + return mesh; + }; + frame(skull(), "head", "head"); + const plate = frame(fracture(), "head", "head"); + const nasal = frame(bar([0, 120.4, 3.6], [0, 118.3, 5], 0.55, WHITE, 0.5), "head", "head"); + const jaw = [frame(jawHalf(1), "head", "head"), frame(jawHalf(-1), "head", "head")] as const; + frame(spine(108.5, 116.5, -3.4), "body", "neck"); + frame(spine(88, 108, -6.2), "body", "chest"); + frame(spine(76, 87.5, -3.6), "body", "spine"); + frame(pelvis(), "body", "hips"); + frame(merged([ + painted(new THREE.BoxGeometry(2.2, 10.5, 0.9).translate(0, 99, 4.3), WHITE), + bar([1.4, 106.4, 2.8], [13.6, 105.2, -3.4], 0.55), bar([-1.4, 106.4, 2.8], [-13.6, 105.2, -3.4], 0.55), + ball([11, 101, -7.6], [3.6, 4.6, 0.7]), ball([-11, 101, -7.6], [3.6, 4.6, 0.7]), + ]), "body", "chest"); + frame(ribs(1, false), "body", "chest"); + frame(ribs(-1, false), "body", "chest"); + const ribsFront = [frame(ribs(1, true), "body", "chest"), frame(ribs(-1, true), "body", "chest")] as const; + const upper = metrics.armL.upper * units; + const fore = metrics.armL.lower * units; + const thigh = metrics.legL.upper * units; + const shank = metrics.legL.lower * units; + const humerusGeometry = longBone(upper, 0.95, 1.5); + const foreGeometry = longBone(fore, 0.62, 1.15, 0.9); + const femurGeometry = longBone(thigh, 1.25, 2); + const shinGeometry = longBone(shank, 1.05, 1.75, 1.5); + const footGeometry = bar([0, 0, 0], [0, 10, 0], 0.9, WHITE, 0.6); + const humerus = [long(humerusGeometry, "shoulderL", "elbowL", upper), long(humerusGeometry, "shoulderR", "elbowR", upper)] as const; + long(foreGeometry, "elbowL", "gloveL", fore); + long(foreGeometry, "elbowR", "gloveR", fore); + long(femurGeometry, "hipL", "kneeL", thigh); + long(femurGeometry, "hipR", "kneeR", thigh); + const shin = [long(shinGeometry, "kneeL", "ankleL", shank), long(shinGeometry, "kneeR", "ankleR", shank)] as const; + long(footGeometry, "ankleL", "toeL", 10); + long(footGeometry, "ankleR", "toeR", 10); + // The two ends of a snapped upper arm: each has its knuckle and a splintered end with marrow in it. + const split = upper * 0.62; + const stump = add(merged([bar([0, 0, 0], [0, split, 0], 0.95, WHITE, 0.85), ball([0, 0, 0], 1.5), bar([0, split, 0], [0.5, split + 1.6, 0.2], 0.7, WHITE, 0.1), ball([0, split, 0], 0.6, MARROW)])); + const shard = add(merged([bar([0, 0.4, 0], [0, upper - split, 0], 0.85), ball([0, upper - split, 0], 1.3), bar([0, 0.6, 0], [-0.4, -1.5, -0.3], 0.7, WHITE, 0.1), ball([0, 0.5, 0], 0.55, MARROW)])); + const chip = painted(new THREE.TetrahedronGeometry(1), WHITE); + const blob = painted(new THREE.IcosahedronGeometry(1, 1), MARROW); + for (let index = 0; index < CHIPS + BLOBS; index += 1) { + this.chips.push(add(index < CHIPS ? chip : blob)); + this.sprays.push(new THREE.Vector3()); + } + this.pieces = { plate, nasal, jaw, ribsFront, humerus, shin, stump, shard }; + } +}