@joy-ride/game 0.26.1 → 0.27.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -4
- package/THIRD_PARTY_NOTICES.md +35 -0
- package/bookmarklet.d.ts +1 -1
- package/bookmarklet.js +1 -1
- package/embed-assets/boost-2QB6phrp.opus +0 -0
- package/embed-assets/chevrolet-corvette-c8-z06-top-DTz9k7Fu.webp +0 -0
- package/embed-assets/collision-r7KCgXfr.opus +0 -0
- package/embed-assets/crush-CN-lxC7x.opus +0 -0
- package/embed-assets/explosion-DyvbNXFI.opus +0 -0
- package/embed-assets/ferrari-812-superfast-top-C3DkIkN7.webp +0 -0
- package/embed-assets/fire-BYgTEP5X.opus +0 -0
- package/embed-assets/gunfire-DUWyQGGm.opus +0 -0
- package/embed-assets/mazda-mx5-nd-top-CLqHp7ox.webp +0 -0
- package/embed-assets/mazda-rx7-fd-top-C3bZMAQw.webp +0 -0
- package/embed-assets/mclaren-720s-top-8TdR01SB.webp +0 -0
- package/embed-assets/nissan-gtr-r35-top-DSpGgr3L.webp +0 -0
- package/embed-assets/ram-2500-top-B653eJDL.webp +0 -0
- package/embed-assets/ricochet-BTW-Iqeu.opus +0 -0
- package/embed-assets/tires-B_97_Y5P.opus +0 -0
- package/embed-assets/toyota-gr-corolla-top-B0NnJP3L.webp +0 -0
- package/embed-assets/toyota-supra-a80-top-BjqFr9TR.webp +0 -0
- package/embed-chunks/{CodeBlock-Dn8EZ_BP.js → CodeBlock-CJRe6lHv.js} +1 -1
- package/embed-chunks/{Documentation-FnghYLFE.js → Documentation-DULnk8tf.js} +2 -2
- package/embed-chunks/{EmbedPanel-DZGEiiy9.js → EmbedPanel-D6NV8mze.js} +1 -1
- package/embed-chunks/JoyRideView-Ob58zdVp.js +1 -0
- package/embed-chunks/{configuration~index~embed-0luxl74s.js → configuration~index~embed-ynFxJP_I.js} +1 -1
- package/embed-chunks/configuration~index~embed~bookmarklet-BGiS_NuJ.js +1 -0
- package/embed-chunks/{controls~index~embed-B_C92tUz.js → controls~index~embed-CFqR-DAK.js} +1 -1
- package/embed-chunks/{definitions~index~embed-CDMM_m1T.js → definitions~index~embed-CnmHo4Z4.js} +1 -1
- package/embed-chunks/definitions~index~embed~bookmarklet-CfH2mYuH.js +1 -0
- package/embed-chunks/definitions~index~embed~bookmarklet~vehicle-popover~Documentation~JoyRideView~browser-sessi~fklztn3g-BG7sJuWo.js +1 -0
- package/embed-chunks/{runtime~JoyRideView~browser-session-core-D3nCbCee.js → runtime~JoyRideView~browser-session-core-D5ZWMVDY.js} +1 -1
- package/embed-chunks/runtime~browser-session-core-BAKqCyId.js +1 -0
- package/embed-chunks/runtime~index~embed-OYVxs2-3.js +210 -0
- package/embed-chunks/{runtime~index~embed~vehicle-popover~browser-session-core~renderer-YuWj6rHi.js → runtime~index~embed~vehicle-popover~browser-session-core~renderer-ZRVlax1L.js} +1 -1
- package/embed-chunks/{runtime~vehicle-popover-vmgt62ll.js → runtime~vehicle-popover-DRMddEZO.js} +1 -1
- package/embed-chunks/runtime~vehicle-popover~browser-session-core-Duk0oqZL.js +1 -0
- package/embed-chunks/runtime~vehicle-popover~browser-session-core~renderer-Cf4rBrLo.js +4 -0
- package/embed-chunks/runtime~vehicle-popover~renderer-JCHjG7Oa.js +849 -0
- package/embed-chunks/src-Dz21SH_d.js +2 -0
- package/embed-chunks/vehicle-catalog~index~embed-Dpqr1rYZ.js +1 -0
- package/embed-chunks/vehicle-popover-uy2DwcVy.js +1 -0
- package/embed.js +1 -1
- package/{index-BeKl7UbC.d.ts → index-At4NsLPU.d.ts} +15 -116
- package/index.d.ts +2 -2
- package/index.js +1 -1
- package/npm-chunks/{Documentation-_R0nI0HT.js → Documentation-B_Eb81Ol.js} +2 -2
- package/npm-chunks/{EmbedPanel-lzZkV-zO.js → EmbedPanel-Cu4-LaxN.js} +1 -1
- package/npm-chunks/JoyRideView-DHvlq6T7.js +1 -0
- package/npm-chunks/{configuration~react-CgNlw0cC.js → configuration~react-CPx5MlF4.js} +1 -1
- package/npm-chunks/{configuration~react~browser-session-core-CyXr42pk.js → configuration~react~browser-session-core-Ca4_fO4n.js} +1 -1
- package/npm-chunks/configuration~react~vehicle-popover~JoyRideView~browser-session-core~renderer-CPZkP_Db.js +1 -0
- package/npm-chunks/{controls~react~vehicle-popover~Documentation~JoyRideView~browser-session-core-CLDwfJ48.js → controls~react~vehicle-popover~Documentation~JoyRideView~browser-session-core-CoAcght5.js} +1 -1
- package/npm-chunks/{definitions~react~browser-session-core-acRq5AYt.js → definitions~react~browser-session-core-Bc5BhqaX.js} +1 -1
- package/npm-chunks/definitions~react~vehicle-popover~Documentation~JoyRideView~browser-session-core-DcDccU8O.js +1 -0
- package/npm-chunks/definitions~react~vehicle-popover~Documentation~JoyRideView~browser-session-core~renderer-BG7sJuWo.js +1 -0
- package/npm-chunks/{runtime~JoyRideView~browser-session-core-BkwDrc9q.js → runtime~JoyRideView~browser-session-core-DkTKYWMV.js} +1 -1
- package/npm-chunks/runtime~browser-session-core-AEIWcEJB.js +1 -0
- package/npm-chunks/{runtime~react-CoMJOwyg.js → runtime~react-C9tzIsBm.js} +1 -1
- package/npm-chunks/{runtime~react~browser-session-core-35T1PZHO.js → runtime~react~browser-session-core-B9a1rLNB.js} +1 -1
- package/npm-chunks/runtime~react~vehicle-popover~browser-session-core-CdrNmP2l.js +210 -0
- package/npm-chunks/{runtime~react~vehicle-popover~browser-session-core~renderer-Be8cIaU4.js → runtime~react~vehicle-popover~browser-session-core~renderer-Dmgs7E8f.js} +1 -1
- package/npm-chunks/{runtime~vehicle-popover-PLJOXbUU.js → runtime~vehicle-popover-VyqXHkfB.js} +1 -1
- package/npm-chunks/runtime~vehicle-popover~browser-session-core-D0thHU3T.js +1 -0
- package/npm-chunks/runtime~vehicle-popover~browser-session-core~renderer-EswVyRVp.js +4 -0
- package/npm-chunks/runtime~vehicle-popover~renderer-4RpQDOHk.js +849 -0
- package/npm-chunks/theme-CjrpDpKE.js +2 -0
- package/npm-chunks/vehicle-catalog~react~browser-session-core-D5_CJzRM.js +1 -0
- package/npm-chunks/vehicle-catalog~react~vehicle-popover~browser-session-core-B042f61I.js +1 -0
- package/npm-chunks/vehicle-popover-DErhsXB9.js +1 -0
- package/package.json +1 -1
- package/{playground-e0rOBXY5.d.ts → playground-BcoLBJrj.d.ts} +12 -70
- package/react.d.ts +2 -2
- package/react.js +2 -2
- package/embed-assets/attractor-B0xCt_Fj.mp3 +0 -0
- package/embed-assets/boost-BLJDRtPH.mp3 +0 -0
- package/embed-assets/bullet-ricochet-1-BKWD_WRI.mp3 +0 -0
- package/embed-assets/bullet-ricochet-2-CmbSTqg5.mp3 +0 -0
- package/embed-assets/bullet-ricochet-3-DV3Th6nn.mp3 +0 -0
- package/embed-assets/burning-fire--0zItqR0.mp3 +0 -0
- package/embed-assets/collision-hard-b_eauD-v.mp3 +0 -0
- package/embed-assets/collision-medium-Bhw86k_p.mp3 +0 -0
- package/embed-assets/collision-soft-DIwEkPCV.mp3 +0 -0
- package/embed-assets/collision-soft-fVT-mQmJ.mp3 +0 -0
- package/embed-assets/combustible-explosion-XvpDzpm9.mp3 +0 -0
- package/embed-assets/crush-BZKARh2Y.mp3 +0 -0
- package/embed-assets/electric-bolt-Cg9Fmi6S.mp3 +0 -0
- package/embed-assets/electric-charge-zw1IjLo4.mp3 +0 -0
- package/embed-assets/electric-gt-top-DTcvEjMR.webp +0 -0
- package/embed-assets/flamethrower-B5pUrS5p.mp3 +0 -0
- package/embed-assets/ghost-mode-B33_bxYX.mp3 +0 -0
- package/embed-assets/machine-gun-C4ag4X6T.mp3 +0 -0
- package/embed-assets/rocket-explosion-DKnN7_wY.mp3 +0 -0
- package/embed-assets/rocket-launch-C-Yvbb7P.mp3 +0 -0
- package/embed-assets/tire-screech-DEsAg1CH.mp3 +0 -0
- package/embed-chunks/JoyRideView-EDSeeY9m.js +0 -1
- package/embed-chunks/configuration~index~embed~bookmarklet-BH7GyoGh.js +0 -1
- package/embed-chunks/definitions~index~embed~bookmarklet-BfjknPZN.js +0 -1
- package/embed-chunks/definitions~index~embed~bookmarklet~vehicle-popover~Documentation~JoyRideView~browser-sessi~fklztn3g-Dt96jol6.js +0 -1
- package/embed-chunks/runtime~browser-session-core-CXDCVDsi.js +0 -1
- package/embed-chunks/runtime~index~embed-BVbNVFHj.js +0 -210
- package/embed-chunks/runtime~vehicle-popover~browser-session-core-CjXpkmYi.js +0 -1
- package/embed-chunks/runtime~vehicle-popover~browser-session-core~renderer-CLLM7CAb.js +0 -4
- package/embed-chunks/runtime~vehicle-popover~renderer-Cx3wjyMH.js +0 -1077
- package/embed-chunks/src-BBr94UQ7.js +0 -2
- package/embed-chunks/vehicle-catalog~index~embed-CZzI6C0M.js +0 -1
- package/embed-chunks/vehicle-popover-DxuDMFyq.js +0 -1
- package/npm-chunks/JoyRideView-fHWzVVNB.js +0 -1
- package/npm-chunks/configuration~react~vehicle-popover~JoyRideView~browser-session-core~renderer-B70Mpi9X.js +0 -1
- package/npm-chunks/definitions~react~vehicle-popover~Documentation~JoyRideView~browser-session-core-BZJqthWX.js +0 -1
- package/npm-chunks/definitions~react~vehicle-popover~Documentation~JoyRideView~browser-session-core~renderer-Dt96jol6.js +0 -1
- package/npm-chunks/runtime~browser-session-core-Y1rfFp6D.js +0 -1
- package/npm-chunks/runtime~react~vehicle-popover~browser-session-core-BzXBN4rK.js +0 -210
- package/npm-chunks/runtime~vehicle-popover~browser-session-core-Ce3U7qky.js +0 -1
- package/npm-chunks/runtime~vehicle-popover~browser-session-core~renderer-jVG7K050.js +0 -4
- package/npm-chunks/runtime~vehicle-popover~renderer-Dmf1M43y.js +0 -1077
- package/npm-chunks/theme-C4ZE2-nQ.js +0 -2
- package/npm-chunks/vehicle-catalog~react~browser-session-core-BzB5J-Lm.js +0 -1
- package/npm-chunks/vehicle-catalog~react~vehicle-popover~browser-session-core-CX066OIY.js +0 -1
- package/npm-chunks/vehicle-popover-Deuulng7.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,c as t,o as n,r}from"./configuration~react~vehicle-popover~JoyRideView~browser-session-core~renderer-B70Mpi9X.js";import{a as i}from"./definitions~react~vehicle-popover~Documentation~JoyRideView~browser-session-core~renderer-Dt96jol6.js";import{r as a}from"./definitions~react~vehicle-popover~browser-session-core~renderer-RDNEXk_b.js";function o(e,t){return{lifetime:{unit:`seconds`,amount:1},modifiers:{driveForce:1.08,grip:1.04},additiveModifiers:{forwardAccelerationMps2:e/Math.max(.1,t)}}}var s={oil:{lifetime:{unit:`distanceM`,amount:i.oil.effectDistanceM},modifiers:{grip:i.oil.minimumGrip}},mud:{lifetime:{unit:`distanceM`,amount:i.mud.effectDistanceM},modifiers:{grip:i.mud.minimumGrip,speed:i.mud.speedFactor,driveForce:i.mud.driveForceFactor}}},c={mud:{grip:i.mud.contactGrip,speed:i.mud.contactSpeedFactor,driveForce:i.mud.contactDriveForceFactor}};function l(e,t=0){let n=e.definition.lifetime.unit===`seconds`?Math.max(0,e.remaining-t):e.remaining,r=Math.min(1,n/e.definition.lifetime.amount);return e.definition.intensity===`constant`?+(n>0):e.definition.intensity===`pulse`?Math.sin(Math.PI*(1-r)):r}var u=class{active=new Map;contacts=new Map;captureState(){return a({active:this.active,contacts:this.contacts})}restoreState(e){let t=a(e);this.active=t.active,this.contacts=t.contacts}setContacts(e,t,n){n.length?this.contacts.set(e,new Map(n.map(e=>[e,t]))):this.contacts.delete(e)}apply(e,t,n){if(t.lifetime.amount<=0)return;let r=this.active.get(e);r||(r=new Map,this.active.set(e,r)),r.set(n??`vehicle`,{remaining:t.lifetime.amount,definition:t})}remaining(e,t){let n=this.active.get(e);return t===void 0?Math.max(0,...[...n?.values()??[]].map(e=>e.remaining)):n?.get(t)?.remaining??0}remove(e){this.active.delete(e)}bonus(e,t,n=4,r=0){if(t===void 0){let t=0;for(let i=0;i<n;i++)t+=this.bonus(e,i,n,r);return t/n}let i=0;for(let n of this.active.values())for(let a of[`vehicle`,t]){let t=n.get(a);i+=(t?.definition.additiveModifiers?.[e]??0)*(t?l(t,r):0)}return i}indicators(){return[...new Set([...this.active.keys(),...this.contacts.keys()])].map(e=>{let t=this.active.get(e),n=Math.max(0,...[...t?.values()??[]].map(e=>Math.min(1,e.remaining/e.definition.lifetime.amount)));return{label:e.charAt(0).toUpperCase()+e.slice(1),fraction:this.contacts.has(e)?1:n}})}factor(e,t,n=4){return this.factorFrom(null,e,t,n)}factorFrom(e,t,n,r=4){if(n===void 0){let n=0;for(let i=0;i<r;i++)n+=this.factorFrom(e,t,i);return n/r}let i=1;for(let[r,a]of this.active)for(let o of[`vehicle`,n]){if(e!==null&&r!==e)continue;let n=a.get(o),s=n?.definition.modifiers[t];if(n&&s!==void 0){let e=l(n);i*=1+(s-1)*e}}for(let[r,a]of this.contacts)for(let o of[`vehicle`,n])(e===null||r===e)&&(i*=a.get(o)?.[t]??1);return i}advance(e,t){for(let[n,r]of this.active){for(let[n,i]of r){let a=i.definition.lifetime.unit===`distanceM`?e:t;i.remaining=Math.max(0,i.remaining-Math.max(0,a)),i.remaining===0&&r.delete(n)}r.size===0&&this.active.delete(n)}}clearTire(e){for(let[t,n]of this.active)n.delete(e),n.size===0&&this.active.delete(t);for(let[t,n]of this.contacts)n.delete(e),n.size===0&&this.contacts.delete(t)}clear(){this.active.clear(),this.contacts.clear()}},d={defaultHealth:100,smokeFraction:.5,smoulderFraction:.35,ignitionFraction:.25,damagePerSecond:48,burnDownSeconds:8,impactDamagePerMps:3.5,explosionSeconds:.8,fireballSeconds:.38,blastRadiusPx:78},f={pixelsPerTenPoints:2500,minimum:10,maximum:1e3};function p(e,t,n){let r=Math.max(0,t)*Math.max(0,n);return w(e,`data-jr-points`,Math.min(f.maximum,Math.max(f.minimum,Math.round(r/f.pixelsPerTenPoints)*10)))}var m=class{maxHealth;health;explodedAt=null;blastQueued=!1;blastAge=0;lastBlastEmission=-1/0;lastDamageAt=-1/0;healthBarShownAt=-1/0;constructor(e=d.defaultHealth){this.maxHealth=e,this.maxHealth=Math.max(1,e),this.health=this.maxHealth}get stage(){return g(this.health,this.maxHealth)}get healthFraction(){return this.health/this.maxHealth}resetBurnable(e=this.maxHealth){let t=this.health!==Math.max(1,e);this.maxHealth=Math.max(1,e),this.health=this.maxHealth,this.explodedAt=null,this.blastQueued=!1,this.blastAge=0,this.lastBlastEmission=-1/0,this.lastDamageAt=t?performance.now():-1/0,this.healthBarShownAt=this.lastDamageAt}damage(e,t=performance.now()){return this.explodedAt!==null||!Number.isFinite(e)||e<=0||(this.health=Math.max(0,this.health-e),t-this.lastDamageAt>=2900&&(this.healthBarShownAt=t),this.lastDamageAt=t,this.health>0)?!1:(this.explodedAt=t,!0)}healthBarAlpha(e=performance.now()){let t=e-this.lastDamageAt;return this.stage===`burning`&&this.health>0?Math.max(0,Math.min(1,(e-this.healthBarShownAt)/120)):t<0||t>=2900?0:Math.min(1,(e-this.healthBarShownAt)/120,(2900-t)/650)}},h={defaultHealth:600,impactThresholdMps:3,impactDamagePerMps:5.5,maxImpactDamageFraction:.3,burningDamagePerSecond:14,respawnSeconds:2.5};function g(e,t){if(e<=0)return`exploded`;let n=e/Math.max(t,.001);return n<=d.ignitionFraction?`burning`:n<=d.smoulderFraction?`smouldering`:n<=d.smokeFraction?`smoking`:`intact`}function _(e,t){let n=e/Math.max(t,.001);return Math.max(0,Math.min(1,(d.smokeFraction-n)/d.smokeFraction))}function v(e,t,n){let r=Math.max(1,Math.min(e,t));return Math.max(13,r*.28)+r*.52*Math.max(0,Math.min(1,n))}function y(e,t,n,r){let i=g(e,t);if(i===`intact`||i===`exploded`)return null;let a=_(e,t),o=i===`burning`?Math.max(0,1-e/Math.max(t*d.ignitionFraction,.001)):0;return{stage:i,age:.19,spreadSeconds:0,burnSeconds:.8,fixedRadius:v(n,r,a),intensity:i===`burning`?.65+o*1.4:0,smokeOnly:i!==`burning`,smokeRate:i===`burning`?10+o*4:18+a*12}}function b(e){return{age:e,spreadSeconds:0,burnSeconds:d.fireballSeconds,blastAge:e,blastSeconds:d.fireballSeconds,smokeRate:12}}function x(e,t){return g(e,t)===`intact`||e<=0?0:.06+_(e,t)*.94}function S(t,n,i=0){let a=d.damagePerSecond;return t===`bullet`?a/(2*r(n).roundsPerSecond):t===`rocket`?a/e(n).roundsPerSecond:a*Math.max(0,i)}function C(e,t,n){return e*d.ignitionFraction*t/n}function w(e,t,n){let r=Number(e.getAttribute(t));return Number.isFinite(r)&&r>=0&&e.hasAttribute(t)?r:n}var T=(e=0,t=0)=>({x:e,y:t}),E=(e,t)=>T(e.x+t.x,e.y+t.y),D=(e,t)=>T(e.x-t.x,e.y-t.y),O=(e,t)=>T(e.x*t,e.y*t),k=(e,t)=>e.x*t.x+e.y*t.y,A=(e,t)=>e.x*t.y-e.y*t.x,j=e=>Math.hypot(e.x,e.y),M=(e,t)=>{let n=Math.cos(t),r=Math.sin(t);return T(e.x*n-e.y*r,e.x*r+e.y*n)},N=(e,t,n)=>Math.max(t,Math.min(n,e)),P=e=>Math.atan2(Math.sin(e),Math.cos(e));function F(e){let t=N(5.8+e.engineForceN/e.massKg*.12,6.5,8.5);return{speed:t,radius:t/N(t*Math.tan(e.maxSteerAngleRad)/e.geometry.wheelbaseM*.62,1.3,1.8)}}var I=class{mass=1e3;inertia=this.mass*20/12;position=T();velocity=T();angle=0;spin=0;force=T();torque=0;captureState(){return a({mass:this.mass,inertia:this.inertia,position:this.position,velocity:this.velocity,angle:this.angle,spin:this.spin,force:this.force,torque:this.torque})}restoreState(e){let t=a(e);this.mass=t.mass,this.inertia=t.inertia,this.position=t.position,this.velocity=t.velocity,this.angle=t.angle,this.spin=t.spin,this.force=t.force,this.torque=t.torque}reset(){this.position=T(),this.velocity=T(),this.angle=0,this.spin=0,this.force=T(),this.torque=0}world(e){return E(this.position,M(e,this.angle))}local(e){return M(D(e,this.position),-this.angle)}velocityAt(e){let t=D(e,this.position);return E(this.velocity,T(-this.spin*t.y,this.spin*t.x))}push(e,t=this.position){this.force=E(this.force,e),this.torque+=A(D(t,this.position),e)}impulse(e,t=this.position){this.velocity=E(this.velocity,O(e,1/this.mass)),this.spin+=A(D(t,this.position),e)/this.inertia}tick(e){this.velocity=E(this.velocity,O(this.force,e/this.mass)),this.spin+=this.torque*e/this.inertia,this.position=E(this.position,O(this.velocity,e)),this.angle+=this.spin*e,this.force=T(),this.torque=0}},L=class extends m{destructible=!0;get stage(){return this.destructible?super.stage:`intact`}damage(e,t=performance.now()){return this.destructible?super.damage(e,t):!1}tires=[];engineForce=0;rollingResistance=0;lateralResistance=0;handbrakeStrength=0;drifting=!1;donuting=!1;burnout=!1;launchSpinSeconds=0;boostCharge=0;boostReady=!1;get boostActive(){return this.statusEffects.remaining(`boost`)>0}burnOriginLocal=T(.7,0);statusEffects=new u;get oilDistanceRemainingM(){return this.statusEffects.remaining(`oil`)}get oilGripFactor(){return this.statusEffects.factorFrom(`oil`,`grip`,void 0,this.tires.length||4)}oilGripFactorFor(e){return this.statusEffects.factorFrom(`oil`,`grip`,e)}coatWithOil(e){if(e===void 0)for(let e=0;e<this.tires.length;e++)this.statusEffects.apply(`oil`,s.oil,e);else e>=0&&e<this.tires.length&&this.statusEffects.apply(`oil`,s.oil,e)}coatWithMud(e){if(e===void 0)for(let e=0;e<this.tires.length;e++)this.statusEffects.apply(`mud`,s.mud,e);else e>=0&&e<this.tires.length&&this.statusEffects.apply(`mud`,s.mud,e)}washWheel(e){e>=0&&e<this.tires.length&&(this.statusEffects.clearTire(e),this.tires[e].heat=0)}advanceOil(e){this.statusEffects.advance(e,0)}frontLoadFraction=.5;slideAngleRad=0;countersteering=!1;driftDirection=0;driftStart=null;donutDirection=0;steeringAngle=0;steeringReferenceSpeed=0;previousVelocity=null;longitudinalAcceleration=0;burnoutSeconds=0;boostChargeSeconds=0;launchPeakRpm=0;launchAssistElapsed=0;launchAssistGainMps=0;preset=t.porsche911997;constructor(){super(h.defaultHealth),this.configure(t.porsche911997)}captureState(){return a({maxHealth:this.maxHealth,health:this.health,explodedAt:this.explodedAt,blastQueued:this.blastQueued,blastAge:this.blastAge,lastBlastEmission:this.lastBlastEmission,lastDamageAt:this.lastDamageAt,healthBarShownAt:this.healthBarShownAt,destructible:this.destructible,tires:this.tires,engineForce:this.engineForce,rollingResistance:this.rollingResistance,lateralResistance:this.lateralResistance,handbrakeStrength:this.handbrakeStrength,drifting:this.drifting,donuting:this.donuting,burnout:this.burnout,launchSpinSeconds:this.launchSpinSeconds,boostCharge:this.boostCharge,boostReady:this.boostReady,burnOriginLocal:this.burnOriginLocal,frontLoadFraction:this.frontLoadFraction,slideAngleRad:this.slideAngleRad,countersteering:this.countersteering,driftDirection:this.driftDirection,driftStart:this.driftStart,donutDirection:this.donutDirection,steeringAngle:this.steeringAngle,steeringReferenceSpeed:this.steeringReferenceSpeed,previousVelocity:this.previousVelocity,longitudinalAcceleration:this.longitudinalAcceleration,burnoutSeconds:this.burnoutSeconds,boostChargeSeconds:this.boostChargeSeconds,launchPeakRpm:this.launchPeakRpm,launchAssistElapsed:this.launchAssistElapsed,launchAssistGainMps:this.launchAssistGainMps,statusEffects:this.statusEffects.captureState()})}restoreState(e){let t=a(e);this.maxHealth=t.maxHealth,this.health=t.health,this.explodedAt=t.explodedAt,this.blastQueued=t.blastQueued,this.blastAge=t.blastAge,this.lastBlastEmission=t.lastBlastEmission,this.lastDamageAt=t.lastDamageAt,this.healthBarShownAt=t.healthBarShownAt,this.destructible=t.destructible,this.tires=t.tires,this.engineForce=t.engineForce,this.rollingResistance=t.rollingResistance,this.lateralResistance=t.lateralResistance,this.handbrakeStrength=t.handbrakeStrength,this.drifting=t.drifting,this.donuting=t.donuting,this.burnout=t.burnout,this.launchSpinSeconds=t.launchSpinSeconds,this.boostCharge=t.boostCharge,this.boostReady=t.boostReady,this.burnOriginLocal=t.burnOriginLocal,this.frontLoadFraction=t.frontLoadFraction,this.slideAngleRad=t.slideAngleRad,this.countersteering=t.countersteering,this.driftDirection=t.driftDirection,this.driftStart=t.driftStart,this.donutDirection=t.donutDirection,this.steeringAngle=t.steeringAngle,this.steeringReferenceSpeed=t.steeringReferenceSpeed,this.previousVelocity=t.previousVelocity,this.longitudinalAcceleration=t.longitudinalAcceleration,this.burnoutSeconds=t.burnoutSeconds,this.boostChargeSeconds=t.boostChargeSeconds,this.launchPeakRpm=t.launchPeakRpm,this.launchAssistElapsed=t.launchAssistElapsed,this.launchAssistGainMps=t.launchAssistGainMps,this.statusEffects.restoreState(t.statusEffects)}takeImpact(e,t=T(.7,0)){let n=this.stage===`burning`,r=Math.max(0,e-h.impactThresholdMps)*h.impactDamagePerMps,i=this.damage(Math.min(r,this.maxHealth*h.maxImpactDamageFraction));return!n&&this.health>0&&this.healthFraction<=d.ignitionFraction&&(this.burnOriginLocal={...t}),i}advanceBurn(e){return this.stage===`burning`&&this.damage(h.burningDamagePerSecond*Math.max(0,e))}configure(e){this.preset=e,this.engineForce=e.engineForceN,this.rollingResistance=e.rollingResistance,this.lateralResistance=e.lateralResistance,this.handbrakeStrength=e.handbrakeStrength;let{geometry:t}=e;this.tires=[{x:t.rearAxleXM??-t.wheelbaseM/2,track:t.rearTrackWidthM??t.trackWidthM,front:!1},{x:t.frontAxleXM??t.wheelbaseM/2,track:t.frontTrackWidthM??t.trackWidthM,front:!0}].flatMap(({x:e,track:t,front:n})=>[-t/2,t/2].map(t=>({local:T(e,t),front:n,angle:0,skidding:!1,lateralSpeed:0,slipSpeedMps:0,wheelSurfaceSpeedMps:0,slip:0,heat:0,spinning:!1,lateralForceN:0,gripUtilization:0}))),this.reset()}reset(){this.resetBurnable(this.preset.health??h.defaultHealth),this.burnOriginLocal=T(.7,0),this.drifting=!1,this.donuting=!1,this.frontLoadFraction=this.preset.frontWeightFraction??.5,this.slideAngleRad=0,this.countersteering=!1,this.driftDirection=0,this.driftStart=null,this.donutDirection=0,this.steeringAngle=0,this.steeringReferenceSpeed=0,this.previousVelocity=null,this.longitudinalAcceleration=0,this.burnout=!1,this.burnoutSeconds=0,this.launchPeakRpm=0,this.boostChargeSeconds=0,this.boostCharge=0,this.boostReady=!1,this.launchSpinSeconds=0,this.launchAssistElapsed=0,this.launchAssistGainMps=0,this.statusEffects.clear();for(let e of this.tires)e.angle=0,e.skidding=!1,e.lateralSpeed=0,e.slipSpeedMps=0,e.wheelSurfaceSpeedMps=0,e.slip=0,e.heat=0,e.spinning=!1,e.lateralForceN=0,e.gripUtilization=0}get fastDrifting(){return this.driftDirection!==0}prepareDrift(e,t){let n=j(e.velocity),r=k(e.velocity,M(T(1,0),e.angle)),i=this.preset.drift;this.fastDrifting&&(!t.action||Math.abs(t.steer)<=.2||n<i.entrySpeedMps*.65||t.throttle<=.5)&&(this.driftDirection=0),!this.fastDrifting&&t.action&&Math.abs(t.steer)>.2&&r>i.entrySpeedMps&&t.throttle>.5&&(this.driftDirection=Math.sign(t.steer),this.statusEffects.remove(`boost`)),this.driftStart=this.fastDrifting?{position:{...e.position},velocity:{...e.velocity},angle:e.angle,spin:e.spin}:null}tick(e,t,n,r){this.prepareDrift(e,t);let i=this.fastDrifting?{...t,action:!1}:t;this.tickForces(e,i,n,r)}tickForces(e,t,n,r){let i=this.burnout,a=this.boostReady&&!!t.boost,s=t.action||(t.brake??0)>.5;if(t.boost&&t.throttle>.5&&!s&&!this.fastDrifting?this.statusEffects.apply(`boost`,o(this.preset.driveBoost.gainMps,this.preset.driveBoost.durationSeconds)):this.statusEffects.remove(`boost`),this.burnout=s&&t.throttle>.5&&j(e.velocity)<1.2,this.burnout){this.burnoutSeconds+=n,this.boostChargeSeconds=t.boost?this.boostChargeSeconds+n:0;let e=Math.max(.1,this.preset.launch.burnoutRampSeconds);this.boostCharge=N(this.boostChargeSeconds/e,0,1),this.boostReady=this.boostChargeSeconds>=e&&this.burnoutSeconds>=e;let i=Math.max(r??0,this.preset.launch.minRpm*Math.min(1,this.burnoutSeconds/.9));this.launchPeakRpm=Math.max(this.launchPeakRpm,i)}else i&&!s&&t.throttle>.5?(this.burnoutSeconds>=.25&&this.launchPeakRpm>=this.preset.launch.minRpm&&(this.launchAssistGainMps=a?this.preset.launch.boostedBoostMps:this.preset.launch.boostMps,this.launchAssistElapsed=0),this.launchSpinSeconds=a?this.preset.launch.chargedSpinSeconds:.4):this.launchSpinSeconds=Math.max(0,this.launchSpinSeconds-n),this.burnoutSeconds=0,this.launchPeakRpm=0,this.boostChargeSeconds=0,this.boostCharge=0,this.boostReady=!1;let c=M(T(1,0),e.angle),l=Math.max(.1,this.preset.launch.assistDurationSeconds);if(this.launchAssistGainMps>0&&t.throttle>.5&&!s){let t=Math.min(l,this.launchAssistElapsed+n*.5),r=Math.sin(Math.PI*t/l);e.push(O(c,e.mass*this.launchAssistGainMps*Math.PI*r/(2*l))),this.launchAssistElapsed+=n,this.launchAssistElapsed>=l&&(this.launchAssistGainMps=0)}else this.launchAssistGainMps=0;let u=this.statusEffects.bonus(`forwardAccelerationMps2`,void 0,this.tires.length,n*.5);u>0&&t.throttle>.5&&!s&&e.push(O(c,e.mass*u));let d=T(-c.y,c.x),f=j(e.velocity),p=k(e.velocity,c),m=k(e.velocity,d),h=this.previousVelocity===null?0:N(k(D(e.velocity,this.previousVelocity),c)/Math.max(n,1e-4),-16,16);this.previousVelocity={...e.velocity},this.longitudinalAcceleration+=(h-this.longitudinalAcceleration)*(1-Math.exp(-n/.12));let g=this.preset.frontWeightFraction??.5;this.frontLoadFraction=N(g-this.longitudinalAcceleration*.012,.34,.68),this.slideAngleRad=Math.atan2(m,Math.max(2,Math.abs(p)));let _=Math.abs(t.steer),v=t.throttle>.5&&_>.8&&!t.action&&!this.fastDrifting;if(this.donuting?v&&Math.sign(t.steer)===this.donutDirection||(this.donuting=!1,this.donutDirection=0):v&&f<4.5&&(this.donuting=!0,this.donutDirection=Math.sign(t.steer)),this.drifting=this.fastDrifting||this.donuting,this.countersteering=this.fastDrifting&&t.steer*this.driftDirection<0,!this.drifting&&!t.action&&f>4&&p>0){let t=N(Math.abs(this.slideAngleRad)-.05,0,.8);e.spin+=Math.sign(this.slideAngleRad)*t*40*n}let y=t.throttle<0&&k(e.velocity,c)<=0,b=(t.action?.18:1)*(1-N(t.brake??0,0,1));e.push(O(c,t.throttle*b*this.engineForce*this.statusEffects.factor(`driveForce`,void 0,this.tires.length)*(y?this.preset.reversePowerRatio:1))),this.steeringReferenceSpeed=t.steer?Math.max(f,this.steeringReferenceSpeed-8*n):f;let x=Math.atan(this.preset.geometry.wheelbaseM*this.preset.corneringAccelerationMps2/(this.steeringReferenceSpeed**2+16)),S=t.steer*(this.donuting?this.preset.maxSteerAngleRad:Math.min(this.preset.maxSteerAngleRad,x));this.steeringAngle+=(S-this.steeringAngle)*(1-Math.exp(-n/(t.steer?.06:.04)));for(let[r,i]of this.tires.entries()){i.angle=i.front?this.steeringAngle:0;let a=e.world(i.local),o=e.velocityAt(a),s=e.angle+i.angle,c=T(Math.cos(s),Math.sin(s)),l=T(-c.y,c.x),u=k(o,c),d=k(o,l);i.lateralSpeed=Math.abs(d),i.spinning=!i.front&&(this.burnout||this.launchSpinSeconds>0||this.donuting);let p=!i.front&&t.action?Math.abs(u)*.65:0,m=this.burnout?5.2*(.3+.7*N(this.burnoutSeconds/Math.max(.1,this.preset.launch.burnoutRampSeconds),0,1))*(t.boost?1.6:1):5.2;i.wheelSurfaceSpeedMps=i.spinning?u+m:!i.front&&t.action?u*.35:u,i.slipSpeedMps=Math.max(i.lateralSpeed,p,Math.abs(i.wheelSurfaceSpeedMps-u)),i.slip=N((i.slipSpeedMps-.45)/4.8,0,1);let h=N((i.slipSpeedMps-.4)/5.2,0,1),_=h>i.heat?.65:2.2;i.heat+=(h-i.heat)*(1-Math.exp(-n/_));let v=i.front?this.frontLoadFraction:1-this.frontLoadFraction,y=N(v/(i.front?g:1-g),.65,1.35),b=(!i.front&&this.donuting?.5:1)*(1-i.heat*(i.front?.06:.12))*this.statusEffects.factor(`grip`,r),x=this.lateralResistance*(1+Math.min(f,40)/18)*y*b,S=e.mass*this.preset.corneringAccelerationMps2*v*.5*b,C=-x*d,w=N(C,-S,S);i.lateralForceN=w,i.gripUtilization=Math.abs(C)/Math.max(1,S);let D=Math.abs(C)>S*.92,A=i.skidding?1.2:1.8;i.skidding=i.spinning||i.slipSpeedMps>A&&(D||i.lateralSpeed>(i.front?2.8:2.1)||p>2.4);let j=this.rollingResistance*(!i.front&&t.action?1+this.handbrakeStrength*7:1);e.push(E(O(c,-j*u),O(l,w)),a)}}slow(e,t,r){let i=(t.throttle===0?this.preset.coastDecelerationMps2:0)+(t.action?this.preset.handbrakeDecelerationMps2:0),a=j(e.velocity);if(a===0)return;i&&(e.velocity=O(e.velocity,Math.max(0,a-i*r)/a));let o=N(t.brake??0,0,1);if(!o)return;let s=T(Math.cos(e.angle),Math.sin(e.angle)),c=k(e.velocity,s),l=Math.min(Math.abs(c),o*n(this.preset)*Math.max(.35,this.statusEffects.factor(`grip`,void 0,this.tires.length))*r);e.velocity=D(e.velocity,O(s,Math.sign(c)*l))}finishDrift(e,t,n){let r=this.driftStart;if(!this.fastDrifting||!r)return;let i=j(r.velocity),a=N(i/12,.55,1.2),o=this.driftDirection*(.92+.24*a)+N(t.steer,-1,1)*.47;e.spin=r.spin+(o-r.spin)*(1-Math.exp(-12*n)),e.angle=r.angle+e.spin*n;let s=j(e.velocity),c=Math.max(s,i-.5*n),l=Math.atan2(r.velocity.y,r.velocity.x),u=l+N(P(e.angle-this.driftDirection*this.preset.drift.slipAngleRad-l)*(1-Math.exp(-7*n)),-3.5*n,3.5*n);e.velocity=T(Math.cos(u)*c,Math.sin(u)*c),e.position=E(r.position,O(e.velocity,n)),this.slideAngleRad=P(u-e.angle);for(let e of this.tires)e.front||(e.skidding=!0,e.lateralSpeed=c*Math.sin(this.preset.drift.slipAngleRad),e.slipSpeedMps=Math.max(e.slipSpeedMps,e.lateralSpeed),e.slip=N(e.slipSpeedMps/4,0,1),e.heat+=(.8-e.heat)*(1-Math.exp(-2*n)),e.gripUtilization=Math.max(e.gripUtilization,1))}arcadeAssist(e,t,n){let r=j(e.velocity),{speed:i,radius:a}=F(this.preset);if(this.donuting){let t=i*this.statusEffects.factor(`speed`,void 0,this.tires.length),o=Math.atan2(e.velocity.y,e.velocity.x),s=e.angle-this.donutDirection*.22,c=Math.atan2(Math.sin(s-o),Math.cos(s-o))*(1-Math.exp(-n/.11)),l=r+(t-r)*(1-Math.exp(-n/.28));e.velocity=O(T(Math.cos(o+c),Math.sin(o+c)),l),e.spin=this.donutDirection*l/a;return}let o=M(T(1,0),e.angle);if(k(e.velocity,o)<-.35&&t.throttle<0&&!t.action){let i=this.preset.maxReverseSpeedMps??7;r>i&&(e.velocity=O(e.velocity,i/r)),e.spin=-t.steer*Math.min(r,i)/a;let s=O(o,-1),c=Math.atan2(A(s,e.velocity),k(s,e.velocity));e.velocity=M(e.velocity,-N(c,-.45,.45)*(1-Math.exp(-5*n)));return}if(r<2||this.drifting||t.action||k(e.velocity,o)<=0)return;let s=Math.atan2(A(o,e.velocity),k(o,e.velocity)),c=N((r-2)/10,0,1)*(t.steer?4.5:6)*this.statusEffects.factor(`grip`,void 0,this.tires.length),l=-N(s,-.55,.55)*(1-Math.exp(-c*n));e.velocity=M(e.velocity,l),t.steer||(e.spin*=Math.exp(-4.5*n))}},R=class{headAngle=0;appliedForce=T();craft=T(4,0);counterweight=T(-2,0);radius=.9;captureState(){return a({headAngle:this.headAngle,appliedForce:this.appliedForce,craft:this.craft,counterweight:this.counterweight,radius:this.radius})}restoreState(e){let t=a(e);this.headAngle=t.headAngle,this.appliedForce=t.appliedForce,Object.assign(this,{craft:t.craft,counterweight:t.counterweight,radius:t.radius})}reset(){this.headAngle=0,this.appliedForce=T()}tick(e,t,n){this.headAngle+=t.steer*2.5*n;let r=(t.throttle||+!!t.action)*5e3*(t.action?2:1);this.appliedForce=M(T(r,0),this.headAngle),e.push(M(this.appliedForce,e.angle),e.world(this.craft)),e.push(O(e.velocity,-e.mass*.12)),e.spin*=Math.exp(-.35*n)}},z=class{body=new I;car=new L;ship=new R;mode=`car`;gravity=!1;barrier=!1;paused=!1;lastInput={throttle:0,steer:0,action:!1};brickForce=null;captureState(){return{at:performance.now(),preset:a(this.car.preset),simulation:a({mode:this.mode,gravity:this.gravity,barrier:this.barrier,paused:this.paused,lastInput:this.lastInput,brickForce:this.brickForce}),body:this.body.captureState(),car:this.car.captureState(),ship:this.ship.captureState()}}restoreState(e){let t=a(e);this.setPreset(t.preset),this.body.restoreState(t.body),this.car.restoreState(t.car),this.ship.restoreState(t.ship),this.mode=t.simulation.mode,this.gravity=t.simulation.gravity,this.barrier=t.simulation.barrier,this.paused=t.simulation.paused,this.lastInput=t.simulation.lastInput,this.brickForce=t.simulation.brickForce;let n=performance.now()-t.at;this.car.explodedAt!==null&&(this.car.explodedAt+=n),Number.isFinite(this.car.lastBlastEmission)&&(this.car.lastBlastEmission+=n)}setPreset(e){this.car.configure(e),this.mode===`car`&&(this.body.mass=e.massKg,this.body.inertia=e.massKg*(e.geometry.lengthM**2+e.geometry.widthM**2)/12)}setMode(e){this.mode=e,this.body.mass=e===`car`?this.car.preset.massKg:1e3,this.body.inertia=e===`ship`?this.body.mass*(1/3*(1.8**2/18+.8**2/6+16)+2/3*(.9**2/2+4)):this.body.mass*(this.car.preset.geometry.lengthM**2+this.car.preset.geometry.widthM**2)/12,this.car.reset(),this.ship.reset(),this.brickForce=null}reset(){this.body.reset(),this.car.reset(),this.ship.reset(),this.brickForce=null,this.lastInput={throttle:0,steer:0,action:!1}}resetAtCurrentPose(){let e={...this.body.position},t=this.body.angle;this.reset(),this.body.position=e,this.body.angle=t}tick(e,t,n){if(this.paused)return;if(this.mode===`car`&&this.car.explodedAt!==null){this.body.velocity=T(),this.body.spin=0,this.lastInput={throttle:0,steer:0,action:!1,boost:!1};return}this.lastInput={...e};let r=this.body,i={...r.position};if(this.gravity){let e=r.mass*3/30;r.push(T(-e*r.velocity.x,-r.mass*3-e*r.velocity.y))}if(this.mode===`car`&&this.car.tick(r,e,t,n),this.mode===`ship`){let n=r.angle;this.ship.tick(r,e,t),r.tick(t),this.ship.headAngle-=r.angle-n}else if(this.mode===`brick`&&this.brickForce&&r.push(this.brickForce.force,r.world(this.brickForce.local)),r.tick(t),this.mode===`car`){let n=this.car.fastDrifting?{...e,action:!1}:e;this.car.slow(r,n,t),this.car.fastDrifting?this.car.finishDrift(r,e,t):this.car.arcadeAssist(r,n,t);let a=this.car.statusEffects.factor(`speed`,void 0,this.car.tires.length);a<1&&(r.velocity=O(r.velocity,Math.exp(-5*(1-a)*t))),this.car.statusEffects.advance(j(D(r.position,i)),t)}}contain(e){let t=this.body,n=this.mode===`car`?this.car.preset.geometry.lengthM/2:2,r=this.mode===`car`?this.car.preset.geometry.widthM/2:1,i=this.mode===`ship`?[T(1.2,0),T(-.6,-.8),T(-.6,.8)].map(e=>t.world(E(this.ship.craft,M(e,this.ship.headAngle)))):[T(-n,-r),T(n,-r),T(n,r),T(-n,r)].map(e=>t.world(e));this.mode===`ship`&&i.push(t.world(this.ship.counterweight));let a=[[T(1),e.left],[T(-1),-e.right],[T(0,1),e.bottom],[T(0,-1),-e.top]];for(let e=0;e<4;e++)for(let[e,n]of a){let r=i.map(t=>k(t,e)-(this.mode===`ship`?this.ship.radius:0)),a=Math.min(...r),o=n-a;if(o<-1e-8)continue;let s=i[r.indexOf(a)],c=O(e,Math.max(0,o));t.position=E(t.position,c);for(let e of i)e.x+=c.x,e.y+=c.y;let l=E(s,O(e,this.mode===`ship`?-this.ship.radius:0)),u=k(t.velocityAt(l),e);if(u>=0)continue;let d=A(D(l,t.position),e),f=1/t.mass+d*d/t.inertia;t.impulse(O(e,-(1+(u<-.5?.55:0))*u/f),l)}}};function B(e,t){}function V(e,t=1){}export{c as C,h as S,S as _,A as a,g as b,D as c,O as d,T as f,d as g,C as h,N as i,E as l,x as m,B as n,k as o,m as p,z as r,j as s,V as t,M as u,y as v,p as x,b as y};
|
|
1
|
+
import{a as e,l as t,o as n,r}from"./configuration~react~vehicle-popover~JoyRideView~browser-session-core~renderer-CPZkP_Db.js";import{a as i}from"./definitions~react~vehicle-popover~Documentation~JoyRideView~browser-session-core~renderer-BG7sJuWo.js";import{r as a}from"./definitions~react~vehicle-popover~browser-session-core~renderer-RDNEXk_b.js";function o(e,t){return{lifetime:{unit:`seconds`,amount:1},modifiers:{driveForce:1.08,grip:1.04},additiveModifiers:{forwardAccelerationMps2:e/Math.max(.1,t)}}}var s={oil:{lifetime:{unit:`distanceM`,amount:i.oil.effectDistanceM},modifiers:{grip:i.oil.minimumGrip}},mud:{lifetime:{unit:`distanceM`,amount:i.mud.effectDistanceM},modifiers:{grip:i.mud.minimumGrip,speed:i.mud.speedFactor,driveForce:i.mud.driveForceFactor}}},c={mud:{grip:i.mud.contactGrip,speed:i.mud.contactSpeedFactor,driveForce:i.mud.contactDriveForceFactor}};function l(e,t=0){let n=e.definition.lifetime.unit===`seconds`?Math.max(0,e.remaining-t):e.remaining,r=Math.min(1,n/e.definition.lifetime.amount);return e.definition.intensity===`constant`?+(n>0):e.definition.intensity===`pulse`?Math.sin(Math.PI*(1-r)):r}var u=class{active=new Map;contacts=new Map;captureState(){return a({active:this.active,contacts:this.contacts})}restoreState(e){let t=a(e);this.active=t.active,this.contacts=t.contacts}setContacts(e,t,n){n.length?this.contacts.set(e,new Map(n.map(e=>[e,t]))):this.contacts.delete(e)}apply(e,t,n){if(t.lifetime.amount<=0)return;let r=this.active.get(e);r||(r=new Map,this.active.set(e,r)),r.set(n??`vehicle`,{remaining:t.lifetime.amount,definition:t})}remaining(e,t){let n=this.active.get(e);return t===void 0?Math.max(0,...[...n?.values()??[]].map(e=>e.remaining)):n?.get(t)?.remaining??0}remove(e){this.active.delete(e)}bonus(e,t,n=4,r=0){if(t===void 0){let t=0;for(let i=0;i<n;i++)t+=this.bonus(e,i,n,r);return t/n}let i=0;for(let n of this.active.values())for(let a of[`vehicle`,t]){let t=n.get(a);i+=(t?.definition.additiveModifiers?.[e]??0)*(t?l(t,r):0)}return i}indicators(){return[...new Set([...this.active.keys(),...this.contacts.keys()])].map(e=>{let t=this.active.get(e),n=Math.max(0,...[...t?.values()??[]].map(e=>Math.min(1,e.remaining/e.definition.lifetime.amount)));return{label:e.charAt(0).toUpperCase()+e.slice(1),fraction:this.contacts.has(e)?1:n}})}factor(e,t,n=4){return this.factorFrom(null,e,t,n)}factorFrom(e,t,n,r=4){if(n===void 0){let n=0;for(let i=0;i<r;i++)n+=this.factorFrom(e,t,i);return n/r}let i=1;for(let[r,a]of this.active)for(let o of[`vehicle`,n]){if(e!==null&&r!==e)continue;let n=a.get(o),s=n?.definition.modifiers[t];if(n&&s!==void 0){let e=l(n);i*=1+(s-1)*e}}for(let[r,a]of this.contacts)for(let o of[`vehicle`,n])(e===null||r===e)&&(i*=a.get(o)?.[t]??1);return i}advance(e,t){for(let[n,r]of this.active){for(let[n,i]of r){let a=i.definition.lifetime.unit===`distanceM`?e:t;i.remaining=Math.max(0,i.remaining-Math.max(0,a)),i.remaining===0&&r.delete(n)}r.size===0&&this.active.delete(n)}}clearTire(e){for(let[t,n]of this.active)n.delete(e),n.size===0&&this.active.delete(t);for(let[t,n]of this.contacts)n.delete(e),n.size===0&&this.contacts.delete(t)}clear(){this.active.clear(),this.contacts.clear()}},d={defaultHealth:100,smokeFraction:.5,smoulderFraction:.35,ignitionFraction:.25,damagePerSecond:48,burnDownSeconds:8,impactDamagePerMps:3.5,explosionSeconds:.8,fireballSeconds:.38,blastRadiusPx:78},f={pixelsPerTenPoints:2500,minimum:10,maximum:1e3};function p(e,t,n){let r=Math.max(0,t)*Math.max(0,n);return w(e,`data-jr-points`,Math.min(f.maximum,Math.max(f.minimum,Math.round(r/f.pixelsPerTenPoints)*10)))}var m=class{maxHealth;health;explodedAt=null;blastQueued=!1;blastAge=0;lastBlastEmission=-1/0;lastDamageAt=-1/0;healthBarShownAt=-1/0;constructor(e=d.defaultHealth){this.maxHealth=e,this.maxHealth=Math.max(1,e),this.health=this.maxHealth}get stage(){return g(this.health,this.maxHealth)}get healthFraction(){return this.health/this.maxHealth}resetBurnable(e=this.maxHealth){let t=this.health!==Math.max(1,e);this.maxHealth=Math.max(1,e),this.health=this.maxHealth,this.explodedAt=null,this.blastQueued=!1,this.blastAge=0,this.lastBlastEmission=-1/0,this.lastDamageAt=t?performance.now():-1/0,this.healthBarShownAt=this.lastDamageAt}damage(e,t=performance.now()){return this.explodedAt!==null||!Number.isFinite(e)||e<=0||(this.health=Math.max(0,this.health-e),t-this.lastDamageAt>=2900&&(this.healthBarShownAt=t),this.lastDamageAt=t,this.health>0)?!1:(this.explodedAt=t,!0)}healthBarAlpha(e=performance.now()){let t=e-this.lastDamageAt;return this.stage===`burning`&&this.health>0?Math.max(0,Math.min(1,(e-this.healthBarShownAt)/120)):t<0||t>=2900?0:Math.min(1,(e-this.healthBarShownAt)/120,(2900-t)/650)}},h={defaultHealth:600,impactThresholdMps:3,impactDamagePerMps:5.5,maxImpactDamageFraction:.3,burningDamagePerSecond:14,respawnSeconds:2.5};function g(e,t){if(e<=0)return`exploded`;let n=e/Math.max(t,.001);return n<=d.ignitionFraction?`burning`:n<=d.smoulderFraction?`smouldering`:n<=d.smokeFraction?`smoking`:`intact`}function _(e,t){let n=e/Math.max(t,.001);return Math.max(0,Math.min(1,(d.smokeFraction-n)/d.smokeFraction))}function v(e,t,n){let r=Math.max(1,Math.min(e,t));return Math.max(13,r*.28)+r*.52*Math.max(0,Math.min(1,n))}function y(e,t,n,r){let i=g(e,t);if(i===`intact`||i===`exploded`)return null;let a=_(e,t),o=i===`burning`?Math.max(0,1-e/Math.max(t*d.ignitionFraction,.001)):0;return{stage:i,age:.19,spreadSeconds:0,burnSeconds:.8,fixedRadius:v(n,r,a),intensity:i===`burning`?.65+o*1.4:0,smokeOnly:i!==`burning`,smokeRate:i===`burning`?10+o*4:18+a*12}}function b(e){return{age:e,spreadSeconds:0,burnSeconds:d.fireballSeconds,blastAge:e,blastSeconds:d.fireballSeconds,smokeRate:12}}function x(e,t){return g(e,t)===`intact`||e<=0?0:.06+_(e,t)*.94}function S(t,n,i=0){let a=d.damagePerSecond;return t===`bullet`?a/(2*r(n).roundsPerSecond):t===`rocket`?a/e(n).roundsPerSecond:a*Math.max(0,i)}function C(e,t,n){return e*d.ignitionFraction*t/n}function w(e,t,n){let r=Number(e.getAttribute(t));return Number.isFinite(r)&&r>=0&&e.hasAttribute(t)?r:n}var T=(e=0,t=0)=>({x:e,y:t}),E=(e,t)=>T(e.x+t.x,e.y+t.y),D=(e,t)=>T(e.x-t.x,e.y-t.y),O=(e,t)=>T(e.x*t,e.y*t),k=(e,t)=>e.x*t.x+e.y*t.y,A=(e,t)=>e.x*t.y-e.y*t.x,j=e=>Math.hypot(e.x,e.y),M=(e,t)=>{let n=Math.cos(t),r=Math.sin(t);return T(e.x*n-e.y*r,e.x*r+e.y*n)},N=(e,t,n)=>Math.max(t,Math.min(n,e)),P=e=>Math.atan2(Math.sin(e),Math.cos(e));function F(e){let t=N(5.8+e.engineForceN/e.massKg*.12,6.5,8.5);return{speed:t,radius:t/N(t*Math.tan(e.maxSteerAngleRad)/e.geometry.wheelbaseM*.62,1.3,1.8)}}var I=class{mass=1e3;inertia=this.mass*20/12;position=T();velocity=T();angle=0;spin=0;force=T();torque=0;captureState(){return a({mass:this.mass,inertia:this.inertia,position:this.position,velocity:this.velocity,angle:this.angle,spin:this.spin,force:this.force,torque:this.torque})}restoreState(e){let t=a(e);this.mass=t.mass,this.inertia=t.inertia,this.position=t.position,this.velocity=t.velocity,this.angle=t.angle,this.spin=t.spin,this.force=t.force,this.torque=t.torque}reset(){this.position=T(),this.velocity=T(),this.angle=0,this.spin=0,this.force=T(),this.torque=0}world(e){return E(this.position,M(e,this.angle))}local(e){return M(D(e,this.position),-this.angle)}velocityAt(e){let t=D(e,this.position);return E(this.velocity,T(-this.spin*t.y,this.spin*t.x))}push(e,t=this.position){this.force=E(this.force,e),this.torque+=A(D(t,this.position),e)}impulse(e,t=this.position){this.velocity=E(this.velocity,O(e,1/this.mass)),this.spin+=A(D(t,this.position),e)/this.inertia}tick(e){this.velocity=E(this.velocity,O(this.force,e/this.mass)),this.spin+=this.torque*e/this.inertia,this.position=E(this.position,O(this.velocity,e)),this.angle+=this.spin*e,this.force=T(),this.torque=0}},L=class extends m{destructible=!0;get stage(){return this.destructible?super.stage:`intact`}damage(e,t=performance.now()){return this.destructible?super.damage(e,t):!1}tires=[];engineForce=0;rollingResistance=0;lateralResistance=0;handbrakeStrength=0;drifting=!1;donuting=!1;burnout=!1;launchSpinSeconds=0;boostCharge=0;boostReady=!1;get boostActive(){return this.statusEffects.remaining(`boost`)>0}burnOriginLocal=T(.7,0);statusEffects=new u;get oilDistanceRemainingM(){return this.statusEffects.remaining(`oil`)}get oilGripFactor(){return this.statusEffects.factorFrom(`oil`,`grip`,void 0,this.tires.length||4)}oilGripFactorFor(e){return this.statusEffects.factorFrom(`oil`,`grip`,e)}coatWithOil(e){if(e===void 0)for(let e=0;e<this.tires.length;e++)this.statusEffects.apply(`oil`,s.oil,e);else e>=0&&e<this.tires.length&&this.statusEffects.apply(`oil`,s.oil,e)}coatWithMud(e){if(e===void 0)for(let e=0;e<this.tires.length;e++)this.statusEffects.apply(`mud`,s.mud,e);else e>=0&&e<this.tires.length&&this.statusEffects.apply(`mud`,s.mud,e)}washWheel(e){e>=0&&e<this.tires.length&&(this.statusEffects.clearTire(e),this.tires[e].heat=0)}advanceOil(e){this.statusEffects.advance(e,0)}frontLoadFraction=.5;slideAngleRad=0;countersteering=!1;driftDirection=0;driftStart=null;donutDirection=0;steeringAngle=0;steeringReferenceSpeed=0;previousVelocity=null;longitudinalAcceleration=0;burnoutSeconds=0;boostChargeSeconds=0;launchPeakRpm=0;launchAssistElapsed=0;launchAssistGainMps=0;preset=t.porsche911997;constructor(){super(h.defaultHealth),this.configure(t.porsche911997)}captureState(){return a({maxHealth:this.maxHealth,health:this.health,explodedAt:this.explodedAt,blastQueued:this.blastQueued,blastAge:this.blastAge,lastBlastEmission:this.lastBlastEmission,lastDamageAt:this.lastDamageAt,healthBarShownAt:this.healthBarShownAt,destructible:this.destructible,tires:this.tires,engineForce:this.engineForce,rollingResistance:this.rollingResistance,lateralResistance:this.lateralResistance,handbrakeStrength:this.handbrakeStrength,drifting:this.drifting,donuting:this.donuting,burnout:this.burnout,launchSpinSeconds:this.launchSpinSeconds,boostCharge:this.boostCharge,boostReady:this.boostReady,burnOriginLocal:this.burnOriginLocal,frontLoadFraction:this.frontLoadFraction,slideAngleRad:this.slideAngleRad,countersteering:this.countersteering,driftDirection:this.driftDirection,driftStart:this.driftStart,donutDirection:this.donutDirection,steeringAngle:this.steeringAngle,steeringReferenceSpeed:this.steeringReferenceSpeed,previousVelocity:this.previousVelocity,longitudinalAcceleration:this.longitudinalAcceleration,burnoutSeconds:this.burnoutSeconds,boostChargeSeconds:this.boostChargeSeconds,launchPeakRpm:this.launchPeakRpm,launchAssistElapsed:this.launchAssistElapsed,launchAssistGainMps:this.launchAssistGainMps,statusEffects:this.statusEffects.captureState()})}restoreState(e){let t=a(e);this.maxHealth=t.maxHealth,this.health=t.health,this.explodedAt=t.explodedAt,this.blastQueued=t.blastQueued,this.blastAge=t.blastAge,this.lastBlastEmission=t.lastBlastEmission,this.lastDamageAt=t.lastDamageAt,this.healthBarShownAt=t.healthBarShownAt,this.destructible=t.destructible,this.tires=t.tires,this.engineForce=t.engineForce,this.rollingResistance=t.rollingResistance,this.lateralResistance=t.lateralResistance,this.handbrakeStrength=t.handbrakeStrength,this.drifting=t.drifting,this.donuting=t.donuting,this.burnout=t.burnout,this.launchSpinSeconds=t.launchSpinSeconds,this.boostCharge=t.boostCharge,this.boostReady=t.boostReady,this.burnOriginLocal=t.burnOriginLocal,this.frontLoadFraction=t.frontLoadFraction,this.slideAngleRad=t.slideAngleRad,this.countersteering=t.countersteering,this.driftDirection=t.driftDirection,this.driftStart=t.driftStart,this.donutDirection=t.donutDirection,this.steeringAngle=t.steeringAngle,this.steeringReferenceSpeed=t.steeringReferenceSpeed,this.previousVelocity=t.previousVelocity,this.longitudinalAcceleration=t.longitudinalAcceleration,this.burnoutSeconds=t.burnoutSeconds,this.boostChargeSeconds=t.boostChargeSeconds,this.launchPeakRpm=t.launchPeakRpm,this.launchAssistElapsed=t.launchAssistElapsed,this.launchAssistGainMps=t.launchAssistGainMps,this.statusEffects.restoreState(t.statusEffects)}takeImpact(e,t=T(.7,0)){let n=this.stage===`burning`,r=Math.max(0,e-h.impactThresholdMps)*h.impactDamagePerMps,i=this.damage(Math.min(r,this.maxHealth*h.maxImpactDamageFraction));return!n&&this.health>0&&this.healthFraction<=d.ignitionFraction&&(this.burnOriginLocal={...t}),i}advanceBurn(e){return this.stage===`burning`&&this.damage(h.burningDamagePerSecond*Math.max(0,e))}configure(e){this.preset=e,this.engineForce=e.engineForceN,this.rollingResistance=e.rollingResistance,this.lateralResistance=e.lateralResistance,this.handbrakeStrength=e.handbrakeStrength;let{geometry:t}=e;this.tires=[{x:t.rearAxleXM??-t.wheelbaseM/2,track:t.rearTrackWidthM??t.trackWidthM,front:!1},{x:t.frontAxleXM??t.wheelbaseM/2,track:t.frontTrackWidthM??t.trackWidthM,front:!0}].flatMap(({x:e,track:t,front:n})=>[-t/2,t/2].map(t=>({local:T(e,t),front:n,angle:0,skidding:!1,lateralSpeed:0,slipSpeedMps:0,wheelSurfaceSpeedMps:0,slip:0,heat:0,spinning:!1,lateralForceN:0,gripUtilization:0}))),this.reset()}reset(){this.resetBurnable(this.preset.health??h.defaultHealth),this.burnOriginLocal=T(.7,0),this.drifting=!1,this.donuting=!1,this.frontLoadFraction=this.preset.frontWeightFraction??.5,this.slideAngleRad=0,this.countersteering=!1,this.driftDirection=0,this.driftStart=null,this.donutDirection=0,this.steeringAngle=0,this.steeringReferenceSpeed=0,this.previousVelocity=null,this.longitudinalAcceleration=0,this.burnout=!1,this.burnoutSeconds=0,this.launchPeakRpm=0,this.boostChargeSeconds=0,this.boostCharge=0,this.boostReady=!1,this.launchSpinSeconds=0,this.launchAssistElapsed=0,this.launchAssistGainMps=0,this.statusEffects.clear();for(let e of this.tires)e.angle=0,e.skidding=!1,e.lateralSpeed=0,e.slipSpeedMps=0,e.wheelSurfaceSpeedMps=0,e.slip=0,e.heat=0,e.spinning=!1,e.lateralForceN=0,e.gripUtilization=0}get fastDrifting(){return this.driftDirection!==0}prepareDrift(e,t){let n=j(e.velocity),r=k(e.velocity,M(T(1,0),e.angle)),i=this.preset.drift;this.fastDrifting&&(!t.action||Math.abs(t.steer)<=.2||n<i.entrySpeedMps*.65||t.throttle<=.5)&&(this.driftDirection=0),!this.fastDrifting&&t.action&&Math.abs(t.steer)>.2&&r>i.entrySpeedMps&&t.throttle>.5&&(this.driftDirection=Math.sign(t.steer),this.statusEffects.remove(`boost`)),this.driftStart=this.fastDrifting?{position:{...e.position},velocity:{...e.velocity},angle:e.angle,spin:e.spin}:null}tick(e,t,n,r){this.prepareDrift(e,t);let i=this.fastDrifting?{...t,action:!1}:t;this.tickForces(e,i,n,r)}tickForces(e,t,n,r){let i=this.burnout,a=this.boostReady&&!!t.boost,s=t.action||(t.brake??0)>.5;if(t.boost&&t.throttle>.5&&!s&&!this.fastDrifting?this.statusEffects.apply(`boost`,o(this.preset.driveBoost.gainMps,this.preset.driveBoost.durationSeconds)):this.statusEffects.remove(`boost`),this.burnout=s&&t.throttle>.5&&j(e.velocity)<1.2,this.burnout){this.burnoutSeconds+=n,this.boostChargeSeconds=t.boost?this.boostChargeSeconds+n:0;let e=Math.max(.1,this.preset.launch.burnoutRampSeconds);this.boostCharge=N(this.boostChargeSeconds/e,0,1),this.boostReady=this.boostChargeSeconds>=e&&this.burnoutSeconds>=e;let i=Math.max(r??0,this.preset.launch.minRpm*Math.min(1,this.burnoutSeconds/.9));this.launchPeakRpm=Math.max(this.launchPeakRpm,i)}else i&&!s&&t.throttle>.5?(this.burnoutSeconds>=.25&&this.launchPeakRpm>=this.preset.launch.minRpm&&(this.launchAssistGainMps=a?this.preset.launch.boostedBoostMps:this.preset.launch.boostMps,this.launchAssistElapsed=0),this.launchSpinSeconds=a?this.preset.launch.chargedSpinSeconds:.4):this.launchSpinSeconds=Math.max(0,this.launchSpinSeconds-n),this.burnoutSeconds=0,this.launchPeakRpm=0,this.boostChargeSeconds=0,this.boostCharge=0,this.boostReady=!1;let c=M(T(1,0),e.angle),l=Math.max(.1,this.preset.launch.assistDurationSeconds);if(this.launchAssistGainMps>0&&t.throttle>.5&&!s){let t=Math.min(l,this.launchAssistElapsed+n*.5),r=Math.sin(Math.PI*t/l);e.push(O(c,e.mass*this.launchAssistGainMps*Math.PI*r/(2*l))),this.launchAssistElapsed+=n,this.launchAssistElapsed>=l&&(this.launchAssistGainMps=0)}else this.launchAssistGainMps=0;let u=this.statusEffects.bonus(`forwardAccelerationMps2`,void 0,this.tires.length,n*.5);u>0&&t.throttle>.5&&!s&&e.push(O(c,e.mass*u));let d=T(-c.y,c.x),f=j(e.velocity),p=k(e.velocity,c),m=k(e.velocity,d),h=this.previousVelocity===null?0:N(k(D(e.velocity,this.previousVelocity),c)/Math.max(n,1e-4),-16,16);this.previousVelocity={...e.velocity},this.longitudinalAcceleration+=(h-this.longitudinalAcceleration)*(1-Math.exp(-n/.12));let g=this.preset.frontWeightFraction??.5;this.frontLoadFraction=N(g-this.longitudinalAcceleration*.012,.34,.68),this.slideAngleRad=Math.atan2(m,Math.max(2,Math.abs(p)));let _=Math.abs(t.steer),v=t.throttle>.5&&_>.8&&!t.action&&!this.fastDrifting;if(this.donuting?v&&Math.sign(t.steer)===this.donutDirection||(this.donuting=!1,this.donutDirection=0):v&&f<4.5&&(this.donuting=!0,this.donutDirection=Math.sign(t.steer)),this.drifting=this.fastDrifting||this.donuting,this.countersteering=this.fastDrifting&&t.steer*this.driftDirection<0,!this.drifting&&!t.action&&f>4&&p>0){let t=N(Math.abs(this.slideAngleRad)-.05,0,.8);e.spin+=Math.sign(this.slideAngleRad)*t*40*n}let y=t.throttle<0&&k(e.velocity,c)<=0,b=(t.action?.18:1)*(1-N(t.brake??0,0,1));e.push(O(c,t.throttle*b*this.engineForce*this.statusEffects.factor(`driveForce`,void 0,this.tires.length)*(y?this.preset.reversePowerRatio:1))),this.steeringReferenceSpeed=t.steer?Math.max(f,this.steeringReferenceSpeed-8*n):f;let x=Math.atan(this.preset.geometry.wheelbaseM*this.preset.corneringAccelerationMps2/(this.steeringReferenceSpeed**2+16)),S=t.steer*(this.donuting?this.preset.maxSteerAngleRad:Math.min(this.preset.maxSteerAngleRad,x));this.steeringAngle+=(S-this.steeringAngle)*(1-Math.exp(-n/(t.steer?.06:.04)));for(let[r,i]of this.tires.entries()){i.angle=i.front?this.steeringAngle:0;let a=e.world(i.local),o=e.velocityAt(a),s=e.angle+i.angle,c=T(Math.cos(s),Math.sin(s)),l=T(-c.y,c.x),u=k(o,c),d=k(o,l);i.lateralSpeed=Math.abs(d),i.spinning=!i.front&&(this.burnout||this.launchSpinSeconds>0||this.donuting);let p=!i.front&&t.action?Math.abs(u)*.65:0,m=this.burnout?5.2*(.3+.7*N(this.burnoutSeconds/Math.max(.1,this.preset.launch.burnoutRampSeconds),0,1))*(t.boost?1.6:1):5.2;i.wheelSurfaceSpeedMps=i.spinning?u+m:!i.front&&t.action?u*.35:u,i.slipSpeedMps=Math.max(i.lateralSpeed,p,Math.abs(i.wheelSurfaceSpeedMps-u)),i.slip=N((i.slipSpeedMps-.45)/4.8,0,1);let h=N((i.slipSpeedMps-.4)/5.2,0,1),_=h>i.heat?.65:2.2;i.heat+=(h-i.heat)*(1-Math.exp(-n/_));let v=i.front?this.frontLoadFraction:1-this.frontLoadFraction,y=N(v/(i.front?g:1-g),.65,1.35),b=(!i.front&&this.donuting?.5:1)*(1-i.heat*(i.front?.06:.12))*this.statusEffects.factor(`grip`,r),x=this.lateralResistance*(1+Math.min(f,40)/18)*y*b,S=e.mass*this.preset.corneringAccelerationMps2*v*.5*b,C=-x*d,w=N(C,-S,S);i.lateralForceN=w,i.gripUtilization=Math.abs(C)/Math.max(1,S);let D=Math.abs(C)>S*.92,A=i.skidding?1.2:1.8;i.skidding=i.spinning||i.slipSpeedMps>A&&(D||i.lateralSpeed>(i.front?2.8:2.1)||p>2.4);let j=this.rollingResistance*(!i.front&&t.action?1+this.handbrakeStrength*7:1);e.push(E(O(c,-j*u),O(l,w)),a)}}slow(e,t,r){let i=(t.throttle===0?this.preset.coastDecelerationMps2:0)+(t.action?this.preset.handbrakeDecelerationMps2:0),a=j(e.velocity);if(a===0)return;i&&(e.velocity=O(e.velocity,Math.max(0,a-i*r)/a));let o=N(t.brake??0,0,1);if(!o)return;let s=T(Math.cos(e.angle),Math.sin(e.angle)),c=k(e.velocity,s),l=Math.min(Math.abs(c),o*n(this.preset)*Math.max(.35,this.statusEffects.factor(`grip`,void 0,this.tires.length))*r);e.velocity=D(e.velocity,O(s,Math.sign(c)*l))}finishDrift(e,t,n){let r=this.driftStart;if(!this.fastDrifting||!r)return;let i=j(r.velocity),a=N(i/12,.55,1.2),o=this.driftDirection*(.92+.24*a)+N(t.steer,-1,1)*.47;e.spin=r.spin+(o-r.spin)*(1-Math.exp(-12*n)),e.angle=r.angle+e.spin*n;let s=j(e.velocity),c=Math.max(s,i-.5*n),l=Math.atan2(r.velocity.y,r.velocity.x),u=l+N(P(e.angle-this.driftDirection*this.preset.drift.slipAngleRad-l)*(1-Math.exp(-7*n)),-3.5*n,3.5*n);e.velocity=T(Math.cos(u)*c,Math.sin(u)*c),e.position=E(r.position,O(e.velocity,n)),this.slideAngleRad=P(u-e.angle);for(let e of this.tires)e.front||(e.skidding=!0,e.lateralSpeed=c*Math.sin(this.preset.drift.slipAngleRad),e.slipSpeedMps=Math.max(e.slipSpeedMps,e.lateralSpeed),e.slip=N(e.slipSpeedMps/4,0,1),e.heat+=(.8-e.heat)*(1-Math.exp(-2*n)),e.gripUtilization=Math.max(e.gripUtilization,1))}arcadeAssist(e,t,n){let r=j(e.velocity),{speed:i,radius:a}=F(this.preset);if(this.donuting){let t=i*this.statusEffects.factor(`speed`,void 0,this.tires.length),o=Math.atan2(e.velocity.y,e.velocity.x),s=e.angle-this.donutDirection*.22,c=Math.atan2(Math.sin(s-o),Math.cos(s-o))*(1-Math.exp(-n/.11)),l=r+(t-r)*(1-Math.exp(-n/.28));e.velocity=O(T(Math.cos(o+c),Math.sin(o+c)),l),e.spin=this.donutDirection*l/a;return}let o=M(T(1,0),e.angle);if(k(e.velocity,o)<-.35&&t.throttle<0&&!t.action){let i=this.preset.maxReverseSpeedMps??7;r>i&&(e.velocity=O(e.velocity,i/r)),e.spin=-t.steer*Math.min(r,i)/a;let s=O(o,-1),c=Math.atan2(A(s,e.velocity),k(s,e.velocity));e.velocity=M(e.velocity,-N(c,-.45,.45)*(1-Math.exp(-5*n)));return}if(r<2||this.drifting||t.action||k(e.velocity,o)<=0)return;let s=Math.atan2(A(o,e.velocity),k(o,e.velocity)),c=N((r-2)/10,0,1)*(t.steer?4.5:6)*this.statusEffects.factor(`grip`,void 0,this.tires.length),l=-N(s,-.55,.55)*(1-Math.exp(-c*n));e.velocity=M(e.velocity,l),t.steer||(e.spin*=Math.exp(-4.5*n))}},R=class{headAngle=0;appliedForce=T();craft=T(4,0);counterweight=T(-2,0);radius=.9;captureState(){return a({headAngle:this.headAngle,appliedForce:this.appliedForce,craft:this.craft,counterweight:this.counterweight,radius:this.radius})}restoreState(e){let t=a(e);this.headAngle=t.headAngle,this.appliedForce=t.appliedForce,Object.assign(this,{craft:t.craft,counterweight:t.counterweight,radius:t.radius})}reset(){this.headAngle=0,this.appliedForce=T()}tick(e,t,n){this.headAngle+=t.steer*2.5*n;let r=(t.throttle||+!!t.action)*5e3*(t.action?2:1);this.appliedForce=M(T(r,0),this.headAngle),e.push(M(this.appliedForce,e.angle),e.world(this.craft)),e.push(O(e.velocity,-e.mass*.12)),e.spin*=Math.exp(-.35*n)}},z=class{body=new I;car=new L;ship=new R;mode=`car`;gravity=!1;barrier=!1;paused=!1;lastInput={throttle:0,steer:0,action:!1};brickForce=null;captureState(){return{at:performance.now(),preset:a(this.car.preset),simulation:a({mode:this.mode,gravity:this.gravity,barrier:this.barrier,paused:this.paused,lastInput:this.lastInput,brickForce:this.brickForce}),body:this.body.captureState(),car:this.car.captureState(),ship:this.ship.captureState()}}restoreState(e){let t=a(e);this.setPreset(t.preset),this.body.restoreState(t.body),this.car.restoreState(t.car),this.ship.restoreState(t.ship),this.mode=t.simulation.mode,this.gravity=t.simulation.gravity,this.barrier=t.simulation.barrier,this.paused=t.simulation.paused,this.lastInput=t.simulation.lastInput,this.brickForce=t.simulation.brickForce;let n=performance.now()-t.at;this.car.explodedAt!==null&&(this.car.explodedAt+=n),Number.isFinite(this.car.lastBlastEmission)&&(this.car.lastBlastEmission+=n)}setPreset(e){this.car.configure(e),this.mode===`car`&&(this.body.mass=e.massKg,this.body.inertia=e.massKg*(e.geometry.lengthM**2+e.geometry.widthM**2)/12)}setMode(e){this.mode=e,this.body.mass=e===`car`?this.car.preset.massKg:1e3,this.body.inertia=e===`ship`?this.body.mass*(1/3*(1.8**2/18+.8**2/6+16)+2/3*(.9**2/2+4)):this.body.mass*(this.car.preset.geometry.lengthM**2+this.car.preset.geometry.widthM**2)/12,this.car.reset(),this.ship.reset(),this.brickForce=null}reset(){this.body.reset(),this.car.reset(),this.ship.reset(),this.brickForce=null,this.lastInput={throttle:0,steer:0,action:!1}}resetAtCurrentPose(){let e={...this.body.position},t=this.body.angle;this.reset(),this.body.position=e,this.body.angle=t}tick(e,t,n){if(this.paused)return;if(this.mode===`car`&&this.car.explodedAt!==null){this.body.velocity=T(),this.body.spin=0,this.lastInput={throttle:0,steer:0,action:!1,boost:!1};return}this.lastInput={...e};let r=this.body,i={...r.position};if(this.gravity){let e=r.mass*3/30;r.push(T(-e*r.velocity.x,-r.mass*3-e*r.velocity.y))}if(this.mode===`car`&&this.car.tick(r,e,t,n),this.mode===`ship`){let n=r.angle;this.ship.tick(r,e,t),r.tick(t),this.ship.headAngle-=r.angle-n}else if(this.mode===`brick`&&this.brickForce&&r.push(this.brickForce.force,r.world(this.brickForce.local)),r.tick(t),this.mode===`car`){let n=this.car.fastDrifting?{...e,action:!1}:e;this.car.slow(r,n,t),this.car.fastDrifting?this.car.finishDrift(r,e,t):this.car.arcadeAssist(r,n,t);let a=this.car.statusEffects.factor(`speed`,void 0,this.car.tires.length);a<1&&(r.velocity=O(r.velocity,Math.exp(-5*(1-a)*t))),this.car.statusEffects.advance(j(D(r.position,i)),t)}}contain(e){let t=this.body,n=this.mode===`car`?this.car.preset.geometry.lengthM/2:2,r=this.mode===`car`?this.car.preset.geometry.widthM/2:1,i=this.mode===`ship`?[T(1.2,0),T(-.6,-.8),T(-.6,.8)].map(e=>t.world(E(this.ship.craft,M(e,this.ship.headAngle)))):[T(-n,-r),T(n,-r),T(n,r),T(-n,r)].map(e=>t.world(e));this.mode===`ship`&&i.push(t.world(this.ship.counterweight));let a=[[T(1),e.left],[T(-1),-e.right],[T(0,1),e.bottom],[T(0,-1),-e.top]];for(let e=0;e<4;e++)for(let[e,n]of a){let r=i.map(t=>k(t,e)-(this.mode===`ship`?this.ship.radius:0)),a=Math.min(...r),o=n-a;if(o<-1e-8)continue;let s=i[r.indexOf(a)],c=O(e,Math.max(0,o));t.position=E(t.position,c);for(let e of i)e.x+=c.x,e.y+=c.y;let l=E(s,O(e,this.mode===`ship`?-this.ship.radius:0)),u=k(t.velocityAt(l),e);if(u>=0)continue;let d=A(D(l,t.position),e),f=1/t.mass+d*d/t.inertia;t.impulse(O(e,-(1+(u<-.5?.55:0))*u/f),l)}}};function B(e,t){}function V(e,t=1){}export{c as C,h as S,S as _,A as a,g as b,D as c,O as d,T as f,d as g,C as h,N as i,E as l,x as m,B as n,k as o,m as p,z as r,j as s,V as t,M as u,y as v,p as x,b as y};
|
package/npm-chunks/{runtime~vehicle-popover-PLJOXbUU.js → runtime~vehicle-popover-VyqXHkfB.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./configuration~react~vehicle-popover~JoyRideView~browser-session-core~renderer-
|
|
1
|
+
import{i as e}from"./configuration~react~vehicle-popover~JoyRideView~browser-session-core~renderer-CPZkP_Db.js";function t(t,n){return[{label:`Speed`,read:e=>e.engineForceN/e.rollingResistance},{label:`Acceleration`,read:e=>e.engineForceN/e.massKg},{label:`Handling`,read:t=>t.corneringAccelerationMps2/Math.sqrt(e(t))},{label:`Drift`,read:e=>e.drift.slipAngleRad/e.drift.entrySpeedMps},{label:`Braking`,read:e=>e.handbrakeDecelerationMps2}].map(({label:e,read:r})=>{let i=n.map(r),a=Math.min(...i),o=Math.max(...i),s=o===a?.5:(r(t)-a)/(o-a);return{label:e,value:Math.round(20+s*80)}})}export{t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,n as t,r as n}from"./configuration~react~vehicle-popover~JoyRideView~browser-session-core~renderer-CPZkP_Db.js";import{a as r,r as i}from"./definitions~react~vehicle-popover~Documentation~JoyRideView~browser-session-core~renderer-BG7sJuWo.js";import{r as a}from"./definitions~react~vehicle-popover~browser-session-core~renderer-RDNEXk_b.js";import{S as o,c as s,d as c,f as l,i as u,l as d,o as f,s as p,u as m}from"./runtime~react~vehicle-popover~browser-session-core~renderer-Dmgs7E8f.js";import{_ as h,g,h as _,v,y}from"./runtime~vehicle-popover~browser-session-core~renderer-EswVyRVp.js";import{n as b,r as x,t as S}from"./definitions~react~vehicle-popover~Documentation~JoyRideView~browser-session-core-DcDccU8O.js";import{n as ee,r as C}from"./vehicle-catalog~react~vehicle-popover~browser-session-core-B042f61I.js";function te(){if(typeof globalThis<`u`)return globalThis;if(typeof self<`u`)return self;if(typeof window<`u`)return window;if(typeof global<`u`)return global}function ne(){let e=te();if(e.__xstate__)return e.__xstate__}var re=e=>{if(typeof window>`u`)return;let t=ne();t&&t.register(e)},ie=class{constructor(e){this._process=e,this._active=!1,this._current=null,this._last=null}start(){this._active=!0,this.flush()}clear(){this._current&&(this._current.next=null,this._last=this._current)}enqueue(e){let t={value:e,next:null};this._current?(this._last.next=t,this._last=t):(this._current=t,this._last=t,this._active&&this.flush())}flush(){for(;this._current;){let e=this._current;this._process(e.value),this._current=e.next}this._last=null}},ae=``,oe=`#`,se=`*`,ce=`xstate.init`,le=`xstate.stop`;function ue(e,t){return{type:`xstate.after.${e}.${t}`}}function de(e,t){return{type:`xstate.done.state.${e}`,output:t}}function fe(e,t){return{type:`xstate.done.actor.${e}`,output:t,actorId:e}}function pe(e,t){return{type:`xstate.error.actor.${e}`,error:t,actorId:e}}function me(e){return{type:ce,input:e}}function w(e){setTimeout(()=>{throw e})}var he=typeof Symbol==`function`&&Symbol.observable||`@@observable`;function ge(e,t){let n=_e(e),r=_e(t);return typeof r==`string`?typeof n==`string`&&r===n:typeof n==`string`?n in r:Object.keys(n).every(e=>e in r&&ge(n[e],r[e]))}function T(e){if(Se(e))return e;let t=[],n=``;for(let r=0;r<e.length;r++){switch(e.charCodeAt(r)){case 92:n+=e[r+1],r++;continue;case 46:t.push(n),n=``;continue}n+=e[r]}return t.push(n),t}function _e(e){return jt(e)?e.value:typeof e==`string`?ve(T(e)):e}function ve(e){if(e.length===1)return e[0];let t={},n=t;for(let t=0;t<e.length-1;t++)if(t===e.length-2)n[e[t]]=e[t+1];else{let r=n;n={},r[e[t]]=n}return t}function ye(e,t){let n={},r=Object.keys(e);for(let i=0;i<r.length;i++){let a=r[i];n[a]=t(e[a],a,e,i)}return n}function be(e){return Se(e)?e:[e]}function E(e){return e===void 0?[]:be(e)}function xe(e,t,n,r){return typeof e==`function`?e({context:t,event:n,self:r}):e}function Se(e){return Array.isArray(e)}function Ce(e){return e.type.startsWith(`xstate.error.actor`)}function D(e){return be(e).map(e=>e===void 0||typeof e==`string`?{target:e}:e)}function we(e){if(e!==void 0&&e!==ae)return E(e)}function O(e,t,n){let r=typeof e==`object`,i=r?e:void 0;return{next:(r?e.next:e)?.bind(i),error:(r?e.error:t)?.bind(i),complete:(r?e.complete:n)?.bind(i)}}function Te(e,t){return`${t}.${e}`}function Ee(e,t){let n=t.match(/^xstate\.invoke\.(\d+)\.(.*)/);if(!n)return e.implementations.actors[t];let[,r,i]=n,a=e.getStateNodeById(i).config.invoke;return(Array.isArray(a)?a[r]:a).src}function De(e,t){if(t===e||t===se)return!0;if(!t.endsWith(`.*`))return!1;let n=t.split(`.`),r=e.split(`.`);for(let e=0;e<n.length;e++){let t=n[e],i=r[e];if(t===`*`)return e===n.length-1;if(t!==i)return!1}return!0}function Oe(e,t){return`${e.sessionId}.${t}`}var ke=0;function Ae(e,t){let n=new Map,r=new Map,i=new WeakMap,a=new Set,o={},{clock:s,logger:c}=t,l={schedule:(e,t,n,r,i=Math.random().toString(36).slice(2))=>{let a={source:e,target:t,event:n,delay:r,id:i,startedAt:Date.now()},c=Oe(e,i);u._snapshot._scheduledEvents[c]=a;let l=s.setTimeout(()=>{delete o[c],delete u._snapshot._scheduledEvents[c],u._relay(e,t,n)},r);o[c]=l},cancel:(e,t)=>{let n=Oe(e,t),r=o[n];delete o[n],delete u._snapshot._scheduledEvents[n],r!==void 0&&s.clearTimeout(r)},cancelAll:e=>{for(let t in u._snapshot._scheduledEvents){let n=u._snapshot._scheduledEvents[t];n.source===e&&l.cancel(e,n.id)}}},u={_snapshot:{_scheduledEvents:(t?.snapshot&&t.snapshot.scheduler)??{}},_bookId:()=>`x:${ke++}`,_register:(e,t)=>(n.set(e,t),e),_unregister:e=>{n.delete(e.sessionId);let t=i.get(e);t!==void 0&&(r.delete(t),i.delete(e))},get:e=>r.get(e),getAll:()=>Object.fromEntries(r.entries()),_set:(e,t)=>{let n=r.get(e);if(n&&n!==t)throw Error(`Actor with system ID '${e}' already exists.`);r.set(e,t),i.set(t,e)},inspect:e=>{let t=O(e);return a.add(t),{unsubscribe(){a.delete(t)}}},_sendInspectionEvent:t=>{if(!a.size)return;let n={...t,rootId:e.sessionId};a.forEach(e=>e.next?.(n))},_relay:(e,t,n)=>{u._sendInspectionEvent({type:`@xstate.event`,sourceRef:e,actorRef:t,event:n}),t._send(n)},scheduler:l,getSnapshot:()=>({_scheduledEvents:{...u._snapshot._scheduledEvents}}),start:()=>{let e=u._snapshot._scheduledEvents;u._snapshot._scheduledEvents={};for(let t in e){let{source:n,target:r,event:i,delay:a,id:o}=e[t];l.schedule(n,r,i,a,o)}},_clock:s,_logger:c};return u}var je=!1,k=function(e){return e[e.NotStarted=0]=`NotStarted`,e[e.Running=1]=`Running`,e[e.Stopped=2]=`Stopped`,e}({}),Me={clock:{setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e)},logger:console.log.bind(console),devTools:!1},Ne=class{constructor(e,t){this.logic=e,this._snapshot=void 0,this.clock=void 0,this.options=void 0,this.id=void 0,this.mailbox=new ie(this._process.bind(this)),this.observers=new Set,this.eventListeners=new Map,this.logger=void 0,this._processingStatus=k.NotStarted,this._parent=void 0,this._syncSnapshot=void 0,this.ref=void 0,this._actorScope=void 0,this.systemId=void 0,this.sessionId=void 0,this.system=void 0,this._doneEvent=void 0,this.src=void 0,this._deferred=[];let n={...Me,...t},{clock:r,logger:i,parent:a,syncSnapshot:o,id:s,systemId:c,inspect:l}=n;this.system=a?a.system:Ae(this,{clock:r,logger:i}),l&&!a&&this.system.inspect(O(l)),this.sessionId=this.system._bookId(),this.id=s??this.sessionId,this.logger=t?.logger??this.system._logger,this.clock=t?.clock??this.system._clock,this._parent=a,this._syncSnapshot=o,this.options=n,this.src=n.src??e,this.ref=this,this._actorScope={self:this,id:this.id,sessionId:this.sessionId,logger:this.logger,defer:e=>{this._deferred.push(e)},system:this.system,stopChild:e=>{if(e._parent!==this)throw Error(`Cannot stop child actor ${e.id} of ${this.id} because it is not a child`);e._stop()},emit:e=>{let t=this.eventListeners.get(e.type),n=this.eventListeners.get(`*`);if(!t&&!n)return;let r=[...t?t.values():[],...n?n.values():[]];for(let t of r)try{t(e)}catch(e){w(e)}},actionExecutor:e=>{let t=()=>{if(this._actorScope.system._sendInspectionEvent({type:`@xstate.action`,actorRef:this,action:{type:e.type,params:e.params}}),!e.exec)return;let t=je;try{je=!0,e.exec(e.info,e.params)}finally{je=t}};this._processingStatus===k.Running?t():this._deferred.push(t)}},this.send=this.send.bind(this),this.system._sendInspectionEvent({type:`@xstate.actor`,actorRef:this}),c&&(this.systemId=c,this.system._set(c,this)),this._initState(t?.snapshot??t?.state),c&&this._snapshot.status!==`active`&&this.system._unregister(this)}_initState(e){try{this._snapshot=e?this.logic.restoreSnapshot?this.logic.restoreSnapshot(e,this._actorScope):e:this.logic.getInitialSnapshot(this._actorScope,this.options?.input)}catch(e){this._snapshot={status:`error`,output:void 0,error:e}}}update(e,t){this._snapshot=e;let n;for(;n=this._deferred.shift();)try{n()}catch(t){this._deferred.length=0,this._snapshot={...e,status:`error`,error:t}}switch(this._snapshot.status){case`active`:for(let t of this.observers)try{t.next?.(e)}catch(e){w(e)}break;case`done`:for(let t of this.observers)try{t.next?.(e)}catch(e){w(e)}this._stopProcedure(),this._complete(),this._doneEvent=fe(this.id,this._snapshot.output),this._parent&&this.system._relay(this,this._parent,this._doneEvent);break;case`error`:this._error(this._snapshot.error)}this.system._sendInspectionEvent({type:`@xstate.snapshot`,actorRef:this,event:t,snapshot:e})}subscribe(e,t,n){let r=O(e,t,n);if(this._processingStatus!==k.Stopped)this.observers.add(r);else switch(this._snapshot.status){case`done`:try{r.complete?.()}catch(e){w(e)}break;case`error`:{let e=this._snapshot.error;if(!r.error)w(e);else try{r.error(e)}catch(e){w(e)}break}}return{unsubscribe:()=>{this.observers.delete(r)}}}on(e,t){let n=this.eventListeners.get(e);n||(n=new Set,this.eventListeners.set(e,n));let r=t.bind(void 0);return n.add(r),{unsubscribe:()=>{n.delete(r)}}}select(e,t=Object.is){return{subscribe:n=>{let r=O(n),i=e(this.getSnapshot());return this.subscribe(n=>{let a=e(n);t(i,a)||(i=a,r.next?.(a))})},get:()=>e(this.getSnapshot())}}start(){if(this._processingStatus===k.Running)return this;this._syncSnapshot&&this.subscribe({next:e=>{e.status===`active`&&this.system._relay(this,this._parent,{type:`xstate.snapshot.${this.id}`,snapshot:e})},error:()=>{}}),this.system._register(this.sessionId,this),this.systemId&&this.system._set(this.systemId,this),this._processingStatus=k.Running;let e=me(this.options.input);switch(this.system._sendInspectionEvent({type:`@xstate.event`,sourceRef:this._parent,actorRef:this,event:e}),this._snapshot.status){case`done`:return this.update(this._snapshot,e),this;case`error`:return this._error(this._snapshot.error),this}if(this._parent||this.system.start(),this.logic.start)try{this.logic.start(this._snapshot,this._actorScope)}catch(e){return this._snapshot={...this._snapshot,status:`error`,error:e},this._error(e),this}return this.update(this._snapshot,e),this.options.devTools&&this.attachDevTools(),this.mailbox.start(),this}_process(e){let t,n;try{t=this.logic.transition(this._snapshot,e,this._actorScope)}catch(e){n={err:e}}if(n){let{err:e}=n;this._snapshot={...this._snapshot,status:`error`,error:e},this._error(e)}else this.update(t,e),e.type===`xstate.stop`&&(this._stopProcedure(),this._complete())}_stop(){return this._processingStatus===k.Stopped?this:(this.mailbox.clear(),this._processingStatus===k.NotStarted?(this._processingStatus=k.Stopped,this):(this.mailbox.enqueue({type:le}),this))}stop(){if(this._parent)throw Error(`A non-root actor cannot be stopped directly.`);return this._stop()}_complete(){for(let e of this.observers)try{e.complete?.()}catch(e){w(e)}this.observers.clear(),this.eventListeners.clear()}_reportError(e){if(!this.observers.size){this._parent||w(e),this.eventListeners.clear();return}let t=!1;for(let n of this.observers){let r=n.error;t||=!r;try{r?.(e)}catch(e){w(e)}}this.observers.clear(),this.eventListeners.clear(),t&&w(e)}_error(e){this._stopProcedure(),this._reportError(e),this._parent&&this.system._relay(this,this._parent,pe(this.id,e))}_stopProcedure(){return this._processingStatus===k.Running&&(this.system.scheduler.cancelAll(this),this.mailbox.clear(),this.mailbox=new ie(this._process.bind(this)),this._processingStatus=k.Stopped,this.system._unregister(this)),this}_send(e){this._processingStatus!==k.Stopped&&this.mailbox.enqueue(e)}send(e){this.system._relay(void 0,this,e)}attachDevTools(){let{devTools:e}=this.options;e&&(typeof e==`function`?e:re)(this)}toJSON(){return{xstate$$type:1,id:this.id}}getPersistedSnapshot(e){return this.logic.getPersistedSnapshot(this._snapshot,e)}[he](){return this}getSnapshot(){return this._snapshot}};function A(e,...[t]){return new Ne(e,t)}function Pe(e,t,n,r,{sendId:i}){return[t,{sendId:typeof i==`function`?i(n,r):i},void 0]}function Fe(e,t){e.defer(()=>{e.system.scheduler.cancel(e.self,t.sendId)})}function Ie(e){function t(e,t){}return t.type=`xstate.cancel`,t.sendId=e,t.resolve=Pe,t.execute=Fe,t}function Le(e,t,n,r,{id:i,systemId:a,src:o,input:s,syncSnapshot:c}){let l=typeof o==`string`?Ee(t.machine,o):o,u=typeof i==`function`?i(n):i,d,f;return l&&(f=typeof s==`function`?s({context:t.context,event:n.event,self:e.self}):s,d=A(l,{id:u,src:o,parent:e.self,syncSnapshot:c,systemId:a,input:f})),[q(t,{children:{...t.children,[u]:d}}),{id:i,systemId:a,actorRef:d,src:o,input:f},void 0]}function Re(e,{actorRef:t}){t&&e.defer(()=>{t._processingStatus!==k.Stopped&&t.start()})}function ze(...[e,{id:t,systemId:n,input:r,syncSnapshot:i=!1}={}]){function a(e,t){}return a.type=`xstate.spawnChild`,a.id=t,a.systemId=n,a.src=e,a.input=r,a.syncSnapshot=i,a.resolve=Le,a.execute=Re,a}function Be(e,t,n,r,{actorRef:i}){let a=typeof i==`function`?i(n,r):i,o=typeof a==`string`?t.children[a]:a,s=t.children;return o&&(s={...s},delete s[o.id]),[q(t,{children:s}),o,void 0]}function Ve(e,t){let n=t.getSnapshot();if(n&&`children`in n)for(let t of Object.values(n.children))Ve(e,t);e.system._unregister(t)}function He(e,t){t&&(Ve(e,t),t._processingStatus===k.Running?e.defer(()=>{e.stopChild(t)}):e.stopChild(t))}function j(e){function t(e,t){}return t.type=`xstate.stopChild`,t.actorRef=e,t.resolve=Be,t.execute=He,t}function Ue(e,{context:t,event:n},{guards:r}){return r.every(r=>M(r,t,n,e))}function We(e){function t(e,t){return!1}return t.check=Ue,t.guards=e,t}function M(e,t,n,r){let{machine:i}=r,a=typeof e==`function`,o=a?e:i.implementations.guards[typeof e==`string`?e:e.type];if(!a&&!o)throw Error(`Guard '${typeof e==`string`?e:e.type}' is not implemented.'.`);if(typeof o!=`function`)return M(o,t,n,r);let s={context:t,event:n},c=a||typeof e==`string`?void 0:`params`in e?typeof e.params==`function`?e.params({context:t,event:n}):e.params:void 0;return`check`in o?o.check(r,s,o):o(s,c)}function Ge(e){return e.type===`atomic`||e.type===`final`}function N(e){return Object.values(e.states).filter(e=>e.type!==`history`)}function P(e,t){let n=[];if(t===e)return n;let r=e.parent;for(;r&&r!==t;)n.push(r),r=r.parent;return n}function F(e){let t=new Set(e),n=qe(t);for(let e of t)if(e.type===`compound`&&(!n.get(e)||!n.get(e).length))rt(e).forEach(e=>t.add(e));else if(e.type===`parallel`){for(let n of N(e))if(n.type!==`history`&&!t.has(n)){let e=rt(n);for(let n of e)t.add(n)}}for(let e of t){let n=e.parent;for(;n;)t.add(n),n=n.parent}return t}function Ke(e,t){let n=t.get(e);if(!n)return{};if(e.type===`compound`){let e=n[0];if(e){if(Ge(e))return e.key}else return{}}let r={};for(let e of n)r[e.key]=Ke(e,t);return r}function qe(e){let t=new Map;for(let n of e)t.has(n)||t.set(n,[]),n.parent&&(t.has(n.parent)||t.set(n.parent,[]),t.get(n.parent).push(n));return t}function Je(e,t){return Ke(e,qe(F(t)))}function Ye(e,t){return t.type===`compound`?N(t).some(t=>t.type===`final`&&e.has(t)):t.type===`parallel`?N(t).every(t=>Ye(e,t)):t.type===`final`}var I=e=>e[0]===oe;function Xe(e,t){let n=e.transitions.get(t),r=[...e.transitions.keys()].filter(e=>e!==t&&De(t,e)).sort((e,t)=>t.length-e.length).flatMap(t=>e.transitions.get(t));return n?[...n,...r]:r}function Ze(e){let t=e.config.after;if(!t)return[];let n=t=>{let n=ue(t,e.id),r=n.type;return e.entry.push(Ht(n,{id:r,delay:t})),e.exit.push(Ie(r)),r};return Object.keys(t).flatMap(e=>{let r=t[e],i=typeof r==`string`?{target:r}:r,a=Number.isNaN(+e)?e:+e,o=n(a);return E(i).map(e=>({...e,event:o,delay:a}))}).map(t=>{let{delay:n}=t;return{...L(e,t.event,t),delay:n}})}function L(e,t,n){let r=we(n.target),i=n.reenter??!1,a=tt(e,r),o={...n,actions:E(n.actions),guard:n.guard,target:a,source:e,reenter:i,eventType:t,toJSON:()=>({...o,source:`#${e.id}`,target:a?a.map(e=>`#${e.id}`):void 0})};return o}function Qe(e){let t=new Map;if(e.config.on)for(let n of Object.keys(e.config.on)){if(n===``)throw Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.');let r=e.config.on[n];t.set(n,D(r).map(t=>L(e,n,t)))}if(e.config.onDone){let n=`xstate.done.state.${e.id}`;t.set(n,D(e.config.onDone).map(t=>L(e,n,t)))}for(let n of e.invoke){if(n.onDone){let r=`xstate.done.actor.${n.id}`;t.set(r,D(n.onDone).map(t=>L(e,r,t)))}if(n.onError){let r=`xstate.error.actor.${n.id}`;t.set(r,D(n.onError).map(t=>L(e,r,t)))}if(n.onSnapshot){let r=`xstate.snapshot.${n.id}`;t.set(r,D(n.onSnapshot).map(t=>L(e,r,t)))}}for(let n of e.after){let e=t.get(n.eventType);e||(e=[],t.set(n.eventType,e)),e.push(n)}return t}function $e(e){let t=[],n=r=>{Object.values(r).forEach(r=>{if(r.config.route&&r.config.id){let n=r.config.id,i=r.config.route.guard,a=({event:e})=>e.to===`#${n}`,o={...r.config.route,guard:i?We([a,i]):a,target:`#${n}`};t.push(L(e,`xstate.route`,o))}r.states&&n(r.states)})};n(e.states),t.length>0&&e.transitions.set(`xstate.route`,t)}function et(e,t){let n=typeof t==`string`?e.states[t]:t?e.states[t.target]:void 0;if(!n&&t)throw Error(`Initial state node "${t}" not found on parent state node #${e.id}`);let r={source:e,actions:!t||typeof t==`string`?[]:E(t.actions),eventType:null,reenter:!1,target:n?[n]:[],meta:typeof t==`object`?t.meta:void 0,description:typeof t==`object`?t.description:void 0,toJSON:()=>({...r,source:`#${e.id}`,target:n?[`#${n.id}`]:[]})};return r}function tt(e,t){if(t!==void 0)return t.map(t=>{if(typeof t!=`string`)return t;if(I(t))return e.machine.getStateNodeById(t);let n=t[0]===`.`;if(n&&!e.parent)return B(e,t.slice(1));let r=n?e.key+t:t;if(e.parent)try{return B(e.parent,r)}catch(t){throw Error(`Invalid transition definition for state node '${e.id}':\n${t.message}`)}throw Error(`Invalid target: "${t}" is not a valid target from the root node. Did you mean ".${t}"?`)})}function nt(e){let t=we(e.config.target);return t?{target:t.map(t=>typeof t==`string`?B(e.parent,t):t)}:e.parent.type===`parallel`?{target:[e.parent]}:e.parent.initial}function R(e){return e.type===`history`}function rt(e){let t=it(e);for(let n of t)for(let r of P(n,e))t.add(r);return t}function it(e){let t=new Set;function n(e){if(!t.has(e)){if(t.add(e),e.type===`compound`)n(e.initial.target[0]);else if(e.type===`parallel`)for(let t of N(e))n(t)}}return n(e),t}function z(e,t){if(I(t))return e.machine.getStateNodeById(t);if(!e.states)throw Error(`Unable to retrieve child state '${t}' from '${e.id}'; no child states exist.`);let n=e.states[t];if(!n)throw Error(`Child state '${t}' does not exist on '${e.id}'`);return n}function B(e,t){if(typeof t==`string`&&I(t))try{return e.machine.getStateNodeById(t)}catch{}let n=T(t).slice(),r=e;for(;n.length;){let e=n.shift();if(!e.length)break;r=z(r,e)}return r}function V(e,t){if(typeof t==`string`){let n=e.states[t];if(!n)throw Error(`State '${t}' does not exist on '${e.id}'`);return[e,n]}let n=Object.keys(t),r=n.map(t=>z(e,t)).filter(Boolean);return[e.machine.root,e].concat(r,n.reduce((n,r)=>{let i=z(e,r);if(!i)return n;let a=V(i,t[r]);return n.concat(a)},[]))}function at(e,t,n,r){let i=z(e,t).next(n,r);return!i||!i.length?e.next(n,r):i}function ot(e,t,n,r){let i=Object.keys(t),a=ct(z(e,i[0]),t[i[0]],n,r);return!a||!a.length?e.next(n,r):a}function st(e,t,n,r){let i=[];for(let a of Object.keys(t)){let o=t[a];if(!o)continue;let s=ct(z(e,a),o,n,r);s&&i.push(...s)}return i.length?i:e.next(n,r)}function ct(e,t,n,r){return typeof t==`string`?at(e,t,n,r):Object.keys(t).length===1?ot(e,t,n,r):st(e,t,n,r)}function lt(e){return Object.keys(e.states).map(t=>e.states[t]).filter(e=>e.type===`history`)}function H(e,t){let n=e;for(;n.parent&&n.parent!==t;)n=n.parent;return n.parent===t}function ut(e,t){let n=new Set(e),r=new Set(t);for(let e of n)if(r.has(e))return!0;for(let e of r)if(n.has(e))return!0;return!1}function dt(e,t,n){let r=new Set;for(let i of e){let e=!1,a=new Set;for(let o of r)if(ut(mt([i],t,n),mt([o],t,n))){if(H(i.source,o.source))a.add(o);else{e=!0;break}}if(!e){for(let e of a)r.delete(e);r.add(i)}}return Array.from(r)}function ft(e){let[t,...n]=e;for(let e of P(t,void 0))if(n.every(t=>H(t,e)))return e}function U(e,t){if(!e.target)return[];let n=new Set;for(let r of e.target)if(R(r)){if(t[r.id])for(let e of t[r.id])n.add(e);else for(let e of U(nt(r),t))n.add(e)}else n.add(r);return[...n]}function pt(e,t){let n=U(e,t);if(!n)return;if(!e.reenter&&n.every(t=>t===e.source||H(t,e.source)))return e.source;let r=ft(n.concat(e.source));if(r)return r;if(!e.reenter)return e.source.machine.root}function mt(e,t,n){let r=new Set;for(let i of e)if(i.target?.length){let e=pt(i,n);i.reenter&&i.source===e&&r.add(e);for(let n of t)H(n,e)&&r.add(n)}return[...r]}function ht(e,t){if(e.length!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function gt(e,t,n,r,i){return _t([{target:[...it(e)],source:e,reenter:!0,actions:[],eventType:null,toJSON:null}],t,n,r,!0,i)}function _t(e,t,n,r,i,a){let o=[];if(!e.length)return[t,o];let s=n.actionExecutor;n.actionExecutor=e=>{o.push(e),s(e)};try{let s=new Set(t._nodes),c=t.historyValue,l=dt(e,s,c),u=t;i||([u,c]=Ct(u,r,n,l,s,c,a,n.actionExecutor)),u=G(u,r,n,l.flatMap(e=>e.actions),a,void 0),u=yt(u,r,n,l,s,a,c,i);let d=[...s];u.status===`done`&&(u=G(u,r,n,d.sort((e,t)=>t.order-e.order).flatMap(e=>e.exit),a,void 0));try{return c===t.historyValue&&ht(t._nodes,s)?[u,o]:[q(u,{_nodes:d,historyValue:c}),o]}catch(e){throw e}}finally{n.actionExecutor=s}}function vt(e,t,n,r,i){if(r.output===void 0)return;let a=de(i.id,i.output!==void 0&&i.parent?xe(i.output,e.context,t,n.self):void 0);return xe(r.output,e.context,a,n.self)}function yt(e,t,n,r,i,a,o,s){let c=e,l=new Set,u=new Set;bt(r,o,u,l),s&&u.add(e.machine.root);let d=new Set;for(let e of[...l].sort((e,t)=>e.order-t.order)){i.add(e);let r=[];r.push(...e.entry);for(let t of e.invoke)r.push(ze(t.src,{...t,syncSnapshot:!!t.onSnapshot}));if(u.has(e)){let t=e.initial.actions;r.push(...t)}if(c=G(c,t,n,r,a,e.invoke.map(e=>e.id)),e.type===`final`){let r=e.parent,o=r?.type===`parallel`?r:r?.parent,s=o||e;for(r?.type===`compound`&&a.push(de(r.id,e.output===void 0?void 0:xe(e.output,c.context,t,n.self)));o?.type===`parallel`&&!d.has(o)&&Ye(i,o);)d.add(o),a.push(de(o.id)),s=o,o=o.parent;if(o)continue;c=q(c,{status:`done`,output:vt(c,t,n,c.machine.root,s)})}}return c}function bt(e,t,n,r){for(let i of e){let e=pt(i,t);for(let a of i.target||[])!R(a)&&(i.source!==a||i.source!==e||i.reenter)&&(r.add(a),n.add(a)),W(a,t,n,r);let a=U(i,t);for(let o of a){let a=P(o,e);e?.type===`parallel`&&a.push(e),xt(r,t,n,a,!i.source.parent&&i.reenter?void 0:e)}}}function W(e,t,n,r){if(R(e)){if(t[e.id]){let i=t[e.id];for(let e of i)r.add(e),W(e,t,n,r);for(let a of i)St(a,e.parent,r,t,n)}else{let i=nt(e);for(let a of i.target)r.add(a),i===e.parent?.initial&&n.add(e.parent),W(a,t,n,r);for(let a of i.target)St(a,e.parent,r,t,n)}}else if(e.type===`compound`){let[i]=e.initial.target;R(i)||(r.add(i),n.add(i)),W(i,t,n,r),St(i,e,r,t,n)}else if(e.type===`parallel`)for(let i of N(e).filter(e=>!R(e)))[...r].some(e=>H(e,i))||(R(i)||(r.add(i),n.add(i)),W(i,t,n,r))}function xt(e,t,n,r,i){for(let a of r)if((!i||H(a,i))&&e.add(a),a.type===`parallel`)for(let r of N(a).filter(e=>!R(e)))[...e].some(e=>H(e,r))||(e.add(r),W(r,t,n,e))}function St(e,t,n,r,i){xt(n,r,i,P(e,t))}function Ct(e,t,n,r,i,a,o,s){let c=e,l=mt(r,i,a);l.sort((e,t)=>t.order-e.order);let u;for(let e of l)for(let t of lt(e)){let n;n=t.history===`deep`?t=>Ge(t)&&H(t,e):t=>t.parent===e,u??={...a},u[t.id]=Array.from(i).filter(n)}for(let e of l)c=G(c,t,n,[...e.exit,...e.invoke.map(e=>j(e.id))],o,void 0),i.delete(e);return[c,u||a]}function wt(e,t){return e.implementations.actions[t]}function Tt(e,t,n,r,i,a){let{machine:o}=e,s=e;for(let e of r){let r=typeof e==`function`,c=r?e:wt(o,typeof e==`string`?e:e.type),l={context:s.context,event:t,self:n.self,system:n.system},u=r||typeof e==`string`?void 0:`params`in e?typeof e.params==`function`?e.params({context:s.context,event:t}):e.params:void 0;if(!c||!(`resolve`in c)){n.actionExecutor({type:typeof e==`string`?e:typeof e==`object`?e.type:e.name||`(anonymous)`,info:l,params:u,exec:c});continue}let d=c,[f,p,m]=d.resolve(n,s,l,u,c,i);s=f,`retryResolve`in d&&a?.push([d,p]),`execute`in d&&n.actionExecutor({type:d.type,info:l,params:p,exec:d.execute.bind(null,n,p)}),m&&(s=Tt(s,t,n,m,i,a))}return s}function G(e,t,n,r,i,a){let o=a?[]:void 0,s=Tt(e,t,n,r,{internalQueue:i,deferredActorIds:a},o);return o?.forEach(([e,t])=>{e.retryResolve(n,s,t)}),s}function Et(e,t,n,r){let i=e,a=[];function o(e,t,r){n.system._sendInspectionEvent({type:`@xstate.microstep`,actorRef:n.self,event:t,snapshot:e[0],_transitions:r}),a.push(e)}if(t.type===`xstate.stop`)return i=q(Dt(i,t,n),{status:`stopped`}),o([i,[]],t,[]),{snapshot:i,microsteps:a};let s=t;if(s.type!==ce){let t=s,c=Ce(t),l=Ot(t,i);if(c&&!l.length)return i=q(Dt(i,t,n),{status:`error`,error:t.error}),o([i,[]],t,[]),{snapshot:i,microsteps:a};let u=_t(l,e,n,s,!1,r);i=u[0],o(u,t,l)}let c=!0,l=e.machine.options?.maxIterations??1/0,u=0;for(;i.status===`active`;){if(u++,u>l)throw Error(`Infinite loop detected: the machine has processed more than ${l} microsteps without reaching a stable state. This usually happens when there's a cycle of transitions (e.g., eventless transitions or raised events causing state A -> B -> C -> A).`);let e=c?kt(i,s):[],t=e.length?i:void 0;if(!e.length){if(!r.length)break;s=r.shift(),e=Ot(s,i)}let a=_t(e,i,n,s,!1,r);i=a[0],c=i!==t,o(a,s,e)}return i.status!==`active`&&Dt(i,s,n),{snapshot:i,microsteps:a}}function Dt(e,t,n){return G(e,t,n,Object.values(e.children).map(e=>j(e)),[],void 0)}function Ot(e,t){return t.machine.getTransitionData(t,e)}function kt(e,t){let n=new Set,r=e._nodes.filter(Ge);for(let i of r)loop:for(let r of[i].concat(P(i,void 0)))if(r.always){for(let i of r.always)if(i.guard===void 0||M(i.guard,e.context,t,e)){n.add(i);break loop}}return dt(Array.from(n),new Set(e._nodes),e.historyValue)}function At(e,t){return Je(e,[...F(V(e,t))])}function jt(e){return!!e&&typeof e==`object`&&`machine`in e&&`value`in e}var Mt=function(e){return ge(e,this.value)},Nt=function(e){return this.tags.has(e)},Pt=function(e){let t=this.machine.getTransitionData(this,e);return!!t?.length&&t.some(e=>e.target!==void 0||e.actions.length)},Ft=function(){let{_nodes:e,tags:t,machine:n,getMeta:r,toJSON:i,can:a,hasTag:o,matches:s,...c}=this;return{...c,tags:Array.from(t)}},It=function(){return this._nodes.reduce((e,t)=>(t.meta!==void 0&&(e[t.id]=t.meta),e),{})};function K(e,t){return{status:e.status,output:e.output,error:e.error,machine:t,context:e.context,_nodes:e._nodes,value:Je(t.root,e._nodes),tags:new Set(e._nodes.flatMap(e=>e.tags)),children:e.children,historyValue:e.historyValue||{},matches:Mt,hasTag:Nt,can:Pt,getMeta:It,toJSON:Ft}}function q(e,t={}){return K({...e,...t},e.machine)}function Lt(e){if(typeof e!=`object`||!e)return{};let t={};for(let n in e){let r=e[n];Array.isArray(r)&&(t[n]=r.map(e=>({id:e.id})))}return t}function Rt(e,t){let{_nodes:n,tags:r,machine:i,children:a,context:o,can:s,hasTag:c,matches:l,getMeta:u,toJSON:d,...f}=e,p={};for(let e in a){let n=a[e];p[e]={snapshot:n.getPersistedSnapshot(t),src:n.src,systemId:n.systemId,syncSnapshot:n._syncSnapshot}}return{...f,context:zt(o),children:p,historyValue:Lt(f.historyValue)}}function zt(e){let t;for(let n in e){let r=e[n];if(r&&typeof r==`object`){if(`sessionId`in r&&`send`in r&&`ref`in r)t??=Array.isArray(e)?e.slice():{...e},t[n]={xstate$$type:1,id:r.id};else{let i=zt(r);i!==r&&(t??=Array.isArray(e)?e.slice():{...e},t[n]=i)}}}return t??e}function Bt(e,t,n,r,{event:i,id:a,delay:o},{internalQueue:s}){let c=t.machine.implementations.delays;if(typeof i==`string`)throw Error(`Only event objects may be used with raise; use raise({ type: "${i}" }) instead`);let l=typeof i==`function`?i(n,r):i,u;if(typeof o==`string`){let e=c&&c[o];u=typeof e==`function`?e(n,r):e}else u=typeof o==`function`?o(n,r):o;return typeof u!=`number`&&s.push(l),[t,{event:l,id:a,delay:u},void 0]}function Vt(e,t){let{event:n,delay:r,id:i}=t;typeof r==`number`&&e.defer(()=>{let t=e.self;e.system.scheduler.schedule(t,t,n,r,i)})}function Ht(e,t){function n(e,t){}return n.type=`xstate.raise`,n.event=e,n.id=t?.id,n.delay=t?.delay,n.resolve=Bt,n.execute=Vt,n}function Ut(e,{machine:t,context:n},r,i){let a=(a,o)=>{if(typeof a==`string`){let s=Ee(t,a);if(!s)throw Error(`Actor logic '${a}' not implemented in machine '${t.id}'`);let c=A(s,{id:o?.id,parent:e.self,syncSnapshot:o?.syncSnapshot,input:typeof o?.input==`function`?o.input({context:n,event:r,self:e.self}):o?.input,src:a,systemId:o?.systemId});return i[c.id]=c,c}return A(a,{id:o?.id,parent:e.self,syncSnapshot:o?.syncSnapshot,input:o?.input,src:a,systemId:o?.systemId})};return(t,n)=>{let r=a(t,n);return i[r.id]=r,e.defer(()=>{r._processingStatus!==k.Stopped&&r.start()}),r}}function Wt(e,t,n,r,{assignment:i}){if(!t.context)throw Error("Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.");let a={},o={context:t.context,event:n.event,spawn:Ut(e,t,n.event,a),self:e.self,system:e.system},s={};if(typeof i==`function`)s=i(o,r);else for(let e of Object.keys(i)){let t=i[e];s[e]=typeof t==`function`?t(o,r):t}return[q(t,{context:Object.assign({},t.context,s),children:Object.keys(a).length?{...t.children,...a}:t.children}),void 0,void 0]}function Gt(e){function t(e,t){}return t.type=`xstate.assign`,t.assignment=e,t.resolve=Wt,t}var Kt=new WeakMap;function J(e,t,n){let r=Kt.get(e);return r?t in r||(r[t]=n()):(r={[t]:n()},Kt.set(e,r)),r[t]}var qt={},Y=e=>typeof e==`string`?{type:e}:typeof e==`function`?`resolve`in e?{type:e.type}:{type:e.name}:e,Jt=class e{constructor(t,n){if(this.config=t,this.key=void 0,this.id=void 0,this.type=void 0,this.path=void 0,this.states=void 0,this.history=void 0,this.entry=void 0,this.exit=void 0,this.parent=void 0,this.machine=void 0,this.meta=void 0,this.output=void 0,this.order=-1,this.description=void 0,this.tags=[],this.transitions=void 0,this.always=void 0,this.parent=n._parent,this.key=n._key,this.machine=n._machine,this.path=this.parent?this.parent.path.concat(this.key):[],this.id=this.config.id||[this.machine.id,...this.path].join(`.`),this.type=this.config.type||(this.config.states&&Object.keys(this.config.states).length?`compound`:this.config.history?`history`:`atomic`),this.description=this.config.description,this.order=this.machine.idMap.size,this.machine.idMap.set(this.id,this),this.states=this.config.states?ye(this.config.states,(t,n)=>new e(t,{_parent:this,_key:n,_machine:this.machine})):qt,this.type===`compound`&&!this.config.initial)throw Error(`No initial state specified for compound state node "#${this.id}". Try adding { initial: "${Object.keys(this.states)[0]}" } to the state config.`);this.history=this.config.history===!0?`shallow`:this.config.history||!1,this.entry=E(this.config.entry).slice(),this.exit=E(this.config.exit).slice(),this.meta=this.config.meta,this.output=this.type===`final`||!this.parent?this.config.output:void 0,this.tags=E(t.tags).slice()}_initialize(){this.transitions=Qe(this),this.config.always&&(this.always=D(this.config.always).map(e=>L(this,``,e))),Object.keys(this.states).forEach(e=>{this.states[e]._initialize()})}get definition(){return{id:this.id,key:this.key,version:this.machine.version,type:this.type,initial:this.initial?{target:this.initial.target,source:this,actions:this.initial.actions.map(Y),eventType:null,reenter:!1,meta:this.initial.meta,description:this.initial.description,toJSON:()=>({target:this.initial.target.map(e=>`#${e.id}`),source:`#${this.id}`,actions:this.initial.actions.map(Y),eventType:null,meta:this.initial.meta,description:this.initial.description})}:void 0,history:this.history,states:ye(this.states,e=>e.definition),on:this.on,transitions:[...this.transitions.values()].flat().map(e=>({...e,actions:e.actions.map(Y)})),entry:this.entry.map(Y),exit:this.exit.map(Y),meta:this.meta,order:this.order||-1,output:this.output,invoke:this.invoke,description:this.description,tags:this.tags}}toJSON(){return this.definition}get invoke(){return J(this,`invoke`,()=>E(this.config.invoke).map((e,t)=>{let{src:n,systemId:r}=e,i=e.id??Te(this.id,t),a=typeof n==`string`?n:`xstate.invoke.${Te(this.id,t)}`;return{...e,src:a,id:i,systemId:r,toJSON(){let{onDone:t,onError:n,...r}=e;return{...r,type:`xstate.invoke`,src:a,id:i}}}}))}get on(){return J(this,`on`,()=>[...this.transitions].flatMap(([e,t])=>t.map(t=>[e,t])).reduce((e,[t,n])=>(e[t]=e[t]||[],e[t].push(n),e),{}))}get after(){return J(this,`delayedTransitions`,()=>Ze(this))}get initial(){return J(this,`initial`,()=>et(this,this.config.initial))}next(e,t){let n=t.type,r=[],i,a=J(this,`candidates-${n}`,()=>Xe(this,n));for(let o of a){let{guard:a}=o,s=e.context,c=!1;try{c=!a||M(a,s,t,e)}catch(e){let t=typeof a==`string`?a:typeof a==`object`?a.type:void 0;throw Error(`Unable to evaluate guard ${t?`'${t}' `:``}in transition for event '${n}' in state node '${this.id}':\n${e.message}`)}if(c){r.push(...o.actions),i=o;break}}return i?[i]:void 0}get events(){return J(this,`events`,()=>{let{states:e}=this,t=new Set(this.ownEvents);if(e)for(let n of Object.keys(e)){let r=e[n];if(r.states)for(let e of r.events)t.add(`${e}`)}return Array.from(t)})}get ownEvents(){let e=Object.keys(Object.fromEntries(this.transitions)),t=new Set(e.filter(e=>this.transitions.get(e).some(e=>!(!e.target&&!e.actions.length&&!e.reenter))));return Array.from(t)}},Yt=class e{constructor(e,t){this.config=e,this.version=void 0,this.schemas=void 0,this.implementations=void 0,this.options=void 0,this.__xstatenode=!0,this.idMap=new Map,this.root=void 0,this.id=void 0,this.states=void 0,this.events=void 0,this.id=e.id||`(machine)`,this.implementations={actors:t?.actors??{},actions:t?.actions??{},delays:t?.delays??{},guards:t?.guards??{}},this.version=this.config.version,this.schemas=this.config.schemas,this.options={maxIterations:1/0,...this.config.options},this.transition=this.transition.bind(this),this.getInitialSnapshot=this.getInitialSnapshot.bind(this),this.getPersistedSnapshot=this.getPersistedSnapshot.bind(this),this.restoreSnapshot=this.restoreSnapshot.bind(this),this.start=this.start.bind(this),this.root=new Jt(e,{_key:this.id,_machine:this}),this.root._initialize(),$e(this.root),this.states=this.root.states,this.events=this.root.events}provide(t){let{actions:n,guards:r,actors:i,delays:a}=this.implementations;return new e(this.config,{actions:{...n,...t.actions},guards:{...r,...t.guards},actors:{...i,...t.actors},delays:{...a,...t.delays}})}resolveState(e){let t=At(this.root,e.value),n=F(V(this.root,t));return K({_nodes:[...n],context:e.context||{},children:{},status:Ye(n,this.root)?`done`:e.status||`active`,output:e.output,error:e.error,historyValue:e.historyValue},this)}transition(e,t,n){return Et(e,t,n,[]).snapshot}microstep(e,t,n){return Et(e,t,n,[]).microsteps.map(([e])=>e)}getTransitionData(e,t){return ct(this.root,e.value,e,t)||[]}_getPreInitialState(e,t,n){let{context:r}=this.config,i=K({context:typeof r!=`function`&&r?r:{},_nodes:[this.root],children:{},status:`active`},this);return typeof r==`function`?G(i,t,e,[Gt(({spawn:e,event:t,self:n})=>r({spawn:e,input:t.input,self:n}))],n,void 0):i}getInitialSnapshot(e,t){let n=me(t),r=[],i=K({context:typeof this.config.context!=`function`&&this.config.context?this.config.context:{},_nodes:[this.root],children:{},status:`active`},this);try{i=this._getPreInitialState(e,n,r);let[t]=gt(this.root,i,e,n,r),{snapshot:a}=Et(t,n,e,r);return a}catch(e){return q(i,{status:`error`,error:e})}}start(e){Object.values(e.children).forEach(e=>{e.getSnapshot().status===`active`&&e.start()})}getStateNodeById(e){let t=T(e),n=t.slice(1),r=I(t[0])?t[0].slice(1):t[0],i=this.idMap.get(r);if(!i)throw Error(`Child state node '#${r}' does not exist on machine '${this.id}'`);return B(i,n)}get definition(){return this.root.definition}toJSON(){return this.definition}getPersistedSnapshot(e,t){return Rt(e,t)}restoreSnapshot(e,t){let n={},r=e.children;Object.keys(r).forEach(e=>{let i=r[e],a=i.snapshot,o=i.src,s=typeof o==`string`?Ee(this,o):o;if(!s)return;let c=A(s,{id:e,parent:t.self,syncSnapshot:i.syncSnapshot,snapshot:a,src:o,systemId:i.systemId});n[e]=c});function i(e,t){if(t instanceof Jt)return t;try{return e.machine.getStateNodeById(t.id)}catch{}}function a(e,t){if(!t||typeof t!=`object`)return{};let n={};for(let r in t){let a=t[r];for(let t of a){let a=i(e,t);a&&(n[r]??=[],n[r].push(a))}}return n}let o=a(this.root,e.historyValue),s=K({...e,children:n,_nodes:Array.from(F(V(this.root,e.value))),historyValue:o},this),c=new Set;function l(e,t){if(!c.has(e)){c.add(e);for(let n in e){let r=e[n];if(r&&typeof r==`object`){if(`xstate$$type`in r&&r.xstate$$type===1){e[n]=t[r.id];continue}l(r,t)}}}}return l(s.context,n),s}};function Xt(e,t,n,r,{event:i}){return[t,{event:typeof i==`function`?i(n,r):i},void 0]}function Zt(e,{event:t}){e.defer(()=>e.emit(t))}function Qt(e){function t(e,t){}return t.type=`xstate.emit`,t.event=e,t.resolve=Xt,t.execute=Zt,t}var $t=function(e){return e.Parent=`#_parent`,e.Internal=`#_internal`,e}({});function en(e,t,n,r,{to:i,event:a,id:o,delay:s},c){let l=t.machine.implementations.delays;if(typeof a==`string`)throw Error(`Only event objects may be used with sendTo; use sendTo({ type: "${a}" }) instead`);let u=typeof a==`function`?a(n,r):a,d;if(typeof s==`string`){let e=l&&l[s];d=typeof e==`function`?e(n,r):e}else d=typeof s==`function`?s(n,r):s;let f=typeof i==`function`?i(n,r):i,p;if(typeof f==`string`){if(p=f===$t.Parent?e.self._parent:f===$t.Internal?e.self:f.startsWith(`#_`)?t.children[f.slice(2)]:c.deferredActorIds?.includes(f)?f:t.children[f],!p)throw Error(`Unable to send event to actor '${f}' from machine '${t.machine.id}'.`)}else p=f||e.self;return[t,{to:p,targetId:typeof f==`string`?f:void 0,event:u,id:o,delay:d},void 0]}function tn(e,t,n){typeof n.to==`string`&&(n.to=t.children[n.to])}function nn(e,t){e.defer(()=>{let{to:n,event:r,delay:i,id:a}=t;typeof i==`number`?e.system.scheduler.schedule(e.self,n,r,i,a):e.system._relay(e.self,n,r.type===`xstate.error`?pe(e.self.id,r.data):r)})}function rn(e,t,n){function r(e,t){}return r.type=`xstate.sendTo`,r.to=e,r.event=t,r.id=n?.id,r.delay=n?.delay,r.resolve=en,r.retryResolve=tn,r.execute=nn,r}function an(e,t){return rn($t.Parent,e,t)}function on(e,t,n,r,{collect:i}){let a=[],o=function(e){a.push(e)};return o.assign=(...e)=>{a.push(Gt(...e))},o.cancel=(...e)=>{a.push(Ie(...e))},o.raise=(...e)=>{a.push(Ht(...e))},o.sendTo=(...e)=>{a.push(rn(...e))},o.sendParent=(...e)=>{a.push(an(...e))},o.spawnChild=(...e)=>{a.push(ze(...e))},o.stopChild=(...e)=>{a.push(j(...e))},o.emit=(...e)=>{a.push(Qt(...e))},i({context:n.context,event:n.event,enqueue:o,check:e=>M(e,t.context,n.event,t),self:e.self,system:e.system},r),[t,void 0,a]}function sn(e){function t(e,t){}return t.type=`xstate.enqueueActions`,t.collect=e,t.resolve=on,t}function cn(e,t,n,r,{value:i,label:a}){return[t,{value:typeof i==`function`?i(n,r):i,label:a},void 0]}function ln({logger:e},{value:t,label:n}){n?e(n,t):e(t)}function un(e=({context:e,event:t})=>({context:e,event:t}),t){function n(e,t){}return n.type=`xstate.log`,n.value=e,n.label=t,n.resolve=cn,n.execute=ln,n}function dn(e,t){return new Yt(e,t)}function fn({schemas:e,actors:t,actions:n,guards:r,delays:i}){return{assign:Gt,sendTo:rn,raise:Ht,log:un,cancel:Ie,stopChild:j,enqueueActions:sn,emit:Qt,spawnChild:ze,createStateConfig:e=>e,createAction:e=>e,createMachine:a=>dn({...a,schemas:e},{actors:t,actions:n,guards:r,delays:i}),extend:a=>fn({schemas:e,actors:t,actions:{...n,...a.actions},guards:{...r,...a.guards},delays:{...i,...a.delays}})}}var pn=(e,t,n)=>Math.max(t,Math.min(n,e)),mn=class{dents=[];revision=0;enabled=!1;maxDepthM=0;maskCache=new WeakMap;spriteCache=null;captureState(){return a({dents:this.dents,revision:this.revision,enabled:this.enabled,maxDepthM:this.maxDepthM})}restoreState(e){let t=a(e);this.dents=t.dents,this.revision=t.revision,this.enabled=t.enabled,this.maxDepthM=t.maxDepthM,this.maskCache=new WeakMap,this.spriteCache=null}get hasDamage(){return this.enabled&&this.dents.length>0}get geometryRevision(){return this.revision}setEnabled(e){this.enabled!==e&&(this.enabled=e,e||this.reset())}reset(){this.dents=[],this.maxDepthM=0,this.revision++,this.spriteCache=null}hit(e,t,n,r,i){if(!this.enabled||r<=2.5||!Number.isFinite(r))return!1;let a=Math.max(1,i),o=s(e,n.center),u=l(f(o,n.forward)/a,f(o,n.side)/a),d=l(f(t,n.forward),f(t,n.side)),m=p(d);if(m<.001)return!1;let h=pn((r-2.5)/17.5,0,1)**1.5;return this.maxDepthM=Math.min(.25,8/a),this.dents.push({center:u,inward:c(d,1/m),depthM:this.maxDepthM*h,radiusAlongM:.65+h*.5,radiusAcrossM:.55+h*.55}),this.dents.length>12&&this.dents.shift(),this.revision++,this.spriteCache=null,!0}point(e){if(!this.hasDamage)return e;let t=l();for(let n of this.dents){let r=(e.x-n.center.x)/n.radiusAlongM,i=(e.y-n.center.y)/n.radiusAcrossM,a=Math.hypot(r,i);if(a>=1)continue;let o=(1-a*a)**2;t=d(t,c(n.inward,n.depthM*o))}let n=p(t);return n>this.maxDepthM&&(t=c(t,this.maxDepthM/n)),d(e,t)}maskFor(e){if(!this.hasDamage)return e;let t=this.maskCache.get(e);if(t?.revision===this.revision)return t.value;let{columns:n,rows:r,solid:i}=e.alpha,a=new Uint8Array(i.length),o=e.lengthM/n,c=e.widthM/r;for(let t=0;t<r;t++)for(let u=0;u<n;u++){let f=l((u+.5)*o-e.lengthM/2,(t+.5)*c-e.widthM/2),p=f;for(let e=0;e<5;e++)p=d(p,s(f,this.point(p)));let m=Math.floor((p.x/e.lengthM+.5)*n),h=Math.floor((p.y/e.widthM+.5)*r);m>=0&&m<n&&h>=0&&h<r&&(a[t*n+u]=i[h*n+m])}let u={...e,alpha:{columns:n,rows:r,solid:a}};return this.maskCache.set(e,{revision:this.revision,value:u}),u}spriteFor(e,t){if(!this.hasDamage)return null;let n=`${t.source.x}:${t.source.y}:${t.source.width}:${t.source.height}:${t.lengthM}:${t.widthM}`;if(this.spriteCache?.image===e&&this.spriteCache.key===n&&this.spriteCache.revision===this.revision)return this.spriteCache.canvas;let r=document.createElement(`canvas`);r.width=Math.max(1,Math.round(t.source.width)),r.height=Math.max(1,Math.round(t.source.height));let i=r.getContext(`2d`);if(!i)return null;let a=e=>{let n=l((e.x/r.width-.5)*t.lengthM,(e.y/r.height-.5)*t.widthM),i=this.point(n);return l((i.x/t.lengthM+.5)*r.width,(i.y/t.widthM+.5)*r.height)};for(let n=0;n<10;n++)for(let o=0;o<20;o++){let s=o*r.width/20,c=(o+1)*r.width/20,u=n*r.height/10,d=(n+1)*r.height/10,f=l(s,u),p=l(c,u),m=l(s,d),h=l(c,d);this.drawTriangle(i,e,t,[f,p,m],[a(f),a(p),a(m)]),this.drawTriangle(i,e,t,[h,m,p],[a(h),a(m),a(p)])}return this.spriteCache={image:e,key:n,revision:this.revision,canvas:r},r}drawTriangle(e,t,n,r,i){let[a,o,s]=r,[c,l,u]=i,d=o.x-a.x,f=o.y-a.y,p=s.x-a.x,m=s.y-a.y,h=d*m-p*f;if(Math.abs(h)<1e-4)return;let g=l.x-c.x,_=l.y-c.y,v=u.x-c.x,y=u.y-c.y,b=(g*m-v*f)/h,x=(_*m-y*f)/h,S=(v*d-g*p)/h,ee=(y*d-_*p)/h,C=c.x-b*a.x-S*a.y,te=c.y-x*a.x-ee*a.y;e.save(),e.beginPath(),e.moveTo(c.x,c.y),e.lineTo(l.x,l.y),e.lineTo(u.x,u.y),e.closePath(),e.clip(),e.transform(b,x,S,ee,C,te),e.drawImage(t,n.source.x,n.source.y,n.source.width,n.source.height,0,0,e.canvas.width,e.canvas.height),e.restore()}},hn=class{random;pulses=[];constructor(e=Math.random){this.random=e}get active(){return this.pulses}trigger({color:e,angle:t,velocity:n,origin:r}){if(!Number.isFinite(t)||!Number.isFinite(n))throw RangeError(`Pickup angle and velocity must be finite`);if(r&&(!Number.isFinite(r.x)||!Number.isFinite(r.y)||Math.abs(r.x)>.5||Math.abs(r.y)>.5))throw RangeError(`Pickup origin must lie within normalized body coordinates [-0.5, 0.5]`);let a=i(e),o=Math.min(1,Math.abs(n)/32);this.pulses.push({color:[a[0]/255,a[1]/255,a[2]/255],angle:Math.atan2(Math.sin(t),Math.cos(t)),strength:o,velocity:Math.abs(n),origin:r?{...r}:null,variation:this.random(),age:0,duration:.38-o*.1}),this.pulses.length>3&&this.pulses.shift()}step(e){if(!(!this.pulses.length||!Number.isFinite(e)||e<=0)){for(let t of this.pulses)t.age+=e;this.pulses=this.pulses.filter(e=>e.age<e.duration)}}reset(){this.pulses=[]}captureState(){return structuredClone(this.pulses)}restoreState(e){this.pulses=structuredClone(e)}},gn=new Map,X=null;function _n(e){let t=e.match(/^#([\da-f]{3}|[\da-f]{6})$/i)?.[1];if(t){let e=t.length===3?[...t].map(e=>e+e).join(``):t;return[0,2,4].map(t=>parseInt(e.slice(t,t+2),16))}let n=e.match(/^rgba?\(\s*(\d{1,3})[,\s]+(\d{1,3})[,\s]+(\d{1,3})/i);return n?[u(+n[1],0,255),u(+n[2],0,255),u(+n[3],0,255)]:null}function Z(e){let t=_n(e);if(t)return t;if(gn.has(e))return gn.get(e);let n=null;return typeof document<`u`&&(X??=document.createElement(`canvas`).getContext(`2d`),X&&(X.fillStyle=`#010203`,X.fillStyle=e,X.fillStyle!==`#010203`&&(n=_n(X.fillStyle)))),gn.set(e,n),n}var vn=[[0,0],[60,120],[120,180],[240,240],[300,300],[360,360]];function yn(e,t=!1){let n=(e%360+360)%360;for(let e=1;e<vn.length;e++){let[r,i]=vn[e-1],[a,o]=vn[e],s=t?i:r,c=t?o:a;if(n<=c){let e=(n-s)/(c-s);return(t?r+(a-r)*e:i+(o-i)*e)%360}}return 0}function bn([e,t,n]){let r=e/255,i=t/255,a=n/255,o=Math.max(r,i,a),s=Math.min(r,i,a),c=o-s,l=(o+s)/2;if(c===0)return{hue:0,saturation:0,light:l};let u=c/(1-Math.abs(2*l-1));return{hue:((o===r?(i-a)/c%6:o===i?(a-r)/c+2:(r-i)/c+4)*60+360)%360,saturation:u,light:l}}function xn(e,t,n){let r=(1-Math.abs(2*n-1))*t,i=r*(1-Math.abs(e/60%2-1)),a=Math.floor(e/60)%6,o=[[r,i,0],[i,r,0],[0,r,i],[0,i,r],[i,0,r],[r,0,i]][a],s=n-r/2;return`rgb(${o.map(e=>Math.round((e+s)*255)).join(` `)})`}function Sn(e){let t=e.filter(e=>e.strength>0&&Z(e.color));if(!t.length)return e.at(-1)?.color??`rgb(0 0 0)`;if(t.length===1)return`rgb(${Z(t[0].color).join(` `)})`;let n=0,r=0,i=0,a=0,o=0;for(let e of t){let t=bn(Z(e.color)),s=yn(t.hue)*Math.PI/180,c=e.strength*t.saturation;n+=Math.cos(s)*c,r+=Math.sin(s)*c,i+=t.light*e.strength,a+=c,o+=e.strength}return xn(yn((Math.atan2(r,n)*180/Math.PI+360)%360,!0),Math.min(1,a/o),i/o)}var Cn=class{coatings=new Map;previous=new Map;travelM=new Map;previousLayer=new Map;wetPaths=new Map;exits=new Map;sprayRemainder=new Map;marks=[];markCount=0;captureState(){return a({coatings:this.coatings,previous:this.previous,travelM:this.travelM,previousLayer:this.previousLayer,wetPaths:this.wetPaths,exits:this.exits,sprayRemainder:this.sprayRemainder,marks:this.marks,markCount:this.markCount})}restoreState(e){let t=a(e);this.coatings=t.coatings,this.previous=t.previous,this.travelM=t.travelM,this.previousLayer=t.previousLayer,this.wetPaths=t.wetPaths,this.exits=t.exits,this.sprayRemainder=t.sprayRemainder,this.marks.length=0;for(let e of t.marks)this.marks.push(e);this.markCount=t.markCount}get totalMarks(){return this.markCount}get managedBytes(){return this.marks.length*136+this.travelM.size*16+[...this.coatings.values()].reduce((e,t)=>e+t.size*72,0)+this.previous.size*24+this.previousLayer.size*8+[...this.wetPaths.values()].reduce((e,t)=>e+t.marks.length*160,0)+this.exits.size*24+this.sprayRemainder.size*16}reset(){this.travelM.clear(),this.coatings.clear(),this.previous.clear(),this.previousLayer.clear(),this.wetPaths.clear(),this.exits.clear(),this.sprayRemainder.clear(),this.marks.length=0,this.markCount=0}step(e){e.forEach((e,t)=>this.travelM.set(t,(this.travelM.get(t)??0)+Math.max(0,e)));for(let[t,n]of this.coatings){let r=Math.max(0,e[t]??0);for(let[e,t]of n)t.remaining=Math.max(0,t.remaining-r),t.remaining===0&&n.delete(e);n.size===0&&(this.coatings.delete(t),this.previous.delete(t),this.previousLayer.delete(t),this.wetPaths.delete(t),this.exits.delete(t))}}touch(e,t){if(!t||t.opacity<=0||t.distanceM<=0)return;let n=this.coatings.get(e);n||(n=new Map,this.coatings.set(e,n));let r=t.id??t.color,i=n.get(r);if(n.set(r,{...t,opacity:Math.max(i?.opacity??0,u(t.opacity,0,1)),remaining:t.distanceM}),n.size>16){let e=[...n.entries()].filter(([e])=>e!==r).sort((e,t)=>e[1].opacity*e[1].remaining/e[1].distanceM-t[1].opacity*t[1].remaining/t[1].distanceM)[0];e&&n.delete(e[0])}}wash(e,t=[]){let n=this.coatings.get(e);if(n&&t.length){let e=new Set(t.map(e=>e.id??e.color));for(let t of n.keys())e.has(t)||n.delete(t);if(n.size)return}this.coatings.delete(e),this.previous.delete(e),this.previousLayer.delete(e),this.sprayRemainder.delete(e),this.wetPaths.delete(e),this.exits.delete(e)}splatter(e,t,n,i,a,o,s){let c=this.coating(e);if(!c||a<=0||s<=0)return;let l=r.paint.thickness,u=(this.sprayRemainder.get(e)??0)+a*(9+(1-l)*7)*(c.material?.spray??.5),d=Math.min(24,Math.floor(u));this.sprayRemainder.set(e,u-Math.floor(u));for(let e of y(t,n,i,d,o,l)){let t=1+e.angularity*1.7,r={x:e.x,y:e.y};this.marks.push({from:r,point:r,angle:Math.atan2(n.y,n.x),widthM:e.radius*2*t/(s*.76),color:c.color,opacity:c.opacity*e.opacity,droplet:{aspect:(.5+Math.random()*.45)/t}}),this.markCount++}this.marks.length>3e4&&this.marks.splice(0,1e3)}trackWet(e,t,n,r,i,a=0,o=!1){let c=this.coating(e);if(!c){this.pauseTrack(e);return}let l=this.previous.get(e),d=this.wetPaths.get(e);if(!d||!l||p(s(t,l))>=1.5*i)d={marks:[],distanceM:0},this.wetPaths.set(e,d),o&&(this.marks.push({...c,from:{...t},point:{...t},angle:n,widthM:r,phaseM:this.travelM.get(e)??0,slip:u(a,0,1),overPuddle:!0}),this.markCount++);else{let f=d.marks.at(-1),m=f&&p(s(f.point,f.from))/i<.02,h=m?f.from:l;m&&(d.distanceM-=p(s(f.point,f.from))/i);let g=p(s(t,h))/i,_={...c,from:{...h},point:{...t},angle:n,widthM:r,phaseM:(this.travelM.get(e)??0)-g,slip:u(a,0,1)};m?d.marks[d.marks.length-1]=_:d.marks.push(_),d.distanceM+=g,o&&g>=.02&&(this.marks.push({..._,overPuddle:!0}),this.markCount++,this.marks.length>3e4&&this.marks.splice(0,1e3));let v=Math.max(.5,r*6);for(;d.marks.length>1&&(d.distanceM>v||d.marks.length>128);){let e=d.marks.shift();d.distanceM-=p(s(e.point,e.from))/i}}this.exits.delete(e),this.previous.set(e,{...t}),this.previousLayer.set(e,!1)}pauseTrack(e){this.wetPaths.delete(e),this.exits.delete(e),this.previous.delete(e),this.previousLayer.delete(e)}track(e,t,n,r,i,a=!1,o=0){let c=this.coating(e);if(!c)return;let l=this.previous.get(e),d=l?p(s(t,l)):0,f=this.wetPaths.has(e)||this.exits.has(e)?.01:.05;if(l&&d<f*i)return;let m=l&&d<1.5*i,h=this.wetPaths.get(e);if(h&&m){let t=Math.max(.35,r*(2+4*(c.material?.film??.6))),n=-h.distanceM;for(let e of h.marks){let r=n+p(s(e.point,e.from))/i;this.marks.push({...e,overPuddle:!1,exit:{fromM:n,toM:r,lengthM:t,leadInM:h.distanceM}}),this.markCount++,n=r}this.exits.set(e,{distanceM:0,lengthM:t})}else m||this.exits.delete(e);this.wetPaths.delete(e);let g=this.exits.get(e),_=g&&g.distanceM<g.lengthM?{fromM:g.distanceM,toM:g.distanceM+d/i,lengthM:g.lengthM}:void 0;g&&(g.distanceM+=d/i,g.distanceM>=g.lengthM&&this.exits.delete(e)),this.marks.push({from:m?{...l}:{...t},point:{...t},angle:n,widthM:r,phaseM:(this.travelM.get(e)??0)-(m?p(s(t,l))/i:0),wetness:c.wetness,material:c.material,slip:u(o,0,1),color:c.color,opacity:c.opacity,overPuddle:a,exit:_}),this.markCount++,this.previous.set(e,{...t}),this.previousLayer.set(e,a),this.marks.length>3e4&&this.marks.splice(0,1e3)}coating(e){let t=this.coatings.get(e);if(!t?.size)return null;let n=[...t.values()].map(e=>({color:e.color,strength:e.opacity*u(e.remaining/e.distanceM,0,1)})),r=[...t.values()].sort((e,t)=>t.opacity*t.remaining/t.distanceM-e.opacity*e.remaining/e.distanceM)[0],i=u(r.remaining/r.distanceM,0,1);return{material:r.material,wetness:i,color:Sn(n),opacity:Math.max(...n.map(e=>e.strength))*i**+Math.max(0,(r.material?.drain??1)-1),remaining:Math.max(...[...t.values()].map(e=>e.remaining)),distanceM:Math.max(...[...t.values()].map(e=>e.distanceM))}}},Q={opening:.32,raising:.52,igniting:.48,closing:.36},wn=class{previewOpen=!1;inspecting=!1;phase=`idle`;elapsed=0;held=!1;presetId=null;flights=[];launchClock=0;queuedShots=0;launches=0;ignitionDuration=Q.igniting;captureState(){return a({previewOpen:this.previewOpen,inspecting:this.inspecting,phase:this.phase,elapsed:this.elapsed,held:this.held,presetId:this.presetId,flights:this.flights,launchClock:this.launchClock,queuedShots:this.queuedShots,launches:this.launches,ignitionDuration:this.ignitionDuration})}restoreState(e){let t=a(e);this.previewOpen=t.previewOpen,this.inspecting=t.inspecting,this.phase=t.phase,this.elapsed=t.elapsed,this.held=t.held,this.presetId=t.presetId,this.flights=t.flights,this.launchClock=t.launchClock,this.queuedShots=t.queuedShots,this.launches=t.launches,this.ignitionDuration=t.ignitionDuration}get state(){return this.phase}get projectile(){let e=this.flights[0];return e?{...e,position:{...e.position}}:null}get projectileCount(){return this.flights.length}get managedBytes(){return this.flights.length*64}get launchCount(){return this.launches}reset(){this.previewOpen=!1,this.inspecting=!1,this.phase=`idle`,this.elapsed=0,this.held=!1,this.flights=[],this.launchClock=0,this.queuedShots=0,this.launches=0,this.ignitionDuration=Q.igniting,this.presetId=null}disarm(){this.held=!1,this.queuedShots=0,(this.phase===`opening`||this.phase===`raising`||this.phase===`igniting`)&&this.transition(`closing`)}transition(e){this.phase=e,this.elapsed=0}step(t,n,r,i,a,o,s,p){if(n.mode!==`car`){this.reset();return}if(this.presetId&&this.presetId!==n.car.preset.id&&this.reset(),this.previewOpen){this.inspecting=!0,this.presetId=n.car.preset.id,(this.phase===`idle`||this.phase===`closing`)&&this.transition(`opening`),this.elapsed+=t,this.phase===`opening`&&this.elapsed>=Q.opening&&this.transition(`raising`),this.phase===`raising`&&(this.elapsed=Math.min(this.elapsed,Q.raising));return}this.inspecting&&(this.inspecting=!1,this.transition(`closing`));let h=!!n.lastInput.rocket;h&&!this.held&&(this.queuedShots++,(this.phase===`idle`||this.phase===`closing`)&&(this.presetId=n.car.preset.id,this.transition(`opening`))),this.held=h;let g=e(n.car.preset);if(this.phase===`idle`&&!this.flights.length)return;this.elapsed+=t,this.launchClock+=t;let _=n.car.preset.roofRocket,v=Math.max(1.05,_.sizeM*1.12);if(this.phase===`opening`&&this.elapsed>=Q.opening)this.transition(`raising`);else if(this.phase===`raising`&&this.elapsed>=Q.raising)this.ignitionDuration=Q.igniting,this.transition(`igniting`),p?.(n.body.world(l(_.xM,_.yM)));else if(this.phase===`igniting`&&this.elapsed>=this.ignitionDuration){let e=m(l(1,0),n.body.angle),t=n.body.world(l(_.xM,_.yM));this.flights.push({position:t,angle:n.body.angle,speedMps:g.launchSpeedMps+Math.max(0,f(n.body.velocity,e)),distanceM:0,age:0}),this.launches++,o?.(t),this.queuedShots=Math.max(0,this.queuedShots-1),this.launchClock=0,this.transition(`flying`)}else this.phase===`closing`&&this.elapsed>=Q.closing&&this.transition(`idle`);if(this.phase===`igniting`){let e=u(this.elapsed/Math.min(.27,this.ignitionDuration*.65),0,.9),i=m(l(-1,0),n.body.angle),o=n.body.world(l(_.xM-v*.52,_.yM));r({point:o,flow:c(i,3.5),amount:t*14*e,radiusM:.2}),a?.({from:o,to:o,flow:c(i,12),widthM:.16,intensity:e*.75})}this.phase===`flying`&&(!h&&this.queuedShots===0?this.transition(`closing`):this.launchClock>=Math.max(0,1/g.roundsPerSecond-Math.min(Q.igniting,.7/g.roundsPerSecond))&&(this.ignitionDuration=Math.min(Q.igniting,.7/g.roundsPerSecond),this.transition(`igniting`),p?.(n.body.world(l(_.xM,_.yM)))));for(let e=this.flights.length-1;e>=0;e--){let n=this.flights[e],o=m(l(1,0),n.angle);n.speedMps=Math.min(g.maxSpeedMps,n.speedMps+g.accelerationMps2*t);let u=n.speedMps*t,f=n.position,p=d(f,c(o,u)),h=i?.(f,p,_.sizeM*.18);n.position=h??p,n.distanceM+=u,n.age+=t;let y=d(n.position,c(o,-v*.53)),b=d(f,c(o,-v*.53));if(r({point:y,flow:c(o,-5),amount:t*g.smokePerSecond,radiusM:.2}),a?.({from:b,to:y,flow:c(o,-18),widthM:.13,intensity:.9}),h){s?.(h);for(let e=0;e<7;e++){let t=m(l(1,0),e*Math.PI*2/7);r({point:h,flow:c(t,5.5),amount:.18,radiusM:.22})}this.flights.splice(e,1)}else(n.age>=g.lifetimeSeconds||n.distanceM>100)&&this.flights.splice(e,1)}this.phase===`closing`&&this.elapsed>=Q.closing&&this.transition(`idle`)}get open(){return this.phase===`idle`?0:this.phase===`opening`?u(this.elapsed/Q.opening,0,1):this.phase===`closing`?1-u(this.elapsed/Q.closing,0,1):1}drawMount(e,t,n,r,i,a=1,o){let s=this.open;if(s<=0)return;v();let c=r.roofRocket,l=c.sizeM*i,d=s*s*(3-2*s);e.save(),e.translate(t.x,t.y),e.rotate(-n),e.translate(c.xM*i,-c.yM*i),e.globalAlpha*=a;let f=e.createLinearGradient(0,-l/2,0,l/2);f.addColorStop(0,`#11171b`),f.addColorStop(.45,`#030609`),f.addColorStop(1,`#222a2e`),e.fillStyle=f,e.beginPath(),e.roundRect(-l/2,-l/2,l,l,l*.06),e.fill(),e.strokeStyle=`#525c62`,e.lineWidth=Math.max(.45,i*.018),e.stroke();for(let t of[-1,1]){e.fillStyle=`#687279`,e.fillRect(-l*.42,t*l*.2,l*.84,l*.035),e.fillStyle=`#161d22`,e.fillRect(-l*.34,-l*.28,l*.065,l*.56);let n=l*.5*(1-d*.78),r=t*(l*.25+d*l*.22);if(e.save(),e.translate(0,r),e.shadowColor=`rgba(0,0,0,.55)`,e.shadowBlur=l*.08,e.shadowOffsetY=l*.035,e.fillStyle=c.panelColor,e.beginPath(),e.roundRect(-l/2,-n/2,l,n,l*.035),e.fill(),e.shadowBlur=0,e.shadowOffsetY=0,o){e.save(),e.clip();let r=o.source.x+(c.xM-c.sizeM/2+o.lengthM/2)/o.lengthM*o.source.width,i=o.source.y+(-c.yM+(t<0?-c.sizeM/2:0)+o.widthM/2)/o.widthM*o.source.height;e.drawImage(o.image,r,i,c.sizeM/o.lengthM*o.source.width,c.sizeM/2/o.widthM*o.source.height,-l/2,-n/2,l,n),e.restore()}e.strokeStyle=`rgba(8,13,17,.7)`,e.lineWidth=Math.max(.45,i*.018),e.stroke(),e.restore()}if(this.phase===`raising`||this.phase===`igniting`){let t=this.phase===`igniting`?1:u(this.elapsed/Q.raising,0,1);e.save(),e.globalAlpha*=t,e.scale(.35+t*.65,.35+t*.65),this.drawBody(e,Math.max(1.05,c.sizeM*1.12)*i,1),e.restore()}e.restore()}drawFlight(e,t,n,r,i=1){for(let a of this.flights){let o=t(a.position);e.save(),e.translate(o.x,o.y),e.rotate(-a.angle),e.globalAlpha=i,this.drawBody(e,Math.max(1.05,n.roofRocket.sizeM*1.12)*r,1),e.restore()}}drawBody(e,t,n){if(e.save(),e.globalAlpha*=n,e.shadowColor=`rgba(0,0,0,.5)`,e.shadowBlur=t*.055,e.shadowOffsetY=t*.025,!h(e,`rocket`,-t*.53,0,t*1.06)){let n=e.createLinearGradient(0,-t*.045,0,t*.045);n.addColorStop(0,`#3b454d`),n.addColorStop(.35,`#d8dddc`),n.addColorStop(1,`#3e484f`),e.fillStyle=n,e.beginPath(),e.moveTo(-t*.53,-t*.045),e.lineTo(t*.3,-t*.045),e.lineTo(t*.53,0),e.lineTo(t*.3,t*.045),e.lineTo(-t*.53,t*.045),e.closePath(),e.fill(),e.fillStyle=`#30383e`;for(let n of[-1,1])e.beginPath(),e.moveTo(-t*.48,n*t*.12),e.lineTo(-t*.22,n*t*.04),e.lineTo(-t*.44,n*t*.04),e.closePath(),e.fill()}e.restore()}},Tn=.22,En=.24,Dn=class{phase=`closed`;phaseTime=0;shotClock=0;flashAge=1/0;presetId=null;bullets=[];captureState(){return a({phase:this.phase,phaseTime:this.phaseTime,shotClock:this.shotClock,flashAge:this.flashAge,presetId:this.presetId,bullets:this.bullets})}restoreState(e){let t=a(e);this.phase=t.phase,this.phaseTime=t.phaseTime,this.shotClock=t.shotClock,this.flashAge=t.flashAge,this.presetId=t.presetId,this.bullets=t.bullets}get state(){return this.phase}get openAmount(){return this.open}get projectileCount(){return this.bullets.length}get managedBytes(){return this.bullets.length*56}reset(){this.phase=`closed`,this.phaseTime=0,this.shotClock=0,this.flashAge=1/0,this.presetId=null,this.bullets=[]}step(e,t,r,i,a){if(t.mode!==`car`){this.reset();return}this.presetId&&this.presetId!==t.car.preset.id&&this.reset();let o=n(t.car.preset),s=!!t.lastInput.machineGun;if(s&&(this.phase===`closed`||this.phase===`closing`)){this.presetId=t.car.preset.id;let e=this.open;this.phase=`opening`,this.phaseTime=e*Tn}else if(!s&&(this.phase===`opening`||this.phase===`active`)){let e=this.open;this.phase=`closing`,this.phaseTime=(1-e)*En}if(this.phaseTime+=e,this.flashAge+=e,this.phase===`opening`&&this.phaseTime>=Tn&&(this.phase=`active`,this.phaseTime=0,this.shotClock=1/o.roundsPerSecond),this.phase===`active`){if(s){let n=1/Math.max(1,o.roundsPerSecond);this.shotClock+=e;for(let e=0;this.shotClock>=n&&e<4;e++)this.shotClock-=n,this.fire(t),i?.()}}else this.phase===`closing`&&this.phaseTime>=En&&(this.phase=`closed`,this.phaseTime=0);for(let t=this.bullets.length-1;t>=0;t--){let n=this.bullets[t],i=n.position,s=d(i,c(n.velocity,e)),l=r?.(i,s,.075);n.age+=e,l||n.age>=o.bulletLifetimeSeconds?(l&&a?.(l,n.velocity),this.bullets.splice(t,1)):n.position=s}}fire(e){let t=n(e.car.preset),r=m(l(1,0),e.body.angle);for(let n of[-1,1]){let i=e.body.world(g(e.car.preset,n)),a=d(c(r,t.bulletSpeedMps),e.body.velocityAt(i));this.bullets.push({position:i,velocity:a,age:0})}this.flashAge=0}get open(){return this.phase===`closed`?0:this.phase===`opening`?u(this.phaseTime/Tn,0,1):this.phase===`closing`?1-u(this.phaseTime/En,0,1):1}drawMount(e,t,n,r,i,a=1,o){_(e,t,n,r,i,this.open,`gun`,Math.max(0,1-this.flashAge/.075),a,o)}drawProjectiles(e,t,n,r=1){e.save(),e.lineCap=`round`;for(let i of this.bullets){let a=t(i.position),o=Math.hypot(i.velocity.x,i.velocity.y),s=t(d(i.position,c(i.velocity,-.75/Math.max(1,o)))),l=e.createLinearGradient(s.x,s.y,a.x,a.y);l.addColorStop(0,`rgba(224,153,63,0)`),l.addColorStop(.7,`rgba(224,153,63,.25)`),l.addColorStop(1,`rgba(255,225,157,.7)`),e.globalAlpha=r,e.strokeStyle=l,e.lineWidth=Math.max(.65,n*.025),e.beginPath(),e.moveTo(s.x,s.y),e.lineTo(a.x,a.y),e.stroke();let u=t(d(i.position,c(i.velocity,-.09/Math.max(1,o))));e.strokeStyle=`#fff6d7`,e.lineWidth=Math.max(.55,n*.018),e.beginPath(),e.moveTo(u.x,u.y),e.lineTo(a.x,a.y),e.stroke()}e.restore()}},On=.22,kn=.24,$=1/45,An=class{phase=`closed`;phaseTime=0;emitting=!1;presetId=null;fireClock=0;jets=[];captureState(){return a({phase:this.phase,phaseTime:this.phaseTime,emitting:this.emitting,presetId:this.presetId,fireClock:this.fireClock,jets:this.jets})}restoreState(e){let t=a(e);this.phase=t.phase,this.phaseTime=t.phaseTime,this.emitting=t.emitting,this.presetId=t.presetId,this.fireClock=t.fireClock,this.jets=t.jets}get state(){return this.phase}get firing(){return this.emitting}get openAmount(){return this.open}get managedBytes(){return this.jets.length*64}reset(){this.phase=`closed`,this.phaseTime=0,this.emitting=!1,this.presetId=null,this.fireClock=0,this.jets=[]}step(e,n,r,i,a){if(n.mode!==`car`){(this.phase!==`closed`||this.jets.length)&&this.reset();return}this.presetId&&this.presetId!==n.car.preset.id&&this.reset();let o=!!n.lastInput.flamethrower,s=t(n.car.preset);if(o&&(this.phase===`closed`||this.phase===`closing`)){this.presetId=n.car.preset.id;let e=this.open;this.phase=`opening`,this.phaseTime=e*On}else if(!o&&(this.phase===`opening`||this.phase===`active`)){let e=this.open;this.phase=`closing`,this.phaseTime=(1-e)*kn}if(this.phaseTime+=e,this.phase===`opening`&&this.phaseTime>=On&&(this.phase=`active`,this.phaseTime=0,this.fireClock=$),this.emitting=this.phase===`active`&&o,this.phase===`closing`&&this.phaseTime>=kn&&(this.phase=`closed`,this.phaseTime=0),this.emitting){let t=m(l(1,0),n.body.angle),i=s.rangeM/.3;for(this.fireClock+=e;this.fireClock>=$;){this.fireClock-=$;for(let e of[-1,1]){let r=n.body.world(g(n.car.preset,e));this.jets.push({point:r,velocity:d(c(t,i),c(n.body.velocity,.25)),traveled:0,range:s.rangeM,speed:i,width:s.jetWidthM*s.flowRate})}}for(let i of[-1,1]){let a=n.body.world(g(n.car.preset,i));r({point:d(a,c(t,.06)),flow:c(t,5.5),amount:e*s.smokePerSecond*s.flowRate*.38,radiusM:.12})}}let u=[];for(let t of this.jets){let n=Math.min(t.range-t.traveled,t.speed*e),o=t.point,l=d(o,c(t.velocity,n/t.speed)),f=(t.traveled+n)/t.range,p=t.width*(.65+1.45*f),m=i?.(o,l,Math.max(.3,p*1.25),$*s.flowRate),h=m??l;t.point=h,t.traveled+=n,a?.(o,h,p,t.velocity,f),(f>.62||m)&&r({point:h,flow:c(t.velocity,.42),amount:e*s.smokePerSecond*s.flowRate*(m?.42:.18),radiusM:Math.max(.11,p*.48)}),m?a?.(h,h,p*1.35,t.velocity,f):t.traveled+1e-6<t.range&&u.push(t)}this.jets=u}get open(){return this.phase===`closed`?0:this.phase===`opening`?u(this.phaseTime/On,0,1):this.phase===`closing`?1-u(this.phaseTime/kn,0,1):1}drawMount(e,t,n,r,i,a=1,o){_(e,t,n,r,i,this.open,`flame`,this.phase===`active`?.8:0,a,o)}},jn=class{rocket=new wn;machineGuns=new Dn;flamethrower=new An;reset(){this.rocket.reset(),this.machineGuns.reset(),this.flamethrower.reset()}stopFiring(){this.rocket.disarm()}captureState(){return{rocket:this.rocket.captureState(),machineGuns:this.machineGuns.captureState(),flamethrower:this.flamethrower.captureState()}}restoreState(e){this.rocket.restoreState(e.rocket),this.machineGuns.restoreState(e.machineGuns),this.flamethrower.restoreState(e.flamethrower)}get managedBytes(){return this.rocket.managedBytes+this.machineGuns.managedBytes+this.flamethrower.managedBytes}},Mn=e=>({...e,slots:e.slots?[...e.slots]:void 0,slotPresses:e.slotPresses?[...e.slotPresses]:void 0}),Nn=fn({types:{events:{}}}).createMachine({id:`vehicleLifecycle`,initial:`drivable`,states:{drivable:{on:{DESTROYED:`destroyed`}},destroyed:{on:{RESPAWNED:`drivable`}}}}),Pn=class{id;sim;damage=new mn;weapons=new jn;tirePaint=new Cn;pickupEffect=new hn;lifecycle=A(Nn).start();controls={throttle:0,steer:0,action:!1};controlSource=`player`;label=``;appearance=`auto`;slotConfiguration=S;toolPolicy={};numberedSlots=C(S);slotHeld=new Set;slotPulses=new Set;slotPresses=new Set;blockedSlots=new Set;disposed=!1;previousSlotInput=new Set;activeEmitters=[];get slots(){return this.slotConfiguration}set slots(e){if(this.disposed)throw Error(`Vehicle is disposed.`);let t=b(e);this.clearSlotInput(),this.slotConfiguration=t,this.numberedSlots=C(t,this.toolPolicy)}liquidEmissions(e){return!this.sim.lastInput.eject||this.isGhost||this.lifecycleState!==`drivable`?[]:this.activeEmitters.map(({slot:t,liquid:n,pulse:r,rate:i,amount:a})=>({slot:t,liquid:n,amount:r?a:Math.max(0,e)*i})).filter(e=>e.amount>0)}useSlot(e){let t=x(e);return this.disposed||!this.numberedSlots[t-1]||this.lifecycleState!==`drivable`?!1:(this.slotPulses.add(t),!0)}startSlot(e){let t=x(e);return this.disposed||!this.numberedSlots[t-1]||this.lifecycleState!==`drivable`?!1:(this.slotHeld.has(t)||this.slotPresses.add(t),this.slotHeld.add(t),!0)}stopSlot(e){this.slotHeld.delete(x(e))}clearSlotInput(){this.slotHeld.clear(),this.slotPulses.clear(),this.slotPresses.clear(),this.blockedSlots.clear(),this.previousSlotInput.clear(),this.activeEmitters=[]}resolveSlots(e){let t=new Set((e.slots??[]).map(x)),n=new Set((e.slotPresses??[]).map(x));for(let e of this.blockedSlots)!t.has(e)&&!n.has(e)?this.blockedSlots.delete(e):(t.delete(e),n.delete(e));let r=new Set([...this.slotHeld,...t]),i=new Set([...this.slotPresses,...n]),a=Mn(e);this.activeEmitters=[];for(let{number:e,slot:t}of this.numberedSlots){let n=r.has(e)&&!this.previousSlotInput.has(e),o=this.slotPulses.has(e)||(t.activation===`tap`?n||i.has(e):i.has(e)&&!r.has(e));(o||t.activation!==`tap`&&r.has(e))&&(t.action===`eject`?(a.eject=!0,this.activeEmitters.push({slot:e,liquid:t.liquid,pulse:o,rate:t.rate??6,amount:t.amount??.65})):a[t.action]=!0)}if(e.eject&&!this.activeEmitters.length){for(let{number:e,slot:t}of this.numberedSlots)if(t.action===`eject`){this.activeEmitters.push({slot:e,liquid:t.liquid,pulse:!1,rate:t.rate??6,amount:t.amount??.65});break}}return this.previousSlotInput=r,a}constructor(e,t){this.id=e,this.sim=t}get lifecycleState(){return this.lifecycle.getSnapshot().value}get isGhost(){return this.sim.mode===`car`&&this.lifecycleState===`drivable`&&!!this.controls.ghost}setControls(e,t,n={}){if(n.toolsEnabled!==this.toolPolicy.toolsEnabled){let t=C(this.slotConfiguration,n);if(t.length!==this.numberedSlots.length||t.some(({source:e},t)=>e!==this.numberedSlots[t].source)){this.clearSlotInput();for(let t of[...e.slots??[],...e.slotPresses??[]])this.blockedSlots.add(x(t))}this.toolPolicy=n,this.numberedSlots=t}this.controls=ee(this.resolveSlots(e),n.toolsEnabled),this.controlSource=t}step(e,t,n=!1){this.pickupEffect.step(e),n?this.sim.lastInput={throttle:0,steer:0,action:!1,boost:!1}:this.sim.tick(this.lifecycleState===`drivable`?this.controls:{throttle:0,steer:0,action:!1},e,t),this.slotPulses.clear(),this.slotPresses.clear()}synchronizeLifecycle(){let e=this.sim.car.explodedAt!==null;e&&this.lifecycleState===`drivable`?(this.lifecycle.send({type:`DESTROYED`}),this.weapons.stopFiring(),this.clearSlotInput(),this.sim.lastInput={throttle:0,steer:0,action:!1,boost:!1}):!e&&this.lifecycleState===`destroyed`&&this.lifecycle.send({type:`RESPAWNED`})}reset(){this.clearSlotInput(),this.sim.reset(),this.damage.reset(),this.weapons.reset(),this.tirePaint.reset(),this.pickupEffect.reset(),this.synchronizeLifecycle()}restoreHealth(){this.sim.car.resetBurnable(),this.synchronizeLifecycle()}setMode(e){this.clearSlotInput(),this.sim.setMode(e),this.damage.reset(),this.weapons.reset(),this.tirePaint.reset(),this.pickupEffect.reset(),this.synchronizeLifecycle()}setPreset(e){this.clearSlotInput(),this.sim.setPreset(e),this.damage.reset(),this.weapons.reset(),this.tirePaint.reset(),this.pickupEffect.reset(),this.synchronizeLifecycle()}advanceBurn(e){if(this.sim.mode!==`car`)return null;let{car:t}=this.sim;t.advanceBurn(e),this.synchronizeLifecycle();let n=t.stage;if(n===`intact`)return null;let r=!1,i=!1;this.lifecycleState===`destroyed`&&(t.blastQueued||(t.blastQueued=!0,r=!0),t.blastAge+=e,t.blastAge<.36&&t.blastAge-t.lastBlastEmission>=1/30&&(i=!0,t.lastBlastEmission=t.blastAge));let a={stage:n,health:t.health,maxHealth:t.maxHealth,key:t,burnOriginLocal:{...t.burnOriginLocal},blastAge:t.blastAge,explosionStarted:r,blastPulse:i};return this.lifecycleState===`destroyed`&&t.blastAge>=o.respawnSeconds&&(this.sim.resetAtCurrentPose(),this.damage.reset(),this.synchronizeLifecycle()),a}captureState(){return{id:this.id,label:this.label,appearance:this.appearance,slots:structuredClone(this.slots),slotHeld:[...this.slotHeld],slotPulses:[...this.slotPulses],slotPresses:[...this.slotPresses],blockedSlots:[...this.blockedSlots],previousSlotInput:[...this.previousSlotInput],activeEmitters:this.activeEmitters.map(e=>({...e})),simulation:this.sim.captureState(),damage:this.damage.captureState(),weapons:this.weapons.captureState(),tirePaint:this.tirePaint.captureState(),pickupEffect:this.pickupEffect.captureState(),controls:Mn(this.controls),controlSource:this.controlSource,lifecycle:this.lifecycle.getPersistedSnapshot()}}restoreState(e){if(e.id!==this.id)throw Error(`Checkpoint vehicle does not match`);this.label=e.label,this.appearance=e.appearance,this.slots=structuredClone(e.slots),this.slotHeld=new Set(e.slotHeld),this.slotPulses=new Set(e.slotPulses),this.slotPresses=new Set(e.slotPresses),this.blockedSlots=new Set(e.blockedSlots),this.previousSlotInput=new Set(e.previousSlotInput),this.activeEmitters=e.activeEmitters.map(e=>({...e})),this.sim.restoreState(e.simulation),this.damage.restoreState(e.damage),this.weapons.restoreState(e.weapons),this.tirePaint.restoreState(e.tirePaint),this.pickupEffect.restoreState(e.pickupEffect),this.controls=Mn(e.controls),this.controlSource=e.controlSource,this.lifecycle.stop(),this.lifecycle=A(Nn,{snapshot:e.lifecycle}).start()}dispose(){this.disposed=!0,this.pickupEffect.reset(),this.clearSlotInput(),this.lifecycle.stop()}};export{mn as n,Pn as t};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{r as e}from"./configuration~react~vehicle-popover~JoyRideView~browser-session-core~renderer-CPZkP_Db.js";import{c as t,d as n,f as r,l as i,o as a}from"./runtime~react~vehicle-popover~browser-session-core~renderer-Dmgs7E8f.js";function o(e,t,n){let r=e.image?.crop??{x:0,y:0,width:1,height:1},i={x:r.x*t,y:r.y*n,width:r.width*t,height:r.height*n},a=e.geometry.widthM*(e.image?.scale??1)/(e.image?.bodyWidthRatio??1);return{source:i,lengthM:a*i.width/i.height,widthM:a}}function s(e,t){let n=1/0,r=-1/0,i=1/0,a=-1/0,o=2*t.halfLength/e.columns,s=2*t.halfWidth/e.rows,c=Math.max(o,s)*.5;for(let c=0;c<e.rows;c++){let l=(c+.5)*s-t.halfWidth;for(let s=0;s<e.columns;s++){if(!e.solid[c*e.columns+s])continue;let u=(s+.5)*o-t.halfLength,d=t.center.x+t.forward.x*u+t.side.x*l,f=t.center.y+t.forward.y*u+t.side.y*l;n=Math.min(n,d),r=Math.max(r,d),i=Math.min(i,f),a=Math.max(a,f)}}return Number.isFinite(n)?{x:n-c,y:i-c,width:r-n+c*2,height:a-i+c*2}:{x:t.center.x,y:t.center.y,width:0,height:0}}function c(e,t,r){let o=-1/0,s=t.center;for(let c=0;c<e.rows;c++){let l=(2*(c+.5)/e.rows-1)*t.halfWidth;for(let u=0;u<e.columns;u++){if(!e.solid[c*e.columns+u])continue;let d=(2*(u+.5)/e.columns-1)*t.halfLength,f=i(t.center,i(n(t.forward,d),n(t.side,l))),p=a(f,r);p>o&&(o=p,s=f)}}return{...s}}var l=(e,t,n)=>{let{columns:r,rows:i,solid:a}=e,o=n*r+t;return!!a[o]&&(t===0||t===r-1||n===0||n===i-1||!a[o-1]||!a[o+1]||!a[o-r]||!a[o+r])};function u(e,t,r){let a=1/0,o=t.center;for(let s=0;s<e.rows;s++){let c=(2*(s+.5)/e.rows-1)*t.halfWidth;for(let u=0;u<e.columns;u++){if(!l(e,u,s))continue;let d=(2*(u+.5)/e.columns-1)*t.halfLength,f=i(t.center,i(n(t.forward,d),n(t.side,c))),p=Math.max(r.x-f.x,0,f.x-r.x-r.width),m=Math.max(r.y-f.y,0,f.y-r.y-r.height),h=p*p+m*m+(p||m?0:Math.min(f.x-r.x,r.x+r.width-f.x,f.y-r.y,r.y+r.height-f.y)**2);h<a&&(a=h,o=f)}}return{...o}}function d(e,n,r){let i=t(r,n.center),o=a(i,n.forward)/n.halfLength,s=a(i,n.side)/n.halfWidth,c=Math.floor((o+1)*e.columns/2),l=Math.floor((s+1)*e.rows/2);return c>=0&&c<e.columns&&l>=0&&l<e.rows&&!!e.solid[l*e.columns+c]}function f(e,t,n){if(t.halfLength<=0||t.halfWidth<=0||Math.abs(n.halfX.x*n.halfY.y-n.halfX.y*n.halfY.x)<1e-4)return 0;let r=0;for(let i=0;i<16;i++){let a=2*(i+.5)/16-1;for(let i=0;i<16;i++){let o=2*(i+.5)/16-1;d(e,t,{x:n.center.x+n.halfX.x*o+n.halfY.x*a,y:n.center.y+n.halfX.y*o+n.halfY.y*a})&&r++}}return r/256}function p(e,r,o){let s=r.halfLength*2/e.columns,c=r.halfWidth*2/e.rows,l=r.forward,u=r.side,f=Number(d(e,r,i(o,n(l,-s))))-Number(d(e,r,i(o,n(l,s)))),p=Number(d(e,r,i(o,n(u,-c))))-Number(d(e,r,i(o,n(u,c)))),m=i(n(l,f),n(u,p)),h=Math.hypot(m.x,m.y);if(h>.001)return n(m,1/h);let g=t(o,r.center),_=i(n(l,a(g,l)/Math.max(s,r.halfLength)),n(u,a(g,u)/Math.max(c,r.halfWidth))),v=Math.hypot(_.x,_.y);return v>.001?n(_,1/v):{...l}}function m(e,n,i){if(i.width<=0||i.height<=0||n.halfLength<=0||n.halfWidth<=0)return!1;let o=[r(i.x,i.y),r(i.x+i.width,i.y),r(i.x,i.y+i.height),r(i.x+i.width,i.y+i.height)].map(e=>{let i=t(e,n.center);return r(a(i,n.forward),a(i,n.side))}),s=e.columns,c=e.rows,l=(e,t,n)=>Math.floor((e/t+1)*n/2),u=Math.max(0,l(Math.min(...o.map(e=>e.x)),n.halfLength,s)-1),d=Math.min(s-1,l(Math.max(...o.map(e=>e.x)),n.halfLength,s)+1),f=Math.max(0,l(Math.min(...o.map(e=>e.y)),n.halfWidth,c)-1),p=Math.min(c-1,l(Math.max(...o.map(e=>e.y)),n.halfWidth,c)+1);if(u>d||f>p)return!1;let m=Math.min(1,Math.max(n.halfLength/s,n.halfWidth/c));for(let t=f;t<=p;t++)for(let r=u;r<=d;r++){if(!e.solid[t*s+r])continue;let a=(2*(r+.5)/s-1)*n.halfLength,o=(2*(t+.5)/c-1)*n.halfWidth,l=n.center.x+n.forward.x*a+n.side.x*o,u=n.center.y+n.forward.y*a+n.side.y*o;if(l>=i.x-m&&l<=i.x+i.width+m&&u>=i.y-m&&u<=i.y+i.height+m)return!0}return!1}function h(e,t,r,a,o){if(!m(e,t,r))return 0;let s=0,c=Math.max(1,o);for(let o=0;o<3&&m(e,{...t,center:i(t.center,n(a,c))},r);o++)c*=2;for(let o=0;o<10;o++){let o=(s+c)/2;m(e,{...t,center:i(t.center,n(a,o))},r)?s=o:c=o}return c+.25}var g=class{loaded=new Map;pending=new Set;failed=new Set;fallback=new Map;keys=new WeakMap;assembled=new WeakMap;forPreset(e){let t=this.assembled.get(e);if(t)return t;let n=e.image?.src;if(n){let t=this.keys.get(e);t||(t=`${n}|${JSON.stringify(e.image?.crop??null)}`,this.keys.set(e,t));let r=this.loaded.get(t);if(r){let t=o(e,r.imageWidth,r.imageHeight),n={alpha:r,lengthM:t.lengthM,widthM:t.widthM};return this.assembled.set(e,n),n}!this.pending.has(t)&&!this.failed.has(t)&&this.load(t,n,e)}let r=`${e.geometry.lengthM}:${e.geometry.widthM}`,i=this.fallback.get(r);i||(i={columns:96,rows:48,solid:new Uint8Array(4608).fill(1)},this.fallback.set(r,i));let a={alpha:i,lengthM:e.geometry.lengthM,widthM:e.geometry.widthM};return(!n||this.failed.has(this.keys.get(e)??``))&&this.assembled.set(e,a),a}load(e,t,n){this.pending.add(e);let r=new Image;r.crossOrigin=`anonymous`,r.onload=()=>{try{let t=o(n,r.naturalWidth,r.naturalHeight),i=Math.max(24,Math.round(128*t.source.height/t.source.width)),a=document.createElement(`canvas`);a.width=128,a.height=i;let s=a.getContext(`2d`,{willReadFrequently:!0});if(!s)throw Error(`No 2D canvas for vehicle alpha mask`);s.drawImage(r,t.source.x,t.source.y,t.source.width,t.source.height,0,0,128,i);let c=s.getImageData(0,0,128,i).data,l=new Uint8Array(128*i);for(let e=0;e<l.length;e++)l[e]=+(c[e*4+3]>=96);this.loaded.set(e,{columns:128,rows:i,solid:l,imageWidth:r.naturalWidth,imageHeight:r.naturalHeight})}catch{this.failed.add(e)}finally{this.pending.delete(e)}},r.onerror=()=>{this.pending.delete(e),this.failed.add(e)},r.src=t}},_=e=>({x:e.x*28,y:-e.y*28}),v=e=>({x:e.x/28,y:-e.y/28}),ee=class{masks=new g;events;get totalPoints(){return 0}get managedBytes(){return 0}setEvents(e){this.events=e}prepare(e){this.masks.forPreset(e)}vehicleMask(e,t){let n=this.masks.forPreset(e);return t?t.maskFor(n):n}wallRects(){return[]}beginStep(e,t){}stepVehicle(e,t,n=!1,r,i,a=!1){}endStep(e){}forgetVehicle(e){}tirePaintAt(e){return e.map(()=>null)}projectileHit(e,t,n){return null}applyAreaImpact(e,t,n){}bulletImpact(e,t,n,r){return this.projectileHit(e,t,n)?.point??null}rocketImpact(e,t,n,r=1,i){return this.projectileHit(e,t,n)?.point??null}flameContact(e,t,n,r,i){return this.projectileHit(e,t,n)?.point??null}burningProximity(e){return 0}draw(e,t,n){}captureState(){return null}restoreState(e){}destroy(){}};function te(e,t,n,r,i,a,o=Math.random){let s=Math.hypot(t.x,t.y)||1,c={x:t.x/s,y:t.y/s},l={x:-c.y,y:c.x},u=Math.max(.4,Math.min(2,i)),d=[];for(let t=0;t<r;t++){let t=o()<.985-a*.045,r=(t?1+o()**.65*(12+u*15):.8+o()*7)*(1-a*.38),i=(o()+o()-1)*r*(.1+o()*.32),s=t?.025+o()**2.8*n*.14:n*(.16+o()**2*(.2+a*.35));d.push({x:e.x+n*(c.x*r+l.x*i),y:e.y+n*(c.y*r+l.y*i),radius:s,angularity:t?u*(.25+o()*.75):u*o(),opacity:t?.28+o()*.62:.85+o()*.15})}return d}var ne={gun:new URL(`../embed-assets/side-gun-v1-BnpvZN1b.webp`,import.meta.url).href,rocket:new URL(`../embed-assets/roof-rocket-v1-Bs4IEw-s.webp`,import.meta.url).href},re={gun:.55,rocket:.5},ie=new Map;function ae(e){if(typeof Image>`u`)return null;let t=ie.get(e);return t||(t=new Image,t.decoding=`async`,t.crossOrigin=`anonymous`,t.src=ne[e],ie.set(e,t)),t.complete&&t.naturalWidth>0?t:null}function oe(){ae(`gun`),ae(`rocket`)}function se(e,t,n,r,i){let a=ae(t);if(!a)return!1;let o=i*a.naturalHeight/a.naturalWidth;return e.drawImage(a,n,r-o*re[t],i,o),!0}var y=-.65,ce=.35,b=1.04;function le(t,n){let r=e(t);return{x:r.xM+ce,y:n*(t.geometry.widthM/2+r.revealM*.45)}}function ue(t,n,r,i,a,o,s=0){if(o<=0)return;let c=o*o*(3-2*o),l=e(n),u=n.geometry.widthM*r/2,d=r*.16*c;t.beginPath(),t.rect((-i/2-s)*r,(-a/2-s)*r,(i+s*2)*r,(a+s*2)*r);for(let e of[-1,1])t.rect((l.xM+y)*r,e>0?-u:u-d,r*b,d);t.clip(`evenodd`)}function de(t,n,r,i,a,o,s,c=0,l=1,u){if(o<=0)return;oe();let d=e(i),f=i.geometry.widthM*a/2,p=o*o*(3-2*o),m=d.revealM*p*a,h=a*.08*(1-p*.7);t.save(),t.translate(n.x,n.y),t.rotate(-r),t.globalAlpha*=l*Math.min(1,o*10);for(let e of[-1,1]){t.save(),t.translate(d.xM*a,-e*f),t.scale(1,-e);let n=t.createLinearGradient(0,-a*.16,0,a*.045);n.addColorStop(0,`#070b0e`),n.addColorStop(.75,`#252d31`),n.addColorStop(1,`rgba(12,18,22,0)`),t.fillStyle=n,t.fillRect(a*y,-a*.16*p,a*b,a*.205*p);let r=Math.max(0,m-h);if(r>0){t.save(),t.beginPath(),t.rect(a*y,0,a*1.34,r),t.clip();for(let e of[-.5,.16]){let n=t.createLinearGradient((e-.02)*a,0,(e+.02)*a,0);n.addColorStop(0,`#1b2227`),n.addColorStop(.45,`#b8c2c7`),n.addColorStop(.6,`#68767d`),n.addColorStop(1,`#242d32`),t.fillStyle=n,t.fillRect((e-.022)*a,0,a*.044,r)}let e=m*.45;t.translate(0,e);let n=s===`gun`?c*a*.018:0;if(t.shadowColor=`rgba(0,0,0,.6)`,t.shadowBlur=a*.045,t.shadowOffsetY=a*.025,!se(t,`gun`,y*a-n,0,a)){let e=t.createLinearGradient(0,-a*.07,0,a*.07);e.addColorStop(0,`#30383c`),e.addColorStop(.3,`#adb5b6`),e.addColorStop(.55,`#59646a`),e.addColorStop(1,`#141b20`),t.fillStyle=e,t.fillRect(y*a,-a*.085,a*.43,a*.17),t.fillRect(-a*.22,-a*.035,a*.57,a*.07)}if(t.shadowBlur=0,t.shadowOffsetY=0,c>0){t.save(),t.globalAlpha*=c;let e=ce*a,n=a*(s===`flame`?.075:.14),r=t.createRadialGradient(e,0,0,e,0,n);r.addColorStop(0,s===`flame`?`#b2d8ff`:`#fffbea`),r.addColorStop(.22,s===`flame`?`#ffb14d`:`#ffcf75`),r.addColorStop(1,`rgba(255,128,24,0)`),t.fillStyle=r,t.fillRect(e-n,-n,n*2,n*2),s===`gun`&&(t.fillStyle=`#fff4c7`,t.beginPath(),t.moveTo(e,-a*.025),t.lineTo(e+a*.19,-a*.008),t.lineTo(e+a*.24,0),t.lineTo(e+a*.19,a*.008),t.lineTo(e,a*.025),t.closePath(),t.fill()),t.restore()}t.restore()}if(t.fillStyle=i.roofRocket.panelColor,t.strokeStyle=`#22292b`,t.lineWidth=Math.max(.8,a*.025),t.beginPath(),t.roundRect(a*y,m-h,a*b,h*2,a*.025),t.fill(),t.stroke(),u){let n=b/u.lengthM*u.source.width,r=.16/u.widthM*u.source.height,o=u.source.x+(d.xM+y+u.lengthM/2)/u.lengthM*u.source.width,s=-e*(i.geometry.widthM/2-.08),c=u.source.y+(s-.08+u.widthM/2)/u.widthM*u.source.height;t.save(),t.scale(1,-e),t.beginPath(),t.roundRect(a*y,-e*m-h,a*b,h*2,a*.025),t.clip(),t.drawImage(u.image,o,c,n,r,a*y,-e*m-h,a*b,h*2),t.restore()}t.restore()}t.restore()}function fe(e){let{ignitionSeconds:t,spreadSeconds:n,spreadRadiusPx:r,burnSeconds:i,smokePerSecond:a}=e;return{ignitionSeconds:t,spreadSeconds:n,spreadRadiusPx:r,burnSeconds:i,smokePerSecond:a}}function pe(e){let t=(...e)=>e.every(Number.isFinite);if(!e||!t(e.point?.x,e.point?.y,e.radiusPx)||e.radiusPx<0||e.spreadSeconds!==void 0&&(!t(e.spreadSeconds)||e.spreadSeconds<0)||e.mask&&(!e.bounds||!(e.mask.alpha instanceof Uint8Array)||!Number.isInteger(e.mask.pixelWidth)||!Number.isInteger(e.mask.pixelHeight)||e.mask.pixelWidth<=0||e.mask.pixelHeight<=0||e.mask.alpha.length!==e.mask.pixelWidth*e.mask.pixelHeight||!t(e.mask.origin?.x,e.mask.origin?.y)||e.mask.frontRadius!==1/0&&(!t(e.mask.frontRadius)||e.mask.frontRadius<0))||e.bounds&&(!t(e.bounds.x,e.bounds.y,e.bounds.width,e.bounds.height)||e.bounds.width<0||e.bounds.height<0))throw Error(`Invalid fire source: expected finite coordinates and nonnegative geometry`);return{...e,point:{...e.point},...e.bounds&&{bounds:{...e.bounds}},...e.profile&&{profile:{...e.profile}},...e.mask&&{mask:{...e.mask,alpha:e.mask.alpha.slice(),origin:{...e.mask.origin}}}}}function me(e,t){if(e.mask&&e.bounds)return ve({rect:e.bounds,alpha:e.mask.alpha,pixelWidth:e.mask.pixelWidth,pixelHeight:e.mask.pixelHeight},e.mask.origin,e.mask.frontRadius,t,e.radiusPx);if(e.bounds){let n=e.bounds;return Math.hypot(Math.max(t.x-n.x-n.width,n.x-t.x-t.width,0),Math.max(t.y-n.y-n.height,n.y-t.y-t.height,0))}return Math.hypot(Math.max(t.x-e.point.x,0,e.point.x-t.x-t.width),Math.max(t.y-e.point.y,0,e.point.y-t.y-t.height))}function he(e,t,n,r){let i=me(t,n);return i>t.radiusPx?0:e/Math.max(.01,t.spreadSeconds??r)*(1.5-.5*i/Math.max(t.radiusPx,1))}function ge(e,t,n=1024){let{x:r,y:i,width:a,height:o}=e,s=Math.max(1,Math.ceil(a/Math.max(1,t))),c=Math.max(1,Math.ceil(o/Math.max(1,t))),l=Math.min(1,Math.sqrt(n/(s*c))),u=Math.min(n,Math.max(1,Math.floor(s*l))),d=Math.min(n,Math.max(1,Math.floor(c*l)));u=Math.min(u,Math.max(1,Math.floor(n/d)));let f=[];for(let e=0;e<d;e++)for(let t=0;t<u;t++)f.push({x:r+(t+.5)*a/u,y:i+(e+.5)*o/d});return f}function _e(e,t){if(!e.bounds)return[e.point];let n=e.bounds,r=e.radiusPx,i=t?{x:Math.max(n.x,t.x-r),y:Math.max(n.y,t.y-r),width:Math.min(n.x+n.width,t.x+t.width+r)-Math.max(n.x,t.x-r),height:Math.min(n.y+n.height,t.y+t.height+r)-Math.max(n.y,t.y-r)}:n;return i.width<=0||i.height<=0?[]:ge(i,Math.max(1,e.radiusPx)).filter(t=>!e.mask||me({...e,radiusPx:0},{...t,width:0,height:0})===0)}function ve(e,t,n,r,i){let{rect:a,alpha:o,pixelWidth:s,pixelHeight:c}=e;if(a.width<=0||a.height<=0)return 1/0;let l=Math.max(0,Math.floor((r.x-i-a.x)/a.width*s)),u=Math.min(s-1,Math.floor((r.x+r.width+i-a.x)/a.width*s)),d=Math.max(0,Math.floor((r.y-i-a.y)/a.height*c)),f=Math.min(c-1,Math.floor((r.y+r.height+i-a.y)/a.height*c)),p=1/0;for(let e=d;e<=f;e++)for(let i=l;i<=u;i++){if(o[e*s+i]<=32)continue;let l={x:a.x+i*a.width/s,y:a.y+e*a.height/c,width:a.width/s,height:a.height/c};Math.hypot(l.x+l.width/2-t.x,l.y+l.height/2-t.y)>n||(p=Math.min(p,Math.hypot(Math.max(r.x-l.x-l.width,l.x-r.x-r.width,0),Math.max(r.y-l.y-l.height,l.y-r.y-r.height,0))))}return p}var ye=new WeakMap;function be(e,t){let{rect:n,alpha:r,pixelWidth:i,pixelHeight:a}=e,o=t.spreadRadiusPx,s=ye.get(e);if(!s||s.alpha!==r||s.width!==n.width||s.height!==n.height||s.pixelWidth!==i||s.pixelHeight!==a||s.radius!==o){let t=Math.max(1,o*.75),c=Math.max(1,Math.ceil(n.width/t)),l=Math.max(1,Math.ceil(n.height/t)),u=Array(c*l),d=(e,r)=>{let i=Math.min(c-1,Math.floor(e/t)),a=Math.min(l-1,Math.floor(r/t)),o=a*c+i,s=(i+.5)*n.width/c,d=(a+.5)*n.height/l,f=(e-s)**2+(r-d)**2;(!u[o]||f<u[o].distance)&&(u[o]={x:e,y:r,distance:f})};for(let e=0;e<l;e++)for(let t=0;t<c;t++){let o=(t+.5)*n.width/c,s=(e+.5)*n.height/l,u=Math.min(i-1,Math.floor(o/n.width*i));r[Math.min(a-1,Math.floor(s/n.height*a))*i+u]>32&&d(o,s)}for(let e=0;e<a;e++)for(let t=0;t<i;t++)r[e*i+t]<=32||d((t+.5)*n.width/i,(e+.5)*n.height/a);s={alpha:r,width:n.width,height:n.height,pixelWidth:i,pixelHeight:a,radius:o,points:u.filter(e=>e!==void 0).map(({x:e,y:t})=>({x:e,y:t}))},ye.set(e,s)}return s.points.map(e=>({point:{x:n.x+e.x,y:n.y+e.y},radiusPx:o,spreadSeconds:t.spreadSeconds,profile:t}))}var x=null,S=()=>{x&&(x=null,window.removeEventListener(`scroll`,S))};function xe(){if(x)return x;let e={x:window.scrollX,y:window.scrollY};return typeof window.addEventListener==`function`?(window.addEventListener(`scroll`,S,{passive:!0}),x=e):e}var Se=S,Ce=class{frameStart=null;lastFrame=null;frames=0;fps=0;sample(e){if(!Number.isFinite(e))return this.fps;if(this.frameStart===null||this.lastFrame===null||e-this.lastFrame>1e3||e<=this.lastFrame)return this.frameStart=e,this.lastFrame=e,this.frames=0,this.fps=0,this.fps;this.frames++,this.lastFrame=e;let t=e-this.frameStart;return t>=500&&(this.fps=this.frames*1e3/t,this.frameStart=e,this.frames=0),this.fps}reset(){this.frameStart=null,this.lastFrame=null,this.frames=0,this.fps=0}captureState(){return{frameStart:this.frameStart,lastFrame:this.lastFrame,frames:this.frames,fps:this.fps}}restoreState(e){this.frameStart=e.frameStart,this.lastFrame=e.lastFrame,this.frames=e.frames,this.fps=e.fps}},C={};function we(e,t={x:0,y:0},n=1){let r=xe();return{x:e.left/n+r.x+t.x,y:e.top/n+r.y+t.y,width:e.width/n,height:e.height/n}}var Te={scale:1,viewportRectToDocument:we},Ee=`[data-jr-overlay],[data-jr-ui],[data-jr-touch-controls],[data-jr-embed],script,style,link`,De=class{scale=1;signature=``;originals=new Map;viewportRectToDocument(e,t={x:0,y:0}){return we(e,t,this.scale)}apply(e,t){let n=xe(),r=`${e}:${t.x}:${t.y}:${n.x}:${n.y}:${document.body.children.length}`;if(r!==this.signature||C.owner!==this){this.signature=r;for(let r of Array.from(document.body.children))if(r instanceof HTMLElement&&!r.matches(Ee)){if(!this.originals.has(r)){this.originals.set(r,{translate:r.style.translate,scale:r.style.scale,origin:r.style.transformOrigin});let e=0,t=0;for(let n=r;n;n=n.offsetParent)e+=n.offsetLeft,t+=n.offsetTop;r.style.transformOrigin=`${-e}px ${-t}px`}r.style.scale=String(e),r.style.translate=`${n.x-t.x*e}px ${n.y-t.y*e}px`}this.scale=e,C.owner=this}}clear(){for(let[e,t]of this.originals)e.style.translate=t.translate,e.style.scale=t.scale,e.style.transformOrigin=t.origin;this.originals.clear(),this.signature=``,this.scale=1,C.owner===this&&(C.owner=void 0)}},Oe=(e,t)=>{if(typeof e==`number`){if(t===3)return{mode:`rgb`,r:(e>>8&15|e>>4&240)/255,g:(e>>4&15|e&240)/255,b:(e&15|e<<4&240)/255};if(t===4)return{mode:`rgb`,r:(e>>12&15|e>>8&240)/255,g:(e>>8&15|e>>4&240)/255,b:(e>>4&15|e&240)/255,alpha:(e&15|e<<4&240)/255};if(t===6)return{mode:`rgb`,r:(e>>16&255)/255,g:(e>>8&255)/255,b:(e&255)/255};if(t===8)return{mode:`rgb`,r:(e>>24&255)/255,g:(e>>16&255)/255,b:(e>>8&255)/255,alpha:(e&255)/255}}},ke={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},Ae=e=>Oe(ke[e.toLowerCase()],6),je=/^#?([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})$/i,Me=e=>{let t;return(t=e.match(je))?Oe(parseInt(t[1],16),t[1].length):void 0},w=`([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)`,T=`${w}%`,E=`(?:${w}%|${w})`,Ne=`(?:${w}%|${w}|none)`,Pe=`(?:${w}(deg|grad|rad|turn)|${w})`,D=`\\s*,\\s*`;RegExp(`^`+Ne+`$`);var Fe=RegExp(`^rgba?\\(\\s*${w}${D}${w}${D}${w}\\s*(?:,\\s*${E}\\s*)?\\)$`),Ie=RegExp(`^rgba?\\(\\s*${T}${D}${T}${D}${T}\\s*(?:,\\s*${E}\\s*)?\\)$`),Le=e=>{let t={mode:`rgb`},n;if(n=e.match(Fe))n[1]!==void 0&&(t.r=n[1]/255),n[2]!==void 0&&(t.g=n[2]/255),n[3]!==void 0&&(t.b=n[3]/255);else if(n=e.match(Ie))n[1]!==void 0&&(t.r=n[1]/100),n[2]!==void 0&&(t.g=n[2]/100),n[3]!==void 0&&(t.b=n[3]/100);else return;return n[4]===void 0?n[5]!==void 0&&(t.alpha=Math.max(0,Math.min(1,+n[5]))):t.alpha=Math.max(0,Math.min(1,n[4]/100)),t},Re=(e,t)=>e===void 0?void 0:typeof e==`object`?e.mode===void 0?t?{...e,mode:t}:void 0:e:$e(e),ze=(e=`rgb`)=>t=>(t=Re(t,e))===void 0?void 0:t.mode===e?t:O[t.mode][e]?O[t.mode][e](t):e===`rgb`?O[t.mode].rgb(t):O.rgb[e](O[t.mode].rgb(t)),O={},Be={},k=[],Ve={},He=e=>e,A=e=>(O[e.mode]={...O[e.mode],...e.toMode},Object.keys(e.fromMode||{}).forEach(t=>{O[t]||(O[t]={}),O[t][e.mode]=e.fromMode[t]}),e.ranges||={},e.difference||={},e.channels.forEach(t=>{if(e.ranges[t]===void 0&&(e.ranges[t]=[0,1]),!e.interpolate[t])throw Error(`Missing interpolator for: ${t}`);typeof e.interpolate[t]==`function`&&(e.interpolate[t]={use:e.interpolate[t]}),e.interpolate[t].fixup||(e.interpolate[t].fixup=He)}),Be[e.mode]=e,(e.parse||[]).forEach(t=>{We(t,e.mode)}),ze(e.mode)),Ue=e=>Be[e],We=(e,t)=>{if(typeof e==`string`){if(!t)throw Error(`'mode' required when 'parser' is a string`);Ve[e]=t}else typeof e==`function`&&k.indexOf(e)<0&&k.push(e)},j=/[^\x00-\x7F]|[a-zA-Z_]/,Ge=/[^\x00-\x7F]|[-\w]/,M={Function:`function`,Ident:`ident`,Number:`number`,Percentage:`percentage`,ParenClose:`)`,None:`none`,Hue:`hue`,Alpha:`alpha`},N=0;function P(e){let t=e[N],n=e[N+1];return t===`-`||t===`+`?/\d/.test(n)||n===`.`&&/\d/.test(e[N+2]):t===`.`?/\d/.test(n):/\d/.test(t)}function Ke(e){if(N>=e.length)return!1;let t=e[N];if(j.test(t))return!0;if(t===`-`){if(e.length-N<2)return!1;let t=e[N+1];return!!(t===`-`||j.test(t))}return!1}var qe={deg:1,rad:180/Math.PI,grad:9/10,turn:360};function F(e){let t=``;if((e[N]===`-`||e[N]===`+`)&&(t+=e[N++]),t+=I(e),e[N]===`.`&&/\d/.test(e[N+1])&&(t+=e[N++]+I(e)),(e[N]===`e`||e[N]===`E`)&&((e[N+1]===`-`||e[N+1]===`+`)&&/\d/.test(e[N+2])?t+=e[N++]+e[N++]+I(e):/\d/.test(e[N+1])&&(t+=e[N++]+I(e))),Ke(e)){let n=L(e);return n===`deg`||n===`rad`||n===`turn`||n===`grad`?{type:M.Hue,value:t*qe[n]}:void 0}return e[N]===`%`?(N++,{type:M.Percentage,value:+t}):{type:M.Number,value:+t}}function I(e){let t=``;for(;/\d/.test(e[N]);)t+=e[N++];return t}function L(e){let t=``;for(;N<e.length&&Ge.test(e[N]);)t+=e[N++];return t}function Je(e){let t=L(e);return e[N]===`(`?(N++,{type:M.Function,value:t}):t===`none`?{type:M.None,value:void 0}:{type:M.Ident,value:t}}function Ye(e=``){let t=e.trim(),n=[],r;for(N=0;N<t.length;)if(r=t[N++],r===`
|
|
2
|
+
`||r===` `||r===` `)for(;N<t.length&&(t[N]===`
|
|
3
|
+
`||t[N]===` `||t[N]===` `);)N++;else{if(r===`,`)return;if(r===`)`)n.push({type:M.ParenClose});else{if(r===`+`){if(N--,P(t)){n.push(F(t));continue}return}if(r===`-`){if(N--,P(t)){n.push(F(t));continue}if(Ke(t)){n.push({type:M.Ident,value:L(t)});continue}return}if(r===`.`){if(N--,P(t)){n.push(F(t));continue}return}if(r===`/`){for(;N<t.length&&(t[N]===`
|
|
4
|
+
`||t[N]===` `||t[N]===` `);)N++;let e;if(P(t)&&(e=F(t),e.type!==M.Hue)){n.push({type:M.Alpha,value:e});continue}if(Ke(t)&&L(t)===`none`){n.push({type:M.Alpha,value:{type:M.None,value:void 0}});continue}return}if(/\d/.test(r))N--,n.push(F(t));else if(j.test(r))N--,n.push(Je(t));else return}}return n}function Xe(e){e._i=0;let t=e[e._i++];if(!t||t.type!==M.Function||t.value!==`color`||(t=e[e._i++],t.type!==M.Ident))return;let n=Ve[t.value];if(!n)return;let r={mode:n},i=Ze(e,!1);if(!i)return;let a=Ue(n).channels;for(let e=0,t,n;e<a.length;e++)t=i[e],n=a[e],t.type!==M.None&&(r[n]=t.type===M.Number?t.value:t.value/100,n===`alpha`&&(r[n]=Math.max(0,Math.min(1,r[n]))));return r}function Ze(e,t){let n=[],r;for(;e._i<e.length;)if(r=e[e._i++],r.type===M.None||r.type===M.Number||r.type===M.Alpha||r.type===M.Percentage||t&&r.type===M.Hue)n.push(r);else if(r.type===M.ParenClose){if(e._i<e.length)return}else return;if(!(n.length<3||n.length>4)){if(n.length===4){if(n[3].type!==M.Alpha)return;n[3]=n[3].value}return n.length===3&&n.push({type:M.None,value:void 0}),n.every(e=>e.type!==M.Alpha)?n:void 0}}function Qe(e,t){e._i=0;let n=e[e._i++];if(!n||n.type!==M.Function)return;let r=Ze(e,t);if(r)return r.unshift(n.value),r}var $e=e=>{if(typeof e!=`string`)return;let t=Ye(e),n=t?Qe(t,!0):void 0,r,i=0,a=k.length;for(;i<a;)if((r=k[i++](e,n))!==void 0)return r;return t?Xe(t):void 0};function et(e,t){if(!t||t[0]!==`rgb`&&t[0]!==`rgba`)return;let n={mode:`rgb`},[,r,i,a,o]=t;if(r.type!==M.Hue&&i.type!==M.Hue&&a.type!==M.Hue)return r.type!==M.None&&(n.r=r.type===M.Number?r.value/255:r.value/100),i.type!==M.None&&(n.g=i.type===M.Number?i.value/255:i.value/100),a.type!==M.None&&(n.b=a.type===M.Number?a.value/255:a.value/100),o.type!==M.None&&(n.alpha=Math.min(1,Math.max(0,o.type===M.Number?o.value:o.value/100))),n}var tt=e=>e===`transparent`?{mode:`rgb`,r:0,g:0,b:0,alpha:0}:void 0,nt=(e,t,n)=>e+n*(t-e),rt=e=>{let t=[];for(let n=0;n<e.length-1;n++){let r=e[n],i=e[n+1];r===void 0&&i===void 0?t.push(void 0):r!==void 0&&i!==void 0?t.push([r,i]):t.push(r===void 0?[i,i]:[r,r])}return t},R=(e=>t=>{let n=rt(t);return t=>{let r=t*n.length,i=t>=1?n.length-1:Math.max(Math.floor(r),0),a=n[i];return a===void 0?void 0:e(a[0],a[1],r-i)}})(nt),z=e=>{let t=!1,n=e.map(e=>e===void 0?1:(t=!0,e));return t?n:e},B={mode:`rgb`,channels:[`r`,`g`,`b`,`alpha`],parse:[et,Me,Le,Ae,tt,`srgb`],serialize:`srgb`,interpolate:{r:R,g:R,b:R,alpha:{use:R,fixup:z}},gamut:!0,white:{r:1,g:1,b:1},black:{r:0,g:0,b:0}},it=(e=0)=>Math.abs(e)**(563/256)*Math.sign(e),at=e=>{let t=it(e.r),n=it(e.g),r=it(e.b),i={mode:`xyz65`,x:.5766690429101305*t+.1855582379065463*n+.1882286462349947*r,y:.297344975250536*t+.6273635662554661*n+.0752914584939979*r,z:.0270313613864123*t+.0706888525358272*n+.9913375368376386*r};return e.alpha!==void 0&&(i.alpha=e.alpha),i},ot=e=>Math.abs(e)**(256/563)*Math.sign(e),st=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i={mode:`a98`,r:ot(e*2.0415879038107465-t*.5650069742788597-.3447313507783297*n),g:ot(e*-.9692436362808798+t*1.8759675015077206+.0415550574071756*n),b:ot(e*.0134442806320312-t*.1183623922310184+1.0151749943912058*n)};return r!==void 0&&(i.alpha=r),i},ct=(e=0)=>{let t=Math.abs(e);return t<=.04045?e/12.92:(Math.sign(e)||1)*((t+.055)/1.055)**2.4},V=({r:e,g:t,b:n,alpha:r})=>{let i={mode:`lrgb`,r:ct(e),g:ct(t),b:ct(n)};return r!==void 0&&(i.alpha=r),i},H=e=>{let{r:t,g:n,b:r,alpha:i}=V(e),a={mode:`xyz65`,x:.4123907992659593*t+.357584339383878*n+.1804807884018343*r,y:.2126390058715102*t+.715168678767756*n+.0721923153607337*r,z:.0193308187155918*t+.119194779794626*n+.9505321522496607*r};return i!==void 0&&(a.alpha=i),a},U=(e=0)=>{let t=Math.abs(e);return t>.0031308?(Math.sign(e)||1)*(1.055*t**(1/2.4)-.055):e*12.92},W=({r:e,g:t,b:n,alpha:r},i=`rgb`)=>{let a={mode:i,r:U(e),g:U(t),b:U(n)};return r!==void 0&&(a.alpha=r),a},G=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=W({r:e*3.2409699419045226-t*1.537383177570094-.4986107602930034*n,g:e*-.9692436362808796+t*1.8759675015077204+.0415550574071756*n,b:e*.0556300796969936-t*.2039769588889765+1.0569715142428784*n});return r!==void 0&&(i.alpha=r),i},lt={...B,mode:`a98`,parse:[`a98-rgb`],serialize:`a98-rgb`,fromMode:{rgb:e=>st(H(e)),xyz65:st},toMode:{rgb:e=>G(at(e)),xyz65:at}},K=e=>(e%=360)<0?e+360:e,ut=(e,t)=>e.map((n,r,i)=>{if(n===void 0)return n;let a=K(n);return r===0||e[r-1]===void 0?a:t(a-K(i[r-1]))}).reduce((e,t)=>!e.length||t===void 0||e[e.length-1]===void 0?(e.push(t),e):(e.push(t+e[e.length-1]),e),[]),q=e=>ut(e,e=>Math.abs(e)<=180?e:e-360*Math.sign(e)),dt=(e,t)=>{if(e.h===void 0||t.h===void 0||!e.s||!t.s)return 0;let n=K(e.h),r=K(t.h),i=Math.sin((r-n+360)/2*Math.PI/180);return 2*Math.sqrt(e.s*t.s)*i},ft=(e,t)=>{if(e.h===void 0||t.h===void 0)return 0;let n=K(e.h),r=K(t.h);return Math.abs(r-n)>180?n-(r-360*Math.sign(r-n)):r-n},pt=(e,t)=>{if(e.h===void 0||t.h===void 0||!e.c||!t.c)return 0;let n=K(e.h),r=K(t.h),i=Math.sin((r-n+360)/2*Math.PI/180);return 2*Math.sqrt(e.c*t.c)*i},J=e=>{let t=e.reduce((e,t)=>{if(t!==void 0){let n=t*Math.PI/180;e.sin+=Math.sin(n),e.cos+=Math.cos(n)}return e},{sin:0,cos:0}),n=Math.atan2(t.sin,t.cos)*180/Math.PI;return n<0?360+n:n},Y=({l:e,a:t,b:n,alpha:r},i=`lch`)=>{t===void 0&&(t=0),n===void 0&&(n=0);let a=Math.sqrt(t*t+n*n),o={mode:i,l:e,c:a};return a&&(o.h=K(Math.atan2(n,t)*180/Math.PI)),r!==void 0&&(o.alpha=r),o},X=({l:e,c:t,h:n,alpha:r},i=`lab`)=>{n===void 0&&(n=0);let a={mode:i,l:e,a:t?t*Math.cos(n/180*Math.PI):0,b:t?t*Math.sin(n/180*Math.PI):0};return r!==void 0&&(a.alpha=r),a},Z={X:.3457/.3585,Y:1,Z:.2958/.3585};function mt({h:e,s:t,l:n,alpha:r}){e=K(e===void 0?0:e),t===void 0&&(t=0),n===void 0&&(n=0);let i=n+t*(n<.5?n:1-n),a=i-(i-n)*2*Math.abs(e/60%2-1),o;switch(Math.floor(e/60)){case 0:o={r:i,g:a,b:2*n-i};break;case 1:o={r:a,g:i,b:2*n-i};break;case 2:o={r:2*n-i,g:i,b:a};break;case 3:o={r:2*n-i,g:a,b:i};break;case 4:o={r:a,g:2*n-i,b:i};break;case 5:o={r:i,g:2*n-i,b:a};break;default:o={r:2*n-i,g:2*n-i,b:2*n-i}}return o.mode=`rgb`,r!==void 0&&(o.alpha=r),o}function ht({r:e,g:t,b:n,alpha:r}){e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.max(e,t,n),a=Math.min(e,t,n),o={mode:`hsl`,s:i===a?0:(i-a)/(1-Math.abs(i+a-1)),l:.5*(i+a)};return i-a!==0&&(o.h=(i===e?(t-n)/(i-a)+(t<n)*6:i===t?(n-e)/(i-a)+2:(e-t)/(i-a)+4)*60),r!==void 0&&(o.alpha=r),o}var gt=(e,t)=>{switch(t){case`deg`:return+e;case`rad`:return e/Math.PI*180;case`grad`:return e/10*9;case`turn`:return e*360}},_t=RegExp(`^hsla?\\(\\s*${Pe}${D}${T}${D}${T}\\s*(?:,\\s*${E}\\s*)?\\)$`),vt=e=>{let t=e.match(_t);if(!t)return;let n={mode:`hsl`};return t[3]===void 0?t[1]!==void 0&&t[2]!==void 0&&(n.h=gt(t[1],t[2])):n.h=+t[3],t[4]!==void 0&&(n.s=Math.min(Math.max(0,t[4]/100),1)),t[5]!==void 0&&(n.l=Math.min(Math.max(0,t[5]/100),1)),t[6]===void 0?t[7]!==void 0&&(n.alpha=Math.max(0,Math.min(1,+t[7]))):n.alpha=Math.max(0,Math.min(1,t[6]/100)),n};function yt(e,t){if(!t||t[0]!==`hsl`&&t[0]!==`hsla`)return;let n={mode:`hsl`},[,r,i,a,o]=t;if(r.type!==M.None){if(r.type===M.Percentage)return;n.h=r.value}if(i.type!==M.None){if(i.type===M.Hue)return;n.s=i.value/100}if(a.type!==M.None){if(a.type===M.Hue)return;n.l=a.value/100}return o.type!==M.None&&(n.alpha=Math.min(1,Math.max(0,o.type===M.Number?o.value:o.value/100))),n}var bt={mode:`hsl`,toMode:{rgb:mt},fromMode:{rgb:ht},channels:[`h`,`s`,`l`,`alpha`],ranges:{h:[0,360]},gamut:`rgb`,parse:[yt,vt],serialize:e=>`hsl(${e.h===void 0?`none`:e.h} ${e.s===void 0?`none`:e.s*100+`%`} ${e.l===void 0?`none`:e.l*100+`%`}${e.alpha<1?` / ${e.alpha}`:``})`,interpolate:{h:{use:R,fixup:q},s:R,l:R,alpha:{use:R,fixup:z}},difference:{h:dt},average:{h:J}};function xt({h:e,s:t,v:n,alpha:r}){e=K(e===void 0?0:e),t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.abs(e/60%2-1),a;switch(Math.floor(e/60)){case 0:a={r:n,g:n*(1-t*i),b:n*(1-t)};break;case 1:a={r:n*(1-t*i),g:n,b:n*(1-t)};break;case 2:a={r:n*(1-t),g:n,b:n*(1-t*i)};break;case 3:a={r:n*(1-t),g:n*(1-t*i),b:n};break;case 4:a={r:n*(1-t*i),g:n*(1-t),b:n};break;case 5:a={r:n,g:n*(1-t),b:n*(1-t*i)};break;default:a={r:n*(1-t),g:n*(1-t),b:n*(1-t)}}return a.mode=`rgb`,r!==void 0&&(a.alpha=r),a}function St({r:e,g:t,b:n,alpha:r}){e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.max(e,t,n),a=Math.min(e,t,n),o={mode:`hsv`,s:i===0?0:1-a/i,v:i};return i-a!==0&&(o.h=(i===e?(t-n)/(i-a)+(t<n)*6:i===t?(n-e)/(i-a)+2:(e-t)/(i-a)+4)*60),r!==void 0&&(o.alpha=r),o}function Ct({h:e,w:t,b:n,alpha:r}){if(t===void 0&&(t=0),n===void 0&&(n=0),t+n>1){let e=t+n;t/=e,n/=e}return xt({h:e,s:n===1?1:1-t/(1-n),v:1-n,alpha:r})}function wt(e){let t=St(e);if(t===void 0)return;let n=t.s===void 0?0:t.s,r=t.v===void 0?0:t.v,i={mode:`hwb`,w:(1-n)*r,b:1-r};return t.h!==void 0&&(i.h=t.h),t.alpha!==void 0&&(i.alpha=t.alpha),i}function Tt(e,t){if(!t||t[0]!==`hwb`)return;let n={mode:`hwb`},[,r,i,a,o]=t;if(r.type!==M.None){if(r.type===M.Percentage)return;n.h=r.value}if(i.type!==M.None){if(i.type===M.Hue)return;n.w=i.value/100}if(a.type!==M.None){if(a.type===M.Hue)return;n.b=a.value/100}return o.type!==M.None&&(n.alpha=Math.min(1,Math.max(0,o.type===M.Number?o.value:o.value/100))),n}var Et={mode:`hwb`,toMode:{rgb:Ct},fromMode:{rgb:wt},channels:[`h`,`w`,`b`,`alpha`],ranges:{h:[0,360]},gamut:`rgb`,parse:[Tt],serialize:e=>`hwb(${e.h===void 0?`none`:e.h} ${e.w===void 0?`none`:e.w*100+`%`} ${e.b===void 0?`none`:e.b*100+`%`}${e.alpha<1?` / ${e.alpha}`:``})`,interpolate:{h:{use:R,fixup:q},w:R,b:R,alpha:{use:R,fixup:z}},difference:{h:ft},average:{h:J}},Dt=29**3/27,Ot=216/29**3,kt=e=>e**3>Ot?e**3:(116*e-16)/Dt,At=({l:e,a:t,b:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=(e+16)/116,a=t/500+i,o=i-n/200,s={mode:`xyz50`,x:kt(a)*Z.X,y:kt(i)*Z.Y,z:kt(o)*Z.Z};return r!==void 0&&(s.alpha=r),s},jt=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=W({r:e*3.1341359569958707-t*1.6173863321612538-.4906619460083532*n,g:e*-.978795502912089+t*1.916254567259524+.03344273116131949*n,b:e*.07195537988411677-t*.2289768264158322+1.405386058324125*n});return r!==void 0&&(i.alpha=r),i},Mt=e=>jt(At(e)),Nt=e=>{let{r:t,g:n,b:r,alpha:i}=V(e),a={mode:`xyz50`,x:.436065742824811*t+.3851514688337912*n+.14307845442264197*r,y:.22249319175623702*t+.7168870538238823*n+.06061979053616537*r,z:.013923904500943465*t+.09708128566574634*n+.7140993584005155*r};return i!==void 0&&(a.alpha=i),a},Pt=e=>e>Ot?Math.cbrt(e):(Dt*e+16)/116,Ft=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=Pt(e/Z.X),a=Pt(t/Z.Y),o=Pt(n/Z.Z),s={mode:`lab`,l:116*a-16,a:500*(i-a),b:200*(a-o)};return r!==void 0&&(s.alpha=r),s},It=e=>{let t=Ft(Nt(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t};function Lt(e,t){if(!t||t[0]!==`lab`)return;let n={mode:`lab`},[,r,i,a,o]=t;if(r.type!==M.Hue&&i.type!==M.Hue&&a.type!==M.Hue)return r.type!==M.None&&(n.l=Math.min(Math.max(0,r.value),100)),i.type!==M.None&&(n.a=i.type===M.Number?i.value:i.value*125/100),a.type!==M.None&&(n.b=a.type===M.Number?a.value:a.value*125/100),o.type!==M.None&&(n.alpha=Math.min(1,Math.max(0,o.type===M.Number?o.value:o.value/100))),n}var Rt={mode:`lab`,toMode:{xyz50:At,rgb:Mt},fromMode:{xyz50:Ft,rgb:It},channels:[`l`,`a`,`b`,`alpha`],ranges:{l:[0,100],a:[-125,125],b:[-125,125]},parse:[Lt],serialize:e=>`lab(${e.l===void 0?`none`:e.l} ${e.a===void 0?`none`:e.a} ${e.b===void 0?`none`:e.b}${e.alpha<1?` / ${e.alpha}`:``})`,interpolate:{l:R,a:R,b:R,alpha:{use:R,fixup:z}}};function zt(e,t){if(!t||t[0]!==`lch`)return;let n={mode:`lch`},[,r,i,a,o]=t;if(r.type!==M.None){if(r.type===M.Hue)return;n.l=Math.min(Math.max(0,r.value),100)}if(i.type!==M.None&&(n.c=Math.max(0,i.type===M.Number?i.value:i.value*150/100)),a.type!==M.None){if(a.type===M.Percentage)return;n.h=a.value}return o.type!==M.None&&(n.alpha=Math.min(1,Math.max(0,o.type===M.Number?o.value:o.value/100))),n}var Bt={mode:`lch`,toMode:{lab:X,rgb:e=>Mt(X(e))},fromMode:{rgb:e=>Y(It(e)),lab:Y},channels:[`l`,`c`,`h`,`alpha`],ranges:{l:[0,100],c:[0,150],h:[0,360]},parse:[zt],serialize:e=>`lch(${e.l===void 0?`none`:e.l} ${e.c===void 0?`none`:e.c} ${e.h===void 0?`none`:e.h}${e.alpha<1?` / ${e.alpha}`:``})`,interpolate:{h:{use:R,fixup:q},c:R,l:R,alpha:{use:R,fixup:z}},difference:{h:pt},average:{h:J}},Vt={...B,mode:`lrgb`,toMode:{rgb:W},fromMode:{rgb:V},parse:[`srgb-linear`],serialize:`srgb-linear`},Ht=({r:e,g:t,b:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.cbrt(.412221469470763*e+.5363325372617348*t+.0514459932675022*n),a=Math.cbrt(.2119034958178252*e+.6806995506452344*t+.1073969535369406*n),o=Math.cbrt(.0883024591900564*e+.2817188391361215*t+.6299787016738222*n),s={mode:`oklab`,l:.210454268309314*i+.7936177747023054*a-.0040720430116193*o,a:1.9779985324311684*i-2.42859224204858*a+.450593709617411*o,b:.0259040424655478*i+.7827717124575296*a-.8086757549230774*o};return r!==void 0&&(s.alpha=r),s},Ut=e=>{let t=Ht(V(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t},Wt=({l:e,a:t,b:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=(e+.3963377773761749*t+.2158037573099136*n)**3,a=(e-.1055613458156586*t-.0638541728258133*n)**3,o=(e-.0894841775298119*t-1.2914855480194092*n)**3,s={mode:`lrgb`,r:4.076741636075957*i-3.3077115392580616*a+.2309699031821044*o,g:-1.2684379732850317*i+2.6097573492876887*a-.3413193760026573*o,b:-.0041960761386756*i-.7034186179359362*a+1.7076146940746117*o};return r!==void 0&&(s.alpha=r),s},Gt=e=>W(Wt(e));function Kt(e,t){if(!t||t[0]!==`oklab`)return;let n={mode:`oklab`},[,r,i,a,o]=t;if(r.type!==M.Hue&&i.type!==M.Hue&&a.type!==M.Hue)return r.type!==M.None&&(n.l=Math.min(Math.max(0,r.type===M.Number?r.value:r.value/100),1)),i.type!==M.None&&(n.a=i.type===M.Number?i.value:i.value*.4/100),a.type!==M.None&&(n.b=a.type===M.Number?a.value:a.value*.4/100),o.type!==M.None&&(n.alpha=Math.min(1,Math.max(0,o.type===M.Number?o.value:o.value/100))),n}var qt={...Rt,mode:`oklab`,toMode:{lrgb:Wt,rgb:Gt},fromMode:{lrgb:Ht,rgb:Ut},ranges:{l:[0,1],a:[-.4,.4],b:[-.4,.4]},parse:[Kt],serialize:e=>`oklab(${e.l===void 0?`none`:e.l} ${e.a===void 0?`none`:e.a} ${e.b===void 0?`none`:e.b}${e.alpha<1?` / ${e.alpha}`:``})`};function Jt(e,t){if(!t||t[0]!==`oklch`)return;let n={mode:`oklch`},[,r,i,a,o]=t;if(r.type!==M.None){if(r.type===M.Hue)return;n.l=Math.min(Math.max(0,r.type===M.Number?r.value:r.value/100),1)}if(i.type!==M.None&&(n.c=Math.max(0,i.type===M.Number?i.value:i.value*.4/100)),a.type!==M.None){if(a.type===M.Percentage)return;n.h=a.value}return o.type!==M.None&&(n.alpha=Math.min(1,Math.max(0,o.type===M.Number?o.value:o.value/100))),n}var Yt={...Bt,mode:`oklch`,toMode:{oklab:e=>X(e,`oklab`),rgb:e=>Gt(X(e,`oklab`))},fromMode:{rgb:e=>Y(Ut(e),`oklch`),oklab:e=>Y(e,`oklch`)},parse:[Jt],serialize:e=>`oklch(${e.l===void 0?`none`:e.l} ${e.c===void 0?`none`:e.c} ${e.h===void 0?`none`:e.h}${e.alpha<1?` / ${e.alpha}`:``})`,ranges:{l:[0,1],c:[0,.4],h:[0,360]}},Xt=e=>{let{r:t,g:n,b:r,alpha:i}=V(e),a={mode:`xyz65`,x:.486570948648216*t+.265667693169093*n+.1982172852343625*r,y:.2289745640697487*t+.6917385218365062*n+.079286914093745*r,z:0*t+.0451133818589026*n+1.043944368900976*r};return i!==void 0&&(a.alpha=i),a},Zt=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=W({r:e*2.4934969119414263-t*.9313836179191242-.402710784450717*n,g:e*-.8294889695615749+t*1.7626640603183465+.0236246858419436*n,b:e*.0358458302437845-t*.0761723892680418+.9568845240076871*n},`p3`);return r!==void 0&&(i.alpha=r),i},Qt={...B,mode:`p3`,parse:[`display-p3`],serialize:`display-p3`,fromMode:{rgb:e=>Zt(H(e)),xyz65:Zt},toMode:{rgb:e=>G(Xt(e)),xyz65:Xt}},Q=e=>{let t=Math.abs(e);return t>=1/512?Math.sign(e)*t**(1/1.8):16*e},$t=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i={mode:`prophoto`,r:Q(e*1.3457868816471585-t*.2555720873797946-.0511018649755453*n),g:Q(e*-.5446307051249019+t*1.5082477428451466+.0205274474364214*n),b:Q(e*0+t*0+1.2119675456389452*n)};return r!==void 0&&(i.alpha=r),i},en=(e=0)=>{let t=Math.abs(e);return t>=16/512?Math.sign(e)*t**1.8:e/16},tn=e=>{let t=en(e.r),n=en(e.g),r=en(e.b),i={mode:`xyz50`,x:.7977666449006423*t+.1351812974005331*n+.0313477341283922*r,y:.2880748288194013*t+.7118352342418731*n+899369387256e-16*r,z:0*t+0*n+.8251046025104602*r};return e.alpha!==void 0&&(i.alpha=e.alpha),i},nn={...B,mode:`prophoto`,parse:[`prophoto-rgb`],serialize:`prophoto-rgb`,fromMode:{xyz50:$t,rgb:e=>$t(Nt(e))},toMode:{xyz50:tn,rgb:e=>jt(tn(e))}},rn=1.09929682680944,an=.018053968510807,on=e=>{let t=Math.abs(e);return t>an?(Math.sign(e)||1)*(rn*t**.45-.09929682680944008):4.5*e},sn=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i={mode:`rec2020`,r:on(e*1.7166511879712683-t*.3556707837763925-.2533662813736599*n),g:on(e*-.6666843518324893+t*1.6164812366349395+.0157685458139111*n),b:on(e*.0176398574453108-t*.0427706132578085+.9421031212354739*n)};return r!==void 0&&(i.alpha=r),i},cn=1.09929682680944,ln=.018053968510807,un=(e=0)=>{let t=Math.abs(e);return t<ln*4.5?e/4.5:(Math.sign(e)||1)*((t+cn-1)/cn)**(1/.45)},dn=e=>{let t=un(e.r),n=un(e.g),r=un(e.b),i={mode:`xyz65`,x:.6369580483012911*t+.1446169035862083*n+.1688809751641721*r,y:.262700212011267*t+.6779980715188708*n+.059301716469862*r,z:0*t+.0280726930490874*n+1.0609850577107909*r};return e.alpha!==void 0&&(i.alpha=e.alpha),i},fn={...B,mode:`rec2020`,fromMode:{xyz65:sn,rgb:e=>sn(H(e))},toMode:{xyz65:dn,rgb:e=>G(dn(e))},parse:[`rec2020`],serialize:`rec2020`},pn={mode:`xyz50`,parse:[`xyz-d50`],serialize:`xyz-d50`,toMode:{rgb:jt,lab:Ft},fromMode:{rgb:Nt,lab:At},channels:[`x`,`y`,`z`,`alpha`],ranges:{x:[0,.964],y:[0,.999],z:[0,.825]},interpolate:{x:R,y:R,z:R,alpha:{use:R,fixup:z}}},mn={mode:`xyz65`,toMode:{rgb:G,xyz50:e=>{let{x:t,y:n,z:r,alpha:i}=e;t===void 0&&(t=0),n===void 0&&(n=0),r===void 0&&(r=0);let a={mode:`xyz50`,x:1.0479298208405488*t+.0229467933410191*n-.0501922295431356*r,y:.0296278156881593*t+.990434484573249*n-.0170738250293851*r,z:-.0092430581525912*t+.0150551448965779*n+.7518742899580008*r};return i!==void 0&&(a.alpha=i),a}},fromMode:{rgb:H,xyz50:e=>{let{x:t,y:n,z:r,alpha:i}=e;t===void 0&&(t=0),n===void 0&&(n=0),r===void 0&&(r=0);let a={mode:`xyz65`,x:.9554734527042182*t-.0230985368742614*n+.0632593086610217*r,y:-.0283697069632081*t+1.0099954580058226*n+.021041398966943*r,z:.0123140016883199*t-.0205076964334779*n+1.3303659366080753*r};return i!==void 0&&(a.alpha=i),a}},ranges:{x:[0,.95],y:[0,1],z:[0,1.088]},channels:[`x`,`y`,`z`,`alpha`],parse:[`xyz`,`xyz-d65`],serialize:`xyz-d65`,interpolate:{x:R,y:R,z:R,alpha:{use:R,fixup:z}}},hn=A(B);A(Vt),A(bt),A(Et),A(Rt),A(Bt),A(qt);var gn=A(Yt);A(Qt),A(lt),A(nn),A(fn),A(pn),A(mn);var $=new Map,_n=e=>Math.max(0,Math.min(1,e));function vn(e){let t=e.trim().toLowerCase();if(!t||t===`transparent`)return null;if($.has(t))return $.get(t);let n=hn(t),r=null;if(n){let e=[n.r??0,n.g??0,n.b??0],t=n.alpha??1;if([...e,t].every(Number.isFinite)){let[n,i,a]=e.map(_n),o=_n(t),s=gn({mode:`rgb`,r:n,g:i,b:a});r=Object.freeze({paint:Object.freeze({color:`rgb(${[n,i,a].map(e=>Math.round(e*255)).join(` `)})`,alpha:o}),appearance:Object.freeze({lightness:s.l,chroma:s.c,alpha:o})})}}return $.size>=256&&$.delete($.keys().next().value),$.set(t,r),r}function yn(e){return vn(e)?.paint??null}function bn(e){return vn(e)?.appearance??null}function xn(e,t){return e===null?1:Math.max(0,1-(t-e)/240)}export{c as A,g as C,s as D,d as E,o as M,m as O,_ as S,u as T,se as _,Te as a,ee as b,xe as c,he as d,_e as f,le as g,de as h,De as i,p as j,h as k,be as l,ue as m,bn as n,Ce as o,pe as p,yn as r,Se as s,xn as t,fe as u,oe as v,f as w,v as x,te as y};
|